]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - testsuite/Makefile
testsuite: declare dependency between $(TESTS) and generate_nlmsg
[mirror_iproute2.git] / testsuite / Makefile
index 055136b52683615e0ed1fca29b7501dadcabcacf..9b0f1c157a3980a3ac80b8489d316128622698aa 100644 (file)
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
 ## -- Config --
 DEV := lo
 PREFIX := sudo -E unshare -n
@@ -13,15 +14,13 @@ TESTS_DIR := $(dir $(TESTS))
 
 IPVERS := $(filter-out iproute2/Makefile,$(wildcard iproute2/*))
 
+KENVFN := $(shell mktemp /tmp/tc_testkenv.XXXXXX)
 ifneq (,$(wildcard /proc/config.gz))
-       KENV := $(shell cat /proc/config.gz | gunzip | grep ^CONFIG)
+       KCPATH := /proc/config.gz
 else
 KVER := $(shell uname -r)
 KCPATHS := /lib/modules/$(KVER)/config /boot/config-$(KVER)
 KCPATH := $(firstword $(wildcard $(KCPATHS)))
-ifneq (,$(KCPATH))
-       KENV := $(shell cat ${KCPATH} | grep ^CONFIG)
-endif
 endif
 
 .PHONY: compile listtests alltests configure $(TESTS)
@@ -29,7 +28,7 @@ endif
 configure:
        echo "Entering iproute2" && cd iproute2 && $(MAKE) configure && cd ..;
 
-compile: configure
+compile: configure generate_nlmsg
        echo "Entering iproute2" && cd iproute2 && $(MAKE) && cd ..;
 
 listtests:
@@ -37,42 +36,61 @@ listtests:
                echo "$$t"; \
        done
 
-alltests: $(TESTS)
+generate_nlmsg:
+       $(MAKE) -C tools
+
+alltests: generate_nlmsg $(TESTS)
 
-clean:
+testclean:
        @echo "Removing $(RESULTS_DIR) dir ..."
        @rm -rf $(RESULTS_DIR)
 
+clean: testclean
+       @rm -f iproute2/iproute2-this
+       @rm -f tests/ip/link/dev_wo_vf_rate.nl
+       $(MAKE) -C tools clean
+
 distclean: clean
        echo "Entering iproute2" && cd iproute2 && $(MAKE) distclean && cd ..;
 
-$(TESTS): clean
+$(TESTS): generate_nlmsg testclean
+ifeq (,$(IPVERS))
+       $(error Please run make first)
+endif
 ifeq (,$(HAVE_UNSHARED_UTIL))
        $(error Please install util-linux tools to run tests in separated network namespace)
 endif
        @./tools/generate_nlmsg
 
        @mkdir -p $(RESULTS_DIR)
-       
+
        @for d in $(TESTS_DIR); do \
            mkdir -p $(RESULTS_DIR)/$$d; \
        done
-       
+
+       @if [ "$(KCPATH)" = "/proc/config.gz" ]; then \
+               gunzip -c $(KCPATH) >$(KENVFN); \
+       elif [ "$(KCPATH)" != "" ]; then \
+               cat $(KCPATH) >$(KENVFN); \
+       fi
+       @sed -i -e 's/^CONFIG_/export CONFIG_/' $(KENVFN)
+
        @for i in $(IPVERS); do \
                o=`echo $$i | sed -e 's/iproute2\///'`; \
                echo -n "Running $@ [$$o/`uname -r`]: "; \
                TMP_ERR=`mktemp /tmp/tc_testsuite.XXXXXX`; \
                TMP_OUT=`mktemp /tmp/tc_testsuite.XXXXXX`; \
+               . $(KENVFN); \
                STD_ERR="$$TMP_ERR" STD_OUT="$$TMP_OUT" \
-               TC="$$i/tc/tc" IP="$$i/ip/ip" DEV="$(DEV)" IPVER="$@" SNAME="$$i" \
-               ERRF="$(RESULTS_DIR)/$@.$$o.err" $(KENV) $(PREFIX) tests/$@ > $(RESULTS_DIR)/$@.$$o.out; \
+               TC="$$i/tc/tc" IP="$$i/ip/ip" SS=$$i/misc/ss DEV="$(DEV)" IPVER="$@" SNAME="$$i" \
+               ERRF="$(RESULTS_DIR)/$@.$$o.err" $(PREFIX) tests/$@ > $(RESULTS_DIR)/$@.$$o.out; \
                if [ "$$?" = "127" ]; then \
-                       echo "SKIPPED"; \
+                       echo "\e[1;35mSKIPPED\e[0m"; \
                elif [ -e "$(RESULTS_DIR)/$@.$$o.err" ]; then \
-                       echo "FAILED"; \
+                       echo "\e[0;31mFAILED\e[0m"; \
                else \
-                       echo "PASS"; \
+                       echo "\e[0;32mPASS\e[0m"; \
                fi; \
                rm "$$TMP_ERR" "$$TMP_OUT"; \
-               dmesg > $(RESULTS_DIR)/$@.$$o.dmesg; \
+               sudo dmesg > $(RESULTS_DIR)/$@.$$o.dmesg; \
        done