Skip to content

Commit

Permalink
selftests/memory-hotplug: Restore memory before exit
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
  • Loading branch information
Zhao Gongyi authored and Shuah Khan committed Oct 7, 2022
1 parent 13023c3 commit 3e77a49
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ offline_memory_expect_fail()
return 0
}

online_all_offline_memory()
{
for memory in `hotpluggable_offline_memory`; do
if ! online_memory_expect_success $memory; then
echo "$FUNCNAME $memory: unexpected fail" >&2
retval=1
fi
done
}

error=-12
priority=0
# Run with default of ratio=2 for Kselftest run
Expand Down Expand Up @@ -275,11 +285,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
if ! online_memory_expect_success $memory; then
retval=1
fi
done
online_all_offline_memory

#
# Test memory hot-remove error handling (online => offline)
Expand All @@ -296,4 +302,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_offline_memory

exit $retval

0 comments on commit 3e77a49

Please sign in to comment.