summaryrefslogtreecommitdiff
path: root/src/systemc/tests
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-09-20 02:50:48 -0700
committerGabe Black <gabeblack@google.com>2018-10-16 00:24:47 +0000
commit638293cd62fca2d3f133169083977fbbfcc989cc (patch)
tree505afc74be2c40ac54e4ef959ff5ff8b2b5e5048 /src/systemc/tests
parentdfd2e7681e3bf87997ee65a5bc4fbd88cbb19935 (diff)
downloadgem5-638293cd62fca2d3f133169083977fbbfcc989cc.tar.xz
systemc: Teach verify.py how to verify vcd files.
The reference output skips the first 7 lines which have volatile info like the current time. Change-Id: I9c173ff3903982a07349ca6957ab25e07bdf8e54 Reviewed-on: https://gem5-review.googlesource.com/c/12824 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/tests')
-rwxr-xr-xsrc/systemc/tests/verify.py62
1 files changed, 41 insertions, 21 deletions
diff --git a/src/systemc/tests/verify.py b/src/systemc/tests/verify.py
index 14fc8fa48..27273ea8f 100755
--- a/src/systemc/tests/verify.py
+++ b/src/systemc/tests/verify.py
@@ -214,7 +214,31 @@ def warning_filt(num):
def info_filt(num):
return tagged_filt('Info', num)
-class LogChecker(Checker):
+class DiffingChecker(Checker):
+ def __init__(self, ref, test, tag, out_dir):
+ super(DiffingChecker, self).__init__(ref, test, tag)
+ self.out_dir = out_dir
+
+ def diffing_check(self, ref_lines, test_lines):
+ test_file = os.path.basename(self.test)
+ ref_file = os.path.basename(self.ref)
+
+ diff_file = '.'.join([ref_file, 'diff'])
+ diff_path = os.path.join(self.out_dir, diff_file)
+ if test_lines != ref_lines:
+ with open(diff_path, 'w') as diff_f:
+ for line in difflib.unified_diff(
+ ref_lines, test_lines,
+ fromfile=ref_file,
+ tofile=test_file):
+ diff_f.write(line)
+ return False
+ else:
+ if os.path.exists(diff_path):
+ os.unlink(diff_path)
+ return True
+
+class LogChecker(DiffingChecker):
def merge_filts(*filts):
filts = map(lambda f: '(' + f + ')', filts)
filts = '|'.join(filts)
@@ -246,33 +270,26 @@ class LogChecker(Checker):
in_file_filt,
)
- def __init__(self, ref, test, tag, out_dir):
- super(LogChecker, self).__init__(ref, test, tag)
- self.out_dir = out_dir
-
def apply_filters(self, data, filts):
re.sub(filt, '', data)
def check(self):
- test_file = os.path.basename(self.test)
- ref_file = os.path.basename(self.ref)
with open(self.test) as test_f, open(self.ref) as ref_f:
test = re.sub(self.test_filt, '', test_f.read())
ref = re.sub(self.ref_filt, '', ref_f.read())
- diff_file = '.'.join([ref_file, 'diff'])
- diff_path = os.path.join(self.out_dir, diff_file)
- if test != ref:
- with open(diff_path, 'w') as diff_f:
- for line in difflib.unified_diff(
- ref.splitlines(True), test.splitlines(True),
- fromfile=ref_file,
- tofile=test_file):
- diff_f.write(line)
- return False
- else:
- if os.path.exists(diff_path):
- os.unlink(diff_path)
- return True
+ return self.diffing_check(ref.splitlines(True),
+ test.splitlines(True))
+
+class VcdChecker(DiffingChecker):
+ def check(self):
+ with open (self.test) as test_f, open(self.ref) as ref_f:
+ ref = ref_f.read().splitlines(True)
+ test = test_f.read().splitlines(True)
+ # Strip off the first seven lines of the test output which are
+ # date and version information.
+ test = test[7:]
+
+ return self.diffing_check(ref, test)
class GoldenDir(object):
def __init__(self, path, platform):
@@ -447,6 +464,9 @@ class VerifyPhase(TestPhaseBase):
ref_path = gd.entry(name)
if not os.path.exists(test_path):
missing.append(name)
+ elif name.endswith('.vcd'):
+ diffs.append(VcdChecker(ref_path, test_path,
+ name, out_dir))
else:
diffs.append(Checker(ref_path, test_path, name))