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
This commit is contained in:
Chris Bieneman 2016-10-27 23:18:52 +00:00
parent 75f1de0c1a
commit 614dc150ec
12 changed files with 58 additions and 48 deletions

View File

@ -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)

View File

@ -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

View File

@ -7,7 +7,7 @@
#include <string>
#include <vector>
%include_SB_APIs%
#include "lldb-headers.h"
#include "common.h"

View File

@ -7,7 +7,7 @@
#include <thread>
#include <vector>
%include_SB_APIs%
#include "lldb-headers.h"
#include "common.h"
using namespace lldb;

View File

@ -0,0 +1,11 @@
#ifndef LLDB_HEADERS_H
#define LLDB_HEADERS_H
#ifdef __APPLE__
#include <LLDB/LLDB.h>
#else
#include "lldb/API/LLDB.h"
#endif
#endif // LLDB_HEADERS_H

View File

@ -7,7 +7,7 @@
#include <vector>
#include <string>
%include_SB_APIs%
#include "lldb-headers.h"
#include "common.h"

View File

@ -8,7 +8,7 @@
#include <string>
#include <thread>
%include_SB_APIs%
#include "lldb-headers.h"
#include "common.h"

View File

@ -8,7 +8,7 @@
#include <string>
#include <thread>
%include_SB_APIs%
#include "lldb-headers.h"
#include "common.h"

View File

@ -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.

View File

@ -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 <LLDB/SBCommandInterpreter.h>
#include <LLDB/SBCommandReturnObject.h>
#include <LLDB/SBDebugger.h>
#else
#include <lldb/API/SBCommandInterpreter.h>
#include <lldb/API/SBCommandReturnObject.h>
#include <lldb/API/SBDebugger.h>
#endif
namespace lldb {
bool

View File

@ -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()