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