Adequate info can help developers quickly distinguish whether the cause
is a code flaw or a platform limitation when a test fails or is skipped,
and this minor patch-set is doing a little work in that direction.
Previous:
https://lore.kernel.org/kvm/[email protected]/
V1 -> V2 Changelog:
- Apply TEST_REQUIRE() to x86_64/vmx_pmu_caps_test as well;
- Put TEST_REQUIRE() at the very top; (Sean)
Like Xu (2):
KVM: selftests: Add a helper to read kvm boolean module parameters
KVM: selftests: Report enable_pmu module value when test is skipped
tools/testing/selftests/kvm/include/kvm_util_base.h | 1 +
tools/testing/selftests/kvm/lib/kvm_util.c | 5 +++++
tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c | 1 +
tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c | 1 +
4 files changed, 8 insertions(+)
base-commit: 13738a3647368f7f600b30d241779bcd2a3ebbfd
--
2.39.2
From: Like Xu <[email protected]>
Running x86_64/pmu_event_filter_test or x86_64/vmx_pmu_caps_test
with enable_pmu globally disabled will report the following into:
1..0 # SKIP - Requirement not met: use_intel_pmu() || use_amd_pmu()
or
1..0 # SKIP - Requirement not met: kvm_cpu_has(X86_FEATURE_PDCM)
this can be confusing, so add a check on kvm.enable_pmu.
Signed-off-by: Like Xu <[email protected]>
---
tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c | 1 +
tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
index 253e4304bbe3..3cd5fc60717f 100644
--- a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
+++ b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
@@ -768,6 +768,7 @@ int main(int argc, char *argv[])
struct kvm_vcpu *vcpu, *vcpu2 = NULL;
struct kvm_vm *vm;
+ TEST_REQUIRE(get_kvm_param_bool("enable_pmu"));
TEST_REQUIRE(kvm_has_cap(KVM_CAP_PMU_EVENT_FILTER));
TEST_REQUIRE(kvm_has_cap(KVM_CAP_PMU_EVENT_MASKED_EVENTS));
diff --git a/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c b/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c
index c280ba1e6572..2933b1bd754e 100644
--- a/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c
+++ b/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c
@@ -55,6 +55,7 @@ int main(int argc, char *argv[])
/* Create VM */
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
+ TEST_REQUIRE(get_kvm_param_bool("enable_pmu"));
TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_PDCM));
TEST_REQUIRE(kvm_cpu_has_p(X86_PROPERTY_PMU_VERSION));
--
2.39.2
From: Like Xu <[email protected]>
Add a helper function for reading kvm boolean module parameters values.
No functional change intended.
Signed-off-by: Like Xu <[email protected]>
---
tools/testing/selftests/kvm/include/kvm_util_base.h | 1 +
tools/testing/selftests/kvm/lib/kvm_util.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h
index fbc2a79369b8..a089c356f354 100644
--- a/tools/testing/selftests/kvm/include/kvm_util_base.h
+++ b/tools/testing/selftests/kvm/include/kvm_util_base.h
@@ -213,6 +213,7 @@ extern const struct vm_guest_mode_params vm_guest_mode_params[];
int open_path_or_exit(const char *path, int flags);
int open_kvm_dev_path_or_exit(void);
+bool get_kvm_param_bool(const char *param);
bool get_kvm_intel_param_bool(const char *param);
bool get_kvm_amd_param_bool(const char *param);
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 56d5ea949cbb..fa6d69f73199 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -80,6 +80,11 @@ static bool get_module_param_bool(const char *module_name, const char *param)
TEST_FAIL("Unrecognized value '%c' for boolean module param", value);
}
+bool get_kvm_param_bool(const char *param)
+{
+ return get_module_param_bool("kvm", param);
+}
+
bool get_kvm_intel_param_bool(const char *param)
{
return get_module_param_bool("kvm_intel", param);
--
2.39.2
On Mon, Mar 13, 2023, Like Xu wrote:
> Adequate info can help developers quickly distinguish whether the cause
> is a code flaw or a platform limitation when a test fails or is skipped,
> and this minor patch-set is doing a little work in that direction.
>
> Previous:
> https://lore.kernel.org/kvm/[email protected]/
>
> V1 -> V2 Changelog:
> - Apply TEST_REQUIRE() to x86_64/vmx_pmu_caps_test as well;
> - Put TEST_REQUIRE() at the very top; (Sean)
Ah fudge, I missed this in my todo list and applied v1. I'll probably just fixup
and force push. One way or another, I'll take care of it.