All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] lsmod01: keep the output in variables
Date: Wed,  9 Nov 2016 17:34:53 +0300	[thread overview]
Message-ID: <1478702093-15080-1-git-send-email-stanislav.kholmanskikh@oracle.com> (raw)
In-Reply-To: <20161011161557.GD17083@rei.suse.cz>

Operations with a file on NFS may increase the reference
counter of the corresponding module.

This test case creates temporary files in $TMPDIR, so if
$TMPDIR is on NFS, it may fail with output similar to:

  21c21
  < sunrpc 207591 28
  ---
  > sunrpc 207591 29

To overcome this problem it was proposed in [1] to keep the output
in variables.

[1] http://lists.linux.it/pipermail/ltp/2016-October/002803.html

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 testcases/commands/lsmod/lsmod01.sh |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/testcases/commands/lsmod/lsmod01.sh b/testcases/commands/lsmod/lsmod01.sh
index 5cf2fee..cd19ca4 100755
--- a/testcases/commands/lsmod/lsmod01.sh
+++ b/testcases/commands/lsmod/lsmod01.sh
@@ -36,21 +36,25 @@ cleanup()
 
 lsmod_test()
 {
-	lsmod >temp 2>&1
-	if [ $? -ne 0 ]; then
-		tst_resm TFAIL "'lsmod' failed."
-		cat temp
+	lsmod_output=$(lsmod | awk '!/Module/{print $1, $2, $3}' | sort)
+	if [ -z "$lsmod_output" ]; then
+		tst_resm TFAIL "Failed to parse the output from lsmod"
 		return
 	fi
 
-	awk '!/Module/{print $1, $2, $3}' temp |sort >temp1
-
-	awk '{print $1, $2, $3}' /proc/modules |sort >temp2
+	modules_output=$(awk '{print $1, $2, $3}' /proc/modules | sort)
+	if [ -z "$modules_output" ]; then
+		tst_resm TFAIL "Failed to parse /proc/modules"
+		return
+	fi
 
-	diff temp1 temp2 >temp3
-	if [ $? -ne 0 ]; then
+	if [ "$lsmod_output" != "$modules_output" ]; then
 		tst_resm TFAIL "lsmod output different from /proc/modules."
-		cat temp3
+
+		echo "$lsmod_output" > temp1
+		echo "$modules_output" > temp2
+		diff temp1 temp2
+
 		return
 	fi
 
-- 
1.7.1


  reply	other threads:[~2016-11-09 14:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-29 11:08 [LTP] [PATCH] lsmod01: parse a copy of /proc/modules Stanislav Kholmanskikh
2016-08-29 12:50 ` Cyril Hrubis
2016-08-29 13:05   ` Stanislav Kholmanskikh
2016-08-29 13:34     ` Jan Stancek
2016-08-29 14:00       ` Stanislav Kholmanskikh
2016-08-29 14:03         ` Stanislav Kholmanskikh
2016-08-29 15:17           ` Cyril Hrubis
2016-08-29 15:49           ` Jan Stancek
2016-10-11 12:03             ` Stanislav Kholmanskikh
2016-10-11 13:38               ` Cyril Hrubis
2016-10-11 15:47                 ` Stanislav Kholmanskikh
2016-10-11 16:15                   ` Cyril Hrubis
2016-11-09 14:34                     ` Stanislav Kholmanskikh [this message]
2016-11-09 16:49                       ` [LTP] [PATCH] lsmod01: keep the output in variables Cyril Hrubis
2016-11-10 10:07                         ` Stanislav Kholmanskikh
2016-11-10 11:39                           ` Cyril Hrubis
2016-11-10 14:15                             ` Stanislav Kholmanskikh
2016-08-31 13:55 ` [LTP] [PATCH] lsmod01: parse a copy of /proc/modules Cyril Hrubis
2016-09-02 14:12   ` Stanislav Kholmanskikh

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=1478702093-15080-1-git-send-email-stanislav.kholmanskikh@oracle.com \
    --to=stanislav.kholmanskikh@oracle.com \
    --cc=ltp@lists.linux.it \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.