selftests: net: tsn_lib: create common helper for counting received packets
authorVladimir Oltean <vladimir.oltean@nxp.com>
Sat, 26 Apr 2025 14:48:56 +0000 (17:48 +0300)
committerJakub Kicinski <kuba@kernel.org>
Tue, 29 Apr 2025 21:44:34 +0000 (14:44 -0700)
This snippet will be necessary for a future isochron-based test, so
provide a simpler high-level interface for counting the received
packets.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20250426144859.3128352-3-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/drivers/net/ocelot/psfp.sh
tools/testing/selftests/net/forwarding/tsn_lib.sh

index bed748dde4b066daeb60eaba7d13907a1b682f1f..f96a4bc7120f39fed8681e5a614cfae5f3951e8c 100755 (executable)
@@ -272,12 +272,7 @@ run_test()
                "" \
                "${isochron_dat}"
 
-       # Count all received packets by looking at the non-zero RX timestamps
-       received=$(isochron report \
-               --input-file "${isochron_dat}" \
-               --printf-format "%u\n" --printf-args "R" | \
-               grep -w -v '0' | wc -l)
-
+       received=$(isochron_report_num_received "${isochron_dat}")
        if [ "${received}" = "${expected}" ]; then
                RET=0
        else
index b91bcd8008a9930529e6235c3a5d45e04740cf6b..19da1ccceac8239dd842629165608eeee15f2e4b 100644 (file)
@@ -247,3 +247,14 @@ isochron_do()
 
        cpufreq_restore ${ISOCHRON_CPU}
 }
+
+isochron_report_num_received()
+{
+       local isochron_dat=$1; shift
+
+       # Count all received packets by looking at the non-zero RX timestamps
+       isochron report \
+               --input-file "${isochron_dat}" \
+               --printf-format "%u\n" --printf-args "R" | \
+               grep -w -v '0' | wc -l
+}