Message ID | 20220909075200.198363-5-zhaogongyi@huawei.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Optimize and bugfix for notifier error | expand |
On 09.09.22 09:51, Zhao Gongyi wrote: > Some momory will be left in offline state when calling > offline_memory_expect_fail() failed. Restore it before exit. > > Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com> > --- > .../memory-hotplug/mem-on-off-test.sh | 24 +++++++++++++------ > 1 file changed, 17 insertions(+), 7 deletions(-) > > diff --git a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh > index 3bdf3c4d6d06..259fd8978639 100755 > --- a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh > +++ b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh > @@ -134,6 +134,17 @@ offline_memory_expect_fail() > return 0 > } > > +online_all_hot_pluggable_memory() > +{ > + > + for memory in `hotpluggable_offline_memory`; do > + online_memory_expect_success $memory || { > + echo "online memory $memory: unexpected fail" > + retval=1 > + } > + done > +} Maybe call it "online_all_offline_memory()" instead? Note that "removable" as used in hotpluggable_memory() will nowadays always return "1" if the kernel supports memory hotunplug, independent of the specific memory block.
diff --git a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh index 3bdf3c4d6d06..259fd8978639 100755 --- a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh +++ b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh @@ -134,6 +134,17 @@ offline_memory_expect_fail() return 0 } +online_all_hot_pluggable_memory() +{ + + for memory in `hotpluggable_offline_memory`; do + online_memory_expect_success $memory || { + echo "online memory $memory: unexpected fail" + retval=1 + } + done +} + error=-12 priority=0 # Run with default of ratio=2 for Kselftest run @@ -278,13 +289,7 @@ done # Online all hot-pluggable memory # echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error -for memory in `hotpluggable_offline_memory`; do - online_memory_expect_success $memory || { - echo "online memory $memory: unexpected fail" - retval=1 - } - -done +online_all_hot_pluggable_memory # # Test memory hot-remove error handling (online => offline) @@ -303,4 +308,9 @@ done echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error /sbin/modprobe -q -r memory-notifier-error-inject +# +# Restore memory before exit +# +online_all_hot_pluggable_memory + exit $retval
Some momory will be left in offline state when calling offline_memory_expect_fail() failed. Restore it before exit. Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com> --- .../memory-hotplug/mem-on-off-test.sh | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) -- 2.17.1