aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Hastings <abh@cray.com>2011-01-21 08:19:17 -0600
committerEric B Munson <emunson@mgebm.net>2011-02-23 14:28:50 -0500
commit319122ba1f31cf5804901ec078dab5491f9202be (patch)
treecac187a54cceea49c2d314c7b8584f24802ba039
parent48b7ff1d536f63025e6b279be6798d167a4fa87a (diff)
downloadlibhugetlbfs-319122ba1f31cf5804901ec078dab5491f9202be.tar.gz
tests: add support for static linking
Add general support for static linking to the test suite. Build a static version of the shmoverride_linked test; this acts as a test case for a recent patch that allows shmget() to be used in static executables linked against libhugetlbfs. Correct runtests.py to run all cases of shmoverride: with and without LD_PRELOAD, with and without HUGETLB_SHM, with and without prelinking. Signed-off-by: Andrew Hastings <abh@cray.com> on behalf of Cray Inc. Signed-off-by: Eric B Munson <emunson@mgebm.net>
-rw-r--r--tests/Makefile33
-rwxr-xr-xtests/run_tests.py4
2 files changed, 36 insertions, 1 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 7364fdb..cb15767 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -30,7 +30,9 @@ BADTOOLCHAIN = bad-toolchain.sh
CFLAGS = -O2 -Wall -g
CPPFLAGS = -I..
-LDLIBS = -Wl,--no-as-needed -ldl -lpthread -lhugetlbfs_privutils
+STATIC_LIBHUGE = -Wl,--whole-archive -lhugetlbfs -Wl,--no-whole-archive
+STATIC_LDLIBS = -Wl,--no-as-needed -lpthread
+LDLIBS = $(STATIC_LDLIBS) -ldl -lhugetlbfs_privutils
LDFLAGS32 = -L../obj32
LDFLAGS64 = -L../obj64
INSTALL = install
@@ -74,6 +76,19 @@ ifdef CC64
ALLTESTS += $(TESTS_64:%=obj64/%)
endif
+# For now, build only one test as a static binary.
+# Can be changed once libhugetlbfs has better support for static linking.
+# Also, some tests should be changed to use syscall() instead of
+# dlsym() / rtld_next().
+ifdef CC32
+#ALLTESTS += $(LIB_TESTS:%=obj32/%_static) $(STRESS_TESTS:%=obj32/%_static)
+ALLTESTS += obj32/shmoverride_linked_static
+endif
+ifdef CC64
+#ALLTESTS += $(LIB_TESTS:%=obj64/%_static) $(STRESS_TESTS:%=obj64/%_static)
+ALLTESTS += obj64/shmoverride_linked_static
+endif
+
objs_needing_wrappers = \
$(foreach W,$(WRAPPERS:%.sh=%),$(filter $(1)/$(W),$(ALLTESTS)))
WRAPPERS32 = $(addsuffix .sh,$(call objs_needing_wrappers,obj32))
@@ -123,6 +138,14 @@ $(LIB_TESTS:%=obj64/%) $(LIB_TESTS_64:%=obj64/%): %: %.o obj64/testutils.o obj64
@$(VECHO) LD64 "(lib test)" $@
$(CC64) $(LDFLAGS) $(LDFLAGS64) -o $@ $^ $(LDLIBS) -lhugetlbfs
+$(LIB_TESTS:%=obj32/%_static): %_static: %.o obj32/testutils.o obj32/libtestutils.o
+ @$(VECHO) LD32 "(lib test)" $@
+ $(CC32) -static $(LDFLAGS) $(LDFLAGS32) -o $@ $^ $(STATIC_LDLIBS) $(STATIC_LIBHUGE)
+
+$(LIB_TESTS:%=obj64/%_static) $(LIB_TESTS_64:%=obj64/%_static): %_static: %.o obj64/testutils.o obj64/libtestutils.o
+ @$(VECHO) LD64 "(lib test)" $@
+ $(CC64) -static $(LDFLAGS) $(LDFLAGS64) -o $@ $^ $(STATIC_LDLIBS) $(STATIC_LIBHUGE)
+
$(NOLIB_TESTS:%=obj32/%): %: %.o obj32/testutils.o
@$(VECHO) LD32 "(nolib test)" $@
$(CC32) $(LDFLAGS) $(LDFLAGS32) -o $@ $^ $(LDLIBS)
@@ -175,6 +198,14 @@ $(STRESS_TESTS:%=obj64/%): %: %.o obj64/testutils.o
@$(VECHO) LD64 "(lib test)" $@
$(CC64) $(LDFLAGS) $(LDFLAGS64) -o $@ $^ $(LDLIBS) -lhugetlbfs
+$(STRESS_TESTS:%=obj32/%_static): %_static: %.o obj32/testutils.o
+ @$(VECHO) LD32 "(lib test)" $@
+ $(CC32) -static $(LDFLAGS) $(LDFLAGS32) -o $@ $^ $(STATIC_LDLIBS) $(STATIC_LIBHUGE)
+
+$(STRESS_TESTS:%=obj64/%_static): %_static: %.o obj64/testutils.o
+ @$(VECHO) LD64 "(lib test)" $@
+ $(CC64) -static $(LDFLAGS) $(LDFLAGS64) -o $@ $^ $(STATIC_LDLIBS) $(STATIC_LIBHUGE)
+
obj32/xB.%: $(SCRIPTS32).xB $(HUGETLBFS_LD) obj32/%.o obj32/testutils.o
@$(VECHO) LD32 "(xB test)" $@
@mkdir -p obj32
diff --git a/tests/run_tests.py b/tests/run_tests.py
index 99f382a..27a94cb 100755
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -597,7 +597,11 @@ def functional_tests():
# Test overriding of shmget()
do_shm_test("shmoverride_linked")
+ do_shm_test("shmoverride_linked", HUGETLB_SHM="yes")
+ do_shm_test("shmoverride_linked_static")
+ do_shm_test("shmoverride_linked_static", HUGETLB_SHM="yes")
do_shm_test("shmoverride_unlinked", LD_PRELOAD="libhugetlbfs.so")
+ do_shm_test("shmoverride_unlinked", LD_PRELOAD="libhugetlbfs.so", HUGETLB_SHM="yes")
# Test hugetlbfs filesystem quota accounting
do_test("quota.sh")