[libvirt] [PATCH 0/3] tests: drop the JSON field from qemuMonitorTest

Ján Tomko (3): tests: assume JSON in qemuMonitorTestIO tests: qemuMonitorTestProcessCommandDefaultValidate: simplify condition tests: qemuMonitorTest: drop the JSON field tests/qemumonitortestutils.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.19.2

The QMP monitor only uses a newline to separate lines, while HMP and the guest agent also use a carriage return. In preparation to dropping support for testing HMP interaction, only skip the carriage return if we're dealing with the guest agent, removing the need to check the 'json' field. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/qemumonitortestutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 85a2fca659..b29c6d0f53 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -296,7 +296,7 @@ qemuMonitorTestIO(virNetSocketPtr sock, */ t1 = test->incoming; while ((t2 = strstr(t1, "\n")) || - (!test->json && (t2 = strstr(t1, "\r")))) { + (test->agent && (t2 = strstr(t1, "\r")))) { *t2 = '\0'; if (qemuMonitorTestProcessCommand(test, t1) < 0) { -- 2.19.2

On Wed, 2019-06-19 at 22:43 +0200, Ján Tomko wrote:
The QMP monitor only uses a newline to separate lines, while HMP and the guest agent also use a carriage return.
In preparation to dropping support for testing HMP interaction, only skip the carriage return if we're dealing with the guest agent, removing the need to check the 'json' field.
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/qemumonitortestutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

We return success when running this function for either non-JSON monitor testing or guest agent testing. However we no longer test HMP monitor and we do not try to validate the guest agent interaction. Drop the test->json check and report a proper error if someone tries to run this function for the guest agent without properly wiring it up. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/qemumonitortestutils.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index b29c6d0f53..9f18e511ac 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -521,9 +521,16 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test, VIR_AUTOPTR(virJSONValue) emptyargs = NULL; VIR_AUTOFREE(char *) schemapath = NULL; - if (!test->qapischema || !test->json || test->agent) + if (!test->qapischema) return 0; + if (test->agent) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + "Command validation testing is not " + "implemented for the guest agent"); + return -1; + } + /* 'device_add' needs to be skipped as it does not have fully defined schema */ if (STREQ(cmdname, "device_add")) return 0; -- 2.19.2

On Wed, 2019-06-19 at 22:43 +0200, Ján Tomko wrote:
We return success when running this function for either non-JSON monitor testing or guest agent testing.
However we no longer test HMP monitor and we do not try to validate the guest agent interaction.
Drop the test->json check and report a proper error if someone tries to run this function for the guest agent without properly wiring it up.
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/qemumonitortestutils.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

Now that we no longer support testing HMP monitor, the json field is pointless. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/qemumonitortestutils.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 9f18e511ac..d395a9b539 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -51,7 +51,6 @@ struct _qemuMonitorTest { virMutex lock; virThread thread; - bool json; bool quit; bool running; bool started; @@ -1189,7 +1188,6 @@ qemuMonitorTestNew(virDomainXMLOptionPtr xmlopt, if (!(test = qemuMonitorCommonTestNew(xmlopt, vm, &src))) goto error; - test->json = true; test->qapischema = schema; if (!(test->mon = qemuMonitorOpen(test->vm, &src, -- 2.19.2

On Wed, 2019-06-19 at 22:43 +0200, Ján Tomko wrote:
Now that we no longer support testing HMP monitor, the json field is pointless.
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/qemumonitortestutils.c | 2 -- 1 file changed, 2 deletions(-)
Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization
participants (2)
-
Andrea Bolognani
-
Ján Tomko