llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Raphael Isemann (Teemperor) <details> <summary>Changes</summary> This test compiles 9 C++ test files and uses the `generateSource` function to inject includes for every single SB API header. The `generateSource` call also sets `SOURCE_DIR` so the test knows its current source directory. This patch removes the need for `generateSource` by including the SB API headers we actually need. SOURCE_DIR is now specified using an environment variable in the test. The motivation for this patch is that I want to avoid recompiling these source files unless their source or the included headers change. Currently, this test is one of the slowest in the test suite and needs about half a minute to run. In the future, I want to at least avoid the recompilation time for each test file. Note that we still have another test that includes all SB API headers normally and as a framework, so this does not remove test coverage. --- Full diff: https://github.com/llvm/llvm-project/pull/215551.diff 10 Files Affected: - (modified) lldb/test/API/api/multithreaded/TestMultithreaded.py (+6-10) - (renamed) lldb/test/API/api/multithreaded/driver.cpp (+1-1) - (renamed) lldb/test/API/api/multithreaded/listener_test.cpp (+6-1) - (renamed) lldb/test/API/api/multithreaded/test_breakpoint_callback.cpp (+6-1) - (renamed) lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp (+8-1) - (renamed) lldb/test/API/api/multithreaded/test_concurrent_unwind.cpp (+9-1) - (renamed) lldb/test/API/api/multithreaded/test_listener_event_description.cpp (+4-1) - (renamed) lldb/test/API/api/multithreaded/test_listener_event_process_state.cpp (+8-1) - (renamed) lldb/test/API/api/multithreaded/test_listener_resume.cpp (+5-1) - (renamed) lldb/test/API/api/multithreaded/test_stop-hook.cpp (+17-3) ``````````diff diff --git a/lldb/test/API/api/multithreaded/TestMultithreaded.py b/lldb/test/API/api/multithreaded/TestMultithreaded.py index ebe80c7de576a..e2e6df558205d 100644 --- a/lldb/test/API/api/multithreaded/TestMultithreaded.py +++ b/lldb/test/API/api/multithreaded/TestMultithreaded.py @@ -16,15 +16,6 @@ class SBBreakpointCallbackCase(TestBase): def setUp(self): TestBase.setUp(self) - self.generateSource("driver.cpp") - self.generateSource("listener_test.cpp") - self.generateSource("test_breakpoint_callback.cpp") - self.generateSource("test_breakpoint_location_callback.cpp") - self.generateSource("test_listener_event_description.cpp") - self.generateSource("test_listener_event_process_state.cpp") - self.generateSource("test_listener_resume.cpp") - self.generateSource("test_stop-hook.cpp") - self.generateSource("test_concurrent_unwind.cpp") @skipIfRemote # clang-cl does not support throw or catch (llvm.org/pr24538) @@ -128,10 +119,15 @@ def build_and_test(self, sources, test_name, inferior_source="inferior.cpp"): test_exe = self.getBuildArtifact(test_name) exe = [test_exe, self.getBuildArtifact(self.inferior)] + # Tests locate their support files (e.g. test_stop-hook.cpp's + # some_cmd.py) via the LLDB_TEST_SOURCE_DIR environment variable. + env = dict(os.environ) + env["LLDB_TEST_SOURCE_DIR"] = self.getSourceDir() + # check_call will raise a CalledProcessError if the executable doesn't # return exit code 0 to indicate success. We can let this exception go # - the test harness will recognize it as a test failure. - subprocess.check_call(exe) + subprocess.check_call(exe, env=env) def build_program(self, sources, program): return self.buildDriver(sources, program) diff --git a/lldb/test/API/api/multithreaded/driver.cpp.template b/lldb/test/API/api/multithreaded/driver.cpp similarity index 97% rename from lldb/test/API/api/multithreaded/driver.cpp.template rename to lldb/test/API/api/multithreaded/driver.cpp index 443f4fed7653d..e17e967a2875e 100644 --- a/lldb/test/API/api/multithreaded/driver.cpp.template +++ b/lldb/test/API/api/multithreaded/driver.cpp @@ -10,7 +10,7 @@ #include <signal.h> #endif -%include_SB_APIs% +#include "lldb/API/SBDebugger.h" #include "common.h" diff --git a/lldb/test/API/api/multithreaded/listener_test.cpp.template b/lldb/test/API/api/multithreaded/listener_test.cpp similarity index 91% rename from lldb/test/API/api/multithreaded/listener_test.cpp.template rename to lldb/test/API/api/multithreaded/listener_test.cpp index e305d1af4893f..7b7a8112e0ec5 100644 --- a/lldb/test/API/api/multithreaded/listener_test.cpp.template +++ b/lldb/test/API/api/multithreaded/listener_test.cpp @@ -7,7 +7,12 @@ #include <thread> #include <vector> -%include_SB_APIs% +#include "lldb/API/SBBreakpoint.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBError.h" +#include "lldb/API/SBListener.h" +#include "lldb/API/SBProcess.h" +#include "lldb/API/SBTarget.h" #include "common.h" using namespace lldb; diff --git a/lldb/test/API/api/multithreaded/test_breakpoint_callback.cpp.template b/lldb/test/API/api/multithreaded/test_breakpoint_callback.cpp similarity index 86% rename from lldb/test/API/api/multithreaded/test_breakpoint_callback.cpp.template rename to lldb/test/API/api/multithreaded/test_breakpoint_callback.cpp index 4133025aa495a..557a7bb64066e 100644 --- a/lldb/test/API/api/multithreaded/test_breakpoint_callback.cpp.template +++ b/lldb/test/API/api/multithreaded/test_breakpoint_callback.cpp @@ -7,7 +7,12 @@ #include <vector> #include <string> -%include_SB_APIs% +#include "lldb/API/SBBreakpoint.h" +#include "lldb/API/SBBreakpointLocation.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBProcess.h" +#include "lldb/API/SBTarget.h" +#include "lldb/API/SBThread.h" #include "common.h" diff --git a/lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template b/lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp similarity index 86% rename from lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template rename to lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp index a4bc65ab91331..90705aae352bb 100644 --- a/lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template +++ b/lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp @@ -7,7 +7,14 @@ #include <vector> #include <string> -%include_SB_APIs% +#include "lldb/API/SBBreakpoint.h" +#include "lldb/API/SBBreakpointLocation.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBFileSpecList.h" +#include "lldb/API/SBProcess.h" +#include "lldb/API/SBTarget.h" +#include "lldb/API/SBThread.h" #include "common.h" diff --git a/lldb/test/API/api/multithreaded/test_concurrent_unwind.cpp.template b/lldb/test/API/api/multithreaded/test_concurrent_unwind.cpp similarity index 89% rename from lldb/test/API/api/multithreaded/test_concurrent_unwind.cpp.template rename to lldb/test/API/api/multithreaded/test_concurrent_unwind.cpp index e5101dde79619..1272f7464446e 100644 --- a/lldb/test/API/api/multithreaded/test_concurrent_unwind.cpp.template +++ b/lldb/test/API/api/multithreaded/test_concurrent_unwind.cpp @@ -3,7 +3,15 @@ #include <atomic> #include <thread> -%include_SB_APIs% +#include "lldb/API/SBBreakpoint.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBError.h" +#include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBFrame.h" +#include "lldb/API/SBLaunchInfo.h" +#include "lldb/API/SBProcess.h" +#include "lldb/API/SBTarget.h" +#include "lldb/API/SBThread.h" #include "common.h" diff --git a/lldb/test/API/api/multithreaded/test_listener_event_description.cpp.template b/lldb/test/API/api/multithreaded/test_listener_event_description.cpp similarity index 95% rename from lldb/test/API/api/multithreaded/test_listener_event_description.cpp.template rename to lldb/test/API/api/multithreaded/test_listener_event_description.cpp index 63e3f3631e5d2..54bdc4fceb790 100644 --- a/lldb/test/API/api/multithreaded/test_listener_event_description.cpp.template +++ b/lldb/test/API/api/multithreaded/test_listener_event_description.cpp @@ -8,7 +8,10 @@ #include <string> #include <thread> -%include_SB_APIs% +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBEvent.h" +#include "lldb/API/SBListener.h" +#include "lldb/API/SBStream.h" #include "common.h" diff --git a/lldb/test/API/api/multithreaded/test_listener_event_process_state.cpp.template b/lldb/test/API/api/multithreaded/test_listener_event_process_state.cpp similarity index 88% rename from lldb/test/API/api/multithreaded/test_listener_event_process_state.cpp.template rename to lldb/test/API/api/multithreaded/test_listener_event_process_state.cpp index 2926ece4d8d92..1e010b99ab8f1 100644 --- a/lldb/test/API/api/multithreaded/test_listener_event_process_state.cpp.template +++ b/lldb/test/API/api/multithreaded/test_listener_event_process_state.cpp @@ -8,7 +8,14 @@ #include <string> #include <thread> -%include_SB_APIs% +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBEvent.h" +#include "lldb/API/SBFrame.h" +#include "lldb/API/SBListener.h" +#include "lldb/API/SBProcess.h" +#include "lldb/API/SBStream.h" +#include "lldb/API/SBSymbol.h" +#include "lldb/API/SBThread.h" #include "common.h" diff --git a/lldb/test/API/api/multithreaded/test_listener_resume.cpp.template b/lldb/test/API/api/multithreaded/test_listener_resume.cpp similarity index 89% rename from lldb/test/API/api/multithreaded/test_listener_resume.cpp.template rename to lldb/test/API/api/multithreaded/test_listener_resume.cpp index 4adc9b3388793..752e26520bd08 100644 --- a/lldb/test/API/api/multithreaded/test_listener_resume.cpp.template +++ b/lldb/test/API/api/multithreaded/test_listener_resume.cpp @@ -8,7 +8,11 @@ #include <string> #include <thread> -%include_SB_APIs% +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBError.h" +#include "lldb/API/SBEvent.h" +#include "lldb/API/SBListener.h" +#include "lldb/API/SBProcess.h" #include "common.h" diff --git a/lldb/test/API/api/multithreaded/test_stop-hook.cpp.template b/lldb/test/API/api/multithreaded/test_stop-hook.cpp similarity index 86% rename from lldb/test/API/api/multithreaded/test_stop-hook.cpp.template rename to lldb/test/API/api/multithreaded/test_stop-hook.cpp index 393e717cceb5a..a88892340e613 100644 --- a/lldb/test/API/api/multithreaded/test_stop-hook.cpp.template +++ b/lldb/test/API/api/multithreaded/test_stop-hook.cpp @@ -2,13 +2,23 @@ // is set to a FILE *, lldb can still successfully run a // python command in a stop hook. +#include <cstdlib> #include <errno.h> #include <mutex> #include <stdio.h> #include <string> #include <vector> -%include_SB_APIs% +#include "lldb/API/SBBreakpoint.h" +#include "lldb/API/SBBroadcaster.h" +#include "lldb/API/SBCommandInterpreter.h" +#include "lldb/API/SBCommandReturnObject.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBEvent.h" +#include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBListener.h" +#include "lldb/API/SBProcess.h" +#include "lldb/API/SBTarget.h" #include "common.h" @@ -44,7 +54,11 @@ void test(SBDebugger &dbg, std::vector<std::string> args) { // one that runs in the stop hook and sets a variable when it // runs, and one that reports out the variable so we can ensure // that we did indeed run the stop hook. - const char *source_dir = "%SOURCE_DIR%"; + // The test sets LLDB_TEST_SOURCE_DIR to the directory containing this + // test's support files (see TestMultithreaded.py). + const char *source_dir = getenv("LLDB_TEST_SOURCE_DIR"); + if (!source_dir) + throw Exception("LLDB_TEST_SOURCE_DIR is not set"); SBFileSpec script_spec(source_dir); script_spec.AppendPathComponent("some_cmd.py"); char path[PATH_MAX]; @@ -54,7 +68,7 @@ void test(SBDebugger &dbg, std::vector<std::string> args) { import_command.append(path); interp.HandleCommand(import_command.c_str(), result); if (!result.Succeeded()) - throw Exception("Couldn't import %SOURCE_DIR%/some_cmd.py"); + throw Exception(std::string("Couldn't import ") + path); SBProcess process = target.LaunchSimple(nullptr, nullptr, nullptr); if (!process.IsValid()) `````````` </details> https://github.com/llvm/llvm-project/pull/215551 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
