[PATCH 1/1 V2] Selftests: net: Improve missing modules error message

From: David Hunter
Date: Fri Aug 23 2024 - 01:49:27 EST


The error message descirbing the required modules is inaccurate.
Currently, only "SKIP: Need act_mirred module" is printed when any of
the modules are missing. As a result, users might only include that
module; however, three modules are required.

Fix the error message to show any/all modules needed for the script file
to properly execute.

Signed-off-by: David Hunter <david.hunter.linux@xxxxxxxxx>
---
V1 --> V2
- included subject prefixes
- Split the patch into two separate patches (one for each issue)
- fixed typos in message body
- removed second, unnecessary for loop
---
.../selftests/net/test_ingress_egress_chaining.sh | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/test_ingress_egress_chaining.sh b/tools/testing/selftests/net/test_ingress_egress_chaining.sh
index 08adff6bb3b6..d4b97662849b 100644
--- a/tools/testing/selftests/net/test_ingress_egress_chaining.sh
+++ b/tools/testing/selftests/net/test_ingress_egress_chaining.sh
@@ -13,10 +13,19 @@ if [ "$(id -u)" -ne 0 ];then
fi

needed_mods="act_mirred cls_flower sch_ingress"
+mods_missing=""
+numb_mods_needed=0;
+
for mod in $needed_mods; do
- modinfo $mod &>/dev/null || { echo "SKIP: Need act_mirred module"; exit $ksft_skip; }
+ modinfo $mod &>/dev/null ||
+ { mods_missing="$mods_missing$mod " ; numb_mods_needed=$(expr $numb_mods_needed + 1);}
done

+if [[ $numb_mods_needed>0 ]]; then
+ echo "SKIP: $numb_mods_needed modules needed: $mods_missing" ; exit $ksft_skip;
+fi
+
+
ns="ns$((RANDOM%899+100))"
veth1="veth1$((RANDOM%899+100))"
veth2="veth2$((RANDOM%899+100))"
--
2.43.0