[3/5] selftests: check percentage range for memory-hotplug test

Message ID 20170810063239.16182-4-po-hsu.lin@canonical.com
State New
Headers show

Commit Message

Po-Hsu Lin Aug. 10, 2017, 6:32 a.m.
Check the precentage range for -r flag in memory-hotplug test.

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
(cherry picked from commit 72441ea5886780d04ac96913e02dba9e84ea80e5)
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
 tools/testing/selftests/memory-hotplug/mem-on-off-test.sh | 4 ++++
 1 file changed, 4 insertions(+)

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 993ff2b..c735ece 100755
--- a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
+++ b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
@@ -136,6 +136,10 @@  while getopts e:hp:r: opt; do
 		;;
 	r)
 		ratio=$OPTARG
+		if [ "$ratio" -gt 100 ] || [ "$ratio" -lt 0 ]; then
+			echo "The percentage should be an integer within 0~100 range"
+			exit 1
+		fi
 		;;
 	esac
 done