• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2#
3# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
4# Copyright (c) 2017 Petr Vorel <pvorel@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
23SERVER=""
24CLIENT=""
25CLIENT_EXTRA_OPTS=""
26CLEANER=""
27# Program number to register the services to rpcbind
28PROGNUMNOSVC=536875000
29SERVER_STARTUP_SLEEP=1
30
31cleanup()
32{
33	if [ ! -z "$SERVER" ]; then
34		killall -9 $SERVER
35		$CLEANER $PROGNUMNOSVC
36	fi
37}
38
39usage()
40{
41	cat << EOF
42USAGE: $0 [-s sprog] -c clprog [ -e extra ]
43
44sprog   - server program binary
45clprog  - client program binary
46extra   - extra client options
47
48This scripts connects to the remote host and starts sprog there. After that it
49executes clprog passing it the remote host value.
50
51After the test completes, this script kills sprog on remote and performs a
52cleaning operation.
53EOF
54
55	exit 1
56}
57
58while getopts s:c:e:h arg; do
59	case $arg in
60		s) SERVER="$LTPROOT/testcases/bin/$OPTARG" ;;
61		c) CLIENT="$OPTARG" ;;
62		e) CLIENT_EXTRA_OPTS="$OPTARG" ;;
63		h) usage ;;
64	esac
65done
66
67if [ ! -z "$SERVER" ]; then
68	if `echo "$SERVER" | grep -e '^tirpc'`; then
69		CLEANER="$LTPROOT/testcases/bin/tirpc_cleaner"
70	else
71		CLEANER="$LTPROOT/testcases/bin/rpc_cleaner"
72	fi
73fi
74
75if [ -z "$CLIENT" ]; then
76	echo "client program not set"
77	echo ""
78	usage
79fi
80
81TCID="$CLIENT"
82TST_TOTAL=1
83TST_COUNT=1
84TST_CLEANUP=cleanup
85
86. test_net.sh
87
88if [ ! -z "$SERVER" ]; then
89	$SERVER $PROGNUMNOSVC &
90	sleep "$SERVER_STARTUP_SLEEP"
91fi
92
93tst_rhost_run -sc "$CLIENT $(tst_ipaddr) $PROGNUMNOSVC $CLIENT_EXTRA_OPTS"
94
95tst_resm TPASS "Test passed"
96
97tst_exit
98