提交 3fb999e2 编写于 作者: P Peter Krempa

tests: monitor: Rename qemuMonitorReportError to qemuMonitorTestAddErrorResponse

It's a method of the test monitor and it adds a response to the monitor
output. The original qemuMonitorTestAddErrorResponse method is renamed
to qemuMonitorTestAddErrorResponseInternal
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 f8d6b319
...@@ -413,7 +413,7 @@ qemuAgentShutdownTestMonitorHandler(qemuMonitorTestPtr test, ...@@ -413,7 +413,7 @@ qemuAgentShutdownTestMonitorHandler(qemuMonitorTestPtr test,
return -1; return -1;
if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) { if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) {
ret = qemuMonitorReportError(test, "Missing command name in %s", cmdstr); ret = qemuMonitorTestAddErrorResponse(test, "Missing command name in %s", cmdstr);
goto cleanup; goto cleanup;
} }
...@@ -424,20 +424,20 @@ qemuAgentShutdownTestMonitorHandler(qemuMonitorTestPtr test, ...@@ -424,20 +424,20 @@ qemuAgentShutdownTestMonitorHandler(qemuMonitorTestPtr test,
} }
if (!(args = virJSONValueObjectGet(val, "arguments"))) { if (!(args = virJSONValueObjectGet(val, "arguments"))) {
ret = qemuMonitorReportError(test, ret = qemuMonitorTestAddErrorResponse(test,
"Missing arguments section"); "Missing arguments section");
goto cleanup; goto cleanup;
} }
if (!(mode = virJSONValueObjectGetString(args, "mode"))) { if (!(mode = virJSONValueObjectGetString(args, "mode"))) {
ret = qemuMonitorReportError(test, "Missing shutdown mode"); ret = qemuMonitorTestAddErrorResponse(test, "Missing shutdown mode");
goto cleanup; goto cleanup;
} }
if (STRNEQ(mode, data->mode)) { if (STRNEQ(mode, data->mode)) {
ret = qemuMonitorReportError(test, ret = qemuMonitorTestAddErrorResponse(test,
"expected shutdown mode '%s' got '%s'", "expected shutdown mode '%s' got '%s'",
data->mode, mode); data->mode, mode);
goto cleanup; goto cleanup;
} }
......
...@@ -122,8 +122,8 @@ qemuMonitorTestAddResponse(qemuMonitorTestPtr test, ...@@ -122,8 +122,8 @@ qemuMonitorTestAddResponse(qemuMonitorTestPtr test,
static int static int
qemuMonitorTestAddErrorResponse(qemuMonitorTestPtr test, qemuMonitorTestAddErrorResponseInternal(qemuMonitorTestPtr test,
const char *usermsg) const char *usermsg)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
g_autofree char *escapemsg = NULL; g_autofree char *escapemsg = NULL;
...@@ -161,7 +161,7 @@ qemuMonitorTestAddUnexpectedErrorResponse(qemuMonitorTestPtr test, ...@@ -161,7 +161,7 @@ qemuMonitorTestAddUnexpectedErrorResponse(qemuMonitorTestPtr test,
msg = g_strdup_printf("unexpected command: '%s'", command); msg = g_strdup_printf("unexpected command: '%s'", command);
return qemuMonitorTestAddErrorResponse(test, msg); return qemuMonitorTestAddErrorResponseInternal(test, msg);
} }
...@@ -175,12 +175,12 @@ qemuMonitorTestAddInvalidCommandResponse(qemuMonitorTestPtr test, ...@@ -175,12 +175,12 @@ qemuMonitorTestAddInvalidCommandResponse(qemuMonitorTestPtr test,
msg = g_strdup_printf("expected command '%s' got '%s'", expectedcommand, msg = g_strdup_printf("expected command '%s' got '%s'", expectedcommand,
actualcommand); actualcommand);
return qemuMonitorTestAddErrorResponse(test, msg); return qemuMonitorTestAddErrorResponseInternal(test, msg);
} }
int G_GNUC_PRINTF(2, 3) int G_GNUC_PRINTF(2, 3)
qemuMonitorReportError(qemuMonitorTestPtr test, const char *errmsg, ...) qemuMonitorTestAddErrorResponse(qemuMonitorTestPtr test, const char *errmsg, ...)
{ {
va_list msgargs; va_list msgargs;
g_autofree char *msg = NULL; g_autofree char *msg = NULL;
...@@ -527,9 +527,9 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test, ...@@ -527,9 +527,9 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test,
if (virQEMUQAPISchemaPathGet(schemapath, test->qapischema, &schemaroot) < 0 || if (virQEMUQAPISchemaPathGet(schemapath, test->qapischema, &schemaroot) < 0 ||
!schemaroot) { !schemaroot) {
if (qemuMonitorReportError(test, if (qemuMonitorTestAddErrorResponse(test,
"command '%s' not found in QAPI schema", "command '%s' not found in QAPI schema",
cmdname) == 0) cmdname) == 0)
return 1; return 1;
return -1; return -1;
} }
...@@ -546,11 +546,11 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test, ...@@ -546,11 +546,11 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test,
cmdname, NULLSTR(argstr), virBufferCurrentContent(&debug)); cmdname, NULLSTR(argstr), virBufferCurrentContent(&debug));
} }
if (qemuMonitorReportError(test, if (qemuMonitorTestAddErrorResponse(test,
"failed to validate arguments of '%s' " "failed to validate arguments of '%s' "
"against QAPI schema " "against QAPI schema "
"(to see debug output use VIR_TEST_DEBUG=2)", "(to see debug output use VIR_TEST_DEBUG=2)",
cmdname) == 0) cmdname) == 0)
return 1; return 1;
return -1; return -1;
} }
...@@ -574,7 +574,7 @@ qemuMonitorTestProcessCommandDefault(qemuMonitorTestPtr test, ...@@ -574,7 +574,7 @@ qemuMonitorTestProcessCommandDefault(qemuMonitorTestPtr test,
return -1; return -1;
if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) if (!(cmdname = virJSONValueObjectGetString(val, "execute")))
return qemuMonitorReportError(test, "Missing command name in %s", cmdstr); return qemuMonitorTestAddErrorResponse(test, "Missing command name in %s", cmdstr);
cmdargs = virJSONValueObjectGet(val, "arguments"); cmdargs = virJSONValueObjectGet(val, "arguments");
if ((rc = qemuMonitorTestProcessCommandDefaultValidate(test, cmdname, cmdargs)) < 0) if ((rc = qemuMonitorTestProcessCommandDefaultValidate(test, cmdname, cmdargs)) < 0)
...@@ -648,7 +648,7 @@ qemuMonitorTestProcessCommandVerbatim(qemuMonitorTestPtr test, ...@@ -648,7 +648,7 @@ qemuMonitorTestProcessCommandVerbatim(qemuMonitorTestPtr test,
if (data->cmderr) { if (data->cmderr) {
errmsg = g_strdup_printf("%s: %s", data->cmderr, cmdstr); errmsg = g_strdup_printf("%s: %s", data->cmderr, cmdstr);
ret = qemuMonitorTestAddErrorResponse(test, errmsg); ret = qemuMonitorTestAddErrorResponseInternal(test, errmsg);
} else { } else {
ret = qemuMonitorTestAddInvalidCommandResponse(test, ret = qemuMonitorTestAddInvalidCommandResponse(test,
data->command_name, data->command_name,
...@@ -718,7 +718,7 @@ qemuMonitorTestProcessGuestAgentSync(qemuMonitorTestPtr test, ...@@ -718,7 +718,7 @@ qemuMonitorTestProcessGuestAgentSync(qemuMonitorTestPtr test,
return -1; return -1;
if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) { if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) {
ret = qemuMonitorReportError(test, "Missing guest-sync command name"); ret = qemuMonitorTestAddErrorResponse(test, "Missing guest-sync command name");
goto cleanup; goto cleanup;
} }
...@@ -728,12 +728,12 @@ qemuMonitorTestProcessGuestAgentSync(qemuMonitorTestPtr test, ...@@ -728,12 +728,12 @@ qemuMonitorTestProcessGuestAgentSync(qemuMonitorTestPtr test,
} }
if (!(args = virJSONValueObjectGet(val, "arguments"))) { if (!(args = virJSONValueObjectGet(val, "arguments"))) {
ret = qemuMonitorReportError(test, "Missing arguments for guest-sync"); ret = qemuMonitorTestAddErrorResponse(test, "Missing arguments for guest-sync");
goto cleanup; goto cleanup;
} }
if (virJSONValueObjectGetNumberUlong(args, "id", &id)) { if (virJSONValueObjectGetNumberUlong(args, "id", &id)) {
ret = qemuMonitorReportError(test, "Missing id for guest sync"); ret = qemuMonitorTestAddErrorResponse(test, "Missing id for guest sync");
goto cleanup; goto cleanup;
} }
...@@ -782,7 +782,7 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test, ...@@ -782,7 +782,7 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
return -1; return -1;
if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) { if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) {
ret = qemuMonitorReportError(test, "Missing command name in %s", cmdstr); ret = qemuMonitorTestAddErrorResponse(test, "Missing command name in %s", cmdstr);
goto cleanup; goto cleanup;
} }
...@@ -794,9 +794,9 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test, ...@@ -794,9 +794,9 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
} }
if (!(args = virJSONValueObjectGet(val, "arguments"))) { if (!(args = virJSONValueObjectGet(val, "arguments"))) {
ret = qemuMonitorReportError(test, ret = qemuMonitorTestAddErrorResponse(test,
"Missing arguments section for command '%s'", "Missing arguments section for command '%s'",
NULLSTR(data->command_name)); NULLSTR(data->command_name));
goto cleanup; goto cleanup;
} }
...@@ -804,10 +804,10 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test, ...@@ -804,10 +804,10 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
for (i = 0; i < data->nargs; i++) { for (i = 0; i < data->nargs; i++) {
qemuMonitorTestCommandArgsPtr arg = &data->args[i]; qemuMonitorTestCommandArgsPtr arg = &data->args[i];
if (!(argobj = virJSONValueObjectGet(args, arg->argname))) { if (!(argobj = virJSONValueObjectGet(args, arg->argname))) {
ret = qemuMonitorReportError(test, ret = qemuMonitorTestAddErrorResponse(test,
"Missing argument '%s' for command '%s'", "Missing argument '%s' for command '%s'",
arg->argname, arg->argname,
NULLSTR(data->command_name)); NULLSTR(data->command_name));
goto cleanup; goto cleanup;
} }
...@@ -817,13 +817,13 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test, ...@@ -817,13 +817,13 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
/* verify that the argument value is expected */ /* verify that the argument value is expected */
if (STRNEQ(argstr, arg->argval)) { if (STRNEQ(argstr, arg->argval)) {
ret = qemuMonitorReportError(test, ret = qemuMonitorTestAddErrorResponse(test,
"Invalid value of argument '%s' " "Invalid value of argument '%s' "
"of command '%s': " "of command '%s': "
"expected '%s' got '%s'", "expected '%s' got '%s'",
arg->argname, arg->argname,
NULLSTR(data->command_name), NULLSTR(data->command_name),
arg->argval, argstr); arg->argval, argstr);
goto cleanup; goto cleanup;
} }
...@@ -908,7 +908,7 @@ qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTestPtr test, ...@@ -908,7 +908,7 @@ qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTestPtr test,
return -1; return -1;
if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) { if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) {
ret = qemuMonitorReportError(test, "Missing command name in %s", cmdstr); ret = qemuMonitorTestAddErrorResponse(test, "Missing command name in %s", cmdstr);
goto cleanup; goto cleanup;
} }
...@@ -919,9 +919,9 @@ qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTestPtr test, ...@@ -919,9 +919,9 @@ qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTestPtr test,
} }
if (!(args = virJSONValueObjectGet(val, "arguments"))) { if (!(args = virJSONValueObjectGet(val, "arguments"))) {
ret = qemuMonitorReportError(test, ret = qemuMonitorTestAddErrorResponse(test,
"Missing arguments section for command '%s'", "Missing arguments section for command '%s'",
data->command_name); data->command_name);
goto cleanup; goto cleanup;
} }
...@@ -931,10 +931,10 @@ qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTestPtr test, ...@@ -931,10 +931,10 @@ qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTestPtr test,
/* verify that the argument value is expected */ /* verify that the argument value is expected */
if (STRNEQ(argstr, data->expectArgs)) { if (STRNEQ(argstr, data->expectArgs)) {
ret = qemuMonitorReportError(test, ret = qemuMonitorTestAddErrorResponse(test,
"%s: expected arguments: '%s', got: '%s'", "%s: expected arguments: '%s', got: '%s'",
data->command_name, data->command_name,
data->expectArgs, argstr); data->expectArgs, argstr);
goto cleanup; goto cleanup;
} }
......
...@@ -47,7 +47,7 @@ int qemuMonitorTestAddInvalidCommandResponse(qemuMonitorTestPtr test, ...@@ -47,7 +47,7 @@ int qemuMonitorTestAddInvalidCommandResponse(qemuMonitorTestPtr test,
void *qemuMonitorTestItemGetPrivateData(qemuMonitorTestItemPtr item); void *qemuMonitorTestItemGetPrivateData(qemuMonitorTestItemPtr item);
int qemuMonitorReportError(qemuMonitorTestPtr test, const char *errmsg, ...); int qemuMonitorTestAddErrorResponse(qemuMonitorTestPtr test, const char *errmsg, ...);
int qemuMonitorTestAddItem(qemuMonitorTestPtr test, int qemuMonitorTestAddItem(qemuMonitorTestPtr test,
const char *command_name, const char *command_name,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册