]> git.ipfire.org Git - thirdparty/libvirt.git/commit
tests: monitor: json: Fix error message when returning json in json
authorPeter Krempa <pkrempa@redhat.com>
Tue, 3 Jun 2014 15:12:48 +0000 (17:12 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Jun 2014 15:19:24 +0000 (17:19 +0200)
commit9046f910bdb3f7fc3a3777eb7feda1c07108d698
treee11fd6039ca35ddf8d10e601893fce99abc93525
parent23c2763b4fe1820375e51d52813845dfe4657056
tests: monitor: json: Fix error message when returning json in json

The qemu JSON monitor test allows to test also expected command
arguments. As the error from the monitor simulator is returned as a
simulated qemu error (in JSON) all other JSON contained in the error
message needs to be escaped. This will happen if the monitor command
under test receives a JSON array as an argument.

This will improve the error message from:
libvirt:  error : internal error: cannot parse json { "error":  { "desc":
"Invalid value of argument 'keys' of command 'send-key': expected 'ble'
got '[{"type":"number","data":43},{"type":"number","data":26},
{"type":"number","data":46},{"type":"number","data":32}]'",
"class": "UnexpectedCommand" } }: lexical error: invalid string in json text.

To:
libvirt: QEMU Driver error : internal error: unable to execute QEMU
command 'send-key': Invalid value of argument 'keys' of command
'send-key': expected 'ble' got '[{"type":"number","data":43},
{"type":"number","data":26},{"type":"number","data":46},
{"type":"number","data":32}]'

This improvement will not have any effect on tests executing as
expected, but it will help test development.
tests/qemumonitortestutils.c