mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-31 16:38:12 +00:00
d3e3bf5b4c
Prior to this commit individual xsk tests were launched from the shell script 'test_xsk.sh'. When adding a new test type, two new test configurations had to be added to this file - one for each of the supported XDP 'modes' (skb or drv). Should zero copy support be added to the xsk selftest framework in the future, three new test configurations would need to be added for each new test type. Each new test type also typically requires new CLI arguments for the xdpxceiver program. This commit aims to reduce the overhead of adding new tests, by launching the test configurations from within the xdpxceiver program itself, using simple loops. Every test is run every time the C program is executed. Many of the CLI arguments can be removed as a result. Signed-off-by: Ciara Loftus <ciara.loftus@intel.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Link: https://lore.kernel.org/bpf/20210223162304.7450-4-ciara.loftus@intel.com
111 lines
2.2 KiB
Bash
Executable file
111 lines
2.2 KiB
Bash
Executable file
#!/bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# Copyright(c) 2020 Intel Corporation.
|
|
|
|
ksft_pass=0
|
|
ksft_fail=1
|
|
ksft_xfail=2
|
|
ksft_xpass=3
|
|
ksft_skip=4
|
|
|
|
GREEN='\033[0;92m'
|
|
YELLOW='\033[0;93m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m'
|
|
STACK_LIM=131072
|
|
SPECFILE=veth.spec
|
|
XSKOBJ=xdpxceiver
|
|
NUMPKTS=10000
|
|
|
|
validate_root_exec()
|
|
{
|
|
msg="skip all tests:"
|
|
if [ $UID != 0 ]; then
|
|
echo $msg must be run as root >&2
|
|
test_exit $ksft_fail 2
|
|
else
|
|
return $ksft_pass
|
|
fi
|
|
}
|
|
|
|
validate_veth_support()
|
|
{
|
|
msg="skip all tests:"
|
|
if [ $(ip link add $1 type veth 2>/dev/null; echo $?;) != 0 ]; then
|
|
echo $msg veth kernel support not available >&2
|
|
test_exit $ksft_skip 1
|
|
else
|
|
ip link del $1
|
|
return $ksft_pass
|
|
fi
|
|
}
|
|
|
|
validate_veth_spec_file()
|
|
{
|
|
if [ ! -f ${SPECFILE} ]; then
|
|
test_exit $ksft_skip 1
|
|
fi
|
|
}
|
|
|
|
test_status()
|
|
{
|
|
statusval=$1
|
|
if [ -n "${colorconsole+set}" ]; then
|
|
if [ $statusval -eq 2 ]; then
|
|
echo -e "${YELLOW}$2${NC}: [ ${RED}FAIL${NC} ]"
|
|
elif [ $statusval -eq 1 ]; then
|
|
echo -e "${YELLOW}$2${NC}: [ ${RED}SKIPPED${NC} ]"
|
|
elif [ $statusval -eq 0 ]; then
|
|
echo -e "${YELLOW}$2${NC}: [ ${GREEN}PASS${NC} ]"
|
|
fi
|
|
else
|
|
if [ $statusval -eq 2 ]; then
|
|
echo -e "$2: [ FAIL ]"
|
|
elif [ $statusval -eq 1 ]; then
|
|
echo -e "$2: [ SKIPPED ]"
|
|
elif [ $statusval -eq 0 ]; then
|
|
echo -e "$2: [ PASS ]"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
test_exit()
|
|
{
|
|
retval=$1
|
|
if [ $2 -ne 0 ]; then
|
|
test_status $2 $(basename $0)
|
|
fi
|
|
exit $retval
|
|
}
|
|
|
|
clear_configs()
|
|
{
|
|
if [ $(ip netns show | grep $3 &>/dev/null; echo $?;) == 0 ]; then
|
|
[ $(ip netns exec $3 ip link show $2 &>/dev/null; echo $?;) == 0 ] &&
|
|
{ ip netns exec $3 ip link del $2; }
|
|
ip netns del $3
|
|
fi
|
|
#Once we delete a veth pair node, the entire veth pair is removed,
|
|
#this is just to be cautious just incase the NS does not exist then
|
|
#veth node inside NS won't get removed so we explicitly remove it
|
|
[ $(ip link show $1 &>/dev/null; echo $?;) == 0 ] &&
|
|
{ ip link del $1; }
|
|
if [ -f ${SPECFILE} ]; then
|
|
rm -f ${SPECFILE}
|
|
fi
|
|
}
|
|
|
|
cleanup_exit()
|
|
{
|
|
clear_configs $1 $2 $3
|
|
}
|
|
|
|
validate_ip_utility()
|
|
{
|
|
[ ! $(type -P ip) ] && { echo "'ip' not found. Skipping tests."; test_exit $ksft_skip 1; }
|
|
}
|
|
|
|
execxdpxceiver()
|
|
{
|
|
./${XSKOBJ} -i ${VETH0} -i ${VETH1},${NS1} -C ${NUMPKTS} ${VERBOSE_ARG} ${DUMP_PKTS_ARG}
|
|
}
|