1 # SPDX-License-Identifier: GPL-2.0
4 PREFIX
:= sudo
-E unshare
-n
8 HAVE_UNSHARED_UTIL
:= $(shell unshare
--version
2> /dev
/null
)
10 rwildcard
=$(wildcard $1$2) $(foreach d
,$(wildcard $1*),$(call rwildcard
,$d/,$2))
12 TESTS
:= $(patsubst tests
/%,%,$(call rwildcard
,tests
/,*.t
))
13 TESTS_DIR
:= $(dir $(TESTS
))
15 IPVERS
:= $(filter-out iproute2
/Makefile
,$(wildcard iproute2
/*))
17 ifneq (,$(wildcard /proc
/config.gz
))
18 KENV
:= $(shell cat
/proc
/config.gz | gunzip | grep ^CONFIG
)
20 KVER
:= $(shell uname
-r
)
21 KCPATHS
:= /lib
/modules
/$(KVER
)/config
/boot
/config-
$(KVER
)
22 KCPATH
:= $(firstword $(wildcard $(KCPATHS
)))
24 KENV
:= $(shell cat
${KCPATH} | grep ^CONFIG
)
28 .PHONY
: compile listtests alltests configure
$(TESTS
)
31 echo
"Entering iproute2" && cd iproute2
&& $(MAKE
) configure
&& cd ..
;
34 echo
"Entering iproute2" && cd iproute2
&& $(MAKE
) && cd ..
;
37 @for t in
$(TESTS
); do \
44 @echo
"Removing $(RESULTS_DIR) dir ..."
45 @
rm -rf
$(RESULTS_DIR
)
48 echo
"Entering iproute2" && cd iproute2
&& $(MAKE
) distclean && cd ..
;
51 ifeq (,$(HAVE_UNSHARED_UTIL
))
52 $(error Please
install util-linux tools to run tests in separated network namespace
)
54 @.
/tools
/generate_nlmsg
56 @mkdir
-p
$(RESULTS_DIR
)
58 @for d in
$(TESTS_DIR
); do \
59 mkdir
-p
$(RESULTS_DIR
)/$$d; \
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 \
72 elif
[ -e
"$(RESULTS_DIR)/$@.$$o.err" ]; then \
77 rm "$$TMP_ERR" "$$TMP_OUT"; \
78 dmesg
> $(RESULTS_DIR
)/$@.
$$o.dmesg
; \