summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
diff options
context:
space:
mode:
authorVipin Sharma <vipinsh@google.com>2022-11-03 12:17:18 -0700
committerSean Christopherson <seanjc@google.com>2022-11-16 10:03:24 -0800
commit0001725d0f9b5d749540021befb67c117d566416 (patch)
tree5789cf5ac497191de06a10ac0c22e577a382285f /tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
parentc15bdebb32ddc73faac5e5180d6997b360e81619 (diff)
KVM: selftests: Add atoi_positive() and atoi_non_negative() for input validation
Many KVM selftests take command line arguments which are supposed to be positive (>0) or non-negative (>=0). Some tests do these validation and some missed adding the check. Add atoi_positive() and atoi_non_negative() to validate inputs in selftests before proceeding to use those values. Signed-off-by: Vipin Sharma <vipinsh@google.com> Reviewed-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20221103191719.1559407-7-vipinsh@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c')
-rw-r--r--tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
index 354b6902849c..ea0978f22db8 100644
--- a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
+++ b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
@@ -241,7 +241,7 @@ int main(int argc, char **argv)
while ((opt = getopt(argc, argv, "hp:t:r")) != -1) {
switch (opt) {
case 'p':
- reclaim_period_ms = atoi_paranoid(optarg);
+ reclaim_period_ms = atoi_non_negative("Reclaim period", optarg);
break;
case 't':
token = atoi_paranoid(optarg);
@@ -257,7 +257,6 @@ int main(int argc, char **argv)
}
TEST_REQUIRE(kvm_has_cap(KVM_CAP_VM_DISABLE_NX_HUGE_PAGES));
- TEST_REQUIRE(reclaim_period_ms > 0);
__TEST_REQUIRE(token == MAGIC_TOKEN,
"This test must be run with the magic token %d.\n"