]> git.proxmox.com Git - mirror_iproute2.git/blob - testsuite/Makefile
testsuite: Search kernel config in modules dir also
[mirror_iproute2.git] / testsuite / Makefile
1 ## -- Config --
2 DEV := lo
3 PREFIX := sudo -E unshare -n
4 RESULTS_DIR := results
5 ## -- End Config --
6
7 HAVE_UNSHARED_UTIL := $(shell unshare --version 2> /dev/null)
8
9 rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
10
11 TESTS := $(patsubst tests/%,%,$(call rwildcard,tests/,*.t))
12 TESTS_DIR := $(dir $(TESTS))
13
14 IPVERS := $(filter-out iproute2/Makefile,$(wildcard iproute2/*))
15
16 ifneq (,$(wildcard /proc/config.gz))
17 KENV := $(shell cat /proc/config.gz | gunzip | grep ^CONFIG)
18 else
19 KVER := $(shell uname -r)
20 KCPATH := /lib/modules/${KVER}/config
21 ifneq (,$(wildcard ${KCPATH}))
22 KENV := $(shell cat ${KCPATH} | grep ^CONFIG)
23 endif
24 endif
25
26 .PHONY: compile listtests alltests configure $(TESTS)
27
28 configure:
29 echo "Entering iproute2" && cd iproute2 && $(MAKE) configure && cd ..;
30
31 compile: configure
32 echo "Entering iproute2" && cd iproute2 && $(MAKE) && cd ..;
33
34 listtests:
35 @for t in $(TESTS); do \
36 echo "$$t"; \
37 done
38
39 alltests: $(TESTS)
40
41 clean:
42 @echo "Removing $(RESULTS_DIR) dir ..."
43 @rm -rf $(RESULTS_DIR)
44
45 distclean: clean
46 echo "Entering iproute2" && cd iproute2 && $(MAKE) distclean && cd ..;
47
48 $(TESTS): clean
49 ifeq (,$(HAVE_UNSHARED_UTIL))
50 $(error Please install util-linux tools to run tests in separated network namespace)
51 endif
52 @./tools/generate_nlmsg
53
54 @mkdir -p $(RESULTS_DIR)
55
56 @for d in $(TESTS_DIR); do \
57 mkdir -p $(RESULTS_DIR)/$$d; \
58 done
59
60 @for i in $(IPVERS); do \
61 o=`echo $$i | sed -e 's/iproute2\///'`; \
62 echo -n "Running $@ [$$o/`uname -r`]: "; \
63 TMP_ERR=`mktemp /tmp/tc_testsuite.XXXXXX`; \
64 TMP_OUT=`mktemp /tmp/tc_testsuite.XXXXXX`; \
65 STD_ERR="$$TMP_ERR" STD_OUT="$$TMP_OUT" \
66 TC="$$i/tc/tc" IP="$$i/ip/ip" DEV="$(DEV)" IPVER="$@" SNAME="$$i" \
67 ERRF="$(RESULTS_DIR)/$@.$$o.err" $(KENV) $(PREFIX) tests/$@ > $(RESULTS_DIR)/$@.$$o.out; \
68 if [ "$$?" = "127" ]; then \
69 echo "SKIPPED"; \
70 elif [ -e "$(RESULTS_DIR)/$@.$$o.err" ]; then \
71 echo "FAILED"; \
72 else \
73 echo "PASS"; \
74 fi; \
75 rm "$$TMP_ERR" "$$TMP_OUT"; \
76 dmesg > $(RESULTS_DIR)/$@.$$o.dmesg; \
77 done