From 614dc150ec761140d21f52c9bb1a1c45db38e12f Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 27 Oct 2016 23:18:52 +0000 Subject: [PATCH] Revert "[Test Suite] Pull generateSource into lldbtest" This reverts commit r285357. I committed this patch accidentally out of order. Will recommit when the change this depends on is landed. llvm-svn: 285361 --- .../TestPublicAPIHeaders.py | 33 ++++++++++++++++++- .../api/multithreaded/TestMultithreaded.py | 9 ----- .../{driver.cpp.template => driver.cpp} | 2 +- ...er_test.cpp.template => listener_test.cpp} | 2 +- .../test/api/multithreaded/lldb-headers.h | 11 +++++++ ....template => test_breakpoint_callback.cpp} | 2 +- ...te => test_listener_event_description.cpp} | 2 +- ... => test_listener_event_process_state.cpp} | 2 +- ....cpp.template => test_listener_resume.cpp} | 2 +- .../plugins/commands/TestPluginCommands.py | 4 --- .../{plugin.cpp.template => plugin.cpp} | 10 +++++- .../Python/lldbsuite/test/lldbtest.py | 27 --------------- 12 files changed, 58 insertions(+), 48 deletions(-) rename lldb/packages/Python/lldbsuite/test/api/multithreaded/{driver.cpp.template => driver.cpp} (96%) rename lldb/packages/Python/lldbsuite/test/api/multithreaded/{listener_test.cpp.template => listener_test.cpp} (98%) create mode 100644 lldb/packages/Python/lldbsuite/test/api/multithreaded/lldb-headers.h rename lldb/packages/Python/lldbsuite/test/api/multithreaded/{test_breakpoint_callback.cpp.template => test_breakpoint_callback.cpp} (98%) rename lldb/packages/Python/lldbsuite/test/api/multithreaded/{test_listener_event_description.cpp.template => test_listener_event_description.cpp} (98%) rename lldb/packages/Python/lldbsuite/test/api/multithreaded/{test_listener_event_process_state.cpp.template => test_listener_event_process_state.cpp} (98%) rename lldb/packages/Python/lldbsuite/test/api/multithreaded/{test_listener_resume.cpp.template => test_listener_resume.cpp} (98%) rename lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/{plugin.cpp.template => plugin.cpp} (85%) diff --git a/lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py b/lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py index dd6dbe0a37ed..0b202a092f25 100644 --- a/lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py +++ b/lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py @@ -19,9 +19,9 @@ class SBDirCheckerCase(TestBase): def setUp(self): TestBase.setUp(self) + self.template = 'main.cpp.template' self.source = 'main.cpp' self.exe_name = 'a.out' - self.generateSource(self.source) @skipIfNoSBHeaders def test_sb_api_directory(self): @@ -34,9 +34,40 @@ class SBDirCheckerCase(TestBase): self.skipTest( "LLDB is 64-bit and cannot be linked to 32-bit test program.") + # Generate main.cpp, build it, and execute. + self.generate_main_cpp() self.buildDriver(self.source, self.exe_name) self.sanity_check_executable(self.exe_name) + def generate_main_cpp(self): + """Generate main.cpp from main.cpp.template.""" + temp = os.path.join(os.getcwd(), self.template) + with open(temp, 'r') as f: + content = f.read() + + public_api_dir = os.path.join( + os.environ["LLDB_SRC"], "include", "lldb", "API") + + # Look under the include/lldb/API directory and add #include statements + # for all the SB API headers. + public_headers = os.listdir(public_api_dir) + # For different platforms, the include statement can vary. + if self.platformIsDarwin(): + include_stmt = "'#include <%s>' % os.path.join('LLDB', header)" + if self.getPlatform() == "freebsd" or self.getPlatform( + ) == "linux" or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile': + include_stmt = "'#include <%s>' % os.path.join(public_api_dir, header)" + list = [eval(include_stmt) for header in public_headers if ( + header.startswith("SB") and header.endswith(".h"))] + includes = '\n'.join(list) + new_content = content.replace('%include_SB_APIs%', includes) + src = os.path.join(os.getcwd(), self.source) + with open(src, 'w') as f: + f.write(new_content) + + # The main.cpp has been generated, add a teardown hook to remove it. + self.addTearDownHook(lambda: os.remove(src)) + def sanity_check_executable(self, exe_name): """Sanity check executable compiled from the auto-generated program.""" exe = os.path.join(os.getcwd(), exe_name) diff --git a/lldb/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py b/lldb/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py index abd252b1e5bf..970c25107f60 100644 --- a/lldb/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py +++ b/lldb/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py @@ -15,15 +15,6 @@ import subprocess 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_listener_event_description.cpp') - self.generateSource('test_listener_event_process_state.cpp') - self.generateSource('test_listener_resume.cpp') - mydir = TestBase.compute_mydir(__file__) @skipIfRemote diff --git a/lldb/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template b/lldb/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp similarity index 96% rename from lldb/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template rename to lldb/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp index adb1d2006555..fa0c48e0ecfb 100644 --- a/lldb/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template +++ b/lldb/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp @@ -7,7 +7,7 @@ #include #include -%include_SB_APIs% +#include "lldb-headers.h" #include "common.h" diff --git a/lldb/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp.template b/lldb/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp similarity index 98% rename from lldb/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp.template rename to lldb/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp index e305d1af4893..b20868ff94f4 100644 --- a/lldb/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp.template +++ b/lldb/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp @@ -7,7 +7,7 @@ #include #include -%include_SB_APIs% +#include "lldb-headers.h" #include "common.h" using namespace lldb; diff --git a/lldb/packages/Python/lldbsuite/test/api/multithreaded/lldb-headers.h b/lldb/packages/Python/lldbsuite/test/api/multithreaded/lldb-headers.h new file mode 100644 index 000000000000..da0914b3b071 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/api/multithreaded/lldb-headers.h @@ -0,0 +1,11 @@ + +#ifndef LLDB_HEADERS_H +#define LLDB_HEADERS_H + +#ifdef __APPLE__ +#include +#else +#include "lldb/API/LLDB.h" +#endif + +#endif // LLDB_HEADERS_H diff --git a/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp.template b/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp similarity index 98% rename from lldb/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp.template rename to lldb/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp index 4133025aa495..def31f82b0c7 100644 --- a/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp.template +++ b/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp @@ -7,7 +7,7 @@ #include #include -%include_SB_APIs% +#include "lldb-headers.h" #include "common.h" diff --git a/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp.template b/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp similarity index 98% rename from lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp.template rename to lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp index 63e3f3631e5d..0d7844dce6d0 100644 --- a/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp.template +++ b/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp @@ -8,7 +8,7 @@ #include #include -%include_SB_APIs% +#include "lldb-headers.h" #include "common.h" diff --git a/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp.template b/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp similarity index 98% rename from lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp.template rename to lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp index 2926ece4d8d9..574257e98ee1 100644 --- a/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp.template +++ b/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp @@ -8,7 +8,7 @@ #include #include -%include_SB_APIs% +#include "lldb-headers.h" #include "common.h" diff --git a/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp.template b/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp similarity index 98% rename from lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp.template rename to lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp index 4adc9b338879..8cf786b11603 100644 --- a/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp.template +++ b/lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp @@ -8,7 +8,7 @@ #include #include -%include_SB_APIs% +#include "lldb-headers.h" #include "common.h" diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py b/lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py index 18fcc41fa9f6..9341ff97e6f4 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py @@ -18,10 +18,6 @@ class PluginCommandTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - def setUp(self): - TestBase.setUp(self) - self.generateSource('plugin.cpp') - @skipIfNoSBHeaders # Requires a compatible arch and platform to link against the host's built # lldb lib. diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template b/lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp similarity index 85% rename from lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template rename to lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp index 393e9feec796..be3d29325de1 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template +++ b/lldb/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp @@ -13,7 +13,15 @@ Compile this into a dylib foo.dylib and load by placing in appropriate locations by typing plugin load foo.dylib at the LLDB command line */ -%include_SB_APIs% +#if defined (__APPLE__) +#include +#include +#include +#else +#include +#include +#include +#endif namespace lldb { bool diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 2c5cd2e12d8b..a79e06fdbddc 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1824,33 +1824,6 @@ class TestBase(Base): folder = os.path.dirname(folder) continue - def generateSource(self, source): - template = source + '.template' - temp = os.path.join(os.getcwd(), template) - with open(temp, 'r') as f: - content = f.read() - - public_api_dir = os.path.join( - os.environ["LLDB_SRC"], "include", "lldb", "API") - - # Look under the include/lldb/API directory and add #include statements - # for all the SB API headers. - public_headers = os.listdir(public_api_dir) - # For different platforms, the include statement can vary. - if self.hasDarwinFramework(): - include_stmt = "'#include <%s>' % os.path.join('LLDB', header)" - else: - include_stmt = "'#include <%s>' % os.path.join(public_api_dir, header)" - list = [eval(include_stmt) for header in public_headers if ( - header.startswith("SB") and header.endswith(".h"))] - includes = '\n'.join(list) - new_content = content.replace('%include_SB_APIs%', includes) - src = os.path.join(os.getcwd(), source) - with open(src, 'w') as f: - f.write(new_content) - - self.addTearDownHook(lambda: os.remove(src)) - def setUp(self): #import traceback # traceback.print_stack()