tests: fix spurious scons "Error 1" messages
[gem5.git] / tests / SConscript
index 44389142dfa6449f50172eb9c025a05e0cd4febb..12328c0c192e04475cfb5e8231c3c2c62a1f0aba 100644 (file)
@@ -30,7 +30,7 @@
 #          Kevin Lim
 
 import os, signal
-import sys
+import sys, time
 import glob
 from SCons.Script.SConscript import SConsEnvironment
 
@@ -102,19 +102,35 @@ def run_test(target, source, env):
     if env['BATCH']:
         cmd = '%s -t %d %s' % (env['BATCH_CMD'], timeout, cmd)
 
+    pre_exec_time = time.time()
     status = env.Execute(env.subst(cmd, target=target, source=source))
     if status == 0:
         # M5 terminated normally.
         # Run diff on output & ref directories to find differences.
         # Exclude the stats file since we will use diff-out on that.
+
+        # NFS file systems can be annoying and not have updated yet
+        # wait until we see the file modified
+        statsdiff = os.path.join(tgt_dir, 'statsdiff')
+        m_time = 0
+        nap = 0
+        while m_time < pre_exec_time and nap < 10:
+            try:
+                m_time = os.stat(statsdiff).st_mtime
+            except OSError:
+                pass
+            time.sleep(1)
+            nap += 1
+
         outdiff = os.path.join(tgt_dir, 'outdiff')
-        diffcmd = 'diff -ubr %s ${SOURCES[2].dir} %s > %s' \
+        # tack 'true' on the end so scons doesn't report diff's
+        # non-zero exit code as a build error
+        diffcmd = 'diff -ubrs %s ${SOURCES[2].dir} %s > %s; true' \
                   % (output_ignore_args, tgt_dir, outdiff)
         env.Execute(env.subst(diffcmd, target=target, source=source))
         print "===== Output differences ====="
         print contents(outdiff)
         # Run diff-out on stats.txt file
-        statsdiff = os.path.join(tgt_dir, 'statsdiff')
         diffcmd = '$DIFFOUT ${SOURCES[2]} %s > %s' \
                   % (os.path.join(tgt_dir, 'stats.txt'), statsdiff)
         diffcmd = env.subst(diffcmd, target=target, source=source)
@@ -164,7 +180,7 @@ printAction = env.Action(print_test, strfunction = None)
 # - long-winded message about ignored sources
 ignore_msg = '''
 Note: The following file(s) will not be copied.  New non-standard
-      output files must be copied manually once before update_ref will
+      output files must be copied manually once before --update-ref will
       recognize them as outputs.  Otherwise they are assumed to be
       inputs and are ignored.
 '''
@@ -237,7 +253,7 @@ def test_builder(env, ref_dir):
                 testAction)
 
     # phony target to echo status
-    if env['update_ref']:
+    if GetOption('update_ref'):
         p = env.Command(tgt('_update'),
                         [ref_stats, new_stats, status_file],
                         updateAction)
@@ -256,24 +272,39 @@ if env['FULL_SYSTEM']:
                     'tsunami-simple-atomic-dual',
                     'tsunami-simple-timing-dual',
                     'twosys-tsunami-simple-atomic',
-                    'tsunami-o3', 'tsunami-o3-dual']
+                    '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']
+                'inorder-timing', 'rubytest']
 
-if env['RUBY']:
-    # Hack for Ruby
-    configs += [c + '-ruby' for c in configs]
+if env['PROTOCOL'] != 'None':
+    if env['PROTOCOL'] == 'MI_example':
+        configs += [c + "-ruby" for c in configs]
+    else:
+        configs = [c + "-ruby-" + env['PROTOCOL'] for c in configs]
 
 cwd = os.getcwd()
 os.chdir(str(Dir('.').srcdir))
 for config in configs:
     dirs = glob.glob('*/*/ref/%s/*/%s' % (env['TARGET_ISA'], config))
     for d in dirs:
-        test_builder(env, d)
+        if not os.path.exists(os.path.join(d, 'skip')):
+            test_builder(env, d)
 os.chdir(cwd)