diff options
Diffstat (limited to 'tools/testing/selftests/cpu-hotplug')
| -rw-r--r-- | tools/testing/selftests/cpu-hotplug/Makefile | 3 | ||||
| -rw-r--r-- | tools/testing/selftests/cpu-hotplug/on-off-test.sh | 52 |
2 files changed, 53 insertions, 2 deletions
diff --git a/tools/testing/selftests/cpu-hotplug/Makefile b/tools/testing/selftests/cpu-hotplug/Makefile index 790c23a9db44..e9c28d8dc84b 100644 --- a/tools/testing/selftests/cpu-hotplug/Makefile +++ b/tools/testing/selftests/cpu-hotplug/Makefile | |||
| @@ -3,4 +3,7 @@ all: | |||
| 3 | run_tests: | 3 | run_tests: |
| 4 | @/bin/bash ./on-off-test.sh || echo "cpu-hotplug selftests: [FAIL]" | 4 | @/bin/bash ./on-off-test.sh || echo "cpu-hotplug selftests: [FAIL]" |
| 5 | 5 | ||
| 6 | run_full_test: | ||
| 7 | @/bin/bash ./on-off-test.sh -a || echo "cpu-hotplug selftests: [FAIL]" | ||
| 8 | |||
| 6 | clean: | 9 | clean: |
diff --git a/tools/testing/selftests/cpu-hotplug/on-off-test.sh b/tools/testing/selftests/cpu-hotplug/on-off-test.sh index bdde7cf428bb..98b1d6565f2c 100644 --- a/tools/testing/selftests/cpu-hotplug/on-off-test.sh +++ b/tools/testing/selftests/cpu-hotplug/on-off-test.sh | |||
| @@ -11,6 +11,8 @@ prerequisite() | |||
| 11 | exit 0 | 11 | exit 0 |
| 12 | fi | 12 | fi |
| 13 | 13 | ||
| 14 | taskset -p 01 $$ | ||
| 15 | |||
| 14 | SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'` | 16 | SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'` |
| 15 | 17 | ||
| 16 | if [ ! -d "$SYSFS" ]; then | 18 | if [ ! -d "$SYSFS" ]; then |
| @@ -22,6 +24,19 @@ prerequisite() | |||
| 22 | echo $msg cpu hotplug is not supported >&2 | 24 | echo $msg cpu hotplug is not supported >&2 |
| 23 | exit 0 | 25 | exit 0 |
| 24 | fi | 26 | fi |
| 27 | |||
| 28 | echo "CPU online/offline summary:" | ||
| 29 | online_cpus=`cat $SYSFS/devices/system/cpu/online` | ||
| 30 | online_max=${online_cpus##*-} | ||
| 31 | echo -e "\t Cpus in online state: $online_cpus" | ||
| 32 | |||
| 33 | offline_cpus=`cat $SYSFS/devices/system/cpu/offline` | ||
| 34 | if [[ "a$offline_cpus" = "a" ]]; then | ||
| 35 | offline_cpus=0 | ||
| 36 | else | ||
| 37 | offline_max=${offline_cpus##*-} | ||
| 38 | fi | ||
| 39 | echo -e "\t Cpus in offline state: $offline_cpus" | ||
| 25 | } | 40 | } |
| 26 | 41 | ||
| 27 | # | 42 | # |
| @@ -113,15 +128,25 @@ offline_cpu_expect_fail() | |||
| 113 | } | 128 | } |
| 114 | 129 | ||
| 115 | error=-12 | 130 | error=-12 |
| 131 | allcpus=0 | ||
| 116 | priority=0 | 132 | priority=0 |
| 133 | online_cpus=0 | ||
| 134 | online_max=0 | ||
| 135 | offline_cpus=0 | ||
| 136 | offline_max=0 | ||
| 117 | 137 | ||
| 118 | while getopts e:hp: opt; do | 138 | while getopts e:ahp: opt; do |
| 119 | case $opt in | 139 | case $opt in |
| 120 | e) | 140 | e) |
| 121 | error=$OPTARG | 141 | error=$OPTARG |
| 122 | ;; | 142 | ;; |
| 143 | a) | ||
| 144 | allcpus=1 | ||
| 145 | ;; | ||
| 123 | h) | 146 | h) |
| 124 | echo "Usage $0 [ -e errno ] [ -p notifier-priority ]" | 147 | echo "Usage $0 [ -a ] [ -e errno ] [ -p notifier-priority ]" |
| 148 | echo -e "\t default offline one cpu" | ||
| 149 | echo -e "\t run with -a option to offline all cpus" | ||
| 125 | exit | 150 | exit |
| 126 | ;; | 151 | ;; |
| 127 | p) | 152 | p) |
| @@ -138,6 +163,29 @@ fi | |||
| 138 | prerequisite | 163 | prerequisite |
| 139 | 164 | ||
| 140 | # | 165 | # |
| 166 | # Safe test (default) - offline and online one cpu | ||
| 167 | # | ||
| 168 | if [ $allcpus -eq 0 ]; then | ||
| 169 | echo "Limited scope test: one hotplug cpu" | ||
| 170 | echo -e "\t (leaves cpu in the original state):" | ||
| 171 | echo -e "\t online to offline to online: cpu $online_max" | ||
| 172 | offline_cpu_expect_success $online_max | ||
| 173 | online_cpu_expect_success $online_max | ||
| 174 | |||
| 175 | if [[ $offline_cpus -gt 0 ]]; then | ||
| 176 | echo -e "\t offline to online to offline: cpu $offline_max" | ||
| 177 | online_cpu_expect_success $offline_max | ||
| 178 | offline_cpu_expect_success $offline_max | ||
| 179 | fi | ||
| 180 | exit 0 | ||
| 181 | else | ||
| 182 | echo "Full scope test: all hotplug cpus" | ||
| 183 | echo -e "\t online all offline cpus" | ||
| 184 | echo -e "\t offline all online cpus" | ||
| 185 | echo -e "\t online all offline cpus" | ||
| 186 | fi | ||
| 187 | |||
| 188 | # | ||
| 141 | # Online all hot-pluggable CPUs | 189 | # Online all hot-pluggable CPUs |
| 142 | # | 190 | # |
| 143 | for cpu in `hotplaggable_offline_cpus`; do | 191 | for cpu in `hotplaggable_offline_cpus`; do |
