Skip to contentSkip to conversation

tools/time: access /sys/kernel/debug/udelay_test before test.

PATCH Superseded Hui Su 1 participant 2 messages Oct 16, 2020 – Oct 21, 2020 1 message not in the archive

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Hui Su

author
#0 lore raw

PATCH 1/1 tools/time: access /sys/kernel/debug/udelay_test before test.

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.
---
 tools/time/udelay_test.sh | 51 +++++++++++++++++++++++++--------------
 1 file changed, 33 insertions(+), 18 deletions(-)
tools/time/udelay_test.sh +33 -18
index 6779d7e55d85..853ba04e4149 100755
@@ -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,43 @@ cleanup()
 	if [ -f $tmp_file ]; then
 		rm $tmp_file
 	fi
-	/sbin/modprobe -q -r $MODULE_NAME
+	/sbin/modprobe -r $MODULE_NAME
+}
+
+debug_file_exist()
+{
+	if [ ! -d "$UDELAY_PATH" ]; then
+		return 1
+	fi
+	return 0
 }
 
 trap cleanup EXIT
 setup
+debug_file_exist
 
-# 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 [ $? -eq 1 ]; 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
Signature · 1 line
2.25.1
author
#2 lore raw
In reply to a message not in the archive
Quoted 109 lines · David Riley

I don't think it's worth making debug_file_exist a separate function. It's more clear to just do the check for the file, especially since you then log that path in the failure case.

Quoted 103 lines · Hui Su

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.
---
 tools/time/udelay_test.sh | 51 +++++++++++++++++++++++++--------------
 1 file changed, 33 insertions(+), 18 deletions(-)
tools/time/udelay_test.sh +33 -18
index 6779d7e55d85..853ba04e4149 100755
@@ -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,43 @@ cleanup()
        if [ -f $tmp_file ]; then
                rm $tmp_file
        fi
-       /sbin/modprobe -q -r $MODULE_NAME
+       /sbin/modprobe -r $MODULE_NAME
+}
+
+debug_file_exist()
+{
+       if [ ! -d "$UDELAY_PATH" ]; then
+               return 1
+       fi
+       return 0
 }
 
 trap cleanup EXIT
 setup
+debug_file_exist
 
-# 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 [ $? -eq 1 ]; 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
 
Quoted 6 lines
Quoted 6 lines
tools/time/udelay_test.sh +0 -1
 exit $retcode
--

2.25.1

Yeah, i will send PATCH V2 after changing like you said.