Moved assert to check out_path earlier.

Preserve temporary output directory with -d option.
This commit is contained in:
Matt Guthaus 2018-10-31 09:37:47 -07:00
parent 5302fd205f
commit 673027ac8c
1 changed files with 19 additions and 14 deletions

View File

@ -36,22 +36,28 @@ class openram_test(openram_test):
os.chmod(out_path, 0o0750) os.chmod(out_path, 0o0750)
# specify the same verbosity for the system call # specify the same verbosity for the system call
verbosity = "" opts = ""
for i in range(OPTS.debug_level): for i in range(OPTS.debug_level):
verbosity += " -v" opts += " -v"
# keep the temp directory around
if not OPTS.purge_temp:
opts += " -d"
OPENRAM_HOME = os.path.abspath(os.environ.get("OPENRAM_HOME")) OPENRAM_HOME = os.path.abspath(os.environ.get("OPENRAM_HOME"))
cmd = "python3 {0}/openram.py -n -o {1} -p {2} {3} config_20_{4}.py 2>&1 > {5}/output.log".format(OPENRAM_HOME, cmd = "python3 {0}/openram.py -n -o {1} -p {2} {3} config_20_{4}.py 2>&1 > {5}/output.log".format(OPENRAM_HOME,
out_file, out_file,
out_path, out_path,
verbosity, opts,
OPTS.tech_name, OPTS.tech_name,
out_path) out_path)
debug.info(1, cmd) debug.info(1, cmd)
os.system(cmd) os.system(cmd)
# check that the output path was created
self.assertEqual(os.path.exists(out_path),True)
# assert an error until we actually check a resul # assert an error until we actually check a resul
for extension in ["gds", "v", "lef", "sp"]: for extension in ["gds", "v", "lef", "sp"]:
filename = "{0}/{1}.{2}".format(out_path,out_file,extension) filename = "{0}/{1}.{2}".format(out_path,out_file,extension)
@ -64,9 +70,8 @@ class openram_test(openram_test):
self.assertTrue(len(files)>0) self.assertTrue(len(files)>0)
# Make sure there is any .html file # Make sure there is any .html file
if os.path.exists(out_path): datasheets = glob.glob('{0}/*html'.format(out_path))
datasheets = glob.glob('{0}/*html'.format(out_path)) self.assertTrue(len(datasheets)>0)
self.assertTrue(len(datasheets)>0)
# grep any errors from the output # grep any errors from the output
output_log = open("{0}/output.log".format(out_path),"r") output_log = open("{0}/output.log".format(out_path),"r")
@ -76,10 +81,10 @@ class openram_test(openram_test):
self.assertEqual(len(re.findall('WARNING',output)),0) self.assertEqual(len(re.findall('WARNING',output)),0)
# now clean up the directory # now clean up the output directory (or preserve if specified to preserve temp dirs)
if os.path.exists(out_path): if os.path.exists(out_path) and OPTS.purge_temp:
shutil.rmtree(out_path, ignore_errors=True) shutil.rmtree(out_path, ignore_errors=True)
self.assertEqual(os.path.exists(out_path),False) self.assertEqual(os.path.exists(out_path),False)
globals.end_openram() globals.end_openram()