stats: updates due to changes to ruby
[gem5.git] / tests / SConscript
index 12328c0c192e04475cfb5e8231c3c2c62a1f0aba..5c1eb5f7b94d7dbb9d4bd56cbc55d5c3714311f4 100644 (file)
@@ -38,6 +38,9 @@ Import('env')
 
 env['DIFFOUT'] = File('diff-out')
 
+# get the termcap from the environment
+termcap = env['TERMCAP']
+
 # Dict that accumulates lists of tests by category (quick, medium, long)
 env.Tests = {}
 
@@ -60,9 +63,9 @@ retry_signals = (signal.SIGTERM, signal.SIGKILL, signal.SIGINT,
 # regular expressions of lines to ignore when diffing outputs
 output_ignore_regexes = (
     '^command line:',          # for stdout file
-    '^M5 compiled ',           # for stderr file
-    '^M5 started ',            # for stderr file
-    '^M5 executing on ',       # for stderr file
+    '^gem5 compiled ',         # for stderr file
+    '^gem5 started ',          # for stderr file
+    '^gem5 executing on ',     # for stderr file
     '^Simulation complete at', # for stderr file
     '^Listening for',          # for stderr file
     'listening for remote gdb',        # for stderr file
@@ -79,7 +82,7 @@ def run_test(target, source, env):
     target[0] : status
 
     Sources are:
-    source[0] : M5 binary
+    source[0] : gem5 binary
     source[1] : tests/run.py script
     source[2] : reference stats file
 
@@ -102,10 +105,14 @@ def run_test(target, source, env):
     if env['BATCH']:
         cmd = '%s -t %d %s' % (env['BATCH_CMD'], timeout, cmd)
 
+    # Create a default value for the status string, changed as needed
+    # based on the status.
+    status_str = "passed."
+
     pre_exec_time = time.time()
     status = env.Execute(env.subst(cmd, target=target, source=source))
     if status == 0:
-        # M5 terminated normally.
+        # gem5 terminated normally.
         # Run diff on output & ref directories to find differences.
         # Exclude the stats file since we will use diff-out on that.
 
@@ -134,30 +141,34 @@ def run_test(target, source, env):
         diffcmd = '$DIFFOUT ${SOURCES[2]} %s > %s' \
                   % (os.path.join(tgt_dir, 'stats.txt'), statsdiff)
         diffcmd = env.subst(diffcmd, target=target, source=source)
-        status = env.Execute(diffcmd, strfunction=None)
+        diff_status = env.Execute(diffcmd, strfunction=None)
+        # If there is a difference, change the status string to say so
+        if diff_status != 0:
+            status_str = "CHANGED!"
         print "===== Statistics differences ====="
         print contents(statsdiff)
 
-    else: # m5 exit status != 0
-        # M5 did not terminate properly, so no need to check the output
+    else: # gem5 exit status != 0
+        # Consider it a failed test unless the exit status is 2
+        status_str = "FAILED!"
+        # gem5 did not terminate properly, so no need to check the output
         if signaled(status):
-            print 'M5 terminated with signal', signum(status)
+            print 'gem5 terminated with signal', signum(status)
             if signum(status) in retry_signals:
                 # Consider the test incomplete; don't create a 'status' output.
                 # Hand the return status to scons and let scons decide what
                 # to do about it (typically terminate unless run with -k).
                 return status
+        elif status == 2:
+            # The test was skipped, change the status string to say so
+            status_str = "skipped."
         else:
-            print 'M5 exited with non-zero status', status
+            print 'gem5 exited with non-zero status', status
         # complete but failed execution (call to exit() with non-zero
         # status, SIGABORT due to assertion failure, etc.)... fall through
         # and generate FAILED status as if output comparison had failed
 
-    # Generate status file contents based on exit status of m5 or diff-out
-    if status == 0:
-        status_str = "passed."
-    else:
-        status_str = "FAILED!"
+    # Generate status file contents based on exit status of gem5 and diff-out
     f = file(str(target[0]), 'w')
     print >>f, tgt_dir, status_str
     f.close()
@@ -171,7 +182,30 @@ def run_test_string(target, source, env):
 testAction = env.Action(run_test, run_test_string)
 
 def print_test(target, source, env):
-    print '***** ' + contents(source[0])
+    # print the status with colours to make it easier to see what
+    # passed and what failed
+    line = contents(source[0])
+
+    # split the line to words and get the last one
+    words = line.split()
+    status = words[-1]
+
+    # if the test failed make it red, if it passed make it green, and
+    # skip the punctuation
+    if status == "FAILED!":
+        status = termcap.Red + status[:-1] + termcap.Normal + status[-1]
+    elif status == "CHANGED!":
+        status = termcap.Yellow + status[:-1] + termcap.Normal + status[-1]
+    elif status == "passed.":
+        status = termcap.Green + status[:-1] + termcap.Normal + status[-1]
+    elif status == "skipped.":
+        status = termcap.Cyan + status[:-1] + termcap.Normal + status[-1]
+
+    # put it back in the list and join with space
+    words[-1] = status
+    line = " ".join(words)
+
+    print '***** ' + line
     return 0
 
 printAction = env.Action(print_test, strfunction = None)
@@ -233,12 +267,12 @@ updateAction = env.Action(update_test, update_test_string)
 def test_builder(env, ref_dir):
     """Define a test."""
 
-    (category, name, _ref, isa, opsys, config) = ref_dir.split('/')
+    (category, mode, name, _ref, isa, opsys, config) = ref_dir.split('/')
     assert(_ref == 'ref')
 
     # target path (where test output goes) is the same except without
     # the 'ref' component
-    tgt_dir = os.path.join(category, name, isa, opsys, config)
+    tgt_dir = os.path.join(category, mode, name, isa, opsys, config)
 
     # prepend file name with tgt_dir
     def tgt(f):
@@ -248,7 +282,7 @@ def test_builder(env, ref_dir):
     new_stats = tgt('stats.txt')
     status_file = tgt('status')
 
-    env.Command([status_file],
+    env.Command([status_file, new_stats],
                 [env.M5Binary, 'run.py', ref_stats],
                 testAction)
 
@@ -265,34 +299,42 @@ def test_builder(env, ref_dir):
 
 # Figure out applicable configs based on build type
 configs = []
-if env['FULL_SYSTEM']:
-    if env['TARGET_ISA'] == 'alpha':
-        configs += ['tsunami-simple-atomic',
-                    'tsunami-simple-timing',
-                    'tsunami-simple-atomic-dual',
-                    'tsunami-simple-timing-dual',
-                    'twosys-tsunami-simple-atomic',
-                    'tsunami-o3', 'tsunami-o3-dual',
-                    'tsunami-inorder']
-    if env['TARGET_ISA'] == 'sparc':
-        configs += ['t1000-simple-atomic',
-                    't1000-simple-timing']
-    if env['TARGET_ISA'] == 'arm':
-        configs += ['realview-simple-atomic',
-                    'realview-simple-atomic-dual',
-                    'realview-simple-timing',
-                    'realview-simple-timing-dual',
-                    'realview-o3',
-                    'realview-o3-dual']
-    if env['TARGET_ISA'] == 'x86':
-        configs += ['pc-simple-atomic',
-                    'pc-simple-timing',
-                    'pc-o3-timing']
-
-else:
-    configs += ['simple-atomic', 'simple-timing', 'o3-timing', 'memtest',
-                'simple-atomic-mp', 'simple-timing-mp', 'o3-timing-mp',
-                'inorder-timing', 'rubytest']
+if env['TARGET_ISA'] == 'alpha':
+    configs += ['tsunami-simple-atomic',
+                'tsunami-simple-timing',
+                'tsunami-simple-atomic-dual',
+                'tsunami-simple-timing-dual',
+                'twosys-tsunami-simple-atomic',
+                'tsunami-o3', 'tsunami-o3-dual',
+                'tsunami-inorder',
+                'tsunami-switcheroo-full']
+if env['TARGET_ISA'] == 'sparc':
+    configs += ['t1000-simple-atomic',
+                't1000-simple-timing']
+if env['TARGET_ISA'] == 'arm':
+    configs += ['simple-atomic-dummychecker',
+                'o3-timing-checker',
+                'realview-simple-atomic',
+                'realview-simple-atomic-dual',
+                'realview-simple-timing',
+                'realview-simple-timing-dual',
+                'realview-o3',
+                'realview-o3-checker',
+                'realview-o3-dual',
+                'realview-switcheroo-atomic',
+                'realview-switcheroo-timing',
+                'realview-switcheroo-o3',
+                'realview-switcheroo-full']
+if env['TARGET_ISA'] == 'x86':
+    configs += ['pc-simple-atomic',
+                'pc-simple-timing',
+                'pc-o3-timing',
+                'pc-switcheroo-full']
+
+configs += ['simple-atomic', 'simple-timing', 'o3-timing', 'memtest',
+            'simple-atomic-mp', 'simple-timing-mp', 'o3-timing-mp',
+            'inorder-timing', 'rubytest', 'tgen-simple-mem',
+            'tgen-simple-dram']
 
 if env['PROTOCOL'] != 'None':
     if env['PROTOCOL'] == 'MI_example':
@@ -303,7 +345,7 @@ if env['PROTOCOL'] != 'None':
 cwd = os.getcwd()
 os.chdir(str(Dir('.').srcdir))
 for config in configs:
-    dirs = glob.glob('*/*/ref/%s/*/%s' % (env['TARGET_ISA'], config))
+    dirs = glob.glob('*/*/*/ref/%s/*/%s' % (env['TARGET_ISA'], config))
     for d in dirs:
         if not os.path.exists(os.path.join(d, 'skip')):
             test_builder(env, d)