print TWARN when parsing /proc/net/rpc/nfs{,d} fails. NOTE: better would be to quit with TBROK, but at this point test would fail to umount. Signed-off-by: Petr Vorel <pvorel@xxxxxxx> --- NFS developers can ignore this patch (LTP specific). @Cyril, @Martin it'd be nice to fix nfs_lib.sh so that it would support tst_brk. The problem could be that get_calls() is called inside $() therefore cd $LTPROOT (to leave mounted directory) in the cleanup function is done for child process). I would have to redirect to a file and read it afterwards, right? (similarly get_pcr10_aggregate() in ima_tpm.sh does). Kind regards, Petr testcases/network/nfs/nfsstat01/nfsstat01.sh | 29 ++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/testcases/network/nfs/nfsstat01/nfsstat01.sh b/testcases/network/nfs/nfsstat01/nfsstat01.sh index 708750a97..4c09ae135 100755 --- a/testcases/network/nfs/nfsstat01/nfsstat01.sh +++ b/testcases/network/nfs/nfsstat01/nfsstat01.sh @@ -11,20 +11,33 @@ get_calls() local name=$1 local field=$2 local nfs_f=$3 - local calls= - local opt= + local type="lhost" + local calls opt + [ "$name" = "rpc" ] && opt="r" || opt="n" + ! tst_net_use_netns && [ "$nfs_f" != "nfs" ] && type="rhost" - if tst_net_use_netns || [ "$nfs_f" = "nfs" ]; then + if [ "$type" = "lhost" ]; then calls="$(grep $name /proc/net/rpc/$nfs_f | cut -d' ' -f$field)" ROD nfsstat -c$opt | grep -q "$calls" - echo "$calls" - return + else + calls=$(tst_rhost_run -c "grep $name /proc/net/rpc/$nfs_f" | \ + cut -d' ' -f$field) + tst_rhost_run -s -c "nfsstat -s$opt" | grep -q "$calls" + fi + + if ! tst_is_int "$calls"; then + if [ "$type" = "lhost" ]; then + tst_res TINFO "lhost /proc/net/rpc/$nfs_f" + cat /proc/net/rpc/$nfs_f >&2 + else + tst_res TINFO "rhost /proc/net/rpc/$nfs_f" + tst_rhost_run -c "cat /proc/net/rpc/$nfs_f" >&2 + fi + + tst_res TWARN "get_calls: failed to get integer value (args: $@)" fi - calls=$(tst_rhost_run -c "grep $name /proc/net/rpc/$nfs_f" | \ - cut -d' ' -f$field) - tst_rhost_run -s -c "nfsstat -s$opt" | grep -q "$calls" echo "$calls" } -- 2.43.0