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 endif 19 20 .PHONY: compile listtests alltests configure $(TESTS) 21 22 configure: 23 echo "Entering iproute2" && cd iproute2 && $(MAKE) configure && cd ..; 24 25 compile: configure 26 echo "Entering iproute2" && cd iproute2 && $(MAKE) && cd ..; 27 28 listtests: 29 @for t in $(TESTS); do \ 30 echo "$$t"; \ 31 done 32 33 alltests: $(TESTS) 34 35 clean: 36 @echo "Removing $(RESULTS_DIR) dir ..." 37 @rm -rf $(RESULTS_DIR) 38 39 distclean: clean 40 echo "Entering iproute2" && cd iproute2 && $(MAKE) distclean && cd ..; 41 42 $(TESTS): clean 43 ifeq (,$(HAVE_UNSHARED_UTIL)) 44 $(error Please install util-linux tools to run tests in separated network namespace) 45 endif 46 @mkdir -p $(RESULTS_DIR) 47 48 @for d in $(TESTS_DIR); do \ 49 mkdir -p $(RESULTS_DIR)/$$d; \ 50 done 51 52 @for i in $(IPVERS); do \ 53 o=`echo $$i | sed -e 's/iproute2\///'`; \ 54 echo -n "Running $@ [$$o/`uname -r`]: "; \ 55 TMP_ERR=`mktemp /tmp/tc_testsuite.XXXXXX`; \ 56 TMP_OUT=`mktemp /tmp/tc_testsuite.XXXXXX`; \ 57 STD_ERR="$$TMP_ERR" STD_OUT="$$TMP_OUT" \ 58 TC="$$i/tc/tc" IP="$$i/ip/ip" DEV="$(DEV)" IPVER="$@" SNAME="$$i" \ 59 ERRF="$(RESULTS_DIR)/$@.$$o.err" $(KENV) $(PREFIX) tests/$@ > $(RESULTS_DIR)/$@.$$o.out; \ 60 if [ "$$?" = "127" ]; then \ 61 echo "SKIPPED"; \ 62 elif [ -e "$(RESULTS_DIR)/$@.$$o.err" ]; then \ 63 echo "FAILED"; \ 64 else \ 65 echo "PASS"; \ 66 fi; \ 67 rm "$$TMP_ERR" "$$TMP_OUT"; \ 68 dmesg > $(RESULTS_DIR)/$@.$$o.dmesg; \ 69 done 70