style: fix line lengths and include ordering
[gem5.git] / tests / testing / tests.py
index 4c467f25cbedbfde9faafac826481bdc92c1b4ac..c9a2a06b20f09ce70a901cbee3c9389edca7876a 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 #
 # Copyright (c) 2016 ARM Limited
 # All rights reserved
@@ -213,17 +213,35 @@ class Test(object):
             for u in self.verify_units()
         ]
 
-        return TestResult(self.test_name, run_results + verify_results)
+        return TestResult(self.test_name,
+                          run_results=run_results,
+                          verify_results=verify_results)
 
     def __str__(self):
         return self.test_name
 
 class ClassicTest(Test):
-    diff_ignore_files = [
-        # Stat files use a special stat differ, so don't include them
-        # here.
-        "stats.txt",
-    ]
+    # The diff ignore list contains all files that shouldn't be diffed
+    # using DiffOutFile. These files typically use special-purpose
+    # diff tools (e.g., DiffStatFile).
+    diff_ignore_files = FileIgnoreList(
+        names=(
+            # Stat files use a special stat differ
+            "stats.txt",
+        ), rex=(
+        ))
+
+    # These files should never be included in the list of
+    # reference files. This list should include temporary files
+    # and other files that we don't care about.
+    ref_ignore_files = FileIgnoreList(
+        names=(
+            "EMPTY",
+        ), rex=(
+            # Mercurial sometimes leaves backups when applying MQ patches
+            r"\.orig$",
+            r"\.rej$",
+        ))
 
     def __init__(self, gem5, output_dir, config_tuple,
                  timeout=None,
@@ -251,7 +269,7 @@ class ClassicTest(Test):
         for root, dirs, files in os.walk(ref_dir, topdown=False):
             for f in files:
                 fpath = os.path.join(root[len(ref_dir) + 1:], f)
-                if fpath not in ClassicTest.diff_ignore_files:
+                if fpath not in ClassicTest.ref_ignore_files:
                     yield fpath
 
     def run_units(self):
@@ -267,17 +285,21 @@ class ClassicTest(Test):
         ]
 
     def verify_units(self):
-        return [
-            DiffStatFile(ref_dir=self.ref_dir, test_dir=self.output_dir,
-                         skip=self.skip_diff_stat)
-        ] + [
+        ref_files = set(self.ref_files())
+        units = []
+        if "stats.txt" in ref_files:
+            units.append(
+                DiffStatFile(ref_dir=self.ref_dir, test_dir=self.output_dir,
+                             skip=self.skip_diff_stat))
+        units += [
             DiffOutFile(f,
                         ref_dir=self.ref_dir, test_dir=self.output_dir,
                         skip=self.skip_diff_out)
-            for f in self.ref_files()
-            if f not in ClassicTest.diff_ignore_files
+            for f in ref_files if f not in ClassicTest.diff_ignore_files
         ]
 
+        return units
+
     def update_ref(self):
         for fname in self.ref_files():
             shutil.copy(
@@ -318,7 +340,11 @@ def get_tests(isa,
     if ruby_protocol == 'MI_example':
         configs += [ "%s-ruby" % (c, ) for c in configs ]
     elif ruby_protocol is not None:
-        configs += [ "%s-ruby-%s" % (c, ruby_protocol) for c in configs ]
+        # Override generic ISA configs when using Ruby (excluding
+        # MI_example which is included in all ISAs by default). This
+        # reduces the number of generic tests we re-run for when
+        # compiling Ruby targets.
+        configs = [ "%s-ruby-%s" % (c, ruby_protocol) for c in configs ]
 
     # /(quick|long)/(fs|se)/workload/ref/arch/guest/config/
     for conf_script in configs: