Message ID | 20241021062226.108657-5-manali.shukla@amd.com |
---|---|
State | New |
Headers | show |
Series | KVM selftests enhancements | expand |
On Mon, Oct 21, 2024, Manali Shukla wrote: > Compile tested both the selftests. To be very blunt, not actually testing changes of this nature isn't acceptable. The HugeTLB dependency of dirty_log_page_splitting_test makes it annoying to run, as does the root user dependency of nx_huge_pages_test.sh, but I wouldn't say that running them is hard. It's a-ok to not fully test code when you don't have the necessary hardware, configuration, etc., but generally speaking the expectation is that you test the code you post. > static void get_page_stats(struct kvm_vm *vm, struct kvm_page_stats *stats, const char *stage) > { > - stats->pages_4k = vm_get_stat(vm, "pages_4k"); > - stats->pages_2m = vm_get_stat(vm, "pages_2m"); > - stats->pages_1g = vm_get_stat(vm, "pages_1g"); > + stats->pages_4k = vm_get_stat(vm, pages_4k); > + stats->pages_2m = vm_get_stat(vm, pages_2m); > + stats->pages_1g = vm_get_stat(vm, pages_1g); Converting vm_get_stats() to a macro, or rather, changing its parameter to do token pasting, absolutely must update all users at the same time. With only the previous patch applied, the affected tests fail because they try to get stats for the string "\"<stat>\"".
diff --git a/tools/testing/selftests/kvm/x86_64/dirty_log_page_splitting_test.c b/tools/testing/selftests/kvm/x86_64/dirty_log_page_splitting_test.c index 2929c067c207..b0d2b04a7ff2 100644 --- a/tools/testing/selftests/kvm/x86_64/dirty_log_page_splitting_test.c +++ b/tools/testing/selftests/kvm/x86_64/dirty_log_page_splitting_test.c @@ -41,9 +41,9 @@ struct kvm_page_stats { static void get_page_stats(struct kvm_vm *vm, struct kvm_page_stats *stats, const char *stage) { - stats->pages_4k = vm_get_stat(vm, "pages_4k"); - stats->pages_2m = vm_get_stat(vm, "pages_2m"); - stats->pages_1g = vm_get_stat(vm, "pages_1g"); + stats->pages_4k = vm_get_stat(vm, pages_4k); + stats->pages_2m = vm_get_stat(vm, pages_2m); + stats->pages_1g = vm_get_stat(vm, pages_1g); stats->hugepages = stats->pages_2m + stats->pages_1g; pr_debug("\nPage stats after %s: 4K: %ld 2M: %ld 1G: %ld huge: %ld\n", 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 e7efb2b35f8b..c0d84827f736 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 @@ -73,7 +73,7 @@ static void check_2m_page_count(struct kvm_vm *vm, int expected_pages_2m) { int actual_pages_2m; - actual_pages_2m = vm_get_stat(vm, "pages_2m"); + actual_pages_2m = vm_get_stat(vm, pages_2m); TEST_ASSERT(actual_pages_2m == expected_pages_2m, "Unexpected 2m page count. Expected %d, got %d", @@ -84,7 +84,7 @@ static void check_split_count(struct kvm_vm *vm, int expected_splits) { int actual_splits; - actual_splits = vm_get_stat(vm, "nx_lpage_splits"); + actual_splits = vm_get_stat(vm, nx_lpage_splits); TEST_ASSERT(actual_splits == expected_splits, "Unexpected NX huge page split count. Expected %d, got %d",
Previous patch converts vm_get_stat() to macro and adds a concatenation trickery to generate compilation error if the stat doesn't exist. Improve nx_huge_pages_test.c and dirty_log_page_splitting_test.c based on the macro. Compile tested both the selftests. Signed-off-by: Manali Shukla <manali.shukla@amd.com> --- .../selftests/kvm/x86_64/dirty_log_page_splitting_test.c | 6 +++--- tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)