Skip to contentSkip to conversation

tst_net.sh: Print output on unexpected PASS/FAIL

PATCH New Petr Vorel 3 participants 6 messages May 18, 2020 – May 20, 2020

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/2 tst_net.sh: Print output on unexpected PASS/FAIL

This helps debugging.

Use $TMPDIR and PID to guarantee writable directory and unique file without the need to require TST_NEEDS_TMPDIR=1.

---
 testcases/lib/tst_net.sh | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
testcases/lib/tst_net.sh +12 -2
index 011b62267..bfed4a44d 100644
@@ -250,22 +250,32 @@ tst_net_run()
 
 EXPECT_RHOST_PASS()
 {
-	tst_rhost_run -c "$*" > /dev/null
+	local log="$TMPDIR/log.$$"
+
+	tst_rhost_run -c "$*" > $log
 	if [ $? -eq 0 ]; then
 		tst_res_ TPASS "$* passed as expected"
 	else
 		tst_res_ TFAIL "$* failed unexpectedly"
+		cat $log
 	fi
+
+	rm -f $log
 }
 
 EXPECT_RHOST_FAIL()
 {
-	tst_rhost_run -c "$* 2> /dev/null"
+	local log="$TMPDIR/log.$$"
+
+	tst_rhost_run -c "$*" > $log
 	if [ $? -ne 0 ]; then
 		tst_res_ TPASS "$* failed as expected"
 	else
 		tst_res_ TFAIL "$* passed unexpectedly"
+		cat $log
 	fi
+
+	rm -f $log
 }
 
 # Get test interface names for local/remote host.
Signature · 1 line
2.26.2
author
#1 lore raw

PATCH 2/2 rpc_test.sh: Print used TI-RPC implementation

This helps to debug glibc tests. Some of them are failing:
Cannot register service: RPC: Unable to receive; errno = Connection refused

+ unify case on message in check_portmap_rpcbind.

---
 testcases/network/rpc/basic_tests/rpc_lib.sh | 2 +-
 testcases/network/rpc/rpc-tirpc/rpc_test.sh  | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
testcases/network/rpc/basic_tests/rpc_lib.sh +1 -1
index 96dae8dd3..c7c868709 100644
@@ -11,5 +11,5 @@ check_portmap_rpcbind()
 		pgrep rpcbind > /dev/null && PORTMAPPER="rpcbind" || \
 			tst_brk TCONF "portmap or rpcbind is not running"
 	fi
-	tst_res TINFO "Using $PORTMAPPER"
+	tst_res TINFO "using $PORTMAPPER"
 }
testcases/network/rpc/rpc-tirpc/rpc_test.sh +7 -0
index dc97213d0..410482c14 100755
@@ -55,6 +55,13 @@ setup()
 
 	[ -n "$CLIENT" ] || tst_brk TBROK "client program not set"
 	tst_check_cmds $CLIENT $SERVER || tst_brk TCONF "LTP compiled without TI-RPC support?"
+
+	tst_cmd_available ldd which || return
+	if ldd $(which $CLIENT) |grep -q /libtirpc\.so; then
+		tst_res TINFO "using libtirpc: yes"
+	else
+		tst_res TINFO "using libtirpc: no (probably using glibc)"
+	fi
 }
 
 cleanup()
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/2 rpc_test.sh: Print used TI-RPC implementation

Quoted 31 lines · Petr Vorel

This helps to debug glibc tests. Some of them are failing:
Cannot register service: RPC: Unable to receive; errno = Connection refused

+ unify case on message in check_portmap_rpcbind.

---
 testcases/network/rpc/basic_tests/rpc_lib.sh | 2 +-
 testcases/network/rpc/rpc-tirpc/rpc_test.sh  | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
testcases/network/rpc/basic_tests/rpc_lib.sh +1 -1
index 96dae8dd3..c7c868709 100644
@@ -11,5 +11,5 @@ check_portmap_rpcbind()
 		pgrep rpcbind > /dev/null && PORTMAPPER="rpcbind" || \
 			tst_brk TCONF "portmap or rpcbind is not running"
 	fi
-	tst_res TINFO "Using $PORTMAPPER"
+	tst_res TINFO "using $PORTMAPPER"
 }
testcases/network/rpc/rpc-tirpc/rpc_test.sh +0 -0
index dc97213d0..410482c14 100755
@@ -55,6 +55,13 @@ setup()
 
 	[ -n "$CLIENT" ] || tst_brk TBROK "client program not set"
 	tst_check_cmds $CLIENT $SERVER || tst_brk TCONF "LTP compiled without TI-RPC support?"

testcases/network/rpc/rpc-tirpc/rpc_test.sh setup() · line 67

Quoted 10 lines
testcases/network/rpc/rpc-tirpc/rpc_test.sh +7 -0
+
+	tst_cmd_available ldd which || return
+	if ldd $(which $CLIENT) |grep -q /libtirpc\.so; then
+		tst_res TINFO "using libtirpc: yes"
+	else
+		tst_res TINFO "using libtirpc: no (probably using glibc)"
+	fi
 }
 
 cleanup()
#3 lore raw

PATCH 1/2 tst_net.sh: Print output on unexpected PASS/FAIL

In reply to Petr Vorel
Quoted 40 lines · Petr Vorel

This helps debugging.

Use $TMPDIR and PID to guarantee writable directory and unique file without the need to require TST_NEEDS_TMPDIR=1.

---
 testcases/lib/tst_net.sh | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
testcases/lib/tst_net.sh +9 -2
index 011b62267..bfed4a44d 100644
@@ -250,22 +250,32 @@ tst_net_run()
 
 EXPECT_RHOST_PASS()
 {
-	tst_rhost_run -c "$*" > /dev/null
+	local log="$TMPDIR/log.$$"
+
+	tst_rhost_run -c "$*" > $log
 	if [ $? -eq 0 ]; then
 		tst_res_ TPASS "$* passed as expected"
 	else
 		tst_res_ TFAIL "$* failed unexpectedly"
+		cat $log
 	fi
+
+	rm -f $log
 }
 
 EXPECT_RHOST_FAIL()
 {
-	tst_rhost_run -c "$* 2> /dev/null"
+	local log="$TMPDIR/log.$$"
+
+	tst_rhost_run -c "$*" > $log
 	if [ $? -ne 0 ]; then

testcases/lib/tst_net.sh tst_net_run() · line 281

Quoted 10 lines
testcases/lib/tst_net.sh +3 -0
 		tst_res_ TPASS "$* failed as expected"
 	else
 		tst_res_ TFAIL "$* passed unexpectedly"
+		cat $log
 	fi
+
+	rm -f $log
 }
 
 # Get test interface names for local/remote host.
#4 lore raw

PATCH 1/2 tst_net.sh: Print output on unexpected PASS/FAIL

In reply to Petr Vorel

Hi Petr,

I tested the patchset and it also looks good to me.
BTW: These outputs are useful to locate the issue.

Best Regards,
Xiao Yang

Quoted 49 lines · Petr Vorel

This helps debugging.

Use $TMPDIR and PID to guarantee writable directory and unique file without the need to require TST_NEEDS_TMPDIR=1.

---
  testcases/lib/tst_net.sh | 14 ++++++++++++--
  1 file changed, 12 insertions(+), 2 deletions(-)
testcases/lib/tst_net.sh +12 -2
index 011b62267..bfed4a44d 100644
@@ -250,22 +250,32 @@ tst_net_run()
 
  EXPECT_RHOST_PASS()
  {
-	tst_rhost_run -c "$*">  /dev/null
+	local log="$TMPDIR/log.$$"
+
+	tst_rhost_run -c "$*">  $log
  	if [ $? -eq 0 ]; then
  		tst_res_ TPASS "$* passed as expected"
  	else
  		tst_res_ TFAIL "$* failed unexpectedly"
+		cat $log
  	fi
+
+	rm -f $log
  }
 
  EXPECT_RHOST_FAIL()
  {
-	tst_rhost_run -c "$* 2>  /dev/null"
+	local log="$TMPDIR/log.$$"
+
+	tst_rhost_run -c "$*">  $log
  	if [ $? -ne 0 ]; then
  		tst_res_ TPASS "$* failed as expected"
  	else
  		tst_res_ TFAIL "$* passed unexpectedly"
+		cat $log
  	fi
+
+	rm -f $log
  }
 
  # Get test interface names for local/remote host.
author
#5 lore raw

PATCH 1/2 tst_net.sh: Print output on unexpected PASS/FAIL

Hi Alexey, Yang,

Quoted 2 lines

I tested the patchset and it also looks good to me.
BTW: These outputs are useful to locate the issue.

thank you both for your review, merged.

Kind regards,
Petr