diff --git a/compiler/debug.py b/compiler/debug.py index 96303fed..7001373e 100644 --- a/compiler/debug.py +++ b/compiler/debug.py @@ -16,7 +16,7 @@ def check(check,str): print("ERROR: file {0}: line {1}: {2}".format(os.path.basename(filename),line_number,str)) assert 0 -def error(str,return_value): +def error(str,return_value=0): (frame, filename, line_number, function_name, lines, index) = inspect.getouterframes(inspect.currentframe())[1] print("ERROR: file {0}: line {1}: {2}".format(os.path.basename(filename),line_number,str)) diff --git a/compiler/tests/testutils.py b/compiler/tests/testutils.py index 76f7b7fc..4907574b 100644 --- a/compiler/tests/testutils.py +++ b/compiler/tests/testutils.py @@ -62,10 +62,9 @@ class openram_test(unittest.TestCase): relative_diff = abs(value1 - value2) / max(value1,value2) check = relative_diff <= error_tolerance if not check: - debug.info(1,"NOT CLOSE {0} {1} relative diff={2}".format(value1,value2,relative_diff)) + self.fail("NOT CLOSE {0} {1} relative diff={2}".format(value1,value2,relative_diff)) else: debug.info(2,"CLOSE {0} {1} relative diff={2}".format(value1,value2,relative_diff)) - return (check) def relative_compare(self, value1,value2,error_tolerance): """ This is used to compare relative values. """ @@ -124,16 +123,16 @@ class openram_test(unittest.TestCase): # 3. Check if remaining string matches if b1 != b2: - self.fail("Line: {0}\n!=\nLine: {1}".format(b1,b2)) + self.fail("MISMATCH Line: {0}\n!=\nLine: {1}".format(b1,b2)) # 4. Now compare that the floats match if len(b1_floats)!=len(b2_floats): - self.fail("Len {0} != {1}".format(len(b1_floats),len(b2_floats))) + self.fail("MISMATCH Length {0} != {1}".format(len(b1_floats),len(b2_floats))) for (f1,f2) in zip(b1_floats,b2_floats): if not relative_compare(float(f1),float(f2),error_tolerance): - self.fail("Float {0} != {1}".format(f1,f2)) + self.fail("MISMATCH Float {0} != {1}".format(f1,f2)) - if not b1: + if not b1 and not b2: return