88 lines
3.0 KiB
Diff
88 lines
3.0 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Martin Wilck <mwilck@suse.com>
|
||
|
Date: Sat, 19 Sep 2020 00:29:45 +0200
|
||
|
Subject: [PATCH] libmultipath: create separate .so for unit tests
|
||
|
|
||
|
The unit tests use a lot of internal symbols that we don't want
|
||
|
to add to the ABI if we don't have to. As long as we don't
|
||
|
have to make incompatible changes to functions, we can work around
|
||
|
that by simply using a non-versioned library for the unit tests.
|
||
|
Therefore we add a seperate rule here. Do this before actually
|
||
|
adding a version script, to avoid breakage during bisection.
|
||
|
|
||
|
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||
|
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||
|
---
|
||
|
libmultipath/Makefile | 7 +++++++
|
||
|
tests/Makefile | 10 ++++++----
|
||
|
2 files changed, 13 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/libmultipath/Makefile b/libmultipath/Makefile
|
||
|
index 40028556..12bf6300 100644
|
||
|
--- a/libmultipath/Makefile
|
||
|
+++ b/libmultipath/Makefile
|
||
|
@@ -78,6 +78,13 @@ $(LIBS): $(OBJS)
|
||
|
$(DEVLIB): $(LIBS)
|
||
|
$(LN) $(LIBS) $@
|
||
|
|
||
|
+../tests/$(LIBS): $(OBJS) $(VERSION_SCRIPT)
|
||
|
+ $(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=`basename $@` \
|
||
|
+ -o $@ $(OBJS) $(LIBDEPS)
|
||
|
+ $(LN) $@ ${@:.so.0=.so}
|
||
|
+
|
||
|
+test-lib: ../tests/$(LIBS)
|
||
|
+
|
||
|
install: all
|
||
|
$(INSTALL_PROGRAM) -d $(DESTDIR)$(syslibdir)
|
||
|
$(INSTALL_PROGRAM) -m 755 $(LIBS) $(DESTDIR)$(syslibdir)/$(LIBS)
|
||
|
diff --git a/tests/Makefile b/tests/Makefile
|
||
|
index d26b3ce7..9658c9fd 100644
|
||
|
--- a/tests/Makefile
|
||
|
+++ b/tests/Makefile
|
||
|
@@ -10,7 +10,7 @@ W_MISSING_INITIALIZERS := $(call TEST_MISSING_INITIALIZERS)
|
||
|
|
||
|
CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathcmddir) \
|
||
|
-Wno-unused-parameter $(W_MISSING_INITIALIZERS)
|
||
|
-LIBDEPS += -L$(multipathdir) -L$(mpathcmddir) -lmultipath -lmpathcmd -lcmocka
|
||
|
+LIBDEPS += -L. -L$(mpathcmddir) -lmultipath -lmpathcmd -lcmocka
|
||
|
|
||
|
TESTS := uevent parser util dmevents hwtable blacklist unaligned vpd pgpolicy \
|
||
|
alias directio valid devt
|
||
|
@@ -68,7 +68,7 @@ lib/libchecktur.so:
|
||
|
|
||
|
%.out: %-test lib/libchecktur.so
|
||
|
@echo == running $< ==
|
||
|
- @LD_LIBRARY_PATH=$(multipathdir):$(mpathcmddir) ./$< >$@
|
||
|
+ @LD_LIBRARY_PATH=.:$(mpathcmddir) ./$< >$@
|
||
|
|
||
|
%.vgr: %-test lib/libchecktur.so
|
||
|
@echo == running valgrind for $< ==
|
||
|
@@ -78,7 +78,7 @@ lib/libchecktur.so:
|
||
|
OBJS = $(TESTS:%=%.o) $(HELPERS)
|
||
|
|
||
|
test_clean:
|
||
|
- $(RM) $(TESTS:%=%.out) $(TESTS:%=%.vgr)
|
||
|
+ $(RM) $(TESTS:%=%.out) $(TESTS:%=%.vgr) *.so*
|
||
|
|
||
|
valgrind_clean:
|
||
|
$(RM) $(TESTS:%=%.vgr)
|
||
|
@@ -98,12 +98,14 @@ dep_clean:
|
||
|
@sed -n 's/^.*__wrap_\([a-zA-Z0-9_]*\).*$$/-Wl,--wrap=\1/p' $< | \
|
||
|
sort -u | tr '\n' ' ' >$@
|
||
|
|
||
|
+libmultipath.so.0:
|
||
|
+ $(MAKE) -C $(multipathdir) test-lib
|
||
|
|
||
|
# COLON will get expanded during second expansion below
|
||
|
COLON:=:
|
||
|
.SECONDEXPANSION:
|
||
|
%-test: %.o %.o.wrap $$($$@_OBJDEPS) $$($$@_TESTDEPS) $$($$@_TESTDEPS$$(COLON).o=.o.wrap) \
|
||
|
- $(multipathdir)/libmultipath.so Makefile
|
||
|
+ libmultipath.so.0 Makefile
|
||
|
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $< $($@_TESTDEPS) $($@_OBJDEPS) \
|
||
|
$(LIBDEPS) $($@_LIBDEPS) \
|
||
|
$(shell cat $<.wrap) $(foreach dep,$($@_TESTDEPS),$(shell cat $(dep).wrap))
|
||
|
--
|
||
|
2.17.2
|
||
|
|