]> git.itanic.dy.fi Git - linux-stable/commit
KVM: selftests: Generalize check_clocksource() from kvm_clock_test
authorVitaly Kuznetsov <vkuznets@redhat.com>
Tue, 9 Jan 2024 14:11:17 +0000 (15:11 +0100)
committerSean Christopherson <seanjc@google.com>
Thu, 1 Feb 2024 16:58:13 +0000 (08:58 -0800)
commite440c5f2e3e6893aeb39bbba6dd181207840a795
tree35263d862a14f9c0790b1799d6efbbd00a7841a0
parentc2a449a30fa2b5ddc1dd058e92e047157c9eeb9e
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>
tools/testing/selftests/kvm/include/test_util.h
tools/testing/selftests/kvm/include/x86_64/processor.h
tools/testing/selftests/kvm/lib/test_util.c
tools/testing/selftests/kvm/lib/x86_64/processor.c
tools/testing/selftests/kvm/x86_64/kvm_clock_test.c