1 include ../Makefile.inc
3 # Test special behavior of gcc 4.8 with nested initializers
4 # gcc 4.8 compiles blacklist.c only with -Wno-missing-field-initializers
5 TEST_MISSING_INITIALIZERS = $(shell \
6 echo 'struct A {int a, b;}; struct B {struct A a; int b;} b = {.a.a=1};' | \
7 $(CC) -c -Werror -Wmissing-field-initializers -o /dev/null -xc - >/dev/null 2>&1 \
8 || echo -Wno-missing-field-initializers)
9 W_MISSING_INITIALIZERS := $(call TEST_MISSING_INITIALIZERS)
11 CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathcmddir) \
12 -Wno-unused-parameter $(W_MISSING_INITIALIZERS)
13 LIBDEPS += -L$(multipathdir) -lmultipath -lcmocka
15 TESTS := uevent parser util dmevents hwtable blacklist unaligned vpd pgpolicy \
18 .SILENT: $(TESTS:%=%.o)
19 .PRECIOUS: $(TESTS:%=%-test)
23 # test-specific compiler flags
24 # XYZ-test_FLAGS: Additional compiler flags for this test
26 ifneq ($(wildcard directio_test_dev),)
27 DIO_TEST_DEV = $(shell sed -n -e 's/^[[:space:]]*DIO_TEST_DEV[[:space:]]*=[[:space:]]*\([^[:space:]\#]\+\).*/\1/p' < directio_test_dev)
29 ifneq ($(DIO_TEST_DEV),)
30 directio-test_FLAGS := -DDIO_TEST_DEV=\"$(DIO_TEST_DEV)\"
33 # test-specific linker flags
34 # XYZ-test_TESTDEPS: test libraries containing __wrap_xyz functions
35 # XYZ-test_OBJDEPS: object files from libraries to link in explicitly
36 # That may be necessary if functions called from the object file are wrapped
37 # (wrapping works only for symbols which are undefined after processing a
39 # XYZ-test_LIBDEPS: Additional libs to link for this test
41 dmevents-test_LIBDEPS = -lpthread -ldevmapper -lurcu
42 hwtable-test_TESTDEPS := test-lib.o
43 hwtable-test_OBJDEPS := ../libmultipath/discovery.o ../libmultipath/blacklist.o \
44 ../libmultipath/prio.o ../libmultipath/callout.o ../libmultipath/structs.o
45 hwtable-test_LIBDEPS := -ludev -lpthread -ldl
46 blacklist-test_TESTDEPS := test-log.o
47 blacklist-test_OBJDEPS := ../libmultipath/blacklist.o
48 blacklist-test_LIBDEPS := -ludev
49 vpd-test_OBJDEPS := ../libmultipath/discovery.o
50 vpd-test_LIBDEPS := -ludev -lpthread -ldl
51 alias-test_TESTDEPS := test-log.o
52 alias-test_LIBDEPS := -lpthread -ldl
53 ifneq ($(DIO_TEST_DEV),)
54 directio-test_LIBDEPS := -laio
58 $(CC) $(CFLAGS) $($*-test_FLAGS) -c -o $@ $<
62 ln -t lib ../libmultipath/{checkers,prioritizers,foreign}/*.so
64 %.out: %-test lib/libchecktur.so
65 @echo == running $< ==
66 @LD_LIBRARY_PATH=$(multipathdir):$(mpathcmddir) ./$< >$@
68 OBJS = $(TESTS:%=%.o) test-lib.o
71 $(RM) $(TESTS:%=%.out)
73 clean: test_clean dep_clean
74 $(RM) $(TESTS:%=%-test) $(OBJS) *.o.wrap
79 include $(wildcard $(OBJS:.o=.d))
85 @sed -n 's/^.*__wrap_\([a-zA-Z0-9_]*\).*$$/-Wl,--wrap=\1/p' $< | \
86 sort -u | tr '\n' ' ' >$@
89 # COLON will get expanded during second expansion below
92 %-test: %.o %.o.wrap $$($$@_OBJDEPS) $$($$@_TESTDEPS) $$($$@_TESTDEPS$$(COLON).o=.o.wrap) \
93 $(multipathdir)/libmultipath.so Makefile
94 $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $< $($@_TESTDEPS) $($@_OBJDEPS) \
95 $(LIBDEPS) $($@_LIBDEPS) \
96 $(shell cat $<.wrap) $(foreach dep,$($@_TESTDEPS),$(shell cat $(dep).wrap))