[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 41/42] tests/qtest/arm-cpu-features: Add feature setting tests
From: |
Peter Maydell |
Subject: |
[PULL 41/42] tests/qtest/arm-cpu-features: Add feature setting tests |
Date: |
Tue, 23 Jun 2020 12:39:03 +0100 |
From: Andrew Jones <drjones@redhat.com>
Some cpu features may be enabled and disabled for all configurations
that support the feature. Let's test that.
A recent regression[*] inspired adding these tests.
[*] '-cpu host,pmu=on' caused a segfault
Signed-off-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200623090622.30365-2-philmd@redhat.com
Message-Id: <20200623082310.17577-1-drjones@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
tests/qtest/arm-cpu-features.c | 38 ++++++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
index 46921736766..f7e062c1891 100644
--- a/tests/qtest/arm-cpu-features.c
+++ b/tests/qtest/arm-cpu-features.c
@@ -159,16 +159,35 @@ static bool resp_get_feature(QDict *resp, const char
*feature)
qobject_unref(_resp); \
})
-#define assert_feature(qts, cpu_type, feature, expected_value) \
+#define resp_assert_feature(resp, feature, expected_value) \
({ \
- QDict *_resp, *_props; \
+ QDict *_props; \
\
- _resp = do_query_no_props(qts, cpu_type); \
g_assert(_resp); \
g_assert(resp_has_props(_resp)); \
_props = resp_get_props(_resp); \
g_assert(qdict_get(_props, feature)); \
g_assert(qdict_get_bool(_props, feature) == (expected_value)); \
+})
+
+#define assert_feature(qts, cpu_type, feature, expected_value) \
+({ \
+ QDict *_resp; \
+ \
+ _resp = do_query_no_props(qts, cpu_type); \
+ g_assert(_resp); \
+ resp_assert_feature(_resp, feature, expected_value); \
+ qobject_unref(_resp); \
+})
+
+#define assert_set_feature(qts, cpu_type, feature, value) \
+({ \
+ const char *_fmt = (value) ? "{ %s: true }" : "{ %s: false }"; \
+ QDict *_resp; \
+ \
+ _resp = do_query(qts, cpu_type, _fmt, feature); \
+ g_assert(_resp); \
+ resp_assert_feature(_resp, feature, value); \
qobject_unref(_resp); \
})
@@ -424,10 +443,14 @@ static void test_query_cpu_model_expansion(const void
*data)
assert_error(qts, "host", "The CPU type 'host' requires KVM", NULL);
/* Test expected feature presence/absence for some cpu types */
- assert_has_feature_enabled(qts, "max", "pmu");
assert_has_feature_enabled(qts, "cortex-a15", "pmu");
assert_has_not_feature(qts, "cortex-a15", "aarch64");
+ /* Enabling and disabling pmu should always work. */
+ assert_has_feature_enabled(qts, "max", "pmu");
+ assert_set_feature(qts, "max", "pmu", false);
+ assert_set_feature(qts, "max", "pmu", true);
+
assert_has_not_feature(qts, "max", "kvm-no-adjvtime");
if (g_str_equal(qtest_get_arch(), "aarch64")) {
@@ -464,7 +487,10 @@ static void test_query_cpu_model_expansion_kvm(const void
*data)
return;
}
+ /* Enabling and disabling kvm-no-adjvtime should always work. */
assert_has_feature_disabled(qts, "host", "kvm-no-adjvtime");
+ assert_set_feature(qts, "host", "kvm-no-adjvtime", true);
+ assert_set_feature(qts, "host", "kvm-no-adjvtime", false);
if (g_str_equal(qtest_get_arch(), "aarch64")) {
bool kvm_supports_sve;
@@ -475,7 +501,11 @@ static void test_query_cpu_model_expansion_kvm(const void
*data)
char *error;
assert_has_feature_enabled(qts, "host", "aarch64");
+
+ /* Enabling and disabling pmu should always work. */
assert_has_feature_enabled(qts, "host", "pmu");
+ assert_set_feature(qts, "host", "pmu", false);
+ assert_set_feature(qts, "host", "pmu", true);
assert_error(qts, "cortex-a15",
"We cannot guarantee the CPU type 'cortex-a15' works "
--
2.20.1
- [PULL 27/42] hw/i2c/versatile_i2c: Add definitions for register addresses, (continued)
- [PULL 27/42] hw/i2c/versatile_i2c: Add definitions for register addresses, Peter Maydell, 2020/06/23
- [PULL 30/42] hw/arm: Use TYPE_VERSATILE_I2C instead of hardcoded string, Peter Maydell, 2020/06/23
- [PULL 29/42] hw/i2c: Add header for ARM SBCon two-wire serial bus interface, Peter Maydell, 2020/06/23
- [PULL 31/42] hw/arm/mps2: Document CMSDK/FPGA APB subsystem sections, Peter Maydell, 2020/06/23
- [PULL 34/42] hw/arm/mps2: Add CMSDK AHB GPIO peripherals as unimplemented devices, Peter Maydell, 2020/06/23
- [PULL 36/42] hw/arm/mps2: Add SPI devices, Peter Maydell, 2020/06/23
- [PULL 37/42] hw/arm/mps2: Add I2C devices, Peter Maydell, 2020/06/23
- [PULL 32/42] hw/arm/mps2: Rename CMSDK AHB peripheral region, Peter Maydell, 2020/06/23
- [PULL 38/42] hw/arm/mps2: Add audio I2S interface as unimplemented device, Peter Maydell, 2020/06/23
- [PULL 39/42] hw/arm/mps2-tz: Use the ARM SBCon two-wire serial bus interface, Peter Maydell, 2020/06/23
- [PULL 41/42] tests/qtest/arm-cpu-features: Add feature setting tests,
Peter Maydell <=
- [PULL 40/42] target/arm: Check supported KVM features globally (not per vCPU), Peter Maydell, 2020/06/23
- [PULL 35/42] hw/arm/mps2: Map the FPGA I/O block, Peter Maydell, 2020/06/23
- [PULL 42/42] arm/virt: Add memory hot remove support, Peter Maydell, 2020/06/23
- [PULL 33/42] hw/arm/mps2: Add CMSDK APB watchdog device, Peter Maydell, 2020/06/23
- Re: [PULL 00/42] target-arm queue, no-reply, 2020/06/23
- Re: [PULL 00/42] target-arm queue, Peter Maydell, 2020/06/24