SConscript (9674:d35bd171cf2a) SConscript (9781:2bddf82f610b)
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:
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] : M5 binary
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
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
108 pre_exec_time = time.time()
109 status = env.Execute(env.subst(cmd, target=target, source=source))
110 if status == 0:
112 pre_exec_time = time.time()
113 status = env.Execute(env.subst(cmd, target=target, source=source))
114 if status == 0:
111 # M5 terminated normally.
115 # gem5 terminated normally.
112 # Run diff on output & ref directories to find differences.
113 # Exclude the stats file since we will use diff-out on that.
114
115 # NFS file systems can be annoying and not have updated yet
116 # wait until we see the file modified
117 statsdiff = os.path.join(tgt_dir, 'statsdiff')
118 m_time = 0
119 nap = 0

--- 12 unchanged lines hidden (view full) ---

132 % (output_ignore_args, tgt_dir, outdiff)
133 env.Execute(env.subst(diffcmd, target=target, source=source))
134 print "===== Output differences ====="
135 print contents(outdiff)
136 # Run diff-out on stats.txt file
137 diffcmd = '$DIFFOUT ${SOURCES[2]} %s > %s' \
138 % (os.path.join(tgt_dir, 'stats.txt'), statsdiff)
139 diffcmd = env.subst(diffcmd, target=target, source=source)
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)
140 status = env.Execute(diffcmd, strfunction=None)
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!"
141 print "===== Statistics differences ====="
142 print contents(statsdiff)
143
148 print "===== Statistics differences ====="
149 print contents(statsdiff)
150
144 else: # m5 exit status != 0
145 # M5 did not terminate properly, so no need to check the output
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
146 if signaled(status):
155 if signaled(status):
147 print 'M5 terminated with signal', signum(status)
156 print 'gem5 terminated with signal', signum(status)
148 if signum(status) in retry_signals:
149 # Consider the test incomplete; don't create a 'status' output.
150 # Hand the return status to scons and let scons decide what
151 # to do about it (typically terminate unless run with -k).
152 return status
153 elif status == 2:
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:
154 # The test was skipped
155 pass
163 # The test was skipped, change the status string to say so
164 status_str = "skipped."
156 else:
165 else:
157 print 'M5 exited with non-zero status', status
166 print 'gem5 exited with non-zero status', status
158 # complete but failed execution (call to exit() with non-zero
159 # status, SIGABORT due to assertion failure, etc.)... fall through
160 # and generate FAILED status as if output comparison had failed
161
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
162 # Generate status file contents based on exit status of m5 or diff-out
163 if status == 0:
164 status_str = "passed."
165 elif status == 2:
166 status_str = "skipped."
167 else:
168 status_str = "FAILED!"
171 # Generate status file contents based on exit status of gem5 and diff-out
169 f = file(str(target[0]), 'w')
170 print >>f, tgt_dir, status_str
171 f.close()
172 # done
173 return 0
174
175def run_test_string(target, source, env):
176 return env.subst("Running test in ${TARGETS[0].dir}.",

--- 9 unchanged lines hidden (view full) ---

186 # split the line to words and get the last one
187 words = line.split()
188 status = words[-1]
189
190 # if the test failed make it red, if it passed make it green, and
191 # skip the punctuation
192 if status == "FAILED!":
193 status = termcap.Red + status[:-1] + termcap.Normal + status[-1]
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]
194 elif status == "passed.":
195 status = termcap.Green + status[:-1] + termcap.Normal + status[-1]
196 elif status == "skipped.":
199 elif status == "passed.":
200 status = termcap.Green + status[:-1] + termcap.Normal + status[-1]
201 elif status == "skipped.":
197 status = termcap.Yellow + status[:-1] + termcap.Normal + status[-1]
202 status = termcap.Cyan + status[:-1] + termcap.Normal + status[-1]
198
199 # put it back in the list and join with space
200 words[-1] = status
201 line = " ".join(words)
202
203 print '***** ' + line
204 return 0
205

--- 142 unchanged lines hidden ---
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 ---