1 include ../Makefile.inc
3 CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathcmddir)
4 LIBDEPS += -L$(multipathdir) -lmultipath -lcmocka
6 TESTS := uevent parser util dmevents hwtable blacklist unaligned
8 .SILENT: $(TESTS:%=%.o)
9 .PRECIOUS: $(TESTS:%=%-test)
13 # test-specific linker flags
14 # XYZ-test-TESTDEPS: test libraries containing __wrap_xyz functions
15 # XYZ-test_OBJDEPS: object files from libraries to link in explicitly
16 # That may be necessary if functions called from the object file are wrapped
17 # (wrapping works only for symbols which are undefined after processing a
19 # XYZ-test_LIBDEPS: Additional libs to link for this test
21 dmevents-test_LIBDEPS = -lpthread -ldevmapper -lurcu
22 hwtable-test_TESTDEPS := test-lib.o
23 hwtable-test_OBJDEPS := ../libmultipath/discovery.o ../libmultipath/blacklist.o \
24 ../libmultipath/prio.o ../libmultipath/callout.o ../libmultipath/structs.o
25 hwtable-test_LIBDEPS := -ludev -lpthread -ldl
26 blacklist-test_OBJDEPS := ../libmultipath/blacklist.o
27 blacklist-test_LIBDEPS := -ludev
31 ln -t lib ../libmultipath/{checkers,prioritizers,foreign}/*.so
33 %.out: %-test lib/libchecktur.so
34 @echo == running $< ==
35 @LD_LIBRARY_PATH=$(multipathdir):$(mpathcmddir) ./$< >$@
37 OBJS = $(TESTS:%=%.o) test-lib.o
40 $(RM) $(TESTS:%=%-test) $(TESTS:%=%.out) $(OBJS)
45 include $(wildcard $(OBJS:.o=.d))
51 @sed -n 's/^.*__wrap_\([a-zA-Z0-9_]*\).*$$/-Wl,--wrap=\1/p' $< | \
52 sort -u | tr '\n' ' ' >$@
54 # COLON will get expanded during second expansion below
57 %-test: %.o %.o.wrap $$($$@_OBJDEPS) $$($$@_TESTDEPS) $$($$@_TESTDEPS$$(COLON).o=.o.wrap) \
58 $(multipathdir)/libmultipath.so Makefile
59 $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $< $($@_TESTDEPS) $($@_OBJDEPS) \
60 $(LIBDEPS) $($@_LIBDEPS) \
61 $(shell cat $<.wrap) $(foreach dep,$($@_TESTDEPS),$(shell cat $(dep).wrap))