[dm-devel] [PATCH v2 08/12] libmultipath: create separate .so for unit tests
Benjamin Marzinski
bmarzins at redhat.com
Fri Oct 16 21:04:27 UTC 2020
On Fri, Oct 16, 2020 at 12:42:35PM +0200, mwilck at suse.com wrote:
> From: Martin Wilck <mwilck at suse.com>
>
> 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 at redhat.com>
> Signed-off-by: Martin Wilck <mwilck at suse.com>
> ---
> libmultipath/Makefile | 7 +++++++
> tests/Makefile | 10 ++++++----
> 2 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/libmultipath/Makefile b/libmultipath/Makefile
> index af5bb77..cf13561 100644
> --- a/libmultipath/Makefile
> +++ b/libmultipath/Makefile
> @@ -74,6 +74,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 502377f..f6ef16a 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
> @@ -67,7 +67,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 $< ==
> @@ -77,7 +77,7 @@ lib/libchecktur.so:
> OBJS = $(TESTS:%=%.o) test-lib.o
>
> test_clean:
> - $(RM) $(TESTS:%=%.out) $(TESTS:%=%.vgr)
> + $(RM) $(TESTS:%=%.out) $(TESTS:%=%.vgr) *.so*
>
> valgrind_clean:
> $(RM) $(TESTS:%=%.vgr)
> @@ -97,12 +97,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.28.0
More information about the dm-devel
mailing list