Skip to contentSkip to conversation

selftests: livepatch: set LC_ALL=C to fix locale-dependent test failure

PATCH In review Qiang Ma 4 participants 6 messages May 27 – Jun 3

Subsystems (2)
lore
Share & tools
lore

Qiang Ma

author
#0 lore raw

PATCH 1/1 selftests: livepatch: set LC_ALL=C to fix locale-dependent test failure

When executing the command
"make -C tools/testing/selftests TARGETS=livepatch run_tests", the following error message was reported.

TEST: livepatch interaction with ftrace_enabled sysctl ... not ok
...
livepatch: sysctlo
: setting key "kernel.ftrace_enabled": Device or resource busy
livepatch: sysctl: setting key "kernel.ftrace_enabled": 设备或资源忙
...
ERROR: livepatch kselftest(s) failed
not ok 5 selftests: livepatch: test-ftrace.sh # exit=1

To fix it, set LC_ALL=C.

---
 tools/testing/selftests/livepatch/functions.sh | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/livepatch/functions.sh +2 -0
index 8ec0cb64ad94..ecf27c1120f1 100644
@@ -4,6 +4,8 @@
 
 # Shell functions for the rest of the scripts.
 
+export LC_ALL=C
+
 MAX_RETRIES=600
 RETRY_INTERVAL=".1"	# seconds
 SYSFS_KERNEL_DIR="/sys/kernel"
Signature · 1 line
2.20.1
#1 lore raw
Quoted 13 lines · Qiang Ma

When executing the command
"make -C tools/testing/selftests TARGETS=livepatch run_tests", the following error message was reported.

TEST: livepatch interaction with ftrace_enabled sysctl ... not ok
...
livepatch: sysctlo
: setting key "kernel.ftrace_enabled": Device or resource busy
livepatch: sysctl: setting key "kernel.ftrace_enabled": 设备或资源忙
...
ERROR: livepatch kselftest(s) failed
not ok 5 selftests: livepatch: test-ftrace.sh # exit=1

Quoted 1 line

To fix it, set LC_ALL=C.

Would you mind adding more context here? Can you point exactly why is this failing inside test-ftrace.sh script?

Have you double checked if you had any previous loaded livepatches why trying to disable/enable livepatching?

I'll test in my environment, but I'm pretty sure that it used to work not so long ago.

Quoted 20 lines

---
 tools/testing/selftests/livepatch/functions.sh | 2 ++

 1 file changed, 2 insertions(+)
tools/testing/selftests/livepatch/functions.sh +0 -0
index 8ec0cb64ad94..ecf27c1120f1 100644
@@ -4,6 +4,8 @@


 # Shell functions for the rest of the scripts.

tools/testing/selftests/livepatch/functions.sh +2 -0
+export LC_ALL=C
+

 MAX_RETRIES=600
 RETRY_INTERVAL=".1" # seconds
 SYSFS_KERNEL_DIR="/sys/kernel"

author
#2 lore raw
Quoted 14 lines · Marcos Paulo de Souza
Quoted 13 lines · Qiang Ma

When executing the command
"make -C tools/testing/selftests TARGETS=livepatch run_tests", the following error message was reported.

TEST: livepatch interaction with ftrace_enabled sysctl ... not ok
...
livepatch: sysctlo
: setting key "kernel.ftrace_enabled": Device or resource busy
livepatch: sysctl: setting key "kernel.ftrace_enabled": 设备或资源忙
...
ERROR: livepatch kselftest(s) failed
not ok 5 selftests: livepatch: test-ftrace.sh # exit=1

Quoted 3 lines
Quoted 1 line

To fix it, set LC_ALL=C.

Would you mind adding more context here? Can you point exactly why is this failing inside test-ftrace.sh script?

In the check_result(), the values of  result  and expect are compared. In the expect value, one part is
"livepatch: sysctl: setting key \"kernel.ftrace_enabled\": Device or resource busy". However, the actual value of result obtained from dmesg is
"[  220.947876] livepatch: sysctl: 设置键 "kernel.ftrace_enabled": 设备或资源忙".

The comparison is different, so it directly enters the final 'else' branch. Finally, the 'else' branch prints the difference between result and expect:

# --- expected
# +++ result
# @@ -16,7 +16,7 @@ livepatch: 'test_klp_livepatch': initial # livepatch: 'test_klp_livepatch': starting patching transition #  livepatch: 'test_klp_livepatch': completing patching transition
#  livepatch: 'test_klp_livepatch': patching complete
# -livepatch: sysctl: setting key "kernel.ftrace_enabled": Device or resource busy
# +livepatch: sysctl: Set key "kernel.ftrace_enabled": Device or resource is busy #  % echo 0 > /sys/kernel/livepatch/test_klp_livepatch/enabled #  livepatch: 'test_klp_livepatch': initializing unpatching transition
#  livepatch: 'test_klp_livepatch': starting unpatching transition

Quoted 26 lines

Have you double checked if you had any previous loaded livepatches why trying to disable/enable livepatching?

I'll test in my environment, but I'm pretty sure that it used to work not so long ago.

Quoted 19 lines
---
  tools/testing/selftests/livepatch/functions.sh | 2 ++
  1 file changed, 2 insertions(+)
tools/testing/selftests/livepatch/functions.sh +2 -0
index 8ec0cb64ad94..ecf27c1120f1 100644
@@ -4,6 +4,8 @@
 
  # Shell functions for the rest of the scripts.
 
+export LC_ALL=C
+
  MAX_RETRIES=600
  RETRY_INTERVAL=".1"	# seconds
  SYSFS_KERNEL_DIR="/sys/kernel"
maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Qiang Ma
Quoted 13 lines · Qiang Ma

When executing the command
"make -C tools/testing/selftests TARGETS=livepatch run_tests", the following error message was reported.

TEST: livepatch interaction with ftrace_enabled sysctl ... not ok
...
livepatch: sysctlo
: setting key "kernel.ftrace_enabled": Device or resource busy
livepatch: sysctl: setting key "kernel.ftrace_enabled": 设备或资源忙
...
ERROR: livepatch kselftest(s) failed
not ok 5 selftests: livepatch: test-ftrace.sh # exit=1

Quoted 3 lines

To fix it, set LC_ALL=C.

It looks good to me and I think that this is a rather standard thing to do.

I am going to give it few more days for a potential feedback. I'll push it then unless anyone speak against.

Best Regards,
Petr

maintainer
#5 lore raw
In reply to Qiang Ma
Quoted 13 lines · Qiang Ma

When executing the command
"make -C tools/testing/selftests TARGETS=livepatch run_tests", the following error message was reported.

TEST: livepatch interaction with ftrace_enabled sysctl ... not ok
...
livepatch: sysctlo
: setting key "kernel.ftrace_enabled": Device or resource busy
livepatch: sysctl: setting key "kernel.ftrace_enabled": 设备或资源忙
...
ERROR: livepatch kselftest(s) failed
not ok 5 selftests: livepatch: test-ftrace.sh # exit=1

Quoted 3 lines

To fix it, set LC_ALL=C.

JFYI, the patch has been committed into livepatching.git, branch for-7.2-selftests.

Best Regards,
Petr