- # Base command for running test. We mess around with indirectly
- # referring to files via SOURCES and TARGETS so that scons can mess
- # with paths all it wants to and we still get the right files.
- cmd = '${SOURCES[0]} -d %s -re ${SOURCES[1]} %s' % (tgt_dir, tgt_dir)
-
- # Prefix test run with batch job submission command if appropriate.
- # Batch command also supports timeout arg (in seconds, not minutes).
- timeout = 15 * 60 # used to be a param, probably should be again
- 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')
- # 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
- 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)
- print "===== Statistics differences ====="
- print contents(statsdiff)
-
- else: # m5 exit status != 0
- # M5 did not terminate properly, so no need to check the output
- if signaled(status):
- print 'M5 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
- else:
- print 'M5 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!"
- f = file(str(target[0]), 'w')
- print >>f, tgt_dir, status_str
- f.close()
- # done