libvirt/0002-tests-Better-support-f...

76 lines
3.4 KiB
Diff

From 71ed29bb54143829ae46abcee9539e42c80d0d40 Mon Sep 17 00:00:00 2001
Message-Id: <71ed29bb54143829ae46abcee9539e42c80d0d40.1391110483.git.crobinso@redhat.com>
In-Reply-To: <844476f1f21fc3ea4d13aa3ea01ac56a155432a8.1391110483.git.crobinso@redhat.com>
References: <844476f1f21fc3ea4d13aa3ea01ac56a155432a8.1391110483.git.crobinso@redhat.com>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 28 Jan 2014 00:00:44 +0100
Subject: [PATCH 2/5] tests: Better support for
VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES
https://bugzilla.redhat.com/show_bug.cgi?id=1049391
virConnectBaselineCPU test results are now stored in different files
depending on VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES.
(cherry picked from commit 0e9373a5c04e5c69a95b6d1cae7cad8456332be7)
---
tests/cputest.c | 22 +++++++++++++++++++---
...ne-3-result.xml => x86-baseline-3-expanded.xml} | 0
2 files changed, 19 insertions(+), 3 deletions(-)
rename tests/cputestdata/{x86-baseline-3-result.xml => x86-baseline-3-expanded.xml} (100%)
diff --git a/tests/cputest.c b/tests/cputest.c
index 408a510..9bc786b 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -326,6 +326,7 @@ cpuTestBaseline(const void *arg)
virCPUDefPtr baseline = NULL;
unsigned int ncpus = 0;
char *result = NULL;
+ const char *suffix;
size_t i;
if (!(cpus = cpuTestLoadMultiXML(data->arch, data->name, &ncpus)))
@@ -345,7 +346,11 @@ cpuTestBaseline(const void *arg)
if (!baseline)
goto cleanup;
- if (virAsprintf(&result, "%s-result", data->name) < 0)
+ if (data->flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES)
+ suffix = "expanded";
+ else
+ suffix = "result";
+ if (virAsprintf(&result, "%s-%s", data->name, suffix) < 0)
goto cleanup;
if (cpuTestCompareXML(data->arch, baseline, result, 0) < 0)
@@ -537,8 +542,19 @@ mymain(void)
} while (0)
#define DO_TEST_BASELINE(arch, name, flags, result) \
- DO_TEST(arch, API_BASELINE, name, NULL, "baseline-" name, \
- NULL, 0, NULL, flags, result)
+ do { \
+ const char *suffix = ""; \
+ char *label; \
+ if ((flags) & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) \
+ suffix = " (expanded)"; \
+ if (virAsprintf(&label, "%s%s", name, suffix) < 0) { \
+ ret = -1; \
+ } else { \
+ DO_TEST(arch, API_BASELINE, label, NULL, "baseline-" name, \
+ NULL, 0, NULL, flags, result); \
+ } \
+ VIR_FREE(label); \
+ } while (0)
#define DO_TEST_HASFEATURE(arch, host, feature, result) \
DO_TEST(arch, API_HAS_FEATURE, \
diff --git a/tests/cputestdata/x86-baseline-3-result.xml b/tests/cputestdata/x86-baseline-3-expanded.xml
similarity index 100%
rename from tests/cputestdata/x86-baseline-3-result.xml
rename to tests/cputestdata/x86-baseline-3-expanded.xml
--
1.8.5.3