Skip to content

Commit

Permalink
test: Make sure it runs current python trace module
Browse files Browse the repository at this point in the history
It could run uftrace trace with system-installed trace-python.so and
then the test result will not be correct.  Add $objdir and $srcdir to
PYTHONPATH env so that it can pick up the latest build.

Signed-off-by: Namhyung Kim <[email protected]>
  • Loading branch information
namhyung committed Jun 9, 2023
1 parent 2f6440b commit a1dfa5b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,13 @@ def __del__(self):
class PyTestBase(TestBase):
def __init__(self, name, result, lang='Python', cflags='', ldflags='', sort='simple', serial=False):
TestBase.__init__(self, name, result, lang, cflags, ldflags, sort, serial)
# setup PYTHONPATH to load the new code before the inst
orig_path = os.environ["PYTHONPATH"] if "PYTHONPATH" in os.environ else ""
os.environ["PYTHONPATH"] = TestBase.objdir + '/python'
if TestBase.objdir != TestBase.srcdir:
os.environ["PYTHONPATH"] += ':' + TestBase.objdir + '/python'
if orig_path != "":
os.environ["PYTHONPATH"] += ':' + orig_path

RED = '\033[1;31m'
GREEN = '\033[1;32m'
Expand Down

0 comments on commit a1dfa5b

Please sign in to comment.