summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/include/test_util.h
diff options
context:
space:
mode:
authorVitaly Kuznetsov <vkuznets@redhat.com>2024-01-09 17:11:17 +0300
committerSean Christopherson <seanjc@google.com>2024-02-01 19:58:13 +0300
commite440c5f2e3e6893aeb39bbba6dd181207840a795 (patch)
tree35263d862a14f9c0790b1799d6efbbd00a7841a0 /tools/testing/selftests/kvm/include/test_util.h
parentc2a449a30fa2b5ddc1dd058e92e047157c9eeb9e (diff)
downloadlinux-e440c5f2e3e6893aeb39bbba6dd181207840a795.tar.xz
KVM: selftests: Generalize check_clocksource() from kvm_clock_test
Several existing x86 selftests need to check that the underlying system clocksource is TSC or based on TSC but every test implements its own check. As a first step towards unification, extract check_clocksource() from kvm_clock_test and split it into two functions: arch-neutral 'sys_get_cur_clocksource()' and x86-specific 'sys_clocksource_is_tsc()'. Fix a couple of pre-existing issues in kvm_clock_test: memory leakage in check_clocksource() and using TEST_ASSERT() instead of TEST_REQUIRE(). The change also makes the test fail when system clocksource can't be read from sysfs. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Link: https://lore.kernel.org/r/20240109141121.1619463-2-vkuznets@redhat.com [sean: eliminate if-elif pattern just to set a bool true] Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/testing/selftests/kvm/include/test_util.h')
-rw-r--r--tools/testing/selftests/kvm/include/test_util.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h
index 71a41fa924b7..50a5e31ba8da 100644
--- a/tools/testing/selftests/kvm/include/test_util.h
+++ b/tools/testing/selftests/kvm/include/test_util.h
@@ -195,4 +195,6 @@ __printf(3, 4) int guest_snprintf(char *buf, int n, const char *fmt, ...);
char *strdup_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2), nonnull(1)));
+char *sys_get_cur_clocksource(void);
+
#endif /* SELFTEST_KVM_TEST_UTIL_H */