diff --git a/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py b/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py --- a/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py +++ b/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py @@ -14,22 +14,21 @@ mydir = TestBase.compute_mydir(__file__) NO_DEBUG_INFO_TESTCASE = True + def setUp(self): + TestBase.setUp(self) + if os.environ["TEST_INTEL_PT"] != "true": + self.skipTest("Intel PT not supported") + + plugin_path = os.path.join(os.environ["LLDB_IMPLIB_DIR"], "liblldbIntelFeatures.so") + self.runCmd("plugin load " + plugin_path) + @skipIf(oslist=no_match(['linux'])) @skipIf(archs=no_match(['i386', 'x86_64'])) @skipIfRemote def test_basic_flow(self): """Test collection, decoding, and dumping instructions""" - if os.environ.get('TEST_INTEL_PT') != '1': - self.skipTest("The environment variable TEST_INTEL_PT=1 is needed to run this test.") - - lldb_exec_dir = os.environ["LLDB_IMPLIB_DIR"] - lldb_lib_dir = os.path.join(lldb_exec_dir, os.pardir, "lib") - plugin_file = os.path.join(lldb_lib_dir, "liblldbIntelFeatures.so") self.build() - - self.runCmd("plugin load " + plugin_file) - exe = self.getBuildArtifact("a.out") lldbutil.run_to_name_breakpoint(self, "main", exe_name=exe) # We start tracing from main @@ -52,9 +51,9 @@ self.expect("processor-trace show-instr-log -c 100", patterns=[ # We expect to have seen the first instruction of 'fun' - hex(fun_start_adddress), + hex(fun_start_adddress), # We expect to see the exit condition of the for loop - "at main.cpp:" + str(line_number('main.cpp', '// Break for loop')) + "at main.cpp:" + str(line_number('main.cpp', '// Break for loop')) ]) self.runCmd("processor-trace stop") diff --git a/lldb/utils/lldb-dotest/lldb-dotest.in b/lldb/utils/lldb-dotest/lldb-dotest.in --- a/lldb/utils/lldb-dotest/lldb-dotest.in +++ b/lldb/utils/lldb-dotest/lldb-dotest.in @@ -1,6 +1,7 @@ #!@PYTHON_EXECUTABLE@ import subprocess import sys +import os dotest_path = '@LLDB_SOURCE_DIR_CONFIGURED@/test/API/dotest.py' build_dir = '@LLDB_TEST_BUILD_DIRECTORY_CONFIGURED@' @@ -11,6 +12,7 @@ dsymutil = '@LLDB_TEST_DSYMUTIL_CONFIGURED@' filecheck = '@LLDB_TEST_FILECHECK_CONFIGURED@' lldb_libs_dir = "@LLDB_LIBS_DIR_CONFIGURED@" +lldb_build_intel_pt = "@LLDB_BUILD_INTEL_PT@".lower() if __name__ == '__main__': wrapper_args = sys.argv[1:] @@ -26,6 +28,11 @@ cmd.extend(['--filecheck', filecheck]) cmd.extend(['--lldb-libs-dir', lldb_libs_dir]) cmd.extend(wrapper_args) + + if lldb_build_intel_pt not in ["", "false", "off", "n", "no", "ignore"] \ + and not lldb_build_intel_pt.endswith("-NOTFOUND"): + os.environ['TEST_INTEL_PT'] = "true" + # Invoke dotest.py and return exit code. print(' '.join(cmd)) sys.exit(subprocess.call(cmd))