Merge branch 'linux-5.6' of git://github.com/skeggsb/linux into drm-fixes
[linux-2.6-microblaze.git] / tools / testing / selftests / net / fin_ack_lat.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 #
4 # Test latency spikes caused by FIN/ACK handling race.
5
6 set +x
7 set -e
8
9 tmpfile=$(mktemp /tmp/fin_ack_latency.XXXX.log)
10
11 cleanup() {
12         kill $(pidof fin_ack_lat)
13         rm -f $tmpfile
14 }
15
16 trap cleanup EXIT
17
18 do_test() {
19         RUNTIME=$1
20
21         ./fin_ack_lat | tee $tmpfile &
22         PID=$!
23
24         sleep $RUNTIME
25         NR_SPIKES=$(wc -l $tmpfile | awk '{print $1}')
26         if [ $NR_SPIKES -gt 0 ]
27         then
28                 echo "FAIL: $NR_SPIKES spikes detected"
29                 return 1
30         fi
31         return 0
32 }
33
34 do_test "30"
35 echo "test done"