tests: Enable test running outside of gem5's source tree
authorAndreas Sandberg <andreas.sandberg@arm.com>
Mon, 9 May 2016 10:32:07 +0000 (11:32 +0100)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Mon, 9 May 2016 10:32:07 +0000 (11:32 +0100)
The learning gem5 scripts currently assumes that the current working
directory is the root of gem5's source tree. This isn't necessarily
the case when running the tests using gem5's new test runner.

Change-Id: Ief569bbe77b1b3e2b0fb0e6c575fb0705bbba9b3
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Curtis Dunham <curtis.dunham@arm.com>
tests/configs/learning-gem5-p1-simple.py
tests/configs/learning-gem5-p1-two-level.py
tests/configs/memcheck.py
tests/run.py

index 850abccf1ff5e0f3cf89471ee049f476ecbc0d48..9ad70854ed5135ca54494cf3782cdbad90773c4d 100644 (file)
@@ -35,5 +35,10 @@ 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('configs/learning_gem5/part1/simple.py')
+        execfile(srcpath('configs/learning_gem5/part1/simple.py'))
index 1a1f8a0b952d0562f739677aa330190feb866dfb..8101de318e70d7f300501632d1910be438382f01 100644 (file)
@@ -37,6 +37,12 @@ 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/common')
@@ -49,4 +55,4 @@ def run_test(root):
         # For instance, sys.argv.append('--l2_size=512kB')
 
         # Execute the script we are wrapping
-        execfile('configs/learning_gem5/part1/two_level.py')
+        execfile(srcpath('configs/learning_gem5/part1/two_level.py'))
index 52931a0b38328959c1613bca39ef5e25b8207e17..21c8d7d4cf39d6ef6fcb7282acc2626837a4fa39 100644 (file)
@@ -47,6 +47,11 @@ 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__), "../"))
+
         # The path to this script is the only parameter. Delete it so
         # we can execute the script that we want to execute.
         import sys
@@ -56,4 +61,4 @@ def run_test(root):
         sys.argv.append('-m %d' % maxtick)
 
         # Execute the script we are wrapping
-        execfile('configs/example/memcheck.py', globals())
+        execfile(srcpath('configs/example/memcheck.py'), globals())
index 46181355994f90e6adb537608ba74250b0218ad4..ff5be230daae86a0225618c7886264f733cc4c3d 100644 (file)
@@ -171,6 +171,10 @@ def inputpath(app, file=None):
         file = app
     return joinpath(test_progs, app, 'input', file)
 
+def srcpath(path):
+    """Path to file in gem5's source tree"""
+    return joinpath(os.path.dirname(__file__), "..", path)
+
 # build configuration
 sys.path.append(joinpath(tests_root, 'configs'))
 test_filename = config