controllers/cgroup_fj: fix the current problem of testcases
PATCH 1/1 controllers/cgroup_fj: fix the current problem of testcases
The value of subsystem and subsystem_str is in conflict, and we need to check that the subsystem exist before running the tests. Finally according to some parameters, the mount command is error.
--- .../controllers/cgroup_fj/cgroup_fj_function.sh | 4 ++-- .../controllers/cgroup_fj/cgroup_fj_stress.sh | 2 +- .../controllers/cgroup_fj/cgroup_fj_utility.sh | 27 ++++++++++++++++------ 3 files changed, 23 insertions(+), 10 deletions(-)
testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh +2 -2
@@ -148,7 +148,7 @@ mkdir_subgroup; # cpuset.cpus and cpuset.mems should be specified with suitable value # before attaching operation if subsystem is cpuset -if [ "$subsystem" == "cpuset" ] || [ "$subsystem" == "all" ] || [ $subsystem == "none" ] ; then +if [ "$subsystem" == "cpuset" ] || [ "$subsystem" == "all" ] || [ "$subsystem" == "none" ] ; then exist=`grep -w cpuset /proc/cgroups | cut -f1`; if [ "$exist" != "" ]; then if [ "$noprefix_use" == "no" ]; then
@@ -225,7 +225,7 @@ sleep 1 # pid could not be echoed from subgroup if subsystem is ( or include ) ns, # so we kill them here -if [ "$subsystem" == "ns" ] || [ "$subsystem" == "all" ] || [ $subsystem == "none" ] ; then +if [ "$subsystem" == "ns" ] || [ "$subsystem" == "all" ] || [ "$subsystem" == "none" ] ; then do_kill 1 1 9 $pid do_kill 1 1 9 $pid2 # removing operation
testcases/kernel/controllers/cgroup_fj/cgroup_fj_stress.sh +1 -1
@@ -88,7 +88,7 @@ export TMPFILE=$TESTROOT/tmp_tasks pid=0; release_agent_para=1; release_agent_echo=1; -subsystem_str=$subsystem; +get_subsystem; if [ "$?" -ne "0" ] || [ "$#" -ne "5" ]; then usage; exit_parameter;
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh +20 -7
@@ -54,38 +54,48 @@ get_subsystem() { case $subsystem in "debug" ) + subsystem_str="debug" exist_subsystem; ;; "cpuset" ) + subsystem_str="cpuset" exist_subsystem; ;; "ns" ) + subsystem_str="ns" exist_subsystem; ;; "cpu" ) + subsystem_str="cpu" exist_subsystem; ;; "cpuacct" ) + subsystem_str="cpuacct" exist_subsystem; ;; "memory" ) + subsystem_str="memory" exist_subsystem; ;; "all" ) + subsystem_str="all" ;; "none" ) - subsystem="" + subsystem_str="" ;; "debug,debug" ) + subsystem_str="debug,debug" exist_subsystem "debug"; ;; "nonexistent" ) - subsystem="abc"; + subsystem_str="abc"; ;; "freezer" ) + subsystem_str="freezer" exist_subsystem; ;; "devices" ) + subsystem_str="devices" exist_subsystem; ;; * )
@@ -369,8 +379,11 @@ do_mount() echo "\"mount -t cgroup $para_o $something $target\" (expected: fail)" fi fi - - mount -t cgroup $para_o $something $target + if [ "$para_o" == "" ];then + mount -t cgroup $para_o $something $target + else + mount -t cgroup "$para_o" $something $target + fi do_exit $exit_here $expected $?; }
@@ -557,11 +570,11 @@ mount_cgroup () { expected=1 PARAMETER_O=""; - if [ "$subsystem" == "abc" ]; then + if [ "$subsystem_str" == "abc" ]; then expected=0 fi - if [ "$subsystem" != "" ]; then - PARAMETER_O="$subsystem" + if [ "$subsystem_str" != "" ]; then + PARAMETER_O="$subsystem_str" fi if [ "$noprefix_use_str" != "" ]; then if [ "$PARAMETER_O" != "" ]; then
Signature · 1 line
1.8.3.1
PATCH 1/1 controllers/cgroup_fj: fix the current problem of testcases
Hi!
Quoted 14 lines
testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh +1
-1@@ -148,7 +148,7 @@ mkdir_subgroup; # cpuset.cpus and cpuset.mems should be specified with suitable value # before attaching operation if subsystem is cpuset -if [ "$subsystem" == "cpuset" ] || [ "$subsystem" == "all" ] || [ $subsystem == "none" ] ; then +if [ "$subsystem" == "cpuset" ] || [ "$subsystem" == "all" ] || [ "$subsystem" == "none" ] ; then exist=`grep -w cpuset /proc/cgroups | cut -f1`; if [ "$exist" != "" ]; then if [ "$noprefix_use" == "no" ]; then
testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh sleep 1 · line 230
Quoted 7 lines
testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh +1
-1@@ -225,7 +225,7 @@ sleep 1 # pid could not be echoed from subgroup if subsystem is ( or include ) ns, # so we kill them here -if [ "$subsystem" == "ns" ] || [ "$subsystem" == "all" ] || [ $subsystem == "none" ] ; then +if [ "$subsystem" == "ns" ] || [ "$subsystem" == "all" ] || [ "$subsystem" == "none" ] ; then do_kill 1 1 9 $pid do_kill 1 1 9 $pid2
This is fixed in patch by Cedric whose third version should be final one.
Quoted 59 lines
testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh +0
-0# removing operationtestcases/kernel/controllers/cgroup_fj/cgroup_fj_stress.sh +1
-1@@ -88,7 +88,7 @@ export TMPFILE=$TESTROOT/tmp_tasks pid=0; release_agent_para=1; release_agent_echo=1; -subsystem_str=$subsystem; +get_subsystem; if [ "$?" -ne "0" ] || [ "$#" -ne "5" ]; then usage; exit_parameter;testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh +10
-2@@ -54,38 +54,48 @@ get_subsystem() { case $subsystem in "debug" ) + subsystem_str="debug" exist_subsystem; ;; "cpuset" ) + subsystem_str="cpuset" exist_subsystem; ;; "ns" ) + subsystem_str="ns" exist_subsystem; ;; "cpu" ) + subsystem_str="cpu" exist_subsystem; ;; "cpuacct" ) + subsystem_str="cpuacct" exist_subsystem; ;; "memory" ) + subsystem_str="memory" exist_subsystem; ;; "all" ) + subsystem_str="all" ;; "none" ) - subsystem="" + subsystem_str="" ;; "debug,debug" ) + subsystem_str="debug,debug" exist_subsystem "debug"; ;; "nonexistent" ) - subsystem="abc"; + subsystem_str="abc";
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh get_subsystem() · line 101
Quoted 10 lines
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh +2
-0;; "freezer" ) + subsystem_str="freezer" exist_subsystem; ;; "devices" ) + subsystem_str="devices" exist_subsystem; ;; * )
I do not like this at all. Looking at the code the only problem we have is that we compare "$subystem" with none while we should do [ -n "$subsystem" ] instead.
Moreover this case should be change into two ifs. One that calls exists_subsystem when subsystem is not "all" nor "none" and second one that sets $subsytem to be empty when its set to "none".
Quoted 4 lines
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh +0
-0@@ -369,8 +379,11 @@ do_mount() echo "\"mount -t cgroup $para_o $something $target\" (expected: fail)" fi fi
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh do_mount() · line 389
Quoted 10 lines
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh +5
-2- - mount -t cgroup $para_o $something $target + if [ "$para_o" == "" ];then + mount -t cgroup $para_o $something $target + else + mount -t cgroup "$para_o" $something $target + fi do_exit $exit_here $expected $?; }
What is the exact problem here? does $para_o contain whitespaces in some cases?
Quoted 5 lines
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh +0
-1@@ -557,11 +570,11 @@ mount_cgroup () { expected=1 PARAMETER_O=""; - if [ "$subsystem" == "abc" ]; then
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh mount_cgroup () · line 580
Quoted 10 lines
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh +3
-2+ if [ "$subsystem_str" == "abc" ]; then expected=0 fi - if [ "$subsystem" != "" ]; then - PARAMETER_O="$subsystem" + if [ "$subsystem_str" != "" ]; then + PARAMETER_O="$subsystem_str" fi if [ "$noprefix_use_str" != "" ]; then if [ "$PARAMETER_O" != "" ]; then
Hmm, so to original code passed -onone in case subsystem was set to "none". I cannot find what is that supposed to do in any documentation. Is that the same as mounting it without any parameters?
Signature · 2 lines
Cyril Hrubis [email protected]