From 0e32ffeccef54c27f8d7300260fd75eecb4dde2e Mon Sep 17 00:00:00 2001 From: klehman Date: Mon, 25 Oct 2021 16:19:16 -0400 Subject: [PATCH] tests now dump into caller dirs --- src/openpower/test/runner.py | 3 ++- src/openpower/test/state.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/openpower/test/runner.py b/src/openpower/test/runner.py index 9215f0f5..ff4ab26b 100644 --- a/src/openpower/test/runner.py +++ b/src/openpower/test/runner.py @@ -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: diff --git a/src/openpower/test/state.py b/src/openpower/test/state.py index 2b00fbd1..d932ed38 100644 --- a/src/openpower/test/state.py +++ b/src/openpower/test/state.py @@ -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)) -- 2.30.2