xref: /linux/tools/testing/selftests/net/fin_ack_lat.sh (revision af8c8a450bf4698a8a6a7c68956ea5ccafe4cc88)
1*af8c8a45SSeongJae Park#!/bin/bash
2*af8c8a45SSeongJae Park# SPDX-License-Identifier: GPL-2.0
3*af8c8a45SSeongJae Park#
4*af8c8a45SSeongJae Park# Test latency spikes caused by FIN/ACK handling race.
5*af8c8a45SSeongJae Park
6*af8c8a45SSeongJae Parkset +x
7*af8c8a45SSeongJae Parkset -e
8*af8c8a45SSeongJae Park
9*af8c8a45SSeongJae Parktmpfile=$(mktemp /tmp/fin_ack_latency.XXXX.log)
10*af8c8a45SSeongJae Park
11*af8c8a45SSeongJae Parkcleanup() {
12*af8c8a45SSeongJae Park	kill $(pidof fin_ack_lat)
13*af8c8a45SSeongJae Park	rm -f $tmpfile
14*af8c8a45SSeongJae Park}
15*af8c8a45SSeongJae Park
16*af8c8a45SSeongJae Parktrap cleanup EXIT
17*af8c8a45SSeongJae Park
18*af8c8a45SSeongJae Parkdo_test() {
19*af8c8a45SSeongJae Park	RUNTIME=$1
20*af8c8a45SSeongJae Park
21*af8c8a45SSeongJae Park	./fin_ack_lat | tee $tmpfile &
22*af8c8a45SSeongJae Park	PID=$!
23*af8c8a45SSeongJae Park
24*af8c8a45SSeongJae Park	sleep $RUNTIME
25*af8c8a45SSeongJae Park	NR_SPIKES=$(wc -l $tmpfile | awk '{print $1}')
26*af8c8a45SSeongJae Park	if [ $NR_SPIKES -gt 0 ]
27*af8c8a45SSeongJae Park	then
28*af8c8a45SSeongJae Park		echo "FAIL: $NR_SPIKES spikes detected"
29*af8c8a45SSeongJae Park		return 1
30*af8c8a45SSeongJae Park	fi
31*af8c8a45SSeongJae Park	return 0
32*af8c8a45SSeongJae Park}
33*af8c8a45SSeongJae Park
34*af8c8a45SSeongJae Parkdo_test "30"
35*af8c8a45SSeongJae Parkecho "test done"
36