- Execute(Delete(t.abspath))
- # Run diff on output & ref directories to find differences.
- # Exclude m5stats.txt since we will use diff-out on that.
- Execute(env.subst('diff -ubr ${SOURCES[0].dir} ${SOURCES[1].dir} ' +
- '-I "^command line:" ' + # for stdout file
- '-I "^M5 compiled " ' + # for stderr file
- '-I "^M5 started " ' + # for stderr file
- '-I "^M5 executing on " ' + # for stderr file
- '-I "^Simulation complete at" ' + # for stderr file
- '-I "^Listening for" ' + # for stderr file
- '-I "listening for remote gdb" ' + # for stderr file
- '--exclude=m5stats.txt --exclude=SCCS ' +
- '--exclude=${TARGETS[0].file} ' +
- '> ${TARGETS[0]}', target=target, source=source), None)
- print "===== Output differences ====="
- print contents(target[0])
- # Run diff-out on m5stats.txt file
- status = Execute(env.subst('$DIFFOUT $SOURCES > ${TARGETS[1]}',
- target=target, source=source),
- strfunction=None)
- print "===== Statistics differences ====="
- print contents(target[1])
- # Generate status file contents based on exit status of diff-out
+ env.Execute(Delete(t.abspath))
+
+ tgt_dir = os.path.dirname(str(target[0]))
+
+ # 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)
+
+ 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.
+ outdiff = os.path.join(tgt_dir, 'outdiff')
+ diffcmd = 'diff -ubr %s ${SOURCES[2].dir} %s > %s' \
+ % (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)
+ 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