Commit 895b62ee authored by Magnus Karlsson's avatar Magnus Karlsson Committed by Alexei Starovoitov

selftests: xsk: fix reporting of failed tests

Fix the reporting of failed tests as it was broken in several
ways. First, a failed test was reported as both failed and passed
messing up the count. Second, tests were not aborted after a failure
and could generate more "failures" messing up the count even
more. Third, the failure reporting from the application to the shell
script was wrong. It always reported pass. And finally, the handling
of the failures in the launch script was not correct.

Correct all this by propagating the failure up through the function
calls to a calling function that can abort the test. A receiver or
sender thread will mark the new variable in the test spec called fail,
if a test has failed. This is then picked up by the main thread when
everyone else has exited and this is then marked and propagated up to
the calling script.

Also add a summary function in the calling script so that a user
does not have to go through the sub tests to see if something has
failed.
Signed-off-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/r/20220510115604.8717-5-magnus.karlsson@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent f90062b5
...@@ -87,7 +87,7 @@ done ...@@ -87,7 +87,7 @@ done
TEST_NAME="PREREQUISITES" TEST_NAME="PREREQUISITES"
URANDOM=/dev/urandom URANDOM=/dev/urandom
[ ! -e "${URANDOM}" ] && { echo "${URANDOM} not found. Skipping tests."; test_exit 1 1; } [ ! -e "${URANDOM}" ] && { echo "${URANDOM} not found. Skipping tests."; test_exit $ksft_fail; }
VETH0_POSTFIX=$(cat ${URANDOM} | tr -dc '0-9' | fold -w 256 | head -n 1 | head --bytes 4) VETH0_POSTFIX=$(cat ${URANDOM} | tr -dc '0-9' | fold -w 256 | head -n 1 | head --bytes 4)
VETH0=ve${VETH0_POSTFIX} VETH0=ve${VETH0_POSTFIX}
...@@ -155,10 +155,6 @@ TEST_NAME="XSK_SELFTESTS_SOFTIRQ" ...@@ -155,10 +155,6 @@ TEST_NAME="XSK_SELFTESTS_SOFTIRQ"
execxdpxceiver execxdpxceiver
retval=$?
test_status $retval "${TEST_NAME}"
statusList+=($retval)
cleanup_exit ${VETH0} ${VETH1} ${NS1} cleanup_exit ${VETH0} ${VETH1} ${NS1}
TEST_NAME="XSK_SELFTESTS_BUSY_POLL" TEST_NAME="XSK_SELFTESTS_BUSY_POLL"
busy_poll=1 busy_poll=1
...@@ -166,19 +162,20 @@ busy_poll=1 ...@@ -166,19 +162,20 @@ busy_poll=1
setup_vethPairs setup_vethPairs
execxdpxceiver execxdpxceiver
retval=$?
test_status $retval "${TEST_NAME}"
statusList+=($retval)
## END TESTS ## END TESTS
cleanup_exit ${VETH0} ${VETH1} ${NS1} cleanup_exit ${VETH0} ${VETH1} ${NS1}
for _status in "${statusList[@]}" failures=0
echo -e "\nSummary:"
for i in "${!statusList[@]}"
do do
if [ $_status -ne 0 ]; then if [ ${statusList[$i]} -ne 0 ]; then
test_exit $ksft_fail 0 test_status ${statusList[$i]} ${nameList[$i]}
failures=1
fi fi
done done
test_exit $ksft_pass 0 if [ $failures -eq 0 ]; then
echo "All tests successful!"
fi
This diff is collapsed.
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
#define SO_PREFER_BUSY_POLL 69 #define SO_PREFER_BUSY_POLL 69
#endif #endif
#define TEST_PASS 0
#define TEST_FAILURE -1
#define TEST_CONTINUE -2
#define MAX_INTERFACES 2 #define MAX_INTERFACES 2
#define MAX_INTERFACE_NAME_CHARS 7 #define MAX_INTERFACE_NAME_CHARS 7
#define MAX_INTERFACES_NAMESPACE_CHARS 10 #define MAX_INTERFACES_NAMESPACE_CHARS 10
...@@ -160,6 +163,7 @@ struct test_spec { ...@@ -160,6 +163,7 @@ struct test_spec {
u16 total_steps; u16 total_steps;
u16 current_step; u16 current_step;
u16 nb_sockets; u16 nb_sockets;
bool fail;
char name[MAX_TEST_NAME_SIZE]; char name[MAX_TEST_NAME_SIZE];
}; };
......
...@@ -15,7 +15,7 @@ validate_root_exec() ...@@ -15,7 +15,7 @@ validate_root_exec()
msg="skip all tests:" msg="skip all tests:"
if [ $UID != 0 ]; then if [ $UID != 0 ]; then
echo $msg must be run as root >&2 echo $msg must be run as root >&2
test_exit $ksft_fail 2 test_exit $ksft_fail
else else
return $ksft_pass return $ksft_pass
fi fi
...@@ -26,7 +26,7 @@ validate_veth_support() ...@@ -26,7 +26,7 @@ validate_veth_support()
msg="skip all tests:" msg="skip all tests:"
if [ $(ip link add $1 type veth 2>/dev/null; echo $?;) != 0 ]; then if [ $(ip link add $1 type veth 2>/dev/null; echo $?;) != 0 ]; then
echo $msg veth kernel support not available >&2 echo $msg veth kernel support not available >&2
test_exit $ksft_skip 1 test_exit $ksft_skip
else else
ip link del $1 ip link del $1
return $ksft_pass return $ksft_pass
...@@ -36,22 +36,21 @@ validate_veth_support() ...@@ -36,22 +36,21 @@ validate_veth_support()
test_status() test_status()
{ {
statusval=$1 statusval=$1
if [ $statusval -eq 2 ]; then if [ $statusval -eq $ksft_fail ]; then
echo -e "$2: [ FAIL ]" echo "$2: [ FAIL ]"
elif [ $statusval -eq 1 ]; then elif [ $statusval -eq $ksft_skip ]; then
echo -e "$2: [ SKIPPED ]" echo "$2: [ SKIPPED ]"
elif [ $statusval -eq 0 ]; then elif [ $statusval -eq $ksft_pass ]; then
echo -e "$2: [ PASS ]" echo "$2: [ PASS ]"
fi fi
} }
test_exit() test_exit()
{ {
retval=$1 if [ $1 -ne 0 ]; then
if [ $2 -ne 0 ]; then test_status $1 $(basename $0)
test_status $2 $(basename $0)
fi fi
exit $retval exit 1
} }
clear_configs() clear_configs()
...@@ -75,7 +74,7 @@ cleanup_exit() ...@@ -75,7 +74,7 @@ cleanup_exit()
validate_ip_utility() validate_ip_utility()
{ {
[ ! $(type -P ip) ] && { echo "'ip' not found. Skipping tests."; test_exit $ksft_skip 1; } [ ! $(type -P ip) ] && { echo "'ip' not found. Skipping tests."; test_exit $ksft_skip; }
} }
execxdpxceiver() execxdpxceiver()
...@@ -85,4 +84,9 @@ execxdpxceiver() ...@@ -85,4 +84,9 @@ execxdpxceiver()
fi fi
./${XSKOBJ} -i ${VETH0} -i ${VETH1},${NS1} ${ARGS} ./${XSKOBJ} -i ${VETH0} -i ${VETH1},${NS1} ${ARGS}
retval=$?
test_status $retval "${TEST_NAME}"
statusList+=($retval)
nameList+=(${TEST_NAME})
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment