[LTP] [PATCH 1/1] rpc_lib.sh: Check for running RPC

Petr Vorel pvorel@suse.cz
Mon Jan 24 07:59:37 CET 2022


instead of just rpcbind/portmap was running.

This should fix problem for some containers where rpcbind has not been
started and calling rpcinfo should do the socket activation.

Reported-by: Nikita Yushchenko <nikita.yushchenko@virtuozzo.com>
Suggested-by: NeilBrown <neilb@suse.de>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi all,

Nikita, does it really fix your case? Or there needs to be 2 rpcinfo -p
calls with sleep in between?

Kind regards,
Petr

 .../network/rpc/basic_tests/rpc01/rpc01.sh    |  2 +-
 testcases/network/rpc/basic_tests/rpc_lib.sh  | 22 ++++++++++++-------
 .../rpc/basic_tests/rpcinfo/rpcinfo01.sh      |  2 +-
 testcases/network/rpc/rpc-tirpc/rpc_test.sh   |  2 +-
 4 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/testcases/network/rpc/basic_tests/rpc01/rpc01.sh b/testcases/network/rpc/basic_tests/rpc01/rpc01.sh
index 9ca5daae62..a4989b98f2 100755
--- a/testcases/network/rpc/basic_tests/rpc01/rpc01.sh
+++ b/testcases/network/rpc/basic_tests/rpc01/rpc01.sh
@@ -19,7 +19,7 @@ do_cleanup()
 
 do_setup()
 {
-	check_portmap_rpcbind
+	check_rpc
 
 	tst_res TINFO "start rpc_server"
 	ROD rpc_server
diff --git a/testcases/network/rpc/basic_tests/rpc_lib.sh b/testcases/network/rpc/basic_tests/rpc_lib.sh
index c7c868709b..477408bcef 100644
--- a/testcases/network/rpc/basic_tests/rpc_lib.sh
+++ b/testcases/network/rpc/basic_tests/rpc_lib.sh
@@ -1,15 +1,21 @@
 #!/bin/sh
-# Copyright (c) 2020 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) 2020-2021 Petr Vorel <pvorel@suse.cz>
 
+TST_NEEDS_CMDS="rpcinfo $TST_NEEDS_CMDS"
 . tst_net.sh
 
-check_portmap_rpcbind()
+check_rpc()
 {
-	if pgrep portmap > /dev/null; then
-		PORTMAPPER="portmap"
-	else
-		pgrep rpcbind > /dev/null && PORTMAPPER="rpcbind" || \
-			tst_brk TCONF "portmap or rpcbind is not running"
+	local services
+
+	tst_res TINFO "check registered RPC with rpcinfo"
+
+	services=$(rpcinfo -p)
+
+	if [ $? -ne 0 ] || ! echo "$services" | grep -q '[0-9]'; then
+		tst_brk TCONF "no RPC services, is rpcbind/portmap running?"
 	fi
-	tst_res TINFO "using $PORTMAPPER"
+
+	tst_res TINFO "registered RPC"
+	echo "$x"
 }
diff --git a/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01.sh b/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01.sh
index 811f79ef76..ade9711223 100755
--- a/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01.sh
+++ b/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01.sh
@@ -11,7 +11,7 @@ TST_NEEDS_CMDS="rpcinfo wc"
 
 do_setup()
 {
-	check_portmap_rpcbind
+	check_rpc
 
 	# Create file with 1 tcp and 1 udp line. Use for variable assignments.
 	rpcinfo -p $(tst_ipaddr) | grep tcp | sed -n 2p > rpc_out
diff --git a/testcases/network/rpc/rpc-tirpc/rpc_test.sh b/testcases/network/rpc/rpc-tirpc/rpc_test.sh
index 54a689649c..e1d952da81 100755
--- a/testcases/network/rpc/rpc-tirpc/rpc_test.sh
+++ b/testcases/network/rpc/rpc-tirpc/rpc_test.sh
@@ -45,7 +45,7 @@ rpc_parse_args()
 
 setup()
 {
-	check_portmap_rpcbind
+	check_rpc
 
 	if [ -n "$SERVER" ]; then
 		CLEANER="rpc_cleaner"
-- 
2.34.1



More information about the ltp mailing list