2017-11-25 04:21:35 +08:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
2005-06-24 04:18:38 +08:00
|
|
|
## -- Config --
|
|
|
|
DEV := lo
|
2015-05-12 22:40:15 +08:00
|
|
|
PREFIX := sudo -E unshare -n
|
2014-09-06 18:27:07 +08:00
|
|
|
RESULTS_DIR := results
|
2005-06-24 04:18:38 +08:00
|
|
|
## -- End Config --
|
|
|
|
|
2015-05-12 22:40:15 +08:00
|
|
|
HAVE_UNSHARED_UTIL := $(shell unshare --version 2> /dev/null)
|
|
|
|
|
2014-10-10 14:27:19 +08:00
|
|
|
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
|
|
|
|
|
|
|
|
TESTS := $(patsubst tests/%,%,$(call rwildcard,tests/,*.t))
|
|
|
|
TESTS_DIR := $(dir $(TESTS))
|
|
|
|
|
2005-01-18 07:27:05 +08:00
|
|
|
IPVERS := $(filter-out iproute2/Makefile,$(wildcard iproute2/*))
|
2014-09-30 14:15:10 +08:00
|
|
|
|
2018-08-22 16:31:38 +08:00
|
|
|
KENVFN := $(shell mktemp /tmp/tc_testkenv.XXXXXX)
|
2014-09-30 14:15:10 +08:00
|
|
|
ifneq (,$(wildcard /proc/config.gz))
|
2018-08-22 16:31:38 +08:00
|
|
|
KCPATH := /proc/config.gz
|
2017-02-09 18:50:55 +08:00
|
|
|
else
|
2019-06-12 23:48:33 +08:00
|
|
|
KVER := $(shell uname -r)
|
|
|
|
KCPATHS := /lib/modules/$(KVER)/config /boot/config-$(KVER)
|
|
|
|
KCPATH := $(firstword $(wildcard $(KCPATHS)))
|
2014-09-30 14:15:10 +08:00
|
|
|
endif
|
2005-01-18 07:27:05 +08:00
|
|
|
|
2005-06-24 04:18:38 +08:00
|
|
|
.PHONY: compile listtests alltests configure $(TESTS)
|
2005-01-18 07:27:05 +08:00
|
|
|
|
2005-06-24 04:18:38 +08:00
|
|
|
configure:
|
2019-06-14 01:47:02 +08:00
|
|
|
$(MAKE) -C iproute2 configure
|
2005-01-18 07:27:05 +08:00
|
|
|
|
2018-09-20 07:36:23 +08:00
|
|
|
compile: configure generate_nlmsg
|
2019-06-14 01:47:02 +08:00
|
|
|
$(MAKE) -C iproute2
|
2005-01-18 07:27:05 +08:00
|
|
|
|
|
|
|
listtests:
|
|
|
|
@for t in $(TESTS); do \
|
|
|
|
echo "$$t"; \
|
|
|
|
done
|
|
|
|
|
2018-09-20 07:36:23 +08:00
|
|
|
generate_nlmsg:
|
|
|
|
$(MAKE) -C tools
|
|
|
|
|
|
|
|
alltests: generate_nlmsg $(TESTS)
|
2005-01-18 07:27:05 +08:00
|
|
|
|
2018-09-20 07:36:22 +08:00
|
|
|
testclean:
|
2015-01-16 00:59:22 +08:00
|
|
|
@echo "Removing $(RESULTS_DIR) dir ..."
|
2014-09-06 18:27:07 +08:00
|
|
|
@rm -rf $(RESULTS_DIR)
|
2018-09-20 07:36:22 +08:00
|
|
|
|
|
|
|
clean: testclean
|
2018-08-23 02:09:01 +08:00
|
|
|
@rm -f iproute2/iproute2-this
|
|
|
|
@rm -f tests/ip/link/dev_wo_vf_rate.nl
|
|
|
|
$(MAKE) -C tools clean
|
2005-01-18 07:27:05 +08:00
|
|
|
|
2005-06-24 04:18:38 +08:00
|
|
|
distclean: clean
|
2019-06-14 01:47:02 +08:00
|
|
|
$(MAKE) -C iproute2 distclean
|
2005-06-24 04:18:38 +08:00
|
|
|
|
2018-12-17 04:55:38 +08:00
|
|
|
$(TESTS): generate_nlmsg testclean
|
2018-09-20 07:36:24 +08:00
|
|
|
ifeq (,$(IPVERS))
|
|
|
|
$(error Please run make first)
|
|
|
|
endif
|
2015-05-12 22:40:15 +08:00
|
|
|
ifeq (,$(HAVE_UNSHARED_UTIL))
|
|
|
|
$(error Please install util-linux tools to run tests in separated network namespace)
|
|
|
|
endif
|
2017-02-09 18:50:54 +08:00
|
|
|
@./tools/generate_nlmsg
|
|
|
|
|
2014-09-06 18:27:07 +08:00
|
|
|
@mkdir -p $(RESULTS_DIR)
|
2018-09-20 07:36:22 +08:00
|
|
|
|
2014-10-10 14:27:19 +08:00
|
|
|
@for d in $(TESTS_DIR); do \
|
|
|
|
mkdir -p $(RESULTS_DIR)/$$d; \
|
|
|
|
done
|
2018-09-20 07:36:22 +08:00
|
|
|
|
2018-08-22 16:31:38 +08:00
|
|
|
@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)
|
|
|
|
|
2005-01-18 07:27:05 +08:00
|
|
|
@for i in $(IPVERS); do \
|
|
|
|
o=`echo $$i | sed -e 's/iproute2\///'`; \
|
2005-06-24 04:18:38 +08:00
|
|
|
echo -n "Running $@ [$$o/`uname -r`]: "; \
|
2015-06-18 05:28:18 +08:00
|
|
|
TMP_ERR=`mktemp /tmp/tc_testsuite.XXXXXX`; \
|
|
|
|
TMP_OUT=`mktemp /tmp/tc_testsuite.XXXXXX`; \
|
2018-08-22 16:31:38 +08:00
|
|
|
. $(KENVFN); \
|
2015-06-18 05:28:18 +08:00
|
|
|
STD_ERR="$$TMP_ERR" STD_OUT="$$TMP_OUT" \
|
2019-12-16 14:43:42 +08:00
|
|
|
TC="$$i/tc/tc" IP="$$i/ip/ip" SS=$$i/misc/ss BRIDGE="$$i/bridge/bridge" \
|
|
|
|
DEV="$(DEV)" IPVER="$@" SNAME="$$i" \
|
2018-08-22 16:31:38 +08:00
|
|
|
ERRF="$(RESULTS_DIR)/$@.$$o.err" $(PREFIX) tests/$@ > $(RESULTS_DIR)/$@.$$o.out; \
|
2005-06-24 04:18:38 +08:00
|
|
|
if [ "$$?" = "127" ]; then \
|
2018-12-19 03:29:04 +08:00
|
|
|
printf "\033[1;35mSKIPPED\033[0m\n"; \
|
2014-09-06 18:27:07 +08:00
|
|
|
elif [ -e "$(RESULTS_DIR)/$@.$$o.err" ]; then \
|
2018-12-19 03:29:04 +08:00
|
|
|
printf "\033[0;31mFAILED\033[0m\n"; \
|
2005-06-24 04:18:38 +08:00
|
|
|
else \
|
2018-12-19 03:29:04 +08:00
|
|
|
printf "\033[0;32mPASS\033[0m\n"; \
|
2005-06-24 04:18:38 +08:00
|
|
|
fi; \
|
2015-06-18 05:28:18 +08:00
|
|
|
rm "$$TMP_ERR" "$$TMP_OUT"; \
|
2018-08-23 02:09:03 +08:00
|
|
|
sudo dmesg > $(RESULTS_DIR)/$@.$$o.dmesg; \
|
2005-01-18 07:27:05 +08:00
|
|
|
done
|