Deleted Added
sdiff udiff text old ( 2953:10e7700b27f6 ) new ( 2997:d4f750d960e5 )
full compact
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

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

134 return 0
135
136def update_test_string(target, source, env):
137 return env.subst("Updating ${SOURCES[0].dir} from ${SOURCES[1].dir}",
138 target=target, source=source)
139
140updateAction = env.Action(update_test, update_test_string)
141
142def test_builder(env, ref_dir):
143 """Define a test."""
144
145 (category, name, _ref, isa, opsys, config) = ref_dir.split('/')
146 assert(_ref == 'ref')
147
148 # target path (where test output goes) is the same except without
149 # the 'ref' component
150 tgt_dir = os.path.join(category, name, isa, opsys, config)
151
152 # prepend file name with tgt_dir
153 def tgt(f):
154 return os.path.join(tgt_dir, f)
155
156 ref_stats = os.path.join(ref_dir, 'm5stats.txt')
157 new_stats = tgt('m5stats.txt')
158 status_file = tgt('status')
159
160 # Base command for running test. We mess around with indirectly
161 # referring to files via SOURCES and TARGETS so that scons can
162 # mess with paths all it wants to and we still get the right
163 # files.
164 base_cmd = '${SOURCES[0]} -d $TARGET.dir ${SOURCES[1]} %s' % tgt_dir
165 # stdout and stderr files
166 cmd_stdout = '${TARGETS[0]}'
167 cmd_stderr = '${TARGETS[1]}'
168
169 # Prefix test run with batch job submission command if appropriate.
170 # Output redirection is also different for batch runs.
171 # Batch command also supports timeout arg (in seconds, not minutes).
172 if env['BATCH']:
173 cmd = [env['BATCH_CMD'], '-t', str(timeout * 60),
174 '-o', cmd_stdout, '-e', cmd_stderr, base_cmd]
175 else:
176 cmd = [base_cmd, '>', cmd_stdout, '2>', cmd_stderr]
177
178 env.Command([tgt('stdout'), tgt('stderr'), new_stats],
179 [env.M5Binary, 'run.py'], ' '.join(cmd))
180
181 # order of targets is important... see check_test
182 env.Command([tgt('outdiff'), tgt('statsdiff'), status_file],
183 [ref_stats, new_stats],
184 testAction)
185
186 # phony target to echo status
187 if env['update_ref']:
188 p = env.Command(tgt('_update'),
189 [ref_stats, new_stats, status_file],
190 updateAction)
191 else:
192 p = env.Command(tgt('_print'), [status_file], printAction)
193
194 env.AlwaysBuild(p)
195
196
197cwd = os.getcwd()
198os.chdir(str(Dir('.').srcdir))
199for config in ['simple-atomic']:
200 dirs = glob.glob('*/*/ref/%s/*/%s' % (env['TARGET_ISA'], config))
201 for d in dirs:
202 test_builder(env, d)
203os.chdir(cwd)