Home | History | Annotate | Download | only in rpc-tirpc
      1 #!/bin/sh
      2 #
      3 # Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
      4 # Copyright (c) 2017 Petr Vorel <pvorel (at] suse.cz>
      5 #
      6 # This program is free software; you can redistribute it and/or
      7 # modify it under the terms of the GNU General Public License as
      8 # published by the Free Software Foundation; either version 2 of
      9 # the License, or (at your option) any later version.
     10 #
     11 # This program is distributed in the hope that it would be useful,
     12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 # GNU General Public License for more details.
     15 #
     16 # You should have received a copy of the GNU General Public License
     17 # along with this program; if not, write the Free Software Foundation,
     18 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     19 #
     20 # This is a wrapper script to execute tests from the RPC/TI-RPC tests
     21 # suite (http://nfsv4.bullopensource.org/doc/rpc_testsuite.php) in LTP.
     22 
     23 SERVER=""
     24 CLIENT=""
     25 CLIENT_EXTRA_OPTS=""
     26 CLEANER=""
     27 # Program number to register the services to rpcbind
     28 PROGNUMNOSVC=536875000
     29 
     30 cleanup()
     31 {
     32 	if [ ! -z "$SERVER" ]; then
     33 		killall -9 $SERVER
     34 		$CLEANER $PROGNUMNOSVC
     35 	fi
     36 }
     37 
     38 usage()
     39 {
     40 	cat << EOF
     41 USAGE: $0 [-s sprog] -c clprog [ -e extra ]
     42 
     43 sprog   - server program binary
     44 clprog  - client program binary
     45 extra   - extra client options
     46 
     47 This scripts connects to the remote host and starts sprog there. After that it
     48 executes clprog passing it the remote host value.
     49 
     50 After the test completes, this script kills sprog on remote and performs a
     51 cleaning operation.
     52 EOF
     53 
     54 	exit 1
     55 }
     56 
     57 while getopts s:c:e:h arg; do
     58 	case $arg in
     59 		s) SERVER="$OPTARG" ;;
     60 		c) CLIENT="$OPTARG" ;;
     61 		e) CLIENT_EXTRA_OPTS="$OPTARG" ;;
     62 		h) usage ;;
     63 	esac
     64 done
     65 
     66 if [ ! -z "$SERVER" ]; then
     67 	if `echo "$SERVER" | grep -e '^tirpc'`; then
     68 		CLEANER="tirpc_cleaner"
     69 	else
     70 		CLEANER="rpc_cleaner"
     71 	fi
     72 fi
     73 
     74 if [ -z "$CLIENT" ]; then
     75 	echo "client program not set"
     76 	echo ""
     77 	usage
     78 fi
     79 
     80 TCID="$CLIENT"
     81 TST_TOTAL=1
     82 TST_COUNT=1
     83 TST_CLEANUP=cleanup
     84 
     85 . test_net.sh
     86 
     87 if [ ! -z "$SERVER" ]; then
     88 	$SERVER $PROGNUMNOSVC &
     89 
     90 	for i in $(seq 1 10); do
     91 		rpcinfo -p localhost | grep -q $PROGNUMNOSVC && break
     92 		[ "$i" -eq 30 ] && tst_brkm TBROK "server not registered"
     93 		tst_sleep 100ms
     94 	done
     95 fi
     96 
     97 EXPECT_RHOST_PASS $CLIENT $(tst_ipaddr) $PROGNUMNOSVC $CLIENT_EXTRA_OPTS
     98 
     99 tst_exit
    100