xref: /aosp_15_r20/external/ltp/testscripts/network.sh (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) Linux Test Project, 2013-2019
4
5cd $(dirname $0)
6export LTPROOT=${LTPROOT:-"$PWD"}
7echo $LTPROOT | grep -q testscripts
8if [ $? -eq 0 ]; then
9	cd ..
10	export LTPROOT=${PWD}
11fi
12
13export TMPDIR=/tmp/netpan-$$
14mkdir -p $TMPDIR
15CMDFILE=${TMPDIR}/network.tests
16VERBOSE="no"
17NO_KMSG=
18QUIET_MODE=
19TEST_CASES=
20
21export PATH="${PATH}:${LTPROOT}/testcases/bin"
22
23usage()
24{
25	echo "Usage: $0 OPTIONS"
26	echo "  -6    IPv6 tests"
27	echo "  -m    multicast tests"
28	echo "  -n    NFS tests"
29	echo "  -s    SCTP tests"
30	echo "  -t    TCP/IP command tests"
31	echo "  -c    RPC and TI-RPC tests"
32	echo "  -d    TS-RPC tests"
33	echo "  -a    Application stress tests (HTTP, SSH, DNS)"
34	echo "  -e    Interface stress tests"
35	echo "  -b    Stress tests with malformed ICMP packets"
36	echo "  -i    IPsec ICMP stress tests"
37	echo "  -T    IPsec TCP stress tests"
38	echo "  -U    IPsec UDP stress tests"
39	echo "  -D    IPsec DCCP stress tests"
40	echo "  -S    IPsec SCTP stress tests"
41	echo "  -R    route stress tests"
42	echo "  -M    multicast stress tests"
43	echo "  -F    network features tests (TFO, vxlan, etc.)"
44	echo "  -f x  where x is a runtest file"
45	echo "  -q    quiet mode (this implies not logging start of test"
46	echo "        in kernel log)"
47	echo "  -Q    don't log start of test in kernel log"
48	echo "  -V|v  verbose"
49	echo "  -h    print this help"
50}
51
52while getopts 6mnrstaebcdiTUDSRMFf:qQVvh OPTION
53do
54	case $OPTION in
55	6) TEST_CASES="$TEST_CASES net.ipv6 net.ipv6_lib";;
56	m) TEST_CASES="$TEST_CASES net.multicast";;
57	n) TEST_CASES="$TEST_CASES net.nfs";;
58	s) TEST_CASES="$TEST_CASES net.sctp";;
59	t) TEST_CASES="$TEST_CASES net.tcp_cmds";;
60	c) TEST_CASES="$TEST_CASES net.rpc_tests";;
61	d) TEST_CASES="$TEST_CASES net.tirpc_tests";;
62	a) TEST_CASES="$TEST_CASES net_stress.appl";;
63	e) TEST_CASES="$TEST_CASES net_stress.interface";;
64	b) TEST_CASES="$TEST_CASES net_stress.broken_ip";;
65	i) TEST_CASES="$TEST_CASES net_stress.ipsec_icmp";;
66	T) TEST_CASES="$TEST_CASES net_stress.ipsec_tcp";;
67	U) TEST_CASES="$TEST_CASES net_stress.ipsec_udp";;
68	D) TEST_CASES="$TEST_CASES net_stress.ipsec_dccp";;
69	S) TEST_CASES="$TEST_CASES net_stress.ipsec_sctp";;
70	R) TEST_CASES="$TEST_CASES net_stress.route";;
71	M) TEST_CASES="$TEST_CASES net_stress.multicast";;
72	F) TEST_CASES="$TEST_CASES net.features";;
73	f) TEST_CASES=${OPTARG};;
74	q) QUIET_MODE="-q";;
75	Q) NO_KMSG="-Q";;
76	V|v) VERBOSE="yes";;
77	h) usage; exit 0;;
78	*) echo "Error: invalid option..."; usage; exit 1;;
79	esac
80done
81
82if [ "$OPTIND" -eq 1 ]; then
83	echo "Error: option is required"
84	usage
85	exit 1
86fi
87shift $(($OPTIND - 1))
88
89rm -f $CMDFILE
90
91for t in $TEST_CASES; do
92	cat  ${LTPROOT}/runtest/$t >> $CMDFILE
93done
94
95cd $TMPDIR
96
97cmd="${LTPROOT}/bin/ltp-pan $QUIET_MODE $NO_KMSG -e -l /tmp/netpan.log -S -a ltpnet -n ltpnet -f $CMDFILE"
98
99if [ ${VERBOSE} = "yes" ]; then
100	echo "Network parameters:"
101	echo " - ${LHOST_IFACES} local interface (MAC address: ${LHOST_HWADDRS})"
102	echo " - ${RHOST_IFACES} remote interface (MAC address: ${RHOST_HWADDRS})"
103
104	cat $CMDFILE
105	${LTPROOT}/ver_linux
106	echo ""
107	echo $cmd
108fi
109
110$cmd
111
112if [ $? -eq "0" ]; then
113	echo ltp-pan reported PASS
114else
115	echo ltp-pan reported FAIL
116fi
117
118rm -rf $TMPDIR
119