Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: net: lib: Add kill_process

A number of selftests run processes in the background and need to kill them
afterwards. Instead for everyone to open-code the kill / wait / redirect
mantra, add a helper in net/lib.sh. Convert existing open-code sites.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Reviewed-by: Amit Cohen <amcohen@nvidia.com>
Link: https://patch.msgid.link/a9db102067d741c118f0bd93b10c75e2a34665ea.1731589511.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Petr Machata and committed by
Jakub Kicinski
46f6569c af76b443

+41 -34
+2 -2
tools/testing/selftests/drivers/net/mlxsw/tc_sample.sh
··· 218 218 219 219 psample_capture_stop() 220 220 { 221 - { kill %% && wait %%; } 2>/dev/null 221 + kill_process %% 222 222 } 223 223 224 224 __tc_sample_rate_test() ··· 499 499 backlog=$(tc -j -p -s qdisc show dev $rp2 | jq '.[0]["backlog"]') 500 500 501 501 # Kill mausezahn. 502 - { kill %% && wait %%; } 2>/dev/null 502 + kill_process %% 503 503 504 504 psample_capture_stop 505 505
+3 -3
tools/testing/selftests/drivers/net/netdevsim/fib_notifications.sh
··· 94 94 sleep 1 95 95 $IP route add $route dev dummy1 96 96 sleep 1 97 - kill %% && wait %% &> /dev/null 97 + kill_process %% 98 98 99 99 route_notify_check $outfile $expected_num_notifications $offload_failed 100 100 rm -f $outfile ··· 148 148 sleep 1 149 149 $IP route del $route dev dummy1 150 150 sleep 1 151 - kill %% && wait %% &> /dev/null 151 + kill_process %% 152 152 153 153 route_notify_check $outfile $expected_num_notifications 154 154 rm -f $outfile ··· 191 191 sleep 1 192 192 $IP route replace $route dev dummy2 193 193 sleep 1 194 - kill %% && wait %% &> /dev/null 194 + kill_process %% 195 195 196 196 route_notify_check $outfile $expected_num_notifications 197 197 rm -f $outfile
+1 -1
tools/testing/selftests/net/drop_monitor_tests.sh
··· 77 77 78 78 rm ${dir}/packets.pcap 79 79 80 - { kill %% && wait %%; } 2>/dev/null 80 + kill_process %% 81 81 timeout 5 dwdump -o sw -w ${dir}/packets.pcap 82 82 (( $(tshark -r ${dir}/packets.pcap \ 83 83 -Y 'ip.dst == 192.0.2.10' 2> /dev/null | wc -l) == 0))
+4 -4
tools/testing/selftests/net/fib_tests.sh
··· 689 689 690 690 log_test $ret 0 "ipv6 route add notify" 691 691 692 - { kill %% && wait %%; } 2>/dev/null 692 + kill_process %% 693 693 694 694 #rm errors.txt 695 695 ··· 736 736 737 737 log_test $ret 0 "ipv4 route add notify" 738 738 739 - { kill %% && wait %%; } 2>/dev/null 739 + kill_process %% 740 740 741 741 rm errors.txt 742 742 ··· 2328 2328 $IP route del table 123 172.16.101.0/24 dev veth1 2329 2329 $IP rule del pref 100 2330 2330 2331 - { kill %% && wait %%; } 2>/dev/null 2331 + kill_process %% 2332 2332 rm $tmp_file 2333 2333 2334 2334 route_cleanup ··· 2386 2386 $IP -6 route del table 123 2001:db8:101::/64 dev veth1 2387 2387 $IP -6 rule del pref 100 2388 2388 2389 - { kill %% && wait %%; } 2>/dev/null 2389 + kill_process %% 2390 2390 rm $tmp_file 2391 2391 2392 2392 route_cleanup
+1 -2
tools/testing/selftests/net/forwarding/lib.sh
··· 1574 1574 { 1575 1575 local pid=${1-%%}; shift 1576 1576 1577 - # Suppress noise from killing mausezahn. 1578 - { kill $pid && wait $pid; } 2>/dev/null 1577 + kill_process "$pid" 1579 1578 } 1580 1579 1581 1580 declare -A cappid
+4 -4
tools/testing/selftests/net/forwarding/tc_police.sh
··· 148 148 149 149 log_test "$test_name" 150 150 151 - { kill %% && wait %%; } 2>/dev/null 151 + kill_process %% 152 152 tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower 153 153 } 154 154 ··· 198 198 199 199 log_test "$test_name" 200 200 201 - { kill %% && wait %%; } 2>/dev/null 201 + kill_process %% 202 202 } 203 203 204 204 police_shared_test() ··· 278 278 279 279 log_test "$test_name" 280 280 281 - { kill %% && wait %%; } 2>/dev/null 281 + kill_process %% 282 282 tc filter del dev $pol_if $dir protocol ip pref 1 handle 101 flower 283 283 tc filter del dev $h3 ingress protocol ip pref 1 handle 101 flower 284 284 tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower ··· 320 320 321 321 log_test "$test_name" 322 322 323 - { kill %% && wait %%; } 2>/dev/null 323 + kill_process %% 324 324 tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower 325 325 } 326 326
+8
tools/testing/selftests/net/lib.sh
··· 434 434 "$@" 435 435 fi 436 436 } 437 + 438 + kill_process() 439 + { 440 + local pid=$1; shift 441 + 442 + # Suppress noise from killing the process. 443 + { kill $pid && wait $pid; } 2>/dev/null 444 + }