1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3#
4# Test latency spikes caused by FIN/ACK handling race.
5
6set +x
7set -e
8
9tmpfile=$(mktemp /tmp/fin_ack_latency.XXXX.log)
10
11cleanup() {
12	kill $(pidof fin_ack_lat)
13	rm -f $tmpfile
14}
15
16trap cleanup EXIT
17
18do_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
34do_test "30"
35echo "test done"
36