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 <[email protected]> on behalf of Cray Inc. --- Makefile | 33 ++++++++++++++++++++++++++++++++- run_tests.py | 4 ++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff -ruNp libhugetlbfs-2.11-shm/tests/Makefile libhugetlbfs-2.11-shm-tests/tests/Makefile --- libhugetlbfs-2.11-shm/tests/Makefile 2010-12-16 11:38:22.000000000 -0600 +++ libhugetlbfs-2.11-shm-tests/tests/Makefile 2011-01-14 14:38:58.357087000 -0600 @@ -27,7 +27,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 @@ -71,6 +73,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)) @@ -120,6 +135,14 @@ $(LIB_TESTS:%=obj64/%) $(LIB_TESTS_64:%= @$(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) @@ -172,6 +195,14 @@ $(STRESS_TESTS:%=obj64/%): %: %.o obj64/ @$(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 -ruNp libhugetlbfs-2.11-shm/tests/run_tests.py libhugetlbfs-2.11-shm-tests/tests/run_tests.py --- libhugetlbfs-2.11-shm/tests/run_tests.py 2010-12-16 11:38:22.000000000 -0600 +++ libhugetlbfs-2.11-shm-tests/tests/run_tests.py 2011-01-14 14:40:13.263279000 -0600 @@ -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") ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Libhugetlbfs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel
