misc: Merge branch 'release-staging-v20.1.0.0' into develop
[gem5.git] / tests / gem5 / fixture.py
index fc6aee8f78c243783b4820647a6c5168b3a6b366..bb911dde0ff28fe796ba3f1d30e8baa9dc4a9254 100644 (file)
@@ -67,6 +67,23 @@ class TempdirFixture(Fixture):
     def setup(self, testitem):
         self.path = tempfile.mkdtemp(prefix='gem5out')
 
+    def post_test_procedure(self, testitem):
+        suiteUID = testitem.metadata.uid.suite
+        testUID = testitem.metadata.name
+        testing_result_folder = os.path.join(config.result_path,
+                                             "SuiteUID:" + suiteUID,
+                                             "TestUID:" + testUID)
+
+        # Copy the output files of the run from /tmp to testing-results
+        # We want to wipe the entire result folder for this test first. Why?
+        #   If the result folder exists (probably from the previous run), if
+        #   this run emits fewer files, there'll be files from the previous
+        #   run in this folder, which would cause confusion if one does not
+        #   check the timestamp of the file.
+        if os.path.exists(testing_result_folder):
+            shutil.rmtree(testing_result_folder)
+        shutil.copytree(self.path, testing_result_folder)
+
     def teardown(self, testitem):
         if testitem.result == Result.Passed:
             shutil.rmtree(self.path)
@@ -223,7 +240,7 @@ class MakeTarget(Fixture):
 
 class TestProgram(MakeTarget):
     def __init__(self, program, isa, os, recompile=False):
-        make_dir = joinpath('test-progs', program)
+        make_dir = joinpath(config.bin_dir, program)
         make_fixture = MakeFixture(make_dir)
         target = joinpath('bin', isa, os, program)
         super(TestProgram, self).__init__(target, make_fixture)