aboutsummaryrefslogtreecommitdiff
path: root/testscripts/network.sh
blob: afe9c7a97711c50a7258ad49544d9ef3193d9497 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) Linux Test Project, 2013-2019

cd $(dirname $0)
export LTPROOT=${LTPROOT:-"$PWD"}
echo $LTPROOT | grep -q testscripts
if [ $? -eq 0 ]; then
	cd ..
	export LTPROOT=${PWD}
fi

export TMPDIR=/tmp/netpan-$$
mkdir -p $TMPDIR
CMDFILE=${TMPDIR}/network.tests
VERBOSE="no"
NO_KMSG=
QUIET_MODE=
TEST_CASES=

export PATH="${PATH}:${LTPROOT}/testcases/bin"

usage()
{
	echo "Usage: $0 OPTIONS"
	echo "  -6    IPv6 tests"
	echo "  -m    multicast tests"
	echo "  -n    NFS tests"
	echo "  -s    SCTP tests"
	echo "  -t    TCP/IP command tests"
	echo "  -c    RPC and TI-RPC tests"
	echo "  -d    TS-RPC tests"
	echo "  -a    Application stress tests (HTTP, SSH, DNS)"
	echo "  -e    Interface stress tests"
	echo "  -b    Stress tests with malformed ICMP packets"
	echo "  -i    IPsec ICMP stress tests"
	echo "  -T    IPsec TCP stress tests"
	echo "  -U    IPsec UDP stress tests"
	echo "  -D    IPsec DCCP stress tests"
	echo "  -S    IPsec SCTP stress tests"
	echo "  -R    route stress tests"
	echo "  -M    multicast stress tests"
	echo "  -F    network features tests (TFO, vxlan, etc.)"
	echo "  -f x  where x is a runtest file"
	echo "  -q    quiet mode (this implies not logging start of test"
	echo "        in kernel log)"
	echo "  -Q    don't log start of test in kernel log"
	echo "  -V|v  verbose"
	echo "  -h    print this help"
}

while getopts 6mnrstaebcdiTUDSRMFf:qQVvh OPTION
do
	case $OPTION in
	6) TEST_CASES="$TEST_CASES net.ipv6 net.ipv6_lib";;
	m) TEST_CASES="$TEST_CASES net.multicast";;
	n) TEST_CASES="$TEST_CASES net.nfs";;
	s) TEST_CASES="$TEST_CASES net.sctp";;
	t) TEST_CASES="$TEST_CASES net.tcp_cmds";;
	c) TEST_CASES="$TEST_CASES net.rpc_tests";;
	d) TEST_CASES="$TEST_CASES net.tirpc_tests";;
	a) TEST_CASES="$TEST_CASES net_stress.appl";;
	e) TEST_CASES="$TEST_CASES net_stress.interface";;
	b) TEST_CASES="$TEST_CASES net_stress.broken_ip";;
	i) TEST_CASES="$TEST_CASES net_stress.ipsec_icmp";;
	T) TEST_CASES="$TEST_CASES net_stress.ipsec_tcp";;
	U) TEST_CASES="$TEST_CASES net_stress.ipsec_udp";;
	D) TEST_CASES="$TEST_CASES net_stress.ipsec_dccp";;
	S) TEST_CASES="$TEST_CASES net_stress.ipsec_sctp";;
	R) TEST_CASES="$TEST_CASES net_stress.route";;
	M) TEST_CASES="$TEST_CASES net_stress.multicast";;
	F) TEST_CASES="$TEST_CASES net.features";;
	f) TEST_CASES=${OPTARG};;
	q) QUIET_MODE="-q";;
	Q) NO_KMSG="-Q";;
	V|v) VERBOSE="yes";;
	h) usage; exit 0;;
	*) echo "Error: invalid option..."; usage; exit 1;;
	esac
done

if [ "$OPTIND" -eq 1 ]; then
	echo "Error: option is required"
	usage
	exit 1
fi
shift $(($OPTIND - 1))

rm -f $CMDFILE

for t in $TEST_CASES; do
	cat  ${LTPROOT}/runtest/$t >> $CMDFILE
done

cd $TMPDIR

cmd="${LTPROOT}/bin/ltp-pan $QUIET_MODE $NO_KMSG -e -l /tmp/netpan.log -S -a ltpnet -n ltpnet -f $CMDFILE"

if [ ${VERBOSE} = "yes" ]; then
	echo "Network parameters:"
	echo " - ${LHOST_IFACES} local interface (MAC address: ${LHOST_HWADDRS})"
	echo " - ${RHOST_IFACES} remote interface (MAC address: ${RHOST_HWADDRS})"

	cat $CMDFILE
	${LTPROOT}/ver_linux
	echo ""
	echo $cmd
fi

$cmd

if [ $? -eq "0" ]; then
	echo ltp-pan reported PASS
else
	echo ltp-pan reported FAIL
fi

rm -rf $TMPDIR