From: Jiri Denemark <jdene...@redhat.com> The purpose of this test is to enforce loading and parsing of ARM CPU map so that possible issues are found earlier.
Signed-off-by: Jiri Denemark <jdene...@redhat.com> --- tests/cputest.c | 35 +++++++++++++++++++++++++++++ tests/cputestdata/aarch64-guest.xml | 4 ++++ 2 files changed, 39 insertions(+) create mode 100644 tests/cputestdata/aarch64-guest.xml diff --git a/tests/cputest.c b/tests/cputest.c index 326ffebd09..401021e792 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -408,6 +408,34 @@ cpuTestHasFeature(const void *arg) } +static int +cpuTestValidateFeatures(const void *arg) +{ + const struct data *data = arg; + g_autoptr(virCPUDef) cpu = NULL; + int result; + + if (!(cpu = cpuTestLoadXML(data->arch, data->name))) + return -1; + + result = virCPUValidateFeatures(data->arch, cpu); + + if (data->result == -1) + virResetLastError(); + + if (data->result != result) { + VIR_TEST_VERBOSE("\nExpected result %s, got %s", + cpuTestBoolWithErrorStr(data->result), + cpuTestBoolWithErrorStr(result)); + /* Pad to line up with test name ... in virTestRun */ + VIR_TEST_VERBOSE("%74s", "... "); + return -1; + } + + return 0; +} + + typedef enum { /* No JSON data from QEMU. */ JSON_NONE, @@ -986,6 +1014,10 @@ mymain(void) host "/" feature " (" #result ")", \ host, feature, NULL, 0, NULL, 0, result) +#define DO_TEST_VALIDATEFEATURES(arch, name, result) \ + DO_TEST(arch, cpuTestValidateFeatures, name, \ + NULL, name, NULL, 0, NULL, 0, result) + #define DO_TEST_GUESTCPU(arch, host, cpu, models, result) \ DO_TEST(arch, cpuTestGuestCPU, \ host "/" cpu " (" #models ")", \ @@ -1235,6 +1267,9 @@ mymain(void) "Xeon-E5-2609-v3", "Xeon-E5-2650-v4"); DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64, "Haswell+Skylake", "Xeon-E7-8890-v3", "Xeon-Gold-5115"); + + DO_TEST_VALIDATEFEATURES(VIR_ARCH_AARCH64, "guest", 0); + cleanup: #if WITH_QEMU qemuTestDriverFree(&driver); diff --git a/tests/cputestdata/aarch64-guest.xml b/tests/cputestdata/aarch64-guest.xml new file mode 100644 index 0000000000..163bc66bb5 --- /dev/null +++ b/tests/cputestdata/aarch64-guest.xml @@ -0,0 +1,4 @@ +<cpu mode='custom' match='exact'> + <model fallback='forbid'>cortex-a57</model> + <feature name='pauth' policy='require'/> +</cpu> -- 2.49.0