selftests/cgroup: Minor code cleanup and reorganization of test_cpuset_prs.sh
authorWaiman Long <longman@redhat.com>
Wed, 25 Oct 2023 18:25:53 +0000 (14:25 -0400)
committerTejun Heo <tj@kernel.org>
Sun, 12 Nov 2023 21:07:41 +0000 (15:07 -0600)
Minor cleanup of test matrix and relocation of test_isolated() function
to prepare for the next patch. There is no functional change.

Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
tools/testing/selftests/cgroup/test_cpuset_prs.sh

index a6e9848189d62d60131b8cf1c4698004623b47a9..2b825019f806101e5a7f62cf3658a7ee2f2a8249 100755 (executable)
@@ -146,71 +146,6 @@ test_add_proc()
        echo $$ > $CGROUP2/cgroup.procs # Move out the task
 }
 
-#
-# Testing the new "isolated" partition root type
-#
-test_isolated()
-{
-       cd $CGROUP2/test
-       echo 2-3 > cpuset.cpus
-       TYPE=$(cat cpuset.cpus.partition)
-       [[ $TYPE = member ]] || echo member > cpuset.cpus.partition
-
-       console_msg "Change from member to root"
-       test_partition root
-
-       console_msg "Change from root to isolated"
-       test_partition isolated
-
-       console_msg "Change from isolated to member"
-       test_partition member
-
-       console_msg "Change from member to isolated"
-       test_partition isolated
-
-       console_msg "Change from isolated to root"
-       test_partition root
-
-       console_msg "Change from root to member"
-       test_partition member
-
-       #
-       # Testing partition root with no cpu
-       #
-       console_msg "Distribute all cpus to child partition"
-       echo +cpuset > cgroup.subtree_control
-       test_partition root
-
-       mkdir A1
-       cd A1
-       echo 2-3 > cpuset.cpus
-       test_partition root
-       test_effective_cpus 2-3
-       cd ..
-       test_effective_cpus ""
-
-       console_msg "Moving task to partition test"
-       test_add_proc "No space left"
-       cd A1
-       test_add_proc ""
-       cd ..
-
-       console_msg "Shrink and expand child partition"
-       cd A1
-       echo 2 > cpuset.cpus
-       cd ..
-       test_effective_cpus 3
-       cd A1
-       echo 2-3 > cpuset.cpus
-       cd ..
-       test_effective_cpus ""
-
-       # Cleaning up
-       console_msg "Cleaning up"
-       echo $$ > $CGROUP2/cgroup.procs
-       [[ -d A1 ]] && rmdir A1
-}
-
 #
 # Cpuset controller state transition test matrix.
 #
@@ -304,7 +239,7 @@ TEST_MATRIX=(
                                                                       A1:P0,A2:P2,A3:P1 2-4"
        " C0-4:X2-4:S+ C1-4:X2-4:S+:P2 C2-4:X4:P1 \
                                   .      .      X5      .      .    0 A1:0-4,A2:1-4,A3:2-4 \
-                                                                      A1:P0,A2:P-2,A3:P-1 ."
+                                                                      A1:P0,A2:P-2,A3:P-1"
        " C0-4:X2-4:S+ C1-4:X2-4:S+:P2 C2-4:X4:P1 \
                                   .      .      .      X1      .    0 A1:0-1,A2:2-4,A3:2-4 \
                                                                       A1:P0,A2:P2,A3:P-1 2-4"
@@ -347,10 +282,10 @@ TEST_MATRIX=(
        # cpus_allowed/exclusive_cpus update tests
        " C0-3:X2-3:S+ C1-3:X2-3:S+ C2-3:X2-3 \
                                   .     C4      .      P2     .     0 A1:4,A2:4,XA2:,XA3:,A3:4 \
-                                                                      A1:P0,A3:P-2 ."
+                                                                      A1:P0,A3:P-2"
        " C0-3:X2-3:S+ C1-3:X2-3:S+ C2-3:X2-3 \
                                   .     X1      .      P2     .     0 A1:0-3,A2:1-3,XA1:1,XA2:,XA3:,A3:2-3 \
-                                                                      A1:P0,A3:P-2 ."
+                                                                      A1:P0,A3:P-2"
        " C0-3:X2-3:S+ C1-3:X2-3:S+ C2-3:X2-3 \
                                   .      .     C3      P2     .     0 A1:0-2,A2:0-2,XA2:3,XA3:3,A3:3 \
                                                                       A1:P0,A3:P2 3"
@@ -359,13 +294,13 @@ TEST_MATRIX=(
                                                                       A1:P0,A3:P2 3"
        " C0-3:X2-3:S+ C1-3:X2-3:S+ C2-3:X2-3:P2 \
                                   .      .     X3      .      .     0 A1:0-3,A2:1-3,XA2:3,XA3:3,A3:2-3 \
-                                                                      A1:P0,A3:P-2 ."
+                                                                      A1:P0,A3:P-2"
        " C0-3:X2-3:S+ C1-3:X2-3:S+ C2-3:X2-3:P2 \
                                   .      .     C3      .      .     0 A1:0-3,A2:3,XA2:3,XA3:3,A3:3 \
-                                                                      A1:P0,A3:P-2 ."
+                                                                      A1:P0,A3:P-2"
        " C0-3:X2-3:S+ C1-3:X2-3:S+ C2-3:X2-3:P2 \
                                   .     C4      .      .      .     0 A1:4,A2:4,A3:4,XA1:,XA2:,XA3 \
-                                                                      A1:P0,A3:P-2 ."
+                                                                      A1:P0,A3:P-2"
 
        #  old-A1 old-A2 old-A3 old-B1 new-A1 new-A2 new-A3 new-B1 fail ECPUs Pstate ISOLCPUS
        #  ------ ------ ------ ------ ------ ------ ------ ------ ---- ----- ------ --------
@@ -804,6 +739,71 @@ run_state_test()
        echo "All $I tests of $TEST PASSED."
 }
 
+#
+# Testing the new "isolated" partition root type
+#
+test_isolated()
+{
+       cd $CGROUP2/test
+       echo 2-3 > cpuset.cpus
+       TYPE=$(cat cpuset.cpus.partition)
+       [[ $TYPE = member ]] || echo member > cpuset.cpus.partition
+
+       console_msg "Change from member to root"
+       test_partition root
+
+       console_msg "Change from root to isolated"
+       test_partition isolated
+
+       console_msg "Change from isolated to member"
+       test_partition member
+
+       console_msg "Change from member to isolated"
+       test_partition isolated
+
+       console_msg "Change from isolated to root"
+       test_partition root
+
+       console_msg "Change from root to member"
+       test_partition member
+
+       #
+       # Testing partition root with no cpu
+       #
+       console_msg "Distribute all cpus to child partition"
+       echo +cpuset > cgroup.subtree_control
+       test_partition root
+
+       mkdir A1
+       cd A1
+       echo 2-3 > cpuset.cpus
+       test_partition root
+       test_effective_cpus 2-3
+       cd ..
+       test_effective_cpus ""
+
+       console_msg "Moving task to partition test"
+       test_add_proc "No space left"
+       cd A1
+       test_add_proc ""
+       cd ..
+
+       console_msg "Shrink and expand child partition"
+       cd A1
+       echo 2 > cpuset.cpus
+       cd ..
+       test_effective_cpus 3
+       cd A1
+       echo 2-3 > cpuset.cpus
+       cd ..
+       test_effective_cpus ""
+
+       # Cleaning up
+       console_msg "Cleaning up"
+       echo $$ > $CGROUP2/cgroup.procs
+       [[ -d A1 ]] && rmdir A1
+}
+
 #
 # Wait for inotify event for the given file and read it
 # $1: cgroup file to wait for