testcases:Fix the failure of shell script to get path
PATCH 1/1 testcases:Fix the failure of shell script to get path
From 9f372d2d4c9a9df9cda1a7afceddaa2acca27f03 Mon Sep 17 00:00:00 2001
From: Hao Zeng <[email protected]>
Date: Fri, 31 Mar 2023 17:04:07 +0800
Subject: [LTP] [PATCH] testcases:Fix the failure of shell script to get path
For example, in the file testcases/kernel/controllers/cpuset/cpuset_funcs.sh, if the path is obtained by
find "$CPUSET" -type d | sort | sed -n '2,$p' | tac | while read subdir, the escaped characters will be lost,
and by adding the -r option, the escaped characters will be kept as they are without escaping
The errors are as follows:
/opt/ltp/testcases/bin/cpuset_funcs.sh:line178: /dev/cpuset/machine.slice/machine-qemux2d157x2dzhx2dsxf.scope/vcpu7/tasks: The file or directory is not available
rmdir: delete '/dev/cpuset/machine.slice/machine-qemux2d157x2dzhx2dsxf.scope/vcpu7' Failure: The file or directory is not available cpuset_memory_pressure 1 TFAIL: Couldn't remove subdir -
/opt/ltp/testcases/bin/cpuset_funcs.sh:line178: /dev/cpuset/machine.slice/machine-qemux2d157x2dzhx2dsxf.scope/vcpu7/tasks: The file or directory is not available
rmdir: delete '/dev/cpuset/machine.slice/machine-qemux2d157x2dzhx2dsxf.scope/vcpu7' Failure: The file or directory is not available cpuset_memory_pressure 1 TFAIL: Couldn't remove subdir -
--- testcases/kernel/controllers/cpuctl_fj/run_cpuctl_test_fj.sh | 2 +- testcases/kernel/controllers/cpuset/cpuset_funcs.sh | 2 +- testcases/open_posix_testsuite/scripts/generate-makefiles.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
testcases/kernel/controllers/cpuctl_fj/run_cpuctl_test_fj.sh +1 -1
@@ -63,7 +63,7 @@ cleanup() return 0 } - find $CPUCTL -type d | sort | sed -n '2,$p' | tac | while read tmpdir + find $CPUCTL -type d | sort | sed -n '2,$p' | tac | while read -r tmpdir do while read tmppid do
testcases/kernel/controllers/cpuset/cpuset_funcs.sh +1 -1
@@ -184,7 +184,7 @@ cleanup() echo $CHILDREN_VALUE > $CLONE_CHILDREN echo $SCHED_LB_VALUE > $SCHED_LB - find "$CPUSET" -type d | sort | sed -n '2,$p' | tac | while read subdir + find "$CPUSET" -type d | sort | sed -n '2,$p' | tac | while read -r subdir do while read pid do
testcases/open_posix_testsuite/scripts/generate-makefiles.sh +1 -1
@@ -312,7 +312,7 @@ generate_locate_test_makefile buildonly '.test' "$buildonly_compiler_args" generate_locate_test_makefile runnable '.run-test' generate_locate_test_makefile test-tools '' -find . -name Makefile.1 -exec dirname {} \; | while read dir; do +find . -name Makefile.1 -exec dirname {} \; | while read -r dir; do if [ -f "$dir/Makefile.2" ]; then cat $dir/Makefile.1 $dir/Makefile.2 $dir/Makefile.3 > $dir/Makefile fi
Signature · 4 lines
2.37.2 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 56 lines
From
9f372d2d4c9a9df9cda1a7afceddaa2acca27f03Mon Sep 17 00:00:00 2001
From: Hao Zeng <[email protected]>
Date: Fri, 31 Mar 2023 17:04:07 +0800
Subject: [LTP] [PATCH] testcases:Fix the failure of shell script to get pathFor example, in the file
testcases/kernel/controllers/cpuset/cpuset_funcs.sh, if the path is obtained by
find "$CPUSET" -type d | sort | sed -n '2,$p' | tac | while read subdir, the escaped characters will be lost,
and by adding the -r option, the escaped characters will be kept as they are without escaping
The errors are as follows:
/opt/ltp/testcases/bin/cpuset_funcs.sh:line178:/dev/cpuset/machine.slice/machine-qemux2d157x2dzhx2dsxf.scope/vcpu7/tasks: The file or directory is not available
rmdir: delete '/dev/cpuset/machine.slice/machine-qemux2d157x2dzhx2dsxf.scope/vcpu7' Failure: The file or directory is not availablecpuset_memory_pressure1 TFAIL: Couldn't remove subdir -
/opt/ltp/testcases/bin/cpuset_funcs.sh:line178:/dev/cpuset/machine.slice/machine-qemux2d157x2dzhx2dsxf.scope/vcpu7/tasks: The file or directory is not available
rmdir: delete '/dev/cpuset/machine.slice/machine-qemux2d157x2dzhx2dsxf.scope/vcpu7' Failure: The file or directory is not availablecpuset_memory_pressure1 TFAIL: Couldn't remove subdir -Signed-off-by Hao Zeng <[email protected]>--- testcases/kernel/controllers/cpuctl_fj/run_cpuctl_test_fj.sh | 2 +- testcases/kernel/controllers/cpuset/cpuset_funcs.sh | 2 +- testcases/open_posix_testsuite/scripts/generate-makefiles.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)testcases/kernel/controllers/cpuctl_fj/run_cpuctl_test_fj.sh +1
-1@@ -63,7 +63,7 @@ cleanup() return 0 } - find $CPUCTL -type d | sort | sed -n '2,$p' | tac | while read tmpdir + find $CPUCTL -type d | sort | sed -n '2,$p' | tac | while read -r tmpdir do while read tmppid dotestcases/kernel/controllers/cpuset/cpuset_funcs.sh +1
-1@@ -184,7 +184,7 @@ cleanup() echo $CHILDREN_VALUE > $CLONE_CHILDREN echo $SCHED_LB_VALUE > $SCHED_LB - find "$CPUSET" -type d | sort | sed -n '2,$p' | tac | while read subdir + find "$CPUSET" -type d | sort | sed -n '2,$p' | tac | while read -r subdir do while read pid dotestcases/open_posix_testsuite/scripts/generate-makefiles.sh +0
-0
testcases/open_posix_testsuite/scripts/generate-makefiles.sh generate_locate_test_makefile buildonly '.test' "$buildonly_compiler_args" · line 318
Quoted 8 lines
testcases/open_posix_testsuite/scripts/generate-makefiles.sh +1
-1@@ -312,7 +312,7 @@ generate_locate_test_makefile buildonly '.test' "$buildonly_compiler_args" generate_locate_test_makefile runnable '.run-test' generate_locate_test_makefile test-tools '' -find . -name Makefile.1 -exec dirname {} \; | while read dir; do +find . -name Makefile.1 -exec dirname {} \; | while read -r dir; do if [ -f "$dir/Makefile.2" ]; then cat $dir/Makefile.1 $dir/Makefile.2 $dir/Makefile.3 > $dir/Makefile fi
I'd remove change in testcases/open_posix_testsuite/scripts/generate-makefiles.sh IMHO problematic are only controllers shell scripts. Only cpuset are relevant to be escaped. Also, we could use systemd-escape:
systemd-escape -u 'machine-qemu\x2d3\x2dzh\x2dnode1.scope' -> machine/qemu-3-zh-node1.scope
but there are SUT without systemd, thus let's keep "read -r".
(We already talked about it, but you weren't subscribed, thus messages got lost, see the details below.)
Kind regards,
Petr
Quoted 52 lines
Dear Petr
Thank you for taking the time to reply to my email. I appreciate your prompt response and the valuable information you have provided.Quoted 8 lines · Petr Vorel
Quoted 5 lines
For example, in the file
testcases/kernel/controllers/cpuset/cpuset_funcs.sh, if the path is obtained by
find "$CPUSET" -type d | sort | sed -n '2,$p' | tac | while read subdir, the escaped characters will be lost,
and by adding the -r option, the escaped characters will be kept as they are without escaping
The errors are as follows:
/opt/ltp/testcases/bin/cpuset_funcs.sh:line178:/dev/cpuset/machine.slice/machine-qemux2d157x2dzhx2dsxf.scope/vcpu7/tasks: The file or directory is not availableCould you print the path how it looks like with ls:
ls -l
/dev/cpuset/machine.slice/ls -l
/dev/cpuset/machine.slice/testcases/open_posix_testsuite/scripts/generate-makefiles.sh +0
-15-rw-r--r-- 1 root root 0 Apr 5 13:44 cgroup.clone_children -rw-r--r-- 1 root root 0 Apr 5 13:44 cgroup.procs -rw-r--r-- 1 root root 0 Apr 5 13:44 cpuset.cpu_exclusive -rw-r--r-- 1 root root 0 Apr 4 17:41 cpuset.cpus -r--r--r-- 1 root root 0 Apr 5 13:44 cpuset.effective_cpus -r--r--r-- 1 root root 0 Apr 5 13:44 cpuset.effective_mems -rw-r--r-- 1 root root 0 Apr 5 13:44 cpuset.mem_exclusive -rw-r--r-- 1 root root 0 Apr 5 13:44 cpuset.mem_hardwall -rw-r--r-- 1 root root 0 Apr 4 17:41 cpuset.memory_migrate -r--r--r-- 1 root root 0 Apr 5 13:44 cpuset.memory_pressure -rw-r--r-- 1 root root 0 Apr 5 13:44 cpuset.memory_spread_page -rw-r--r-- 1 root root 0 Apr 5 13:44 cpuset.memory_spread_slab -rw-r--r-- 1 root root 0 Apr 4 17:41 cpuset.mems -rw-r--r-- 1 root root 0 Apr 5 13:44 cpuset.sched_load_balance -rw-r--r-- 1 root root 0 Apr 5 13:44 cpuset.sched_relax_domain_leveldrwxr-xr-x 6 root root 0 Apr 5 13:44
'machine-qemu\x2d3\x2dzh\x2dnode1.scope'testcases/open_posix_testsuite/scripts/generate-makefiles.sh +0
-2-rw-r--r-- 1 root root 0 Apr 5 13:44 notify_on_release -rw-r--r-- 1 root root 0 Apr 5 13:44 tasksQuoted 5 lines
FYI cgroup tests written in shell are broken by design, we write new tests in C. Not sure if these old tests are relevant enough to be rewritten into C.
...
get it
Quoted 7 lines
testcases/open_posix_testsuite/scripts/generate-makefiles.sh generate_locate_test_makefile buildonly '.test' "$buildonly_compiler_args" · line 314
Quoted 6 lines
+++
b/testcases/open_posix_testsuite/scripts/generate-makefiles.shtestcases/open_posix_testsuite/scripts/generate-makefiles.sh +1
-1@@ -312,7 +312,7 @@ generate_locate_test_makefile buildonly '.test' "$buildonly_compiler_args" generate_locate_test_makefile runnable '.run-test' generate_locate_test_makefile test-tools '' -find . -name Makefile.1 -exec dirname {} \; | while read dir; do +find . -name Makefile.1 -exec dirname {} \; | while read -r dir; doI don't think it's needed for open posix.
I agree with your viewpoint.
Quoted 2 lines
Kind regards,
PetrBest regards
Hao
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
On Fri, 2023-05-05 at 19:41 +0200, Petr Vorel wrote:
hi Petr
Thanks very much for your reply.
I will follow your suggestion and submit the V2 version
Best regards
Hao
Quoted 184 lines
Quoted 93 lines
From
9f372d2d4c9a9df9cda1a7afceddaa2acca27f03Mon Sep 17 00:00:00 2001
From: Hao Zeng <[email protected]>
Date: Fri, 31 Mar 2023 17:04:07 +0800
Subject: [LTP] [PATCH] testcases:Fix the failure of shell script to get pathFor example, in the file
testcases/kernel/controllers/cpuset/cpuset_funcs.sh, if the path is obtained by
find "$CPUSET" -type d | sort | sed -n '2,$p' | tac | while read subdir, the escaped characters will be lost,
and by adding the -r option, the escaped characters will be kept as they are without escaping
The errors are as follows:
/opt/ltp/testcases/bin/cpuset_funcs.sh:line178:/dev/cpuset/machine.slice/machine-qemux2d157x2dzhx2dsxf.scope/vcpu7/tasks: The file or directory is not available
rmdir: delete '/dev/cpuset/machine.slice/machine-qemux2d157x2dzhx2dsxf.scope/vcpu7' Failure: The file or directory is not availablecpuset_memory_pressure1 TFAIL: Couldn't remove subdir - /opt/ltp/testcases/bin/cpuset_funcs.sh:line178:/dev/cpuset/machine.slice/machine-qemux2d157x2dzhx2dsxf.scope/vcpu7/tasks: The file or directory is not available
rmdir: delete '/dev/cpuset/machine.slice/machine-qemux2d157x2dzhx2dsxf.scope/vcpu7' Failure: The file or directory is not availablecpuset_memory_pressure1 TFAIL: Couldn't remove subdir -Signed-off-by Hao Zeng <[email protected]>---
testcases/kernel/controllers/cpuctl_fj/run_cpuctl_test_fj.sh | 2+- testcases/kernel/controllers/cpuset/cpuset_funcs.sh | 2 +- testcases/open_posix_testsuite/scripts/generate-makefiles.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)diff --git
a/testcases/kernel/controllers/cpuctl_fj/run_cpuctl_test_fj.shb/testcases/kernel/controllers/cpuctl_fj/run_cpuctl_test_fj.shindexab73c801b..5cb6bb566100755testcases/kernel/controllers/cpuctl_fj/run_cpuctl_test_fj.sh +0
-0@@ -63,7 +63,7 @@ cleanup()return 0
}- find $CPUCTL -type d | sort | sed -n '2,$p' | tac | while read tmpdir
+ find $CPUCTL -type d | sort | sed -n '2,$p' | tac | while read -r tmpdir
do
while read tmppid
dotestcases/kernel/controllers/cpuset/cpuset_funcs.sh +0
-0@@ -184,7 +184,7 @@ cleanup()echo $CHILDREN_VALUE > $CLONE_CHILDREN
echo $SCHED_LB_VALUE > $SCHED_LB- find "$CPUSET" -type d | sort | sed -n '2,$p' | tac | while read subdir
+ find "$CPUSET" -type d | sort | sed -n '2,$p' | tac | while read -r subdir
do
while read pid
do(quoted diff) +0
-0
makefiles.shb/testcases/open_posix_testsuite/scripts/generate-makefiles.sh
index0649c480f..f3af3cede100755testcases/open_posix_testsuite/scripts/generate-makefiles.sh +0
-0@@ -312,7 +312,7 @@ generate_locate_test_makefile buildonly '.test'"$buildonly_compiler_args"
generate_locate_test_makefilerunnable '.run-test'generate_locate_test_makefiletest-tools ''testcases/open_posix_testsuite/scripts/generate-makefiles.sh +1
-1-find . -name Makefile.1 -exec dirname {} \; | while read dir; do +find . -name Makefile.1 -exec dirname {} \; | while read -r dir;do
if [ -f "$dir/Makefile.2" ]; then
cat $dir/Makefile.1 $dir/Makefile.2 $dir/Makefile.3Quoted 2 lines
Quoted 1 line
$dir/Makefile
fi
I'd remove change in testcases/open_posix_testsuite/scripts/generate-
makefiles.sh
IMHO problematic are only controllers shell scripts. Only cpuset are relevant
to be escaped. Also, we could use systemd-escape:systemd-escape -u 'machine-qemu\x2d3\x2dzh\x2dnode1.scope' -> machine/qemu-3-zh-node1.scope
but there are SUT without systemd, thus let's keep "read -r".
(We already talked about it, but you weren't subscribed, thus messages got
lost, see the details below.)Reviewed-by Petr Vorel <[email protected]>Kind regards,
PetrQuoted 67 lines
Dear Petr
Thank you for taking the time to reply to my email. I appreciate your prompt
response and the valuable information you have provided.Quoted 12 lines · Petr Vorel
Quoted 4 lines
For example, in the file
testcases/kernel/controllers/cpuset/cpuset_funcs.sh, if the path is obtained by
find "$CPUSET" -type d | sort | sed -n '2,$p' | tac | whileQuoted 8 lines
read subdir, the escaped characters will be lost, and by adding the -r option, the escaped characters will be kept as they are without escaping
The errors are as follows:
/opt/ltp/testcases/bin/cpuset_funcs.sh:line178:/dev/cpuset/machine.slice/machine-qemux2d157x2dzhx2dsxf.scope/vcpu7/tasks: The file or directory is not availableQuoted 3 lines
Could you print the path how it looks like with ls:
ls -l
/dev/cpuset/machine.slice/ls -l
/dev/cpuset/machine.slice/testcases/open_posix_testsuite/scripts/generate-makefiles.sh +0
-15-rw-r--r-- 1 root root 0 Apr 5 13:44 cgroup.clone_children -rw-r--r-- 1 root root 0 Apr 5 13:44 cgroup.procs -rw-r--r-- 1 root root 0 Apr 5 13:44 cpuset.cpu_exclusive -rw-r--r-- 1 root root 0 Apr 4 17:41 cpuset.cpus -r--r--r-- 1 root root 0 Apr 5 13:44 cpuset.effective_cpus -r--r--r-- 1 root root 0 Apr 5 13:44 cpuset.effective_mems -rw-r--r-- 1 root root 0 Apr 5 13:44 cpuset.mem_exclusive -rw-r--r-- 1 root root 0 Apr 5 13:44 cpuset.mem_hardwall -rw-r--r-- 1 root root 0 Apr 4 17:41 cpuset.memory_migrate -r--r--r-- 1 root root 0 Apr 5 13:44 cpuset.memory_pressure -rw-r--r-- 1 root root 0 Apr 5 13:44 cpuset.memory_spread_page -rw-r--r-- 1 root root 0 Apr 5 13:44 cpuset.memory_spread_slab -rw-r--r-- 1 root root 0 Apr 4 17:41 cpuset.mems -rw-r--r-- 1 root root 0 Apr 5 13:44 cpuset.sched_load_balance -rw-r--r-- 1 root root 0 Apr 5 13:44cpuset.sched_relax_domain_level
drwxr-xr-x 6 root root 0 Apr 5 13:44
'machine-qemu\x2d3\x2dzh\x2dnode1.scope'testcases/open_posix_testsuite/scripts/generate-makefiles.sh +0
-2-rw-r--r-- 1 root root 0 Apr 5 13:44 notify_on_release -rw-r--r-- 1 root root 0 Apr 5 13:44 tasksQuoted 7 lines
FYI cgroup tests written in shell are broken by design, we write new tests in C.
Not sure if these old tests are relevant enough to be rewritten into C....
get it
Quoted 11 lines
Quoted 10 lines
+++ b/testcases/open_posix_testsuite/scripts/generate-
makefiles.sh(quoted diff) +0
-0@@ -312,7 +312,7 @@ generate_locate_test_makefile buildonly'.test' "$buildonly_compiler_args"
generate_locate_test_makefilerunnable '.run-test'generate_locate_test_makefiletest-tools ''
-find . -name Makefile.1 -exec dirname {} \; | while read dir; do
+find . -name Makefile.1 -exec dirname {} \; | while read -r dir; doI don't think it's needed for open posix.
I agree with your viewpoint.
Quoted 2 lines
Kind regards,
PetrBest regards
Hao
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp