1# -*- mode:python -*- 2 3# Copyright (c) 2004-2006 The Regents of The University of Michigan 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright --- 68 unchanged lines hidden (view full) --- 77 78def run_test(target, source, env): 79 """Check output from running test. 80 81 Targets are as follows: 82 target[0] : status 83 84 Sources are: |
85 source[0] : gem5 binary |
86 source[1] : tests/run.py script 87 source[2] : reference stats file 88 89 """ 90 # make sure target files are all gone 91 for t in target: 92 if os.path.exists(t.abspath): 93 env.Execute(Delete(t.abspath)) --- 6 unchanged lines hidden (view full) --- 100 cmd = '${SOURCES[0]} -d %s -re ${SOURCES[1]} %s' % (tgt_dir, tgt_dir) 101 102 # Prefix test run with batch job submission command if appropriate. 103 # Batch command also supports timeout arg (in seconds, not minutes). 104 timeout = 15 * 60 # used to be a param, probably should be again 105 if env['BATCH']: 106 cmd = '%s -t %d %s' % (env['BATCH_CMD'], timeout, cmd) 107 |
108 # Create a default value for the status string, changed as needed 109 # based on the status. 110 status_str = "passed." 111 |
112 pre_exec_time = time.time() 113 status = env.Execute(env.subst(cmd, target=target, source=source)) 114 if status == 0: |
115 # gem5 terminated normally. |
116 # Run diff on output & ref directories to find differences. 117 # Exclude the stats file since we will use diff-out on that. 118 119 # NFS file systems can be annoying and not have updated yet 120 # wait until we see the file modified 121 statsdiff = os.path.join(tgt_dir, 'statsdiff') 122 m_time = 0 123 nap = 0 --- 12 unchanged lines hidden (view full) --- 136 % (output_ignore_args, tgt_dir, outdiff) 137 env.Execute(env.subst(diffcmd, target=target, source=source)) 138 print "===== Output differences =====" 139 print contents(outdiff) 140 # Run diff-out on stats.txt file 141 diffcmd = '$DIFFOUT ${SOURCES[2]} %s > %s' \ 142 % (os.path.join(tgt_dir, 'stats.txt'), statsdiff) 143 diffcmd = env.subst(diffcmd, target=target, source=source) |
144 diff_status = env.Execute(diffcmd, strfunction=None) 145 # If there is a difference, change the status string to say so 146 if diff_status != 0: 147 status_str = "CHANGED!" |
148 print "===== Statistics differences =====" 149 print contents(statsdiff) 150 |
151 else: # gem5 exit status != 0 152 # Consider it a failed test unless the exit status is 2 153 status_str = "FAILED!" 154 # gem5 did not terminate properly, so no need to check the output |
155 if signaled(status): |
156 print 'gem5 terminated with signal', signum(status) |
157 if signum(status) in retry_signals: 158 # Consider the test incomplete; don't create a 'status' output. 159 # Hand the return status to scons and let scons decide what 160 # to do about it (typically terminate unless run with -k). 161 return status 162 elif status == 2: |
163 # The test was skipped, change the status string to say so 164 status_str = "skipped." |
165 else: |
166 print 'gem5 exited with non-zero status', status |
167 # complete but failed execution (call to exit() with non-zero 168 # status, SIGABORT due to assertion failure, etc.)... fall through 169 # and generate FAILED status as if output comparison had failed 170 |
171 # Generate status file contents based on exit status of gem5 and diff-out |
172 f = file(str(target[0]), 'w') 173 print >>f, tgt_dir, status_str 174 f.close() 175 # done 176 return 0 177 178def run_test_string(target, source, env): 179 return env.subst("Running test in ${TARGETS[0].dir}.", --- 9 unchanged lines hidden (view full) --- 189 # split the line to words and get the last one 190 words = line.split() 191 status = words[-1] 192 193 # if the test failed make it red, if it passed make it green, and 194 # skip the punctuation 195 if status == "FAILED!": 196 status = termcap.Red + status[:-1] + termcap.Normal + status[-1] |
197 elif status == "CHANGED!": 198 status = termcap.Yellow + status[:-1] + termcap.Normal + status[-1] |
199 elif status == "passed.": 200 status = termcap.Green + status[:-1] + termcap.Normal + status[-1] 201 elif status == "skipped.": |
202 status = termcap.Cyan + status[:-1] + termcap.Normal + status[-1] |
203 204 # put it back in the list and join with space 205 words[-1] = status 206 line = " ".join(words) 207 208 print '***** ' + line 209 return 0 210 --- 142 unchanged lines hidden --- |