From: Gabe Black Date: Sat, 28 Jul 2018 06:39:10 +0000 (-0700) Subject: systemc: Make verify.py compare non output log reference files. X-Git-Tag: v19.0.0.0~1810 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=267b788783f0edd9359ea489aec592910472154d;p=gem5.git systemc: Make verify.py compare non output log reference files. There are only a few of these which are vcd files. If there are reference files which aren't the log and which aren't in the gem5 output directory, mark those tests as failed as well. Change-Id: I2c880c13d0f90ccf16ac0439dbac68de9223cc90 Reviewed-on: https://gem5-review.googlesource.com/12060 Reviewed-by: Gabe Black Maintainer: Gabe Black --- diff --git a/src/systemc/tests/verify.py b/src/systemc/tests/verify.py index ad6131970..062651d5d 100755 --- a/src/systemc/tests/verify.py +++ b/src/systemc/tests/verify.py @@ -227,6 +227,60 @@ class LogChecker(Checker): os.unlink(diff_path) return True +class GoldenDir(object): + def __init__(self, path, platform): + self.path = path + self.platform = platform + + contents = os.listdir(path) + suffix = '.' + platform + suffixed = filter(lambda c: c.endswith(suffix), contents) + bases = map(lambda t: t[:-len(platform)], suffixed) + common = filter(lambda t: not t.startswith(tuple(bases)), contents) + + self.entries = {} + class Entry(object): + def __init__(self, e_path): + self.used = False + self.path = os.path.join(path, e_path) + + def use(self): + self.used = True + + for entry in contents: + self.entries[entry] = Entry(entry) + + def entry(self, name): + def match(n): + return (n == name) or n.startswith(name + '.') + matches = { n: e for n, e in self.entries.items() if match(n) } + + for match in matches.values(): + match.use() + + platform_name = '.'.join([ name, self.platform ]) + if platform_name in matches: + return matches[platform_name].path + if name in matches: + return matches[name].path + else: + return None + + def unused(self): + items = self.entries.items() + items = filter(lambda i: not i[1].used, items) + + items.sort() + sources = [] + i = 0 + while i < len(items): + root = items[i][0] + sources.append(root) + i += 1 + while i < len(items) and items[i][0].startswith(root): + i += 1 + return sources + class VerifyPhase(TestPhaseBase): name = 'verify' number = 3 @@ -321,14 +375,29 @@ class VerifyPhase(TestPhaseBase): diffs = [] + gd = GoldenDir(test.golden_dir(), 'linux64') + + missing = [] log_file = '.'.join([test.name, 'log']) - log_path = os.path.join(test.golden_dir(), log_file) + log_path = gd.entry(log_file) simout_path = os.path.join(out_dir, 'simout') if not os.path.exists(simout_path): - self.failed(test, 'no log output') - if os.path.exists(log_path): - diffs.append(LogChecker( - log_path, simout_path, log_file, out_dir)) + missing.append('log output') + elif log_path: + diffs.append(LogChecker(log_path, simout_path, + log_file, out_dir)) + + for name in gd.unused(): + test_path = os.path.join(out_dir, name) + ref_path = gd.entry(name) + if not os.path.exists(test_path): + missing.append(name) + else: + diffs.append(Checker(ref_path, test_path, name)) + + if missing: + self.failed(test, 'missing output', ' '.join(missing)) + continue failed_diffs = filter(lambda d: not d.check(), diffs) if failed_diffs: