On Tue, Aug 04, 2015 at 11:37:59 +0200, Andrea Bolognani wrote:
Fix a test case that was wrongly expected to fail as well.
---
tests/cputest.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/tests/cputest.c b/tests/cputest.c
index 06b3f12..5b7de0f 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -273,13 +273,8 @@ cpuTestGuestData(const void *arg)
guest->match = VIR_CPU_MATCH_EXACT;
guest->fallback = cpu->fallback;
if (cpuDecode(guest, guestData, data->models,
- data->nmodels, data->preferred) < 0) {
- if (data->result < 0) {
- virResetLastError();
- ret = 0;
- }
+ data->nmodels, data->preferred) < 0)
goto cleanup;
- }
virBufferAsprintf(&buf, "%s+%s", data->host, data->name);
if (data->nmodels)
@@ -302,6 +297,19 @@ cpuTestGuestData(const void *arg)
virCPUDefFree(host);
virCPUDefFree(cpu);
virCPUDefFree(guest);
+
+ if (data->result < 0) {
+ virResetLastError();
+ if (ret < 0) {
+ ret = 0;
+ } else {
+ VIR_TEST_VERBOSE("\n%-70s... ",
+ "cpuGuestData/cpuDecode was expected "
+ "to fail but it succeeded");
+ ret = -1;
+ }
+ }
+
This would apply to any failure, but when, e.g., loading the XML files
or memory allocation fails, we want to fail the test even if it was
expected to fail. This conditional statement should only be applied when
cpuDecode or cpuGuestData fails.
Jirka