From: Petr Vorel <pvorel@suse.cz>
To: Hao Zeng <zenghao@kylinos.cn>
Cc: crawler2015@163.com, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] testcases:Fix the failure of shell script to get path
Date: Fri, 5 May 2023 19:41:41 +0200 [thread overview]
Message-ID: <20230505174141.GA36292@pevik> (raw)
In-Reply-To: <6b2a7ceb.4466.1874a537430.Coremail.crawler2015@163.com>
> From 9f372d2d4c9a9df9cda1a7afceddaa2acca27f03 Mon Sep 17 00:00:00 2001
> From: Hao Zeng <zenghao@kylinos.cn>
> 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 -
> Signed-off-by: Hao Zeng <zenghao@kylinos.cn>
> ---
> 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.sh b/testcases/kernel/controllers/cpuctl_fj/run_cpuctl_test_fj.sh
> index ab73c801b..5cb6bb566 100755
> --- a/testcases/kernel/controllers/cpuctl_fj/run_cpuctl_test_fj.sh
> +++ b/testcases/kernel/controllers/cpuctl_fj/run_cpuctl_test_fj.sh
> @@ -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
> diff --git a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
> index 87ba7da1f..0cfa0c17e 100755
> --- a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
> +++ b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
> @@ -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
> diff --git a/testcases/open_posix_testsuite/scripts/generate-makefiles.sh b/testcases/open_posix_testsuite/scripts/generate-makefiles.sh
> index 0649c480f..f3af3cede 100755
> --- a/testcases/open_posix_testsuite/scripts/generate-makefiles.sh
> +++ b/testcases/open_posix_testsuite/scripts/generate-makefiles.sh
> @@ -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.)
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
> 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.
> 在 2023/4/4 21:36, Petr Vorel 写道:
> > > 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
> > Could you print the path how it looks like with ls:
> > ls -l /dev/cpuset/machine.slice/
> ls -l /dev/cpuset/machine.slice/
> -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_level
> drwxr-xr-x 6 root root 0 Apr 5 13:44
> 'machine-qemu\x2d3\x2dzh\x2dnode1.scope'
> -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 tasks
> > 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
> > > +++ b/testcases/open_posix_testsuite/scripts/generate-makefiles.sh
> > > @@ -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
> > I don't think it's needed for open posix.
> I agree with your viewpoint.
> > Kind regards,
> > Petr
> Best regards
> Hao
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-05-05 17:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-04 3:33 [LTP] [PATCH] testcases:Fix the failure of shell script to get path 曾浩
2023-05-05 17:41 ` Petr Vorel [this message]
2023-05-06 9:31 ` Hao Zeng
[not found] <20230404022808.925841-1-zenghao@kylinos.cn>
2023-04-04 13:36 ` Petr Vorel
2023-04-06 2:58 ` zenghao
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=20230505174141.GA36292@pevik \
--to=pvorel@suse.cz \
--cc=crawler2015@163.com \
--cc=ltp@lists.linux.it \
--cc=zenghao@kylinos.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.