summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2005-09-05 16:31:27 -0400
committerSteve Reinhardt <stever@eecs.umich.edu>2005-09-05 16:31:27 -0400
commit845bdb0d8edf3c8e5f8871eba984933bfca6a743 (patch)
treef4a39ba980264772c503ad25c0298cac909f5770
parent9196fbfe5e2246a4f9086a8692a0569d25fd84d9 (diff)
downloadgem5-845bdb0d8edf3c8e5f8871eba984933bfca6a743.tar.xz
Regression tests now run under scons!
For example, 'scons ALPHA_SE/test/opt/quick' will build ALPHA_SE/m5.opt if necessary and run all the self-identified "quick" tests on it. Other possibilities: - Run just test1: scons ALPHA_SE/test/opt/test1 - Run all tests: scons ALPHA_SE/test/opt - Run all tests on debug build: scons ALPHA_SE/test/debug - Update test1 reference outputs in m5-test: scons update_ref=y ALPHA_SE/test/opt/test1 The proper tests will be selected based on the setting of FULL_SYSTEM, ALPHA_TLASER, etc. README: Update directions to use scons-based test invocation. SConscript: Return list of generated build environments to SConstruct so it can associate tests with each of them. Set 'M5Binary' attribute on each env to record name of generated binary to be tested. build/SConstruct: - Support invoking m5-test tests via scons. - Add new non-sticky option category, for 'update_ref'. - Move existing "sticky" option definitions out of build_dir loop. Someday we can generate help text from these. - Make 'CC' and 'CXX' sticky options; use environment vars as defaults if available. - Make config builder more scons-y. python/m5/__init__.py: Make AddToPath() correctly handle relative path arguments. Assumes that sys.path[0] has the directory where the current Python file lives; new m5execfile() function sets this up properly for exec'd files. --HG-- extra : convert_revision : 48896688592e210d8e63f96c34e57474853d0e66
-rw-r--r--README16
-rw-r--r--SConscript49
-rw-r--r--build/SConstruct148
-rw-r--r--python/m5/__init__.py21
4 files changed, 157 insertions, 77 deletions
diff --git a/README b/README
index cacf27a9e..b07c6fda7 100644
--- a/README
+++ b/README
@@ -61,21 +61,15 @@ make) to run N jobs in parallel.
To build and test the syscall-emulation simulator:
-1. In $top/m5/build, run "scons ALPHA_SE/m5.opt".
-2. In $top/m5-test, run "./do-tests.pl -B ALPHA_SE".
-
-The tests should end with "finished do-tests successfully!"
-Note: if you're running under Cygwin, several tests will fail with an
-"EIO trace inconsistency: ICNT mismatch" error. This is due to the
-lack of fesetround() under Cygwin causing differences in floating-point
-rounding. Other than that discrepancy your simulator is working perfectly.
+ cd $top/m5/build
+ scons ALPHA_SE/test/opt/quick
To build and test the full-system simualator:
-1. Download the full-system binary package from XXX. This package includes
+1. Download the full-system binary package from
+ http://m5.eecs.umich.edu/dist/m5_system_1.1.tar.bz2. This package includes
disk images and kernel, palcode, and console binaries for Linux and FreeBSD.
2. Edit SYSTEMDIR in $top/m5-test/SysPaths.py to point to your local copy
of the binaries.
-3. In $top/m5/build, run "scons ALPHA_FS/m5.opt".
-4. In $top/m5-test, run "./do-tests.pl -B ALPHA_FS".
+3. In $top/m5/build, run "scons ALPHA_FS/opt/test/quick".
diff --git a/SConscript b/SConscript
index 518b8a0f3..2cbc96dda 100644
--- a/SConscript
+++ b/SConscript
@@ -430,25 +430,42 @@ def make_objs(sources, env):
env.Append(CPPPATH='.')
# Debug binary
-debug = env.Copy(OBJSUFFIX='.do')
-debug.Append(CCFLAGS=Split('-g -gstabs+ -O0'))
-debug.Append(CPPDEFINES='DEBUG')
-debug.Program(target = 'm5.debug', source = make_objs(sources, debug))
+debugEnv = env.Copy(OBJSUFFIX='.do')
+debugEnv.Label = 'debug'
+debugEnv.Append(CCFLAGS=Split('-g -gstabs+ -O0'))
+debugEnv.Append(CPPDEFINES='DEBUG')
+tlist = debugEnv.Program(target = 'm5.debug',
+ source = make_objs(sources, debugEnv))
+debugEnv.M5Binary = tlist[0]
# Optimized binary
-opt = env.Copy()
-opt.Append(CCFLAGS=Split('-g -O5'))
-opt.Program(target = 'm5.opt', source = make_objs(sources, opt))
+optEnv = env.Copy()
+optEnv.Label = 'opt'
+optEnv.Append(CCFLAGS=Split('-g -O5'))
+tlist = optEnv.Program(target = 'm5.opt',
+ source = make_objs(sources, optEnv))
+optEnv.M5Binary = tlist[0]
# "Fast" binary
-fast = env.Copy(OBJSUFFIX='.fo')
-fast.Append(CCFLAGS=Split('-O5'))
-fast.Append(CPPDEFINES='NDEBUG')
-fast.Program(target = 'm5.fast.unstripped', source = make_objs(sources, fast))
-fast.Command(target = 'm5.fast', source = 'm5.fast.unstripped',
- action = 'strip $SOURCE -o $TARGET')
+fastEnv = env.Copy(OBJSUFFIX='.fo')
+fastEnv.Label = 'fast'
+fastEnv.Append(CCFLAGS=Split('-O5'))
+fastEnv.Append(CPPDEFINES='NDEBUG')
+fastEnv.Program(target = 'm5.fast.unstripped',
+ source = make_objs(sources, fastEnv))
+tlist = fastEnv.Command(target = 'm5.fast',
+ source = 'm5.fast.unstripped',
+ action = 'strip $SOURCE -o $TARGET')
+fastEnv.M5Binary = tlist[0]
# Profiled binary
-prof = env.Copy(OBJSUFFIX='.po')
-prof.Append(CCFLAGS=Split('-O5 -g -pg'), LINKFLAGS='-pg')
-prof.Program(target = 'm5.prof', source = make_objs(sources, prof))
+profEnv = env.Copy(OBJSUFFIX='.po')
+profEnv.Label = 'prof'
+profEnv.Append(CCFLAGS=Split('-O5 -g -pg'), LINKFLAGS='-pg')
+tlist = profEnv.Program(target = 'm5.prof',
+ source = make_objs(sources, profEnv))
+profEnv.M5Binary = tlist[0]
+
+envList = [debugEnv, optEnv, fastEnv, profEnv]
+
+Return('envList')
diff --git a/build/SConstruct b/build/SConstruct
index b7e769e15..03401b04e 100644
--- a/build/SConstruct
+++ b/build/SConstruct
@@ -160,11 +160,11 @@ env = Environment(ENV = os.environ, # inherit user's environment vars
env.SConsignFile("sconsign")
-if os.environ.has_key('CC'):
- env.Replace(CC=os.environ['CC'])
-
-if os.environ.has_key('CXX'):
- env.Replace(CXX=os.environ['CXX'])
+# I waffle on this setting... it does avoid a few painful but
+# unnecessary builds, but it also seems to make trivial builds take
+# noticeably longer.
+if False:
+ env.TargetSignatures('content')
# M5_EXT is used by isa_parser.py to find the PLY package.
env.Append(ENV = { 'M5_EXT' : EXT_SRCDIR })
@@ -220,26 +220,90 @@ if have_mysql:
env = conf.Finish()
-# The source operand is a Value node containing the value of the option.
-def build_config_file(target, source, env, option):
+# Sticky options get saved in the options file so they persist from
+# one invocation to the next (unless overridden, in which case the new
+# value becomes sticky).
+sticky_opts = Options(args=ARGUMENTS)
+sticky_opts.AddOptions(
+ EnumOption('TARGET_ISA', 'Target ISA', 'alpha', ('alpha')),
+ BoolOption('FULL_SYSTEM', 'Full-system support', False),
+ BoolOption('ALPHA_TLASER',
+ 'Model Alpha TurboLaser platform (vs. Tsunami)', False),
+ BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False),
+ BoolOption('EFENCE', 'Link with Electric Fence malloc debugger',
+ False),
+ BoolOption('SS_COMPATIBLE_FP',
+ 'Make floating-point results compatible with SimpleScalar',
+ False),
+ BoolOption('STATS_BINNING', 'Bin statistics by CPU mode', have_mysql),
+ BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
+ BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
+ ('CC', 'C compiler', os.environ.get('CC', env['CC'])),
+ ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX']))
+ )
+
+# Non-sticky options only apply to the current build.
+nonsticky_opts = Options(args=ARGUMENTS)
+nonsticky_opts.AddOptions(
+ BoolOption('update_ref', 'Update test reference outputs', False)
+ )
+
+# These options get exported to #defines in config/*.hh (see m5/SConscript).
+env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
+ 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
+ 'STATS_BINNING']
+
+# Define a handy 'no-op' action
+def no_action(target, source, env):
+ return 0
+
+env.NoAction = Action(no_action, None)
+
+# libelf build is described in its own SConscript file.
+# SConscript-global is the build in build/libelf shared among all
+# configs.
+env.SConscript('m5/libelf/SConscript-global', exports = 'env')
+
+###################################################
+#
+# Define a SCons builder for configuration flag headers.
+#
+###################################################
+
+# This function generates a config header file that #defines the
+# option symbol to the current option setting (0 or 1). The source
+# operands are the name of the option and a Value node containing the
+# value of the option.
+def build_config_file(target, source, env):
+ (option, value) = [s.get_contents() for s in source]
f = file(str(target[0]), 'w')
- print >> f, '#define', option, int(eval(str(source[0])))
+ print >> f, '#define', option, value
f.close()
return None
-def config_builder(env, option):
+# Generate the message to be printed when building the config file.
+def build_config_file_string(target, source, env):
+ (option, value) = [s.get_contents() for s in source]
+ return "Defining %s as %s in %s." % (option, value, target[0])
+
+# Combine the two functions into a scons Action object.
+config_action = Action(build_config_file, build_config_file_string)
+
+# The emitter munges the source & target node lists to reflect what
+# we're really doing.
+def config_emitter(target, source, env):
+ # extract option name from Builder arg
+ option = str(target[0])
+ # True target is config header file
target = os.path.join('config', option.lower() + '.hh')
- source = Value(env[option])
- def my_build_config_file(target, source, env):
- build_config_file(target, source, env, option)
- env.Command(target, source, my_build_config_file)
+ # Force value to 0/1 even if it's a Python bool
+ val = int(eval(str(env[option])))
+ # Sources are option name & value (packaged in SCons Value nodes)
+ return ([target], [Value(option), Value(val)])
-env.Append(BUILDERS = { 'ConfigFile' : config_builder })
+config_builder = Builder(emitter = config_emitter, action = config_action)
-# libelf build is described in its own SConscript file.
-# SConscript-global is the build in build/libelf shared among all
-# configs.
-env.SConscript('m5/libelf/SConscript-global', exports = 'env')
+env.Append(BUILDERS = { 'ConfigFile' : config_builder })
###################################################
#
@@ -255,31 +319,13 @@ for build_dir in build_dirs:
env = base_env.Copy()
# Set env according to the build directory config.
options_file = os.path.join('build_options', build_dir)
- if not os.path.isfile(options_file):
+ if os.path.isfile(options_file):
+ sticky_opts.files = [options_file]
+ else:
print "Options file %s not found, using defaults." % options_file
- opts = Options(options_file, ARGUMENTS)
- opts.AddOptions(
- EnumOption('TARGET_ISA', 'Target ISA', 'alpha', ('alpha')),
- BoolOption('FULL_SYSTEM', 'Full-system support', False),
- BoolOption('ALPHA_TLASER',
- 'Model Alpha TurboLaser platform (vs. Tsunami)', False),
- BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False),
- BoolOption('EFENCE', 'Link with Electric Fence malloc debugger',
- False),
- BoolOption('SS_COMPATIBLE_FP',
- 'Make floating-point results compatible with SimpleScalar',
- False),
- BoolOption('STATS_BINNING', 'Bin statistics by CPU mode', have_mysql),
- BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
- BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv)
- )
-
- opts.Update(env)
- opts.Save(options_file, env)
-
- env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
- 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
- 'STATS_BINNING']
+
+ sticky_opts.Update(env)
+ nonsticky_opts.Update(env)
# Process option settings.
@@ -305,11 +351,21 @@ for build_dir in build_dirs:
print "Compiling in", build_dir, "with MySQL support."
env.ParseConfig(mysql_config_libs)
env.ParseConfig(mysql_config_include)
-
+
+ # Save sticky option settings back to file
+ sticky_opts.Save(options_file, env)
+
# The m5/SConscript file sets up the build rules in 'env' according
- # to the configured options.
- SConscript('m5/SConscript', build_dir = build_dir, exports = 'env',
- duplicate=0)
+ # to the configured options. It returns a list of environments,
+ # one for each variant build (debug, opt, etc.)
+ envList = SConscript('m5/SConscript', build_dir = build_dir,
+ exports = 'env', duplicate = False)
+
+ # Set up the regression tests for each build.
+ for e in envList:
+ SConscript('m5-test/SConscript',
+ build_dir = os.path.join(build_dir, 'test', e.Label),
+ exports = { 'env' : e }, duplicate = False)
###################################################
#
diff --git a/python/m5/__init__.py b/python/m5/__init__.py
index cf4ba9a54..9bb68a090 100644
--- a/python/m5/__init__.py
+++ b/python/m5/__init__.py
@@ -31,12 +31,25 @@ def panic(string):
print >>sys.stderr, 'panic:', string
sys.exit(1)
-# Add given directory to system module search path, if it is not
-# already there.
+def m5execfile(f, global_dict):
+ # copy current sys.path
+ oldpath = sys.path[:]
+ # push file's directory onto front of path
+ sys.path.insert(0, os.path.abspath(os.path.dirname(f)))
+ execfile(f, global_dict)
+ # restore original path
+ sys.path = oldpath
+
+# Prepend given directory to system module search path.
def AddToPath(path):
+ # if it's a relative path and we know what directory the current
+ # python script is in, make the path relative to that directory.
+ if not os.path.isabs(path) and sys.path[0]:
+ path = os.path.join(sys.path[0], path)
path = os.path.realpath(path)
- if os.path.isdir(path) and path not in sys.path:
- sys.path.append(path)
+ # sys.path[0] should always refer to the current script's directory,
+ # so place the new dir right after that.
+ sys.path.insert(1, path)
# find the m5 compile options: must be specified as a dict in
# __main__.m5_build_env.