xref: /linux/tools/testing/selftests/net/so_txtime.sh (revision 26fbb4c8c7c3ee9a4c3b4de555a8587b5a19154e)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3#
4# Regression tests for the SO_TXTIME interface
5
6# Run in network namespace
7if [[ $# -eq 0 ]]; then
8	if ! ./in_netns.sh $0 __subprocess; then
9		# test is time sensitive, can be flaky
10		echo "test failed: retry once"
11		./in_netns.sh $0 __subprocess
12	fi
13
14	exit $?
15fi
16
17set -e
18
19tc qdisc add dev lo root fq
20./so_txtime -4 -6 -c mono a,-1 a,-1
21./so_txtime -4 -6 -c mono a,0 a,0
22./so_txtime -4 -6 -c mono a,10 a,10
23./so_txtime -4 -6 -c mono a,10,b,20 a,10,b,20
24./so_txtime -4 -6 -c mono a,20,b,10 b,20,a,20
25
26if tc qdisc replace dev lo root etf clockid CLOCK_TAI delta 400000; then
27	! ./so_txtime -4 -6 -c tai a,-1 a,-1
28	! ./so_txtime -4 -6 -c tai a,0 a,0
29	./so_txtime -4 -6 -c tai a,10 a,10
30	./so_txtime -4 -6 -c tai a,10,b,20 a,10,b,20
31	./so_txtime -4 -6 -c tai a,20,b,10 b,10,a,20
32else
33	echo "tc ($(tc -V)) does not support qdisc etf. skipping"
34fi
35
36echo OK. All tests passed
37