2018-05-12 01:32:00 +02:00
|
|
|
#!/usr/bin/env python3
|
2016-11-08 18:57:35 +01:00
|
|
|
"""
|
|
|
|
|
This tests the top-level executable. It checks that it generates the
|
|
|
|
|
appropriate files: .lef, .lib, .sp, .gds, .v. It DOES NOT, however,
|
|
|
|
|
check that these files are right.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import unittest
|
2018-01-30 01:59:29 +01:00
|
|
|
from testutils import header,openram_test
|
2018-01-12 19:24:49 +01:00
|
|
|
import sys,os,re,shutil
|
2016-11-08 18:57:35 +01:00
|
|
|
sys.path.append(os.path.join(sys.path[0],".."))
|
|
|
|
|
import globals
|
2017-11-16 22:52:58 +01:00
|
|
|
from globals import OPTS
|
2016-11-08 18:57:35 +01:00
|
|
|
import debug
|
|
|
|
|
|
2018-01-30 01:59:29 +01:00
|
|
|
class openram_test(openram_test):
|
2016-11-08 18:57:35 +01:00
|
|
|
|
|
|
|
|
def runTest(self):
|
|
|
|
|
globals.init_openram("config_20_{0}".format(OPTS.tech_name))
|
2018-01-21 20:21:09 +01:00
|
|
|
|
2016-11-08 18:57:35 +01:00
|
|
|
debug.info(1, "Testing top-level openram.py with 2-bit, 16 word SRAM.")
|
|
|
|
|
out_file = "testsram"
|
2018-02-08 00:05:21 +01:00
|
|
|
# make a temp directory for output
|
|
|
|
|
out_path = "/tmp/testsram_{0}".format(OPTS.tech_name)
|
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
|
|
|
|
|
verbosity = ""
|
|
|
|
|
for i in range(OPTS.debug_level):
|
|
|
|
|
verbosity += " -v"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OPENRAM_HOME = os.path.abspath(os.environ.get("OPENRAM_HOME"))
|
|
|
|
|
|
2018-05-12 01:32:00 +02:00
|
|
|
cmd = "python3 {0}/openram.py -n -o {1} -p {2} {3} config_20_{4}.py 2>&1 > {5}/output.log".format(OPENRAM_HOME,
|
2016-11-08 18:57:35 +01:00
|
|
|
out_file,
|
|
|
|
|
out_path,
|
|
|
|
|
verbosity,
|
|
|
|
|
OPTS.tech_name,
|
|
|
|
|
out_path)
|
|
|
|
|
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)
|
|
|
|
|
|
2016-11-08 18:57:35 +01:00
|
|
|
# grep any errors from the output
|
|
|
|
|
output = open("{0}/output.log".format(out_path),"r").read()
|
|
|
|
|
self.assertEqual(len(re.findall('ERROR',output)),0)
|
|
|
|
|
self.assertEqual(len(re.findall('WARNING',output)),0)
|
|
|
|
|
|
|
|
|
|
# now clean up the directory
|
|
|
|
|
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
|
|
|
# The default was on, so disable it.
|
|
|
|
|
OPTS.check_lvsdrc=False
|
|
|
|
|
globals.end_openram()
|
|
|
|
|
OPTS.check_lvsdrc=True
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2017-11-16 22:52:58 +01:00
|
|
|
# instantiate a copy of the class to actually run the test
|
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)
|
|
|
|
|
unittest.main()
|