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