linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Cc: Petr Vorel <pvorel@suse.cz>, Martin Doucha <mdoucha@suse.cz>,
	linux-nfs@vger.kernel.org, Cyril Hrubis <chrubis@suse.cz>
Subject: [PATCH 2/4] nfsstat01.sh: Validate parsing /proc/net/rpc/nfs{,d}
Date: Wed, 31 Jan 2024 16:14:44 +0100	[thread overview]
Message-ID: <20240131151446.936281-3-pvorel@suse.cz> (raw)
In-Reply-To: <20240131151446.936281-1-pvorel@suse.cz>

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@suse.cz>
---
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


  parent reply	other threads:[~2024-01-31 15:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-31 15:14 [PATCH 0/4] nfsstat: Test also on NFSv4* Petr Vorel
2024-01-31 15:14 ` [PATCH 1/4 v2] runtest/net.nfs: Rename test names Petr Vorel
2024-01-31 15:14 ` Petr Vorel [this message]
2024-01-31 15:14 ` [PATCH 3/4] nfsstat01.sh: Add support for NFSv4* Petr Vorel
2024-01-31 15:14 ` [PATCH 4/4] nfsstat01.sh: Run on all NFS versions, TCP and UDP Petr Vorel
2024-02-08 14:44   ` Martin Doucha
2024-02-09  8:49     ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240131151446.936281-3-pvorel@suse.cz \
    --to=pvorel@suse.cz \
    --cc=chrubis@suse.cz \
    --cc=linux-nfs@vger.kernel.org \
    --cc=ltp@lists.linux.it \
    --cc=mdoucha@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).