systemc: Run the systemc tests directly from their build directories.
authorGabe Black <gabeblack@google.com>
Thu, 22 Nov 2018 01:51:46 +0000 (17:51 -0800)
committerGabe Black <gabeblack@google.com>
Thu, 29 Nov 2018 01:23:11 +0000 (01:23 +0000)
We were previously running them from the current directory to start
with, and then having the config script switch to the build directory.
That worked, except when output streams might be opened as part of the
global constructors which would run before the config script.

This change makes us start from the build directory directly, making
the switch in the config script unnecessary and ensuring that no files
leak outside of the build when running tests.

Change-Id: I484168793bfc5abc4e5631fb3468733fb9d829af
Reviewed-on: https://gem5-review.googlesource.com/c/14519
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/systemc/tests/verify.py

index c9ede77a05d6ffc2e778516a5806868680a222f7..def0fdc791de04f64ccfdfe187e8dbb9313ace83 100755 (executable)
@@ -153,30 +153,26 @@ class RunPhase(TestPhaseBase):
             '--kill-after', str(args.timeout * 2),
             str(args.timeout)
         ]
-        curdir = os.getcwd()
         def run_test(test):
             cmd = []
             if args.timeout:
                 cmd.extend(timeout_cmd)
             cmd.extend([
-                test.full_path(),
+                os.path.abspath(test.full_path()),
                 '-rd', os.path.abspath(test.m5out_dir()),
                 '--listener-mode=off',
                 '--quiet',
-                config_path,
-                '--working-dir',
-                os.path.dirname(test.dir())
+                os.path.abspath(config_path),
             ])
             # Ensure the output directory exists.
             if not os.path.exists(test.m5out_dir()):
                 os.makedirs(test.m5out_dir())
             try:
-                subprocess.check_call(cmd)
+                subprocess.check_call(cmd, cwd=os.path.dirname(test.dir()))
             except subprocess.CalledProcessError, error:
                 returncode = error.returncode
             else:
                 returncode = 0
-            os.chdir(curdir)
             with open(test.returncode_file(), 'w') as rc:
                 rc.write('%d\n' % returncode)