diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2020-11-03 06:57:46 -0500 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2020-11-04 12:00:02 -0500 |
commit | e27bd4987699df5f49a03e93cf57941abeb82938 (patch) | |
tree | 7a972946615210c7a0c1f375a11101a1609fa49e | |
parent | 794b95608f8d92189baba697a7d6072e94ed2e0e (diff) | |
download | qemu-e27bd4987699df5f49a03e93cf57941abeb82938.zip qemu-e27bd4987699df5f49a03e93cf57941abeb82938.tar.gz qemu-e27bd4987699df5f49a03e93cf57941abeb82938.tar.bz2 |
qtest: escape device name in device-introspect-test
device-introspect-test uses HMP, so it should escape the device name
properly. Because of this, a few devices that had commas in their
names were escaping testing.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | tests/qtest/device-introspect-test.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/qtest/device-introspect-test.c b/tests/qtest/device-introspect-test.c index 9f22340..bbec166 100644 --- a/tests/qtest/device-introspect-test.c +++ b/tests/qtest/device-introspect-test.c @@ -104,7 +104,8 @@ static QList *device_type_list(QTestState *qts, bool abstract) static void test_one_device(QTestState *qts, const char *type) { QDict *resp; - char *help; + char *help, *escaped; + GRegex *comma; g_test_message("Testing device '%s'", type); @@ -113,8 +114,13 @@ static void test_one_device(QTestState *qts, const char *type) type); qobject_unref(resp); - help = qtest_hmp(qts, "device_add \"%s,help\"", type); + comma = g_regex_new(",", 0, 0, NULL); + escaped = g_regex_replace_literal(comma, type, -1, 0, ",,", 0, NULL); + g_regex_unref(comma); + + help = qtest_hmp(qts, "device_add \"%s,help\"", escaped); g_free(help); + g_free(escaped); } static void test_device_intro_list(void) |