aboutsummaryrefslogtreecommitdiff
path: root/tests/qom-test.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2014-06-13 09:35:18 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2014-07-01 10:20:41 +0200
commit563890c7c7e977842e2a35afe7a24d06d2103242 (patch)
tree284a26ca2bcd81b2e0abada9e9838c2be325086c /tests/qom-test.c
parent8ffad850ef5ae14287d0e185d478c9a35820482c (diff)
libqtest: escape strings in QMP commands, fix leak
libqtest is using g_strdup_printf to format QMP commands, but this does not work if the argument strings need to be escaped. Instead, use the fancy %-formatting functionality of QObject. The only change required in tests is that strings have to be formatted as %s, not '%s' or \"%s\". Luckily this usage of parameterized QMP commands is not that frequent. The leak is in socket_sendf. Since we are extracting the send loop to a new function, fix it now. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/qom-test.c')
-rw-r--r--tests/qom-test.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/qom-test.c b/tests/qom-test.c
index d8d1d8d9ff..4246382d38 100644
--- a/tests/qom-test.c
+++ b/tests/qom-test.c
@@ -53,7 +53,7 @@ static void test_properties(const char *path, bool recurse)
g_test_message("Obtaining properties of %s", path);
response = qmp("{ 'execute': 'qom-list',"
- " 'arguments': { 'path': '%s' } }", path);
+ " 'arguments': { 'path': %s } }", path);
g_assert(response);
if (!recurse) {
@@ -76,8 +76,8 @@ static void test_properties(const char *path, bool recurse)
const char *prop = qdict_get_str(tuple, "name");
g_test_message("Testing property %s.%s", path, prop);
response = qmp("{ 'execute': 'qom-get',"
- " 'arguments': { 'path': '%s',"
- " 'property': '%s' } }",
+ " 'arguments': { 'path': %s,"
+ " 'property': %s } }",
path, prop);
/* qom-get may fail but should not, e.g., segfault. */
g_assert(response);