forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/tools/testing/selftests/net/forwarding/tc_common.sh
....@@ -3,23 +3,24 @@
33
44 CHECK_TC="yes"
55
6
+# Can be overridden by the configuration file. See lib.sh
7
+TC_HIT_TIMEOUT=${TC_HIT_TIMEOUT:=1000} # ms
8
+
69 tc_check_packets()
710 {
811 local id=$1
912 local handle=$2
1013 local count=$3
11
- local ret
1214
13
- output="$(tc -j -s filter show $id)"
14
- # workaround the jq bug which causes jq to return 0 in case input is ""
15
- ret=$?
16
- if [[ $ret -ne 0 ]]; then
17
- return $ret
18
- fi
19
- echo $output | \
20
- jq -e ".[] \
21
- | select(.options.handle == $handle) \
22
- | select(.options.actions[0].stats.packets == $count)" \
23
- &> /dev/null
24
- return $?
15
+ busywait "$TC_HIT_TIMEOUT" until_counter_is "== $count" \
16
+ tc_rule_handle_stats_get "$id" "$handle" > /dev/null
17
+}
18
+
19
+tc_check_packets_hitting()
20
+{
21
+ local id=$1
22
+ local handle=$2
23
+
24
+ busywait "$TC_HIT_TIMEOUT" until_counter_is "> 0" \
25
+ tc_rule_handle_stats_get "$id" "$handle" > /dev/null
2526 }