selftests: fix memory-hotplug test
authorPo-Hsu Lin <po-hsu.lin@canonical.com>
Tue, 27 Jun 2017 06:17:15 +0000 (14:17 +0800)
committerShuah Khan <shuahkh@osg.samsung.com>
Fri, 30 Jun 2017 16:06:23 +0000 (10:06 -0600)
commit5ff0c60b0e5e8c2a2139c304d7620b0ea70d721a
tree888991c3eef427301d1f8ff2797c7be478385f41
parent02d8f075ac44f6f0dc46881965f815576921f2c0
selftests: fix memory-hotplug test

In the memory offline test, the $ration was used with RANDOM as the
possibility to get it offlined, correct it to become the portion of
available removable memory blocks.

Also ask the tool to try to offline the next available memory block
if the attempt is unsuccessful. It will only fail if all removable
memory blocks are busy.

A nice example:
$ sudo ./test.sh
Test scope: 10% hotplug memory
online all hot-pluggable memory in offline state:
SKIPPED - no hot-pluggable memory in offline state
offline 10% hot-pluggable memory in online state
trying to offline 3 out of 28 memory block(s):
online->offline memory1
online->offline memory10
./test.sh: line 74: echo: write error: Resource temporarily unavailable
offline_memory_expect_success 10: unexpected fail
online->offline memory100
online->offline memory101
online all hot-pluggable memory in offline state:
offline->online memory1
offline->online memory100
offline->online memory101
skip extra tests: debugfs is not mounted
$ echo $?
0

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
tools/testing/selftests/memory-hotplug/mem-on-off-test.sh