public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Eryu Guan <guaneryu@gmail.com>
Cc: fstests@vger.kernel.org
Subject: [PATCH v2] common/rc: fix check for disabled kmemleak
Date: Sat, 22 Sep 2018 18:23:39 +0300	[thread overview]
Message-ID: <20180922152339.32023-1-amir73il@gmail.com> (raw)

With kernel commit b353756b2b71 ("kmemleak: always register debugfs file")
that was merged to v4.19-rc3, the kmemleak debugfs knob exists even if
kmemleak is disabled, but returns EBUSY on write.

Suppress EBUSY errors in tests by disabling _check_kmemleak() calls if the
write to kmemleak knob failed on _init_kmemleak().

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---

Eryu,

Good suggestion. This approach is much better and also works.

Thanks,
Amir.

Changes from v1:
- Use a file to disable checks instead of hacky chmod a-w

 common/rc | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/common/rc b/common/rc
index ec631ad9..d5bb1fee 100644
--- a/common/rc
+++ b/common/rc
@@ -3508,14 +3508,23 @@ _init_kmemleak()
 {
 	local kern_knob="${DEBUGFS_MNT}/kmemleak"
 
+	# Since kernel v4.19-rc3, the kmemleak knob exists even if kmemleak is
+	# disabled, but returns EBUSY on write. So instead of relying on
+	# existance of writable knob file, we use a test file to indicate that
+	# _check_kmemleak() is enabled only if we actually managed to write to
+	# the knob file.
+	rm -f ${RESULT_BASE}/check_kmemleak
+
 	if [ ! -w "$kern_knob" ]; then
 		return 0
 	fi
 
 	# Disable the automatic scan so that we can control it completely,
 	# then dump all the leaks recorded so far.
-	echo "scan=off" > "$kern_knob"
-	_capture_kmemleak /dev/null
+	if echo "scan=off" > "$kern_knob" 2>/dev/null; then
+		_capture_kmemleak /dev/null
+		touch ${RESULT_BASE}/check_kmemleak
+	fi
 }
 
 # check kmemleak log
@@ -3524,7 +3533,7 @@ _check_kmemleak()
 	local kern_knob="${DEBUGFS_MNT}/kmemleak"
 	local leak_file="${seqres}.kmemleak"
 
-	if [ ! -w "$kern_knob" ]; then
+	if [ ! -f ${RESULT_BASE}/check_kmemleak ]; then
 		return 0
 	fi
 
-- 
2.17.1

                 reply	other threads:[~2018-09-22 21:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20180922152339.32023-1-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    /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