2018-05-12 01:32:00 +02:00
|
|
|
#!/usr/bin/env python3
|
2019-04-26 21:21:50 +02:00
|
|
|
# See LICENSE for licensing information.
|
|
|
|
|
#
|
2019-06-14 17:43:41 +02:00
|
|
|
# Copyright (c) 2016-2019 Regents of the University of California and The Board
|
|
|
|
|
# of Regents for the Oklahoma Agricultural and Mechanical College
|
|
|
|
|
# (acting for and on behalf of Oklahoma State University)
|
|
|
|
|
# All rights reserved.
|
2019-04-26 21:21:50 +02:00
|
|
|
#
|
2016-11-08 18:57:35 +01:00
|
|
|
import unittest
|
2019-05-31 19:51:42 +02:00
|
|
|
from testutils import *
|
2018-01-12 19:24:49 +01:00
|
|
|
import sys,os,re,shutil
|
2019-05-31 19:51:42 +02:00
|
|
|
sys.path.append(os.getenv("OPENRAM_HOME"))
|
2016-11-08 18:57:35 +01:00
|
|
|
import globals
|
2017-11-16 22:52:58 +01:00
|
|
|
from globals import OPTS
|
2019-03-06 23:12:24 +01:00
|
|
|
from sram_factory import factory
|
2016-11-08 18:57:35 +01:00
|
|
|
import debug
|
2018-07-10 00:53:37 +02:00
|
|
|
import getpass
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2019-07-26 17:33:06 +02:00
|
|
|
class openram_back_end_test(openram_test):
|
2016-11-08 18:57:35 +01:00
|
|
|
|
|
|
|
|
def runTest(self):
|
2018-12-06 18:26:38 +01:00
|
|
|
OPENRAM_HOME = os.path.abspath(os.environ.get("OPENRAM_HOME"))
|
2019-11-17 01:44:31 +01:00
|
|
|
config_file = "{}/tests/configs/config_back_end".format(os.getenv("OPENRAM_HOME"))
|
2019-11-15 19:47:59 +01:00
|
|
|
globals.init_openram(config_file)
|
2019-04-27 00:17:19 +02:00
|
|
|
|
|
|
|
|
debug.info(1, "Testing top-level back-end openram.py with 2-bit, 16 word SRAM.")
|
2016-11-08 18:57:35 +01:00
|
|
|
out_file = "testsram"
|
2018-07-06 16:34:38 +02:00
|
|
|
out_path = "/tmp/testsram_{0}_{1}_{2}/".format(OPTS.tech_name,getpass.getuser(),os.getpid())
|
2016-11-08 18:57:35 +01:00
|
|
|
|
|
|
|
|
# make sure we start without the files existing
|
|
|
|
|
if os.path.exists(out_path):
|
|
|
|
|
shutil.rmtree(out_path, ignore_errors=True)
|
|
|
|
|
self.assertEqual(os.path.exists(out_path),False)
|
|
|
|
|
|
|
|
|
|
try:
|
2018-05-12 01:32:00 +02:00
|
|
|
os.makedirs(out_path, 0o0750)
|
2016-11-08 18:57:35 +01:00
|
|
|
except OSError as e:
|
|
|
|
|
if e.errno == 17: # errno.EEXIST
|
2018-05-12 01:32:00 +02:00
|
|
|
os.chmod(out_path, 0o0750)
|
2016-11-08 18:57:35 +01:00
|
|
|
|
|
|
|
|
# specify the same verbosity for the system call
|
2019-09-04 23:33:25 +02:00
|
|
|
options = ""
|
2016-11-08 18:57:35 +01:00
|
|
|
for i in range(OPTS.debug_level):
|
2019-09-04 23:33:25 +02:00
|
|
|
options += " -v"
|
|
|
|
|
|
|
|
|
|
if OPTS.spice_name:
|
|
|
|
|
options += " -s {}".format(OPTS.spice_name)
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2018-12-03 18:13:57 +01:00
|
|
|
# Always perform code coverage
|
2018-12-03 22:24:22 +01:00
|
|
|
if OPTS.coverage == 0:
|
|
|
|
|
debug.warning("Failed to find coverage installation. This can be installed with pip3 install coverage")
|
2019-01-09 17:24:20 +01:00
|
|
|
exe_name = "{0}/openram.py ".format(OPENRAM_HOME)
|
|
|
|
|
else:
|
|
|
|
|
exe_name = "coverage run -p {0}/openram.py ".format(OPENRAM_HOME)
|
2019-10-23 19:48:18 +02:00
|
|
|
config_name = "{0}/tests/{1}/config_back_end.py".format(OPENRAM_HOME,OPTS.tech_name)
|
2018-12-06 14:34:05 +01:00
|
|
|
cmd = "{0} -n -o {1} -p {2} {3} {4} 2>&1 > {5}/output.log".format(exe_name,
|
2019-01-09 17:24:20 +01:00
|
|
|
out_file,
|
|
|
|
|
out_path,
|
2019-09-04 23:33:25 +02:00
|
|
|
options,
|
2019-01-09 17:24:20 +01:00
|
|
|
config_name,
|
|
|
|
|
out_path)
|
2016-11-08 18:57:35 +01:00
|
|
|
debug.info(1, cmd)
|
|
|
|
|
os.system(cmd)
|
|
|
|
|
|
|
|
|
|
# assert an error until we actually check a resul
|
2018-02-12 05:43:41 +01:00
|
|
|
for extension in ["gds", "v", "lef", "sp"]:
|
2016-11-08 18:57:35 +01:00
|
|
|
filename = "{0}/{1}.{2}".format(out_path,out_file,extension)
|
|
|
|
|
debug.info(1,"Checking for file: " + filename)
|
|
|
|
|
self.assertEqual(os.path.exists(filename),True)
|
|
|
|
|
|
2018-02-12 05:43:41 +01:00
|
|
|
# Make sure there is any .lib file
|
|
|
|
|
import glob
|
|
|
|
|
files = glob.glob('{0}/*.lib'.format(out_path))
|
|
|
|
|
self.assertTrue(len(files)>0)
|
2018-10-07 06:15:54 +02:00
|
|
|
|
2018-10-12 00:59:06 +02:00
|
|
|
# Make sure there is any .html file
|
2018-12-03 20:09:45 +01:00
|
|
|
if os.path.exists(out_path):
|
|
|
|
|
datasheets = glob.glob('{0}/*html'.format(out_path))
|
|
|
|
|
self.assertTrue(len(datasheets)>0)
|
2018-10-07 06:15:54 +02:00
|
|
|
|
2016-11-08 18:57:35 +01:00
|
|
|
# grep any errors from the output
|
2018-07-26 23:01:40 +02:00
|
|
|
output_log = open("{0}/output.log".format(out_path),"r")
|
|
|
|
|
output = output_log.read()
|
|
|
|
|
output_log.close()
|
2016-11-08 18:57:35 +01:00
|
|
|
self.assertEqual(len(re.findall('ERROR',output)),0)
|
|
|
|
|
self.assertEqual(len(re.findall('WARNING',output)),0)
|
|
|
|
|
|
2018-07-26 23:01:40 +02:00
|
|
|
|
2018-12-03 20:09:45 +01:00
|
|
|
# now clean up the directory
|
2019-09-04 23:33:25 +02:00
|
|
|
if OPTS.purge_temp:
|
|
|
|
|
if os.path.exists(out_path):
|
|
|
|
|
shutil.rmtree(out_path, ignore_errors=True)
|
|
|
|
|
self.assertEqual(os.path.exists(out_path),False)
|
|
|
|
|
|
2018-01-21 20:21:09 +01:00
|
|
|
globals.end_openram()
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2018-11-03 00:34:26 +01:00
|
|
|
# run the test from the command line
|
2016-11-08 18:57:35 +01:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
(OPTS, args) = globals.parse_args()
|
|
|
|
|
del sys.argv[1:]
|
|
|
|
|
header(__file__, OPTS.tech_name)
|
2019-05-31 19:51:42 +02:00
|
|
|
unittest.main(testRunner=debugTestRunner())
|