public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hui Su <sh_def@163.com>
To: davidriley@chromium.org, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org, sh_def@163.com
Subject: [PATCH v2] tools/time: access /sys/kernel/debug/udelay_test before test
Date: Wed, 21 Oct 2020 23:04:58 +0800	[thread overview]
Message-ID: <20201021150458.GA139977@rlk> (raw)

before(when i did not compile udelay_test.ko):
sh@ubuntu:~/workspace/compile/tools/time$ sudo ./udelay_test.sh
./udelay_test.sh: line 25: /sys/kernel/debug/udelay_test: Permission denied
./udelay_test.sh: line 26: /sys/kernel/debug/udelay_test: No such file or directory
./udelay_test.sh: line 25: /sys/kernel/debug/udelay_test: Permission denied
./udelay_test.sh: line 26: /sys/kernel/debug/udelay_test: No such file or directory
...
about two hundreds lines.

we access '/sys/kernel/debug/udelay_test' the before starting the
udelay_test.

now(when i did not compile udelay_test.ko):
sh@ubuntu:~/workspace/linux-stable/tools/time$ sudo ./udelay_test.sh
modprobe: FATAL: Module udelay_test not found in directory /lib/modules/5.4.44
ERROR, can not access /sys/kernel/debug/udelay_test.
modprobe: FATAL: Module udelay_test not found.

---
v1->v2: remove the debug_file_exist().

Signed-off-by: Hui Su <sh_def@163.com>
---
 tools/time/udelay_test.sh | 42 ++++++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/tools/time/udelay_test.sh b/tools/time/udelay_test.sh
index 6779d7e55d85..c8458d5b7fcd 100755
--- a/tools/time/udelay_test.sh
+++ b/tools/time/udelay_test.sh
@@ -12,10 +12,11 @@
 
 MODULE_NAME=udelay_test
 UDELAY_PATH=/sys/kernel/debug/udelay_test
+retcode=0
 
 setup()
 {
-	/sbin/modprobe -q $MODULE_NAME
+	/sbin/modprobe $MODULE_NAME
 	tmp_file=`mktemp`
 }
 
@@ -31,29 +32,34 @@ cleanup()
 	if [ -f $tmp_file ]; then
 		rm $tmp_file
 	fi
-	/sbin/modprobe -q -r $MODULE_NAME
+	/sbin/modprobe -r $MODULE_NAME
 }
 
 trap cleanup EXIT
 setup
 
-# Delay for a variety of times.
-# 1..200, 200..500 (by 10), 500..2000 (by 100)
-for (( delay = 1; delay < 200; delay += 1 )); do
-	test_one $delay
-done
-for (( delay = 200; delay < 500; delay += 10 )); do
-	test_one $delay
-done
-for (( delay = 500; delay <= 2000; delay += 100 )); do
-	test_one $delay
-done
-
-# Search for failures
-count=`grep -c FAIL $tmp_file`
-if [ $? -eq "0" ]; then
-	echo "ERROR: $count delays failed to delay long enough"
+if [ ! -d "$UDELAY_PATH" ]; then
 	retcode=1
+	echo "ERROR, can not access $UDELAY_PATH."
+else
+	# Delay for a variety of times.
+	# 1..200, 200..500 (by 10), 500..2000 (by 100)
+	for (( delay = 1; delay < 200; delay += 1 )); do
+		test_one $delay
+	done
+	for (( delay = 200; delay < 500; delay += 10 )); do
+		test_one $delay
+	done
+	for (( delay = 500; delay <= 2000; delay += 100 )); do
+		test_one $delay
+	done
+
+	# Search for failures
+	count=`grep -c FAIL $tmp_file`
+	if [ $? -eq "0" ]; then
+		echo "ERROR: $count delays failed to delay long enough"
+		retcode=1
+	fi
 fi
 
 exit $retcode
-- 
2.25.1



             reply	other threads:[~2020-10-21 15:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-21 15:04 Hui Su [this message]
2020-10-21 16:21 ` [PATCH v2] tools/time: access /sys/kernel/debug/udelay_test before test David Riley

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=20201021150458.GA139977@rlk \
    --to=sh_def@163.com \
    --cc=akpm@linux-foundation.org \
    --cc=davidriley@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    /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