]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemumonitorjsontest: Validate more commands against schema
authorEric Blake <eblake@redhat.com>
Wed, 12 Jun 2019 01:59:11 +0000 (20:59 -0500)
committerEric Blake <eblake@redhat.com>
Wed, 12 Jun 2019 02:35:24 +0000 (21:35 -0500)
commit4b658bfe4ba53c63e178a1abdfd4b1ad6bd75d8c
tree939db17350426c0c3b0b3e986d7241cc8b170c35
parent09083437ffa45dbe43771ef57f31d9d58dd324b9
qemumonitorjsontest: Validate more commands against schema

The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.

In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.

Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:

| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
|      if (reason)
|          *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| -    if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| +    if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| +                                           "s:garbage", "foo", NULL)))
|          return -1;
|
|      if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)

Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
tests/qemumonitorjsontest.c