]>
Commit | Line | Data |
---|---|---|
6054c1eb | 1 | # SPDX-License-Identifier: GPL-2.0 |
150a5bc3 SH |
2 | ## -- Config -- |
3 | DEV := lo | |
64dedc47 | 4 | PREFIX := sudo -E unshare -n |
9ecff68d | 5 | RESULTS_DIR := results |
150a5bc3 SH |
6 | ## -- End Config -- |
7 | ||
64dedc47 VK |
8 | HAVE_UNSHARED_UTIL := $(shell unshare --version 2> /dev/null) |
9 | ||
14f8854f | 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 | ||
82af5315 | 15 | IPVERS := $(filter-out iproute2/Makefile,$(wildcard iproute2/*)) |
f2954312 | 16 | |
17 | ifneq (,$(wildcard /proc/config.gz)) | |
18 | KENV := $(shell cat /proc/config.gz | gunzip | grep ^CONFIG) | |
3cef9592 PS |
19 | else |
20 | KVER := $(shell uname -r) | |
d754a64a | 21 | KCPATHS := /lib/modules/$(KVER)/config /boot/config-$(KVER) |
3064a44c AST |
22 | KCPATH := $(firstword $(wildcard $(KCPATHS))) |
23 | ifneq (,$(KCPATH)) | |
3cef9592 PS |
24 | KENV := $(shell cat ${KCPATH} | grep ^CONFIG) |
25 | endif | |
f2954312 | 26 | endif |
82af5315 | 27 | |
150a5bc3 | 28 | .PHONY: compile listtests alltests configure $(TESTS) |
82af5315 | 29 | |
150a5bc3 SH |
30 | configure: |
31 | echo "Entering iproute2" && cd iproute2 && $(MAKE) configure && cd ..; | |
82af5315 | 32 | |
150a5bc3 | 33 | compile: configure |
82af5315 | 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: | |
4cec9db0 | 44 | @echo "Removing $(RESULTS_DIR) dir ..." |
9ecff68d | 45 | @rm -rf $(RESULTS_DIR) |
82af5315 | 46 | |
150a5bc3 SH |
47 | distclean: clean |
48 | echo "Entering iproute2" && cd iproute2 && $(MAKE) distclean && cd ..; | |
49 | ||
4cec9db0 | 50 | $(TESTS): clean |
64dedc47 VK |
51 | ifeq (,$(HAVE_UNSHARED_UTIL)) |
52 | $(error Please install util-linux tools to run tests in separated network namespace) | |
53 | endif | |
886f2c43 PS |
54 | @./tools/generate_nlmsg |
55 | ||
9ecff68d | 56 | @mkdir -p $(RESULTS_DIR) |
14f8854f | 57 | |
58 | @for d in $(TESTS_DIR); do \ | |
59 | mkdir -p $(RESULTS_DIR)/$$d; \ | |
60 | done | |
61 | ||
82af5315 | 62 | @for i in $(IPVERS); do \ |
82af5315 | 63 | o=`echo $$i | sed -e 's/iproute2\///'`; \ |
150a5bc3 | 64 | echo -n "Running $@ [$$o/`uname -r`]: "; \ |
30383b07 VK |
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" \ | |
150a5bc3 | 68 | TC="$$i/tc/tc" IP="$$i/ip/ip" DEV="$(DEV)" IPVER="$@" SNAME="$$i" \ |
9ecff68d | 69 | ERRF="$(RESULTS_DIR)/$@.$$o.err" $(KENV) $(PREFIX) tests/$@ > $(RESULTS_DIR)/$@.$$o.out; \ |
150a5bc3 SH |
70 | if [ "$$?" = "127" ]; then \ |
71 | echo "SKIPPED"; \ | |
9ecff68d | 72 | elif [ -e "$(RESULTS_DIR)/$@.$$o.err" ]; then \ |
82af5315 | 73 | echo "FAILED"; \ |
150a5bc3 SH |
74 | else \ |
75 | echo "PASS"; \ | |
76 | fi; \ | |
30383b07 | 77 | rm "$$TMP_ERR" "$$TMP_OUT"; \ |
9ecff68d | 78 | dmesg > $(RESULTS_DIR)/$@.$$o.dmesg; \ |
82af5315 | 79 | done |