def run_test(root):
# Called from tests/run.py
- # Set the working directory in case we are executing from
- # outside gem5's source tree
- import os
- os.chdir(os.path.join(os.path.dirname(__file__), "../"))
-
- # The path to this script is the only parameter. Delete it so
- # we can execute the script that we want to execute.
import sys
- del sys.argv[1:]
-
- # Add a specific page policy and specify the number of ranks
- sys.argv.append('-p%s' % page_policy)
- sys.argv.append('-r 2')
+ argv = [
+ sys.argv[0],
+ # Add a specific page policy and specify the number of ranks
+ '-p%s' % page_policy,
+ '-r 2',
+ ]
# Execute the script we are wrapping
- execfile(srcpath('configs/dram/low_power_sweep.py'), globals())
+ run_config('configs/dram/low_power_sweep.py', argv=argv)
root = None
def run_test(root):
- # Called from tests/run.py
-
- # Set the working directory in case we are executing from
- # outside gem5's source tree
- import os
- os.chdir(os.path.join(os.path.dirname(__file__), "../"))
-
- # Execute the script we are wrapping
- execfile(srcpath('configs/learning_gem5/part1/simple.py'))
+ run_config('configs/learning_gem5/part1/simple.py')
# For some reason, this is implicitly needed by run.py
root = None
-import m5
-
def run_test(root):
- # Called from tests/run.py
-
-
- # Set the working directory in case we are executing from
- # outside gem5's source tree
- import os
- os.chdir(os.path.join(os.path.dirname(__file__), "../"))
-
- # Add paths that we need
- m5.util.addToPath('../configs/learning_gem5/part1')
- m5.util.addToPath('../configs/')
-
- # The path to this script is the only parameter. Delete it so we can
- # execute the script that we want to execute.
- import sys
- del sys.argv[1:]
- # Note: at this point, we could add options we want to test.
- # For instance, sys.argv.append('--l2_size=512kB')
-
- # Execute the script we are wrapping
- execfile(srcpath('configs/learning_gem5/part1/two_level.py'))
+ run_config('configs/learning_gem5/part1/two_level.py')
def run_test(root):
# Called from tests/run.py
- # Set the working directory in case we are executing from
- # outside gem5's source tree
- import os
- os.chdir(os.path.join(os.path.dirname(__file__), "../"))
-
- # The path to this script is the only parameter. Delete it so
- # we can execute the script that we want to execute.
import sys
- del sys.argv[1:]
-
- # Add a specific max tick
- sys.argv.append('-m %d' % maxtick)
+ argv = [
+ sys.argv[0],
+ '-m %d' % maxtick,
+ ]
# Execute the script we are wrapping
- execfile(srcpath('configs/example/memcheck.py'), globals())
+ run_config('configs/example/memcheck.py', argv=argv)
"""Path to file in gem5's source tree"""
return joinpath(os.path.dirname(__file__), "..", path)
+def run_config(config, argv=None):
+ """Execute a configuration script that is external to the test system"""
+
+ src_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../"))
+ abs_path = joinpath(src_root, config)
+
+ code = compile(open(abs_path, 'r').read(), abs_path, 'exec')
+ scope = {
+ '__file__' : config,
+ '__name__' : '__m5_main__',
+ }
+
+ # Set the working directory in case we are executing from
+ # outside gem5's source tree
+ os.chdir(src_root)
+
+ # gem5 normally adds the script's directory to the path to make
+ # script-relative imports work.
+ sys.path = [ os.path.dirname(abs_path), ] + sys.path
+
+ if argv is None:
+ sys.argv = [ config, ]
+ else:
+ sys.argv = argv
+ exec(code, scope)
+
# build configuration
sys.path.append(joinpath(tests_root, 'configs'))
test_filename = config