if (!(testMon = qemuMonitorTestNewFromFile(json, driver.xmlopt, true)))
goto error;
+ qemuMonitorTestAllowUnusedCommands(testMon);
+
cpu = virCPUDefNew();
cpu->model = g_strdup("host");
&driver, data->vm, qmpschema)))
goto error;
+ qemuMonitorTestAllowUnusedCommands(data->mon);
+
priv->mon = qemuMonitorTestGetMonitor(data->mon);
virObjectUnlock(priv->mon);
if (!(data.test = qemuMonitorTestNewSchema(xmlopt, schema)))
goto cleanup;
+ qemuMonitorTestAllowUnusedCommands(data.test);
+
if (qemuMonitorTestAddItemExpect(data.test, "chardev-add",
expectargs, true, jsonreply) < 0)
goto cleanup;
bool running;
bool started;
+ bool allowUnusedCommands;
+
char *incoming;
size_t incomingLength;
size_t incomingCapacity;
VIR_FREE(test->incoming);
VIR_FREE(test->outgoing);
- for (i = 0; i < test->nitems; i++)
+ for (i = 0; i < test->nitems; i++) {
+ if (!test->allowUnusedCommands) {
+ g_fprintf(stderr,
+ "\nunused test monitor item '%s'",
+ NULLSTR(test->items[i]->identifier));
+ }
+
qemuMonitorTestItemFree(test->items[i]);
+ }
VIR_FREE(test->items);
if (test->tmpdir && rmdir(test->tmpdir) < 0)
VIR_FREE(test->tmpdir);
+ if (!test->allowUnusedCommands &&
+ test->nitems != 0) {
+ qemuMonitorTestError("unused test monitor items are not allowed for this test\n");
+ }
+
virMutexDestroy(&test->lock);
VIR_FREE(test);
}
}
+/**
+ * qemuMonitorTestAllowUnusedCommands:
+ * @test: test monitor object
+ *
+ * By default all test items/commands must be used by the test. This function
+ * allows to override the requirement for individual tests e.g. if it's necessary
+ * to test some negative scenarios which would not use all commands.
+ */
+void
+qemuMonitorTestAllowUnusedCommands(qemuMonitorTestPtr test)
+{
+ test->allowUnusedCommands = true;
+}
+
+
static int
qemuMonitorTestFullAddItem(qemuMonitorTestPtr test,
const char *filename,
int qemuMonitorTestAddErrorResponse(qemuMonitorTestPtr test, const char *errmsg, ...);
+void qemuMonitorTestAllowUnusedCommands(qemuMonitorTestPtr test);
+
int qemuMonitorTestAddItem(qemuMonitorTestPtr test,
const char *command_name,
const char *response);