• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "  -r    RPC tests"
30	echo "  -s    SCTP tests"
31	echo "  -t    TCP/IP command tests"
32	echo "  -c    TI-RPC tests"
33	echo "  -d    TS-RPC tests"
34	echo "  -a    Application stress tests (HTTP, SSH, DNS)"
35	echo "  -e    Interface stress tests"
36	echo "  -b    Stress tests with malformed ICMP packets"
37	echo "  -i    IPsec ICMP stress tests"
38	echo "  -T    IPsec TCP stress tests"
39	echo "  -U    IPsec UDP stress tests"
40	echo "  -D    IPsec DCCP stress tests"
41	echo "  -S    IPsec SCTP stress tests"
42	echo "  -R    route stress tests"
43	echo "  -M    multicast stress tests"
44	echo "  -F    network features tests (TFO, vxlan, etc.)"
45	echo "  -f x  where x is a runtest file"
46	echo "  -q    quiet mode (this implies not logging start of test"
47	echo "        in kernel log)"
48	echo "  -Q    don't log start of test in kernel log"
49	echo "  -V|v  verbose"
50	echo "  -h    print this help"
51}
52
53while getopts 6mnrstaebcdiTUDSRMFf:qQVvh OPTION
54do
55	case $OPTION in
56	6) TEST_CASES="$TEST_CASES net.ipv6 net.ipv6_lib";;
57	m) TEST_CASES="$TEST_CASES net.multicast";;
58	n) TEST_CASES="$TEST_CASES net.nfs";;
59	r) TEST_CASES="$TEST_CASES net.rpc";;
60	s) TEST_CASES="$TEST_CASES net.sctp";;
61	t) TEST_CASES="$TEST_CASES net.tcp_cmds";;
62	c) TEST_CASES="$TEST_CASES net.rpc_tests";;
63	d) TEST_CASES="$TEST_CASES net.tirpc_tests";;
64	a) TEST_CASES="$TEST_CASES net_stress.appl";;
65	e) TEST_CASES="$TEST_CASES net_stress.interface";;
66	b) TEST_CASES="$TEST_CASES net_stress.broken_ip";;
67	i) TEST_CASES="$TEST_CASES net_stress.ipsec_icmp";;
68	T) TEST_CASES="$TEST_CASES net_stress.ipsec_tcp";;
69	U) TEST_CASES="$TEST_CASES net_stress.ipsec_udp";;
70	D) TEST_CASES="$TEST_CASES net_stress.ipsec_dccp";;
71	S) TEST_CASES="$TEST_CASES net_stress.ipsec_sctp";;
72	R) TEST_CASES="$TEST_CASES net_stress.route";;
73	M) TEST_CASES="$TEST_CASES net_stress.multicast";;
74	F) TEST_CASES="$TEST_CASES net.features";;
75	f) TEST_CASES=${OPTARG};;
76	q) QUIET_MODE="-q";;
77	Q) NO_KMSG="-Q";;
78	V|v) VERBOSE="yes";;
79	h) usage; exit 0;;
80	*) echo "Error: invalid option..."; usage; exit 1;;
81	esac
82done
83
84if [ "$OPTIND" -eq 1 ]; then
85	echo "Error: option is required"
86	usage
87	exit 1
88fi
89shift $(($OPTIND - 1))
90
91TST_NO_DEFAULT_RUN=1
92. tst_net.sh
93
94# Reset variables.
95# Don't break the tests which are using 'testcases/lib/cmdlib.sh'
96unset TST_ID TST_LIB_LOADED TST_NO_DEFAULT_RUN
97
98rm -f $CMDFILE
99
100for t in $TEST_CASES; do
101	cat  ${LTPROOT}/runtest/$t >> $CMDFILE
102done
103
104cd $TMPDIR
105
106cmd="${LTPROOT}/bin/ltp-pan $QUIET_MODE $NO_KMSG -e -l /tmp/netpan.log -S -a ltpnet -n ltpnet -f $CMDFILE"
107
108if [ ${VERBOSE} = "yes" ]; then
109	echo "Network parameters:"
110	echo " - ${LHOST_IFACES} local interface (MAC address: ${LHOST_HWADDRS})"
111	echo " - ${RHOST_IFACES} remote interface (MAC address: ${RHOST_HWADDRS})"
112
113	cat $CMDFILE
114	${LTPROOT}/ver_linux
115	echo ""
116	echo $cmd
117fi
118
119$cmd
120
121if [ $? -eq "0" ]; then
122	echo ltp-pan reported PASS
123else
124	echo ltp-pan reported FAIL
125fi
126
127rm -rf $TMPDIR
128