Fixes so tests compile and run remotely.

Fixes include:
- dont set or change LDFLAGS, but set LD_EXTRAS instead
- fix compilation errors for iOS based builds with objective C code
    - fix test cases to create classes instead of relying on classes from AppKit 
    - rename things where it makes sense

llvm-svn: 221496
This commit is contained in:
Greg Clayton 2014-11-06 22:59:28 +00:00
parent 84cf83f240
commit 860fac5338
11 changed files with 51 additions and 48 deletions

View File

@ -4,6 +4,6 @@ DYLIB_NAME := InternalDefiner
DYLIB_OBJC_SOURCES := InternalDefiner.m
OBJC_SOURCES := main.m
LDFLAGS = -framework Foundation
LD_EXTRAS = -framework Foundation
include $(LEVEL)/Makefile.rules

View File

@ -1,6 +1,6 @@
LEVEL = ../../../make
OBJCXX_SOURCES := main.mm
LDFLAGS += -framework Foundation
LD_EXTRAS = -framework Foundation
include $(LEVEL)/Makefile.rules

View File

@ -1,6 +1,6 @@
LEVEL = ../../../make
OBJC_SOURCES := main.m
LDFLAGS = $(CFLAGS) -lobjc -framework AppKit
LD_EXTRAS = -lobjc -framework Foundation
include $(LEVEL)/Makefile.rules

View File

@ -57,16 +57,16 @@ class ObjCDynamicValueTestCase(TestBase):
self.assertTrue(process.GetState() == lldb.eStateStopped,
PROCESS_STOPPED)
button = self.frame().FindVariable("button")
button_ptr_type = button.GetType()
button_pte_type = button_ptr_type.GetPointeeType()
self.assertTrue(button_ptr_type.GetNumberOfDirectBaseClasses() == 1, "NSButton * has one base class")
self.assertTrue(button_pte_type.GetNumberOfDirectBaseClasses() == 1, "NSButton has one base class")
var = self.frame().FindVariable("foo")
var_ptr_type = var.GetType()
var_pte_type = var_ptr_type.GetPointeeType()
self.assertTrue(var_ptr_type.GetNumberOfDirectBaseClasses() == 1, "Foo * has one base class")
self.assertTrue(var_pte_type.GetNumberOfDirectBaseClasses() == 1, "Foo has one base class")
self.assertTrue(button_ptr_type.GetDirectBaseClassAtIndex(0).IsValid(), "NSButton * has a valid base class")
self.assertTrue(button_pte_type.GetDirectBaseClassAtIndex(0).IsValid(), "NSButton * has a valid base class")
self.assertTrue(var_ptr_type.GetDirectBaseClassAtIndex(0).IsValid(), "Foo * has a valid base class")
self.assertTrue(var_pte_type.GetDirectBaseClassAtIndex(0).IsValid(), "Foo * has a valid base class")
self.assertTrue(button_ptr_type.GetDirectBaseClassAtIndex(0).GetName() == button_pte_type.GetDirectBaseClassAtIndex(0).GetName(), "NSButton and its pointer type don't agree on their base class")
self.assertTrue(var_ptr_type.GetDirectBaseClassAtIndex(0).GetName() == var_pte_type.GetDirectBaseClassAtIndex(0).GetName(), "Foo and its pointer type don't agree on their base class")
if __name__ == '__main__':
import atexit

View File

@ -1,8 +1,21 @@
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
@interface Foo : NSObject {}
-(id) init;
@end
@implementation Foo
-(id) init
{
return self = [super init];
}
@end
int main ()
{
NSButton *button = [NSButton new];
Foo *foo = [Foo new];
NSLog(@"a"); // Set breakpoint here.
return 0;
}

View File

@ -4,4 +4,4 @@ OBJC_SOURCES := main.m
include $(LEVEL)/Makefile.rules
LDFLAGS += -framework Foundation -framework Cocoa
LD_EXTRAS = -framework Foundation

View File

@ -15,21 +15,21 @@ class ObjCDynamicSBTypeTestCase(TestBase):
@dsym_test
@skipIfi386
def test_nsimage_dyn_with_dsym(self):
def test_dyn_with_dsym(self):
"""Test that we are able to properly report a usable dynamic type."""
d = {'EXE': self.exe_name}
self.buildDsym(dictionary=d)
self.setTearDownCleanup(dictionary=d)
self.nsimage_dyn(self.exe_name)
self.dyn(self.exe_name)
@dwarf_test
@skipIfi386
def test_nsimage_dyn_with_dwarf(self):
def test_dyn_with_dwarf(self):
"""Test that we are able to properly report a usable dynamic type."""
d = {'EXE': self.exe_name}
self.buildDwarf(dictionary=d)
self.setTearDownCleanup(dictionary=d)
self.nsimage_dyn(self.exe_name)
self.dyn(self.exe_name)
def setUp(self):
# Call super's setUp().
@ -40,7 +40,7 @@ class ObjCDynamicSBTypeTestCase(TestBase):
self.main_source = "main.m"
self.line = line_number(self.main_source, '// Set breakpoint here.')
def nsimage_dyn(self, exe_name):
def dyn(self, exe_name):
"""Test that we are able to properly report a usable dynamic type."""
exe = os.path.join(os.getcwd(), exe_name)
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
@ -49,14 +49,6 @@ class ObjCDynamicSBTypeTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
image = self.frame().EvaluateExpression("(id)image",lldb.eDynamicCanRunTarget)
self.assertTrue(image.GetTypeName() == "NSImage *", "The SBValue is properly type-named")
image_type = image.GetType()
self.assertTrue(image_type.GetName() == "NSImage *", "The dynamic SBType is for the correct type")
image_pointee_type = image_type.GetPointeeType()
self.assertTrue(image_pointee_type.GetName() == "NSImage", "The dynamic type figures out its pointee type just fine")
self.assertTrue(image_pointee_type.GetDirectBaseClassAtIndex(0).GetName() == "NSObject", "The dynamic type can go back to its base class")
v_object = self.frame().FindVariable("object").GetDynamicValue(lldb.eDynamicCanRunTarget)
v_base = self.frame().FindVariable("base").GetDynamicValue(lldb.eDynamicCanRunTarget)
self.assertTrue(v_object.GetTypeName() == "MyDerivedClass *", "The NSObject is properly type-named")

View File

@ -1,5 +1,4 @@
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
@interface MyBaseClass : NSObject
{}
@ -45,14 +44,9 @@
int main (int argc, char const *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSSize size = {10,10};
NSImage *image = [[NSImage alloc] initWithSize:size];
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSObject* object = [[MyDerivedClass alloc] init];
MyBaseClass* base = [[MyDerivedClass alloc] init];
[pool release]; // Set breakpoint here.
return 0;
}

View File

@ -4,4 +4,8 @@ OBJC_SOURCES := main.m
include $(LEVEL)/Makefile.rules
LDFLAGS += -framework Foundation -framework Cocoa
ifneq (,$(findstring arm,$(ARCH)))
LD_EXTRAS = -framework Foundation -framework UIKit
else
LD_EXTRAS = -framework Foundation -framework Cocoa
endif

View File

@ -1,13 +1,23 @@
#import <Foundation/Foundation.h>
#if defined (__i386__) || defined (__x86_64__)
#import <Cocoa/Cocoa.h>
#else
#import <UIKit/UIKit.h>
#endif
int main (int argc, char const *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
#if defined (__i386__) || defined (__x86_64__)
[NSApplication sharedApplication];
NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,100,100) styleMask:NSBorderlessWindowMask backing:NSBackingStoreRetained defer:NO];
[window setCanHide:YES];
[NSApplication sharedApplication];
NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,100,100) styleMask:NSBorderlessWindowMask backing:NSBackingStoreRetained defer:NO];
[window setCanHide:YES];
#else
[UIApplication sharedApplication];
CGRect rect = { 0, 0, 100, 100};
UIWindow* window = [[UIWindow alloc] initWithFrame:rect];
#endif
[pool release]; // Set breakpoint here.
return 0;
}

View File

@ -216,16 +216,6 @@ class GenericTester(TestBase):
# Now iterate through the golden list, comparing against the output from
# 'expr var'.
for var, val in gl:
# Don't overwhelm the expression mechanism.
# This slows down the test suite quite a bit, to enable it, define
# the environment variable LLDB_TYPES_EXPR_TIME_WAIT. For example:
#
# export LLDB_TYPES_EXPR_TIME_WAIT=0.5
#
# causes a 0.5 second delay between 'expression' commands.
if "LLDB_TYPES_EXPR_TIME_WAIT" in os.environ:
time.sleep(float(os.environ["LLDB_TYPES_EXPR_TIME_WAIT"]))
self.runCmd("expression %s" % var)
output = self.res.GetOutput()