[LTP] [PATCH v2] testcases:Fix the failure of shell script to get path

Hao Zeng zenghao@kylinos.cn
Sat May 6 11:27:02 CEST 2023


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>
Suggested-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/controllers/cpuset/cpuset_funcs.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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
-- 
2.37.2



More information about the ltp mailing list