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
TEST_NAME="PREREQUISITES"
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=ve${VETH0_POSTFIX}
......@@ -155,10 +155,6 @@ TEST_NAME="XSK_SELFTESTS_SOFTIRQ"
execxdpxceiver
retval=$?
test_status $retval "${TEST_NAME}"
statusList+=($retval)
cleanup_exit ${VETH0} ${VETH1} ${NS1}
TEST_NAME="XSK_SELFTESTS_BUSY_POLL"
busy_poll=1
......@@ -166,19 +162,20 @@ busy_poll=1
setup_vethPairs
execxdpxceiver
retval=$?
test_status $retval "${TEST_NAME}"
statusList+=($retval)
## END TESTS
cleanup_exit ${VETH0} ${VETH1} ${NS1}
for _status in "${statusList[@]}"
failures=0
echo -e "\nSummary:"
for i in "${!statusList[@]}"
do
if [ $_status -ne 0 ]; then
test_exit $ksft_fail 0
if [ ${statusList[$i]} -ne 0 ]; then
test_status ${statusList[$i]} ${nameList[$i]}
failures=1
fi
done
test_exit $ksft_pass 0
if [ $failures -eq 0 ]; then
echo "All tests successful!"
fi
This diff is collapsed.
......@@ -25,6 +25,9 @@
#define SO_PREFER_BUSY_POLL 69
#endif
#define TEST_PASS 0
#define TEST_FAILURE -1
#define TEST_CONTINUE -2
#define MAX_INTERFACES 2
#define MAX_INTERFACE_NAME_CHARS 7
#define MAX_INTERFACES_NAMESPACE_CHARS 10
......@@ -160,6 +163,7 @@ struct test_spec {
u16 total_steps;
u16 current_step;
u16 nb_sockets;
bool fail;
char name[MAX_TEST_NAME_SIZE];
};
......
......@@ -15,7 +15,7 @@ validate_root_exec()
msg="skip all tests:"
if [ $UID != 0 ]; then
echo $msg must be run as root >&2
test_exit $ksft_fail 2
test_exit $ksft_fail
else
return $ksft_pass
fi
......@@ -26,7 +26,7 @@ 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
test_exit $ksft_skip
else
ip link del $1
return $ksft_pass
......@@ -36,22 +36,21 @@ validate_veth_support()
test_status()
{
statusval=$1
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 ]"
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 ]"
fi
}
test_exit()
{
retval=$1
if [ $2 -ne 0 ]; then
test_status $2 $(basename $0)
if [ $1 -ne 0 ]; then
test_status $1 $(basename $0)
fi
exit $retval
exit 1
}
clear_configs()
......@@ -75,7 +74,7 @@ cleanup_exit()
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()
......@@ -85,4 +84,9 @@ execxdpxceiver()
fi
./${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