Home | History | Annotate | Download | only in testscripts
      1 #!/bin/sh
      2 
      3 cd $(dirname $0)
      4 export LTPROOT=${LTPROOT:-"$PWD"}
      5 echo $LTPROOT | grep -q testscripts
      6 if [ $? -eq 0 ]; then
      7 	cd ..
      8 	export LTPROOT=${PWD}
      9 fi
     10 
     11 export TMPDIR=/tmp/netpan-$$
     12 mkdir -p $TMPDIR
     13 CMDFILE=${TMPDIR}/network.tests
     14 VERBOSE="no"
     15 NO_KMSG=
     16 QUIET_MODE=
     17 TEST_CASES=
     18 
     19 export PATH="${PATH}:${LTPROOT}/testcases/bin"
     20 
     21 usage()
     22 {
     23 	echo "Usage: $0 OPTIONS"
     24 	echo "  -6    IPv6 tests"
     25 	echo "  -m    multicast tests"
     26 	echo "  -n    NFS tests"
     27 	echo "  -r    RPC tests"
     28 	echo "  -s    SCTP tests"
     29 	echo "  -t    TCP/IP command tests"
     30 	echo "  -c    TI-RPC tests"
     31 	echo "  -d    TS-RPC tests"
     32 	echo "  -a    Application stress tests (HTTP, SSH, DNS)"
     33 	echo "  -e    Interface stress tests"
     34 	echo "  -b    Stress tests with malformed ICMP packets"
     35 	echo "  -i    IPsec ICMP stress tests"
     36 	echo "  -T    IPsec TCP stress tests"
     37 	echo "  -U    IPsec UDP stress tests"
     38 	echo "  -D    IPsec DCCP stress tests"
     39 	echo "  -S    IPsec SCTP stress tests"
     40 	echo "  -R    route stress tests"
     41 	echo "  -M    multicast stress tests"
     42 	echo "  -F    network features tests (TFO, vxlan, etc.)"
     43 	echo "  -f x  where x is a runtest file"
     44 	echo "  -q    quiet mode (this implies not logging start of test"
     45 	echo "        in kernel log)"
     46 	echo "  -Q    don't log start of test in kernel log"
     47 	echo "  -V|v  verbose"
     48 	echo "  -h    print this help"
     49 }
     50 
     51 while getopts 6mnrstaebcdiTUDSRMFf:qQVvh OPTION
     52 do
     53 	case $OPTION in
     54 	6) TEST_CASES="$TEST_CASES net.ipv6 net.ipv6_lib";;
     55 	m) TEST_CASES="$TEST_CASES net.multicast";;
     56 	n) TEST_CASES="$TEST_CASES net.nfs";;
     57 	r) TEST_CASES="$TEST_CASES net.rpc";;
     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
     80 done
     81 
     82 if [ "$OPTIND" -eq 1 ]; then
     83 	echo "Error: option is required"
     84 	usage
     85 	exit 1
     86 fi
     87 shift $(($OPTIND - 1))
     88 
     89 TST_NO_DEFAULT_RUN=1
     90 . tst_net.sh
     91 
     92 # Reset variables.
     93 # Don't break the tests which are using 'testcases/lib/cmdlib.sh'
     94 unset TST_ID TST_LIB_LOADED TST_NO_DEFAULT_RUN
     95 
     96 rm -f $CMDFILE
     97 
     98 for t in $TEST_CASES; do
     99 	cat  ${LTPROOT}/runtest/$t >> $CMDFILE
    100 done
    101 
    102 cd $TMPDIR
    103 
    104 cmd="${LTPROOT}/bin/ltp-pan $QUIET_MODE $NO_KMSG -e -l /tmp/netpan.log -S -a ltpnet -n ltpnet -f $CMDFILE"
    105 
    106 if [ ${VERBOSE} = "yes" ]; then
    107 	echo "Network parameters:"
    108 	echo " - ${LHOST_IFACES} local interface (MAC address: ${LHOST_HWADDRS})"
    109 	echo " - ${RHOST_IFACES} remote interface (MAC address: ${RHOST_HWADDRS})"
    110 
    111 	cat $CMDFILE
    112 	${LTPROOT}/ver_linux
    113 	echo ""
    114 	echo $cmd
    115 fi
    116 
    117 $cmd
    118 
    119 if [ $? -eq "0" ]; then
    120 	echo ltp-pan reported PASS
    121 else
    122 	echo ltp-pan reported FAIL
    123 fi
    124 
    125 rm -rf $TMPDIR
    126