tests now dump into caller dirs
authorklehman <klehman9@comcast.net>
Mon, 25 Oct 2021 20:19:16 +0000 (16:19 -0400)
committerklehman <klehman9@comcast.net>
Mon, 25 Oct 2021 20:19:16 +0000 (16:19 -0400)
src/openpower/test/runner.py
src/openpower/test/state.py

index 9215f0f5a82c175585341a099026b2c319f41a55..ff4ab26bfd25798b9e9afcf9419829343e00115e 100644 (file)
@@ -259,7 +259,8 @@ class TestRunnerBase(FHDLTestCase):
                     # setting expected state to last_sim
                     if test.expected is None:
                         e = ExpectedState()
-                        e.dump_state_tofile(last_sim, test.name)
+                        e.dump_state_tofile(last_sim, test.name,
+                                            test.test_file)
 
                     # compare against expected results
                     if test.expected is not None:
index 2b00fbd10cdcd1eb1d416ebb670d85f206c30cae..d932ed38af06d4621b741975120ef4f4395c26aa 100644 (file)
@@ -216,14 +216,18 @@ class ExpectedState(State):
     def get_mem(self):
         if False: yield
 
-    def dump_state_tofile(self, state, testname):
+    def dump_state_tofile(self, state, testname, testfile):
         """dump_state_tofile:  Takes a passed in teststate object along
-        with a test name and generates a code file located at /tmp/testname
-        to set an expected state object
+        with a test name and generates a code file located at
+        /tmp/testfile/testname to set an expected state object
         """
         lindent = ' '*8 # indent for code
-        path = "/tmp/expected/"  # temp for now
+        # create the path
+        path = "/tmp/expected/"
+        if testfile is not None:
+            path += testfile + '/'
         os.makedirs(path, exist_ok=True)
+
         with open("%s%s.py" % (path, testname), "w") as sout:
             # pc and intregs
             sout.write("%se = ExpectedState(pc=%d)\n" % (lindent, state.pc))