forked from OSchip/llvm-project
Add test suite support for TestLoadUnload.py for Linux.
llvm-svn: 190815
This commit is contained in:
parent
f4f8d8acc8
commit
84fee88b98
|
@ -1,51 +1,77 @@
|
||||||
all: a.out liba.dylib libb.dylib libc.dylib libd.dylib
|
|
||||||
|
|
||||||
CC ?= clang
|
CC ?= clang
|
||||||
ifeq "$(ARCH)" ""
|
ifeq "$(ARCH)" ""
|
||||||
ARCH = x86_64
|
ARCH = x86_64
|
||||||
endif
|
endif
|
||||||
CFLAGS ?=-arch $(ARCH) -g -O0
|
|
||||||
|
ifeq "$(OS)" ""
|
||||||
|
OS = $(shell uname -s)
|
||||||
|
endif
|
||||||
|
|
||||||
|
CFLAGS ?= -g -O0
|
||||||
CWD := $(shell pwd)
|
CWD := $(shell pwd)
|
||||||
|
|
||||||
all: a.out hidden/libd.dylib
|
ifeq "$(OS)" "Darwin"
|
||||||
|
CFLAGS += -arch $(ARCH)
|
||||||
|
DS := dsymutil
|
||||||
|
LD_FLAGS := -dynamiclib
|
||||||
|
LIB_A := liba.dylib
|
||||||
|
LIB_B := libb.dylib
|
||||||
|
LIB_C := libc.dylib
|
||||||
|
LIB_D := libd.dylib
|
||||||
|
EXEC_PATH := "@executable_path"
|
||||||
|
EXEC_PATH_A := -install_name $(EXEC_PATH)/$(LIB_A)
|
||||||
|
EXEC_PATH_B := -install_name $(EXEC_PATH)/$(LIB_B)
|
||||||
|
EXEC_PATH_C := -install_name $(EXEC_PATH)/$(LIB_C)
|
||||||
|
EXEC_PATH_D := -install_name $(CWD)/$(LIB_D)
|
||||||
|
else
|
||||||
|
CFLAGS += -fPIC
|
||||||
|
LD_FLAGS := -shared
|
||||||
|
LIB_DL := -ldl
|
||||||
|
LIB_A := liba.so
|
||||||
|
LIB_B := libb.so
|
||||||
|
LIB_C := libc.so
|
||||||
|
LIB_D := libd.so
|
||||||
|
endif
|
||||||
|
|
||||||
a.out: main.o libd.dylib
|
all: a.out $(LIB_A) $(LIB_B) $(LIB_C) $(LIB_D) hidden/$(LIB_D)
|
||||||
$(CC) $(CFLAGS) -o a.out main.o -L. -ld
|
|
||||||
|
a.out: main.o $(LIB_D)
|
||||||
|
$(CC) $(CFLAGS) -o a.out main.o -L. -ld $(LIB_DL)
|
||||||
|
|
||||||
main.o: main.c
|
main.o: main.c
|
||||||
$(CC) $(CFLAGS) -c main.c
|
$(CC) $(CFLAGS) -c main.c
|
||||||
|
|
||||||
hidden/libd.dylib: b.o
|
hidden/$(LIB_D): b.o
|
||||||
$(CC) $(CFLAGS) -dynamiclib -o hidden/libd.dylib d.o
|
$(CC) $(CFLAGS) $(LD_FLAGS) -o hidden/$(LIB_D) d.o
|
||||||
dsymutil -o hidden/libd.dylib.dSYM hidden/libd.dylib
|
if [ "$(OS)" = "Darwin" ]; then dsymutil -o hidden/$(LIB_D).dSYM hidden/$(LIB_D); fi
|
||||||
|
|
||||||
liba.dylib: a.o libb.dylib
|
$(LIB_A): a.o $(LIB_B)
|
||||||
$(CC) $(CFLAGS) -dynamiclib -install_name "@executable_path/liba.dylib" -o liba.dylib a.o -L. -lb
|
$(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_A) -o $(LIB_A) a.o -L. -lb
|
||||||
dsymutil liba.dylib
|
if [ "$(OS)" = "Darwin" ]; then dsymutil $(LIB_A); fi
|
||||||
|
|
||||||
a.o: a.c
|
a.o: a.c
|
||||||
$(CC) $(CFLAGS) -c a.c
|
$(CC) $(CFLAGS) -c a.c
|
||||||
|
|
||||||
libb.dylib: b.o
|
$(LIB_B): b.o
|
||||||
$(CC) $(CFLAGS) -dynamiclib -install_name "@executable_path/libb.dylib" -o libb.dylib b.o
|
$(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_B) -o $(LIB_B) b.o
|
||||||
dsymutil libb.dylib
|
if [ "$(OS)" = "Darwin" ]; then dsymutil $(LIB_B); fi
|
||||||
|
|
||||||
b.o: b.c
|
b.o: b.c
|
||||||
$(CC) $(CFLAGS) -c b.c
|
$(CC) $(CFLAGS) -c b.c
|
||||||
|
|
||||||
libc.dylib: c.o
|
$(LIB_C): c.o
|
||||||
$(CC) $(CFLAGS) -dynamiclib -install_name "@executable_path/libc.dylib" -o libc.dylib c.o
|
$(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_C) -o $(LIB_C) c.o
|
||||||
dsymutil libc.dylib
|
if [ "$(OS)" = "Darwin" ]; then dsymutil $(LIB_C); fi
|
||||||
|
|
||||||
c.o: c.c
|
c.o: c.c
|
||||||
$(CC) $(CFLAGS) -c c.c
|
$(CC) $(CFLAGS) -c c.c
|
||||||
|
|
||||||
libd.dylib: d.o
|
$(LIB_D): d.o
|
||||||
$(CC) $(CFLAGS) -dynamiclib -install_name "$(CWD)/libd.dylib" -o libd.dylib d.o
|
$(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_D) -o $(LIB_D) d.o
|
||||||
dsymutil libd.dylib
|
if [ "$(OS)" = "Darwin" ]; then dsymutil $(LIB_D); fi
|
||||||
|
|
||||||
d.o: d.c
|
d.o: d.c
|
||||||
$(CC) $(CFLAGS) -c d.c
|
$(CC) $(CFLAGS) -c d.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf *.o *~ *.dylib a.out *.dSYM hidden/*
|
rm -rf *.o *~ *.dylib *.so a.out *.dSYM hidden/*
|
||||||
|
|
|
@ -24,9 +24,13 @@ class LoadUnloadTestCase(TestBase):
|
||||||
'// Set break point at this line for test_lldb_process_load_and_unload_commands().')
|
'// Set break point at this line for test_lldb_process_load_and_unload_commands().')
|
||||||
self.line_d_function = line_number('d.c',
|
self.line_d_function = line_number('d.c',
|
||||||
'// Find this line number within d_dunction().')
|
'// Find this line number within d_dunction().')
|
||||||
|
if not sys.platform.startswith("darwin"):
|
||||||
|
if "LD_LIBRARY_PATH" in os.environ:
|
||||||
|
self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.environ["LD_LIBRARY_PATH"] + ":" + os.getcwd())
|
||||||
|
else:
|
||||||
|
self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.getcwd())
|
||||||
|
|
||||||
@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
|
@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
|
||||||
@skipIfLinux # llvm.org/pr14424 - missing linux Makefiles/testcase support
|
|
||||||
@not_remote_testsuite_ready
|
@not_remote_testsuite_ready
|
||||||
def test_modules_search_paths(self):
|
def test_modules_search_paths(self):
|
||||||
"""Test target modules list after loading a different copy of the library libd.dylib, and verifies that it works with 'target modules search-paths add'."""
|
"""Test target modules list after loading a different copy of the library libd.dylib, and verifies that it works with 'target modules search-paths add'."""
|
||||||
|
@ -36,6 +40,8 @@ class LoadUnloadTestCase(TestBase):
|
||||||
|
|
||||||
if sys.platform.startswith("darwin"):
|
if sys.platform.startswith("darwin"):
|
||||||
dylibName = 'libd.dylib'
|
dylibName = 'libd.dylib'
|
||||||
|
else:
|
||||||
|
dylibName = 'libd.so'
|
||||||
|
|
||||||
# The directory with the dynamic library we did not link to.
|
# The directory with the dynamic library we did not link to.
|
||||||
new_dir = os.path.join(os.getcwd(), "hidden")
|
new_dir = os.path.join(os.getcwd(), "hidden")
|
||||||
|
@ -65,7 +71,7 @@ class LoadUnloadTestCase(TestBase):
|
||||||
|
|
||||||
# Obliterate traces of libd from the old location.
|
# Obliterate traces of libd from the old location.
|
||||||
os.remove(old_dylib)
|
os.remove(old_dylib)
|
||||||
# Inform dyld of the new path, too.
|
# Inform (DY)LD_LIBRARY_PATH of the new path, too.
|
||||||
env_cmd_string = "settings set target.env-vars " + self.dylibPath + "=" + new_dir
|
env_cmd_string = "settings set target.env-vars " + self.dylibPath + "=" + new_dir
|
||||||
if self.TraceOn():
|
if self.TraceOn():
|
||||||
print "Set environment to: ", env_cmd_string
|
print "Set environment to: ", env_cmd_string
|
||||||
|
@ -81,10 +87,9 @@ class LoadUnloadTestCase(TestBase):
|
||||||
substrs = [new_dylib])
|
substrs = [new_dylib])
|
||||||
|
|
||||||
@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
|
@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
|
||||||
@skipIfLinux # llvm.org/pr14424 - missing linux Makefiles/testcase support
|
|
||||||
@not_remote_testsuite_ready
|
@not_remote_testsuite_ready
|
||||||
def test_dyld_library_path(self):
|
def test_dyld_library_path(self):
|
||||||
"""Test DYLD_LIBRARY_PATH after moving libd.dylib, which defines d_function, somewhere else."""
|
"""Test (DY)LD_LIBRARY_PATH after moving libd.dylib, which defines d_function, somewhere else."""
|
||||||
|
|
||||||
# Invoke the default build rule.
|
# Invoke the default build rule.
|
||||||
self.buildDefault()
|
self.buildDefault()
|
||||||
|
@ -95,6 +100,8 @@ class LoadUnloadTestCase(TestBase):
|
||||||
if sys.platform.startswith("darwin"):
|
if sys.platform.startswith("darwin"):
|
||||||
dylibName = 'libd.dylib'
|
dylibName = 'libd.dylib'
|
||||||
dsymName = 'libd.dylib.dSYM'
|
dsymName = 'libd.dylib.dSYM'
|
||||||
|
else:
|
||||||
|
dylibName = 'libd.so'
|
||||||
|
|
||||||
# The directory to relocate the dynamic library and its debugging info.
|
# The directory to relocate the dynamic library and its debugging info.
|
||||||
special_dir = "hidden"
|
special_dir = "hidden"
|
||||||
|
@ -102,15 +109,16 @@ class LoadUnloadTestCase(TestBase):
|
||||||
|
|
||||||
old_dylib = os.path.join(os.getcwd(), dylibName)
|
old_dylib = os.path.join(os.getcwd(), dylibName)
|
||||||
new_dylib = os.path.join(new_dir, dylibName)
|
new_dylib = os.path.join(new_dir, dylibName)
|
||||||
old_dSYM = os.path.join(os.getcwd(), dsymName)
|
|
||||||
new_dSYM = os.path.join(new_dir, dsymName)
|
|
||||||
|
|
||||||
#system(["ls", "-lR", "."])
|
#system(["ls", "-lR", "."])
|
||||||
|
|
||||||
# Try running with the DYLD_LIBRARY_PATH environment variable set, make sure
|
# Try running with the (DY)LD_LIBRARY_PATH environment variable set, make sure
|
||||||
# we pick up the hidden dylib.
|
# we pick up the hidden dylib.
|
||||||
|
|
||||||
env_cmd_string = "settings set target.env-vars " + self.dylibPath + "=" + new_dir
|
env_cmd_string = "settings set target.env-vars " + self.dylibPath + "=" + new_dir
|
||||||
|
if not sys.platform.startswith("darwin"):
|
||||||
|
env_cmd_string += ":" + os.getcwd()
|
||||||
|
|
||||||
if self.TraceOn():
|
if self.TraceOn():
|
||||||
print "Set environment to: ", env_cmd_string
|
print "Set environment to: ", env_cmd_string
|
||||||
self.runCmd(env_cmd_string)
|
self.runCmd(env_cmd_string)
|
||||||
|
@ -121,7 +129,7 @@ class LoadUnloadTestCase(TestBase):
|
||||||
|
|
||||||
lldbutil.run_break_set_by_file_and_line (self, "d.c", self.line_d_function, num_expected_locations=1, loc_exact=True)
|
lldbutil.run_break_set_by_file_and_line (self, "d.c", self.line_d_function, num_expected_locations=1, loc_exact=True)
|
||||||
|
|
||||||
# For now we don't track DYLD_LIBRARY_PATH, so the old library will be in
|
# For now we don't track (DY)LD_LIBRARY_PATH, so the old library will be in
|
||||||
# the modules list.
|
# the modules list.
|
||||||
self.expect("target modules list",
|
self.expect("target modules list",
|
||||||
substrs = [os.path.basename(old_dylib)],
|
substrs = [os.path.basename(old_dylib)],
|
||||||
|
@ -138,7 +146,6 @@ class LoadUnloadTestCase(TestBase):
|
||||||
|
|
||||||
@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
|
@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
|
||||||
@not_remote_testsuite_ready
|
@not_remote_testsuite_ready
|
||||||
@skipIfLinux # llvm.org/pr14424 - missing linux Makefiles/testcase support
|
|
||||||
def test_lldb_process_load_and_unload_commands(self):
|
def test_lldb_process_load_and_unload_commands(self):
|
||||||
"""Test that lldb process load/unload command work correctly."""
|
"""Test that lldb process load/unload command work correctly."""
|
||||||
|
|
||||||
|
@ -160,9 +167,14 @@ class LoadUnloadTestCase(TestBase):
|
||||||
error=True, matching=False,
|
error=True, matching=False,
|
||||||
patterns = ["1 match found .* %s" % self.mydir])
|
patterns = ["1 match found .* %s" % self.mydir])
|
||||||
|
|
||||||
|
if sys.platform.startswith("darwin"):
|
||||||
|
dylibName = 'liba.dylib'
|
||||||
|
else:
|
||||||
|
dylibName = 'liba.so'
|
||||||
|
|
||||||
# Use lldb 'process load' to load the dylib.
|
# Use lldb 'process load' to load the dylib.
|
||||||
self.expect("process load liba.dylib", "liba.dylib loaded correctly",
|
self.expect("process load %s" % dylibName, "%s loaded correctly" % dylibName,
|
||||||
patterns = ['Loading "liba.dylib".*ok',
|
patterns = ['Loading "%s".*ok' % dylibName,
|
||||||
'Image [0-9]+ loaded'])
|
'Image [0-9]+ loaded'])
|
||||||
|
|
||||||
# Search for and match the "Image ([0-9]+) loaded" pattern.
|
# Search for and match the "Image ([0-9]+) loaded" pattern.
|
||||||
|
@ -180,14 +192,13 @@ class LoadUnloadTestCase(TestBase):
|
||||||
patterns = ["1 match found .*%s" % self.mydir])
|
patterns = ["1 match found .*%s" % self.mydir])
|
||||||
|
|
||||||
# Use lldb 'process unload' to unload the dylib.
|
# Use lldb 'process unload' to unload the dylib.
|
||||||
self.expect("process unload %s" % index, "liba.dylib unloaded correctly",
|
self.expect("process unload %s" % index, "%s unloaded correctly" % dylibName,
|
||||||
patterns = ["Unloading .* with index %s.*ok" % index])
|
patterns = ["Unloading .* with index %s.*ok" % index])
|
||||||
|
|
||||||
self.runCmd("process continue")
|
self.runCmd("process continue")
|
||||||
|
|
||||||
@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
|
@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
|
||||||
@not_remote_testsuite_ready
|
@not_remote_testsuite_ready
|
||||||
@skipIfLinux # llvm.org/pr14424 - missing linux Makefiles/testcase support
|
|
||||||
def test_load_unload(self):
|
def test_load_unload(self):
|
||||||
"""Test breakpoint by name works correctly with dlopen'ing."""
|
"""Test breakpoint by name works correctly with dlopen'ing."""
|
||||||
|
|
||||||
|
@ -229,7 +240,6 @@ class LoadUnloadTestCase(TestBase):
|
||||||
|
|
||||||
@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
|
@skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
|
||||||
@not_remote_testsuite_ready
|
@not_remote_testsuite_ready
|
||||||
@skipIfLinux # llvm.org/pr14424 - missing linux Makefiles/testcase support
|
|
||||||
def test_step_over_load (self):
|
def test_step_over_load (self):
|
||||||
"""Test stepping over code that loads a shared library works correctly."""
|
"""Test stepping over code that loads a shared library works correctly."""
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,13 @@
|
||||||
int
|
int
|
||||||
main (int argc, char const *argv[])
|
main (int argc, char const *argv[])
|
||||||
{
|
{
|
||||||
|
#if defined (__APPLE__)
|
||||||
const char *a_name = "@executable_path/liba.dylib";
|
const char *a_name = "@executable_path/liba.dylib";
|
||||||
const char *c_name = "@executable_path/libc.dylib";
|
const char *c_name = "@executable_path/libc.dylib";
|
||||||
|
#else
|
||||||
|
const char *a_name = "liba.so";
|
||||||
|
const char *c_name = "libc.so";
|
||||||
|
#endif
|
||||||
void *a_dylib_handle = NULL;
|
void *a_dylib_handle = NULL;
|
||||||
void *c_dylib_handle = NULL;
|
void *c_dylib_handle = NULL;
|
||||||
int (*a_function) (void);
|
int (*a_function) (void);
|
||||||
|
|
Loading…
Reference in New Issue