mirror of https://github.com/VLSIDA/OpenRAM.git
PEP8 format testutils.
This commit is contained in:
parent
e14deff3d1
commit
fb3acae908
|
|
@ -5,18 +5,16 @@
|
||||||
# (acting for and on behalf of Oklahoma State University)
|
# (acting for and on behalf of Oklahoma State University)
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
import unittest,warnings
|
import unittest
|
||||||
import pdb,traceback
|
import sys, os, glob
|
||||||
import sys,os,glob,copy
|
|
||||||
import shutil
|
|
||||||
sys.path.append(os.getenv("OPENRAM_HOME"))
|
sys.path.append(os.getenv("OPENRAM_HOME"))
|
||||||
from globals import OPTS
|
from globals import OPTS
|
||||||
import debug
|
import debug
|
||||||
|
|
||||||
|
|
||||||
class openram_test(unittest.TestCase):
|
class openram_test(unittest.TestCase):
|
||||||
""" Base unit test that we have some shared classes in. """
|
""" Base unit test that we have some shared classes in. """
|
||||||
|
|
||||||
|
|
||||||
def local_drc_check(self, w):
|
def local_drc_check(self, w):
|
||||||
|
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
@ -56,24 +54,26 @@ class openram_test(unittest.TestCase):
|
||||||
|
|
||||||
# Only allow DRC to fail and LVS to pass if we are using magic
|
# Only allow DRC to fail and LVS to pass if we are using magic
|
||||||
if "magic" in OPTS.drc_exe and lvs_result == 0 and drc_result != 0:
|
if "magic" in OPTS.drc_exe and lvs_result == 0 and drc_result != 0:
|
||||||
|
# import shutil
|
||||||
# zip_file = "/tmp/{0}_{1}".format(a.name, os.getpid())
|
# zip_file = "/tmp/{0}_{1}".format(a.name, os.getpid())
|
||||||
# debug.info(0, "Archiving failed files to {}.zip".format(zip_file))
|
# debug.info(0, "Archiving failed files to {}.zip".format(zip_file))
|
||||||
# shutil.make_archive(zip_file, 'zip', OPTS.openram_temp)
|
# shutil.make_archive(zip_file, 'zip', OPTS.openram_temp)
|
||||||
debug.warning("DRC failed but LVS passed: {}".format(a.name))
|
debug.warning("DRC failed but LVS passed: {}".format(a.name))
|
||||||
# self.fail("DRC failed but LVS passed: {}".format(a.name))
|
# self.fail("DRC failed but LVS passed: {}".format(a.name))
|
||||||
elif drc_result != 0:
|
elif drc_result != 0:
|
||||||
|
# import shutil
|
||||||
# zip_file = "/tmp/{0}_{1}".format(a.name, os.getpid())
|
# zip_file = "/tmp/{0}_{1}".format(a.name, os.getpid())
|
||||||
# debug.info(0,"Archiving failed files to {}.zip".format(zip_file))
|
# debug.info(0,"Archiving failed files to {}.zip".format(zip_file))
|
||||||
# shutil.make_archive(zip_file, 'zip', OPTS.openram_temp)
|
# shutil.make_archive(zip_file, 'zip', OPTS.openram_temp)
|
||||||
self.fail("DRC failed: {}".format(a.name))
|
self.fail("DRC failed: {}".format(a.name))
|
||||||
|
|
||||||
if lvs_result != 0:
|
if lvs_result != 0:
|
||||||
|
# import shutil
|
||||||
# zip_file = "/tmp/{0}_{1}".format(a.name, os.getpid())
|
# zip_file = "/tmp/{0}_{1}".format(a.name, os.getpid())
|
||||||
# debug.info(0,"Archiving failed files to {}.zip".format(zip_file))
|
# debug.info(0,"Archiving failed files to {}.zip".format(zip_file))
|
||||||
# shutil.make_archive(zip_file, 'zip', OPTS.openram_temp)
|
# shutil.make_archive(zip_file, 'zip', OPTS.openram_temp)
|
||||||
self.fail("LVS mismatch: {}".format(a.name))
|
self.fail("LVS mismatch: {}".format(a.name))
|
||||||
|
|
||||||
|
|
||||||
# For debug...
|
# For debug...
|
||||||
# import pdb; pdb.set_trace()
|
# import pdb; pdb.set_trace()
|
||||||
if OPTS.purge_temp:
|
if OPTS.purge_temp:
|
||||||
|
|
@ -98,7 +98,7 @@ class openram_test(unittest.TestCase):
|
||||||
debug.info(1, "Finding feasible period for current test.")
|
debug.info(1, "Finding feasible period for current test.")
|
||||||
delay_obj.set_load_slew(load, slew)
|
delay_obj.set_load_slew(load, slew)
|
||||||
test_port = delay_obj.read_ports[0] # Only test one port, assumes other ports have similar period.
|
test_port = delay_obj.read_ports[0] # Only test one port, assumes other ports have similar period.
|
||||||
delay_obj.analysis_init(probe_address="1"*sram.addr_size, probe_data=(sram.word_size-1))
|
delay_obj.analysis_init(probe_address="1" * sram.addr_size, probe_data=sram.word_size - 1)
|
||||||
delay_obj.find_feasible_period_one_port(test_port)
|
delay_obj.find_feasible_period_one_port(test_port)
|
||||||
return delay_obj.period
|
return delay_obj.period
|
||||||
|
|
||||||
|
|
@ -141,8 +141,6 @@ class openram_test(unittest.TestCase):
|
||||||
debug.error("Results exceeded {:.1f}% tolerance compared to golden results:\n".format(error_tolerance * 100) + data_string)
|
debug.error("Results exceeded {:.1f}% tolerance compared to golden results:\n".format(error_tolerance * 100) + data_string)
|
||||||
return data_matches
|
return data_matches
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def isclose(self, key, value, actual_value, error_tolerance=1e-2):
|
def isclose(self, key, value, actual_value, error_tolerance=1e-2):
|
||||||
""" This is used to compare relative values. """
|
""" This is used to compare relative values. """
|
||||||
import debug
|
import debug
|
||||||
|
|
@ -169,13 +167,9 @@ class openram_test(unittest.TestCase):
|
||||||
|
|
||||||
# Get normalization value
|
# Get normalization value
|
||||||
norm_value = abs(max(value1, value2))
|
norm_value = abs(max(value1, value2))
|
||||||
# Edge case where greater is a zero
|
|
||||||
if norm_value == 0:
|
|
||||||
min_value = abs(min(value1, value2))
|
|
||||||
|
|
||||||
return abs(value1 - value2) / norm_value
|
return abs(value1 - value2) / norm_value
|
||||||
|
|
||||||
|
|
||||||
def relative_compare(self, value, actual_value, error_tolerance):
|
def relative_compare(self, value, actual_value, error_tolerance):
|
||||||
""" This is used to compare relative values. """
|
""" This is used to compare relative values. """
|
||||||
if (value==actual_value): # if we don't need a relative comparison!
|
if (value==actual_value): # if we don't need a relative comparison!
|
||||||
|
|
@ -227,7 +221,6 @@ class openram_test(unittest.TestCase):
|
||||||
debug.info(3, "line1_floats: " + str(line1_floats))
|
debug.info(3, "line1_floats: " + str(line1_floats))
|
||||||
debug.info(3, "line2_floats: " + str(line2_floats))
|
debug.info(3, "line2_floats: " + str(line2_floats))
|
||||||
|
|
||||||
|
|
||||||
# 2. Remove the floats from the string
|
# 2. Remove the floats from the string
|
||||||
for f in line1_floats:
|
for f in line1_floats:
|
||||||
line1=line1.replace(f, "", 1)
|
line1=line1.replace(f, "", 1)
|
||||||
|
|
@ -275,7 +268,6 @@ class openram_test(unittest.TestCase):
|
||||||
# Never reached
|
# Never reached
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def isdiff(self, filename1, filename2):
|
def isdiff(self, filename1, filename2):
|
||||||
""" This is used to compare two files and display the diff if they are different.. """
|
""" This is used to compare two files and display the diff if they are different.. """
|
||||||
import debug
|
import debug
|
||||||
|
|
@ -305,6 +297,9 @@ class openram_test(unittest.TestCase):
|
||||||
debug.info(2, "MATCH {0} {1}".format(filename1, filename2))
|
debug.info(2, "MATCH {0} {1}".format(filename1, filename2))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def dbg():
|
||||||
|
import pdb; pdb.set_trace()
|
||||||
|
|
||||||
|
|
||||||
def header(filename, technology):
|
def header(filename, technology):
|
||||||
# Skip the header for gitlab regression
|
# Skip the header for gitlab regression
|
||||||
|
|
@ -323,10 +318,14 @@ def header(filename, technology):
|
||||||
print("|=========" + OPTS.openram_temp.center(60) + "=========|")
|
print("|=========" + OPTS.openram_temp.center(60) + "=========|")
|
||||||
print("|==============================================================================|")
|
print("|==============================================================================|")
|
||||||
|
|
||||||
|
|
||||||
def debugTestRunner(post_mortem=None):
|
def debugTestRunner(post_mortem=None):
|
||||||
"""unittest runner doing post mortem debugging on failing tests"""
|
"""unittest runner doing post mortem debugging on failing tests"""
|
||||||
|
import pdb
|
||||||
|
import traceback
|
||||||
if post_mortem is None and not OPTS.purge_temp:
|
if post_mortem is None and not OPTS.purge_temp:
|
||||||
post_mortem = pdb.post_mortem
|
post_mortem = pdb.post_mortem
|
||||||
|
|
||||||
class DebugTestResult(unittest.TextTestResult):
|
class DebugTestResult(unittest.TextTestResult):
|
||||||
def addError(self, test, err):
|
def addError(self, test, err):
|
||||||
# called before tearDown()
|
# called before tearDown()
|
||||||
|
|
@ -334,6 +333,7 @@ def debugTestRunner(post_mortem=None):
|
||||||
if post_mortem:
|
if post_mortem:
|
||||||
post_mortem(err[2])
|
post_mortem(err[2])
|
||||||
super(DebugTestResult, self).addError(test, err)
|
super(DebugTestResult, self).addError(test, err)
|
||||||
|
|
||||||
def addFailure(self, test, err):
|
def addFailure(self, test, err):
|
||||||
traceback.print_exception(*err)
|
traceback.print_exception(*err)
|
||||||
if post_mortem:
|
if post_mortem:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue