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
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
30 @echo == running $< ==
31 @LD_LIBRARY_PATH=$(multipathdir):$(mpathcmddir) ./$< >$@
33 OBJS = $(TESTS:%=%.o) test-lib.o
36 $(RM) $(TESTS:%=%-test) $(TESTS:%=%.out) $(OBJS)
40 include $(wildcard $(OBJS:.o=.d))
46 @sed -n 's/^.*__wrap_\([a-zA-Z0-9_]*\).*$$/-Wl,--wrap=\1/p' $< | \
47 sort -u | tr '\n' ' ' >$@
49 # COLON will get expanded during second expansion below
52 %-test: %.o %.o.wrap $$($$@_OBJDEPS) $$($$@_TESTDEPS) $$($$@_TESTDEPS$$(COLON).o=.o.wrap) \
53 $(multipathdir)/libmultipath.so Makefile
54 $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $< $($@_TESTDEPS) $($@_OBJDEPS) \
55 $(LIBDEPS) $($@_LIBDEPS) \
56 $(shell cat $<.wrap) $(foreach dep,$($@_TESTDEPS),$(shell cat $(dep).wrap))