flags, result \
}; \
g_autofree char *testLabel = NULL; \
- \
- g_free(virTestLogContentAndReset());\
\
testLabel = g_strdup_printf("%s(%s): %s", #api, \
virArchToString(arch), name); \
\
- if (virTestRun(testLabel, api, &data) < 0) { \
- if (virTestGetDebug()) { \
- char *log; \
- if ((log = virTestLogContentAndReset()) && \
- strlen(log) > 0) \
- VIR_TEST_DEBUG("\n%s", log); \
- VIR_FREE(log); \
- } \
- ret = -1; \
- } \
- \
+ virTestRunLog(&ret, testLabel, api, &data); \
} while (0)
#define DO_TEST_COMPARE(arch, host, cpu, result) \
}
+/*
+ * A wrapper for virTestRun that resets the log content before each run
+ * and sets ret to -1 on failure. On success, ret is untouched.
+ */
+void
+virTestRunLog(int *ret,
+ const char *title,
+ int (*body)(const void *data),
+ const void *data)
+{
+ int rc;
+
+ g_free(virTestLogContentAndReset());
+
+ rc = virTestRun(title, body, data);
+
+ if (rc >= 0)
+ return;
+
+ *ret = -1;
+
+ if (virTestGetDebug()) {
+ g_autofree char *log = virTestLogContentAndReset();
+
+ if (strlen(log) > 0)
+ VIR_TEST_DEBUG("\n%s", log);
+ }
+}
+
+
/**
* virTestLoadFile:
* @file: name of the file to load
int virTestRun(const char *title,
int (*body)(const void *data),
const void *data);
+void virTestRunLog(int *ret,
+ const char *title,
+ int (*body)(const void *data),
+ const void *data);
int virTestLoadFile(const char *file, char **buf);
char *virTestLoadFilePath(const char *p, ...)
G_GNUC_NULL_TERMINATED;