diff mbox series

[-next,2/5] selftests/memory-hotplug: Use 'printf' instead of 'echo'

Message ID 20220909075200.198363-3-zhaogongyi@huawei.com (mailing list archive)
State Superseded
Headers show
Series Optimize and bugfix for notifier error | expand

Commit Message

Zhao Gongyi Sept. 9, 2022, 7:51 a.m. UTC
Fault injection uses debugfs in a way that the provided values via
sysfs are interpreted as u64. Providing negative numbers results
in errors:

  # sh mem-on-off-test.sh
  ...
  mem-on-off-test.sh: line 267: echo: write error: Invalid argument
  ...
  mem-on-off-test.sh: line 283: echo: write error: Invalid argument
  ...
  #

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
 tools/testing/selftests/memory-hotplug/mem-on-off-test.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--
2.17.1
diff mbox series

Patch

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 46a97f318f58..f1a9d81b934c 100755
--- a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
+++ b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
@@ -264,7 +264,8 @@  done
 #
 # Test memory hot-add error handling (offline => online)
 #
-echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error
+printf %#x $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/erro
+
 for memory in `hotpluggable_offline_memory`; do
 	online_memory_expect_fail $memory
 done
@@ -280,7 +281,7 @@  done
 #
 # Test memory hot-remove error handling (online => offline)
 #
-echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error
+printf %#x $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error
 for memory in `hotpluggable_online_memory`; do
 	if [ $((RANDOM % 100)) -lt $ratio ]; then
 		offline_memory_expect_fail $memory