2020-12-08 05:53:29 +08:00
|
|
|
#!/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
|
|
|
|
|
2022-07-07 19:16:12 +08:00
|
|
|
XSKOBJ=xskxceiver
|
2020-12-08 05:53:29 +08:00
|
|
|
|
|
|
|
validate_root_exec()
|
|
|
|
{
|
|
|
|
msg="skip all tests:"
|
|
|
|
if [ $UID != 0 ]; then
|
|
|
|
echo $msg must be run as root >&2
|
2022-05-10 19:55:59 +08:00
|
|
|
test_exit $ksft_fail
|
2020-12-08 05:53:29 +08:00
|
|
|
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
|
2022-05-10 19:55:59 +08:00
|
|
|
test_exit $ksft_skip
|
2020-12-08 05:53:29 +08:00
|
|
|
else
|
|
|
|
ip link del $1
|
|
|
|
return $ksft_pass
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
test_status()
|
|
|
|
{
|
|
|
|
statusval=$1
|
2022-05-10 19:55:59 +08:00
|
|
|
if [ $statusval -eq $ksft_fail ]; then
|
|
|
|
echo "$2: [ FAIL ]"
|
|
|
|
elif [ $statusval -eq $ksft_skip ]; then
|
|
|
|
echo "$2: [ SKIPPED ]"
|
|
|
|
elif [ $statusval -eq $ksft_pass ]; then
|
|
|
|
echo "$2: [ PASS ]"
|
2020-12-08 05:53:29 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
test_exit()
|
|
|
|
{
|
2022-05-10 19:55:59 +08:00
|
|
|
if [ $1 -ne 0 ]; then
|
|
|
|
test_status $1 $(basename $0)
|
2020-12-08 05:53:29 +08:00
|
|
|
fi
|
2022-05-10 19:55:59 +08:00
|
|
|
exit 1
|
2020-12-08 05:53:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
clear_configs()
|
|
|
|
{
|
|
|
|
[ $(ip link show $1 &>/dev/null; echo $?;) == 0 ] &&
|
2021-02-24 00:23:01 +08:00
|
|
|
{ ip link del $1; }
|
2020-12-08 05:53:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
cleanup_exit()
|
|
|
|
{
|
2023-01-11 17:35:19 +08:00
|
|
|
clear_configs $1 $2
|
2020-12-08 05:53:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
validate_ip_utility()
|
|
|
|
{
|
2022-05-10 19:55:59 +08:00
|
|
|
[ ! $(type -P ip) ] && { echo "'ip' not found. Skipping tests."; test_exit $ksft_skip; }
|
2020-12-08 05:53:29 +08:00
|
|
|
}
|
|
|
|
|
2022-07-07 19:16:12 +08:00
|
|
|
exec_xskxceiver()
|
2020-12-08 05:53:30 +08:00
|
|
|
{
|
2022-05-10 19:55:58 +08:00
|
|
|
if [[ $busy_poll -eq 1 ]]; then
|
|
|
|
ARGS+="-b "
|
|
|
|
fi
|
|
|
|
|
2023-01-11 17:35:19 +08:00
|
|
|
./${XSKOBJ} -i ${VETH0} -i ${VETH1} ${ARGS}
|
2022-05-10 19:55:59 +08:00
|
|
|
|
|
|
|
retval=$?
|
|
|
|
test_status $retval "${TEST_NAME}"
|
|
|
|
statusList+=($retval)
|
|
|
|
nameList+=(${TEST_NAME})
|
2020-12-08 05:53:30 +08:00
|
|
|
}
|