• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# Copyright (c) 2020 Petr Vorel <pvorel@suse.cz>
3# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
4# Copyright (c) International Business Machines Corp., 2000
5
6TST_TESTFUNC=do_test
7TST_SETUP=do_setup
8TST_NEEDS_TMPDIR=1
9TST_NEEDS_CMDS="rpcinfo wc"
10. rpc_lib.sh
11
12do_setup()
13{
14	check_portmap_rpcbind
15
16	# Create file with 1 tcp and 1 udp line. Use for variable assignments.
17	rpcinfo -p $(tst_ipaddr) | grep tcp | sed -n 2p > rpc_out
18	rpcinfo -p $(tst_ipaddr) | grep udp | sed -n 2p >> rpc_out
19
20	wc -l rpc_out | grep -q "2" || \
21		tst_brk TBROK "Not enough programs registered on $(tst_ipaddr)"
22
23	# Using "rpc_out" file created above, assign variables for rpcinfo opts
24	TPNUM=$(grep tcp rpc_out | awk '{print $1}')
25	TVNUM=$(grep tcp rpc_out | awk '{print $2}')
26	TCPNAME=$(grep tcp rpc_out | awk '{print $5}')
27	UPNUM=$(grep udp rpc_out | awk '{print $1}')
28	UVNUM=$(grep udp rpc_out | awk '{print $2}')
29	UDPNAME=$(grep udp rpc_out | awk '{print $5}')
30}
31
32do_test()
33{
34	local thost="$(tst_ipaddr)"
35
36	EXPECT_RHOST_PASS rpcinfo -p $thost | grep -q portmapper
37	EXPECT_RHOST_PASS rpcinfo -t $thost $TPNUM
38	EXPECT_RHOST_PASS rpcinfo -t $thost $TPNUM $TVNUM
39	EXPECT_RHOST_PASS rpcinfo -t $thost $TCPNAME
40	EXPECT_RHOST_PASS rpcinfo -t $thost $TCPNAME $TVNUM
41	EXPECT_RHOST_PASS rpcinfo -u $thost 100000
42	EXPECT_RHOST_PASS rpcinfo -u $thost 100000 2
43	EXPECT_RHOST_PASS rpcinfo -u $thost portmapper
44	EXPECT_RHOST_PASS rpcinfo -u $thost portmapper 2
45
46	tst_res TINFO "Test rpcinfo with missing or bad options"
47	EXPECT_RHOST_FAIL rpcinfo -p bogushost
48	EXPECT_RHOST_FAIL rpcinfo -bogusflag
49	EXPECT_RHOST_FAIL rpcinfo -t $thost
50	EXPECT_RHOST_FAIL rpcinfo -u $thost
51	EXPECT_RHOST_FAIL rpcinfo -u $thost bogusprog
52	EXPECT_RHOST_FAIL rpcinfo -u $thost 11579
53	EXPECT_RHOST_FAIL rpcinfo -u $thost 100000 5
54}
55
56tst_run
57