qdev-monitor-test: Simplify using g_assert_cmpstr()
Use g_assert_cmpstr() instead of combining g_assert() and strcmp(3). This simplifies the code since we no longer have to play games to distinguish NULL from "" using "(null)". gcc extension haters will also be happy that ?: was dropped. Suggested-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
1b8601b0ea
commit
a3d7cbc139
|
@ -32,8 +32,9 @@ static void test_device_add(void)
|
||||||
"}}");
|
"}}");
|
||||||
g_assert(response);
|
g_assert(response);
|
||||||
error = qdict_get_qdict(response, "error");
|
error = qdict_get_qdict(response, "error");
|
||||||
g_assert(!strcmp(qdict_get_try_str(error, "desc") ?: "",
|
g_assert_cmpstr(qdict_get_try_str(error, "desc"),
|
||||||
"Device needs media, but drive is empty"));
|
==,
|
||||||
|
"Device needs media, but drive is empty");
|
||||||
QDECREF(response);
|
QDECREF(response);
|
||||||
|
|
||||||
/* Delete the drive */
|
/* Delete the drive */
|
||||||
|
@ -42,7 +43,7 @@ static void test_device_add(void)
|
||||||
" \"command-line\": \"drive_del drive0\""
|
" \"command-line\": \"drive_del drive0\""
|
||||||
"}}");
|
"}}");
|
||||||
g_assert(response);
|
g_assert(response);
|
||||||
g_assert(!strcmp(qdict_get_try_str(response, "return") ?: "(null)", ""));
|
g_assert_cmpstr(qdict_get_try_str(response, "return"), ==, "");
|
||||||
QDECREF(response);
|
QDECREF(response);
|
||||||
|
|
||||||
/* Try to re-add the drive. This fails with duplicate IDs if a leaked
|
/* Try to re-add the drive. This fails with duplicate IDs if a leaked
|
||||||
|
@ -53,8 +54,7 @@ static void test_device_add(void)
|
||||||
" \"command-line\": \"drive_add pci-addr=auto if=none,id=drive0\""
|
" \"command-line\": \"drive_add pci-addr=auto if=none,id=drive0\""
|
||||||
"}}");
|
"}}");
|
||||||
g_assert(response);
|
g_assert(response);
|
||||||
g_assert(!strcmp(qdict_get_try_str(response, "return") ?: "",
|
g_assert_cmpstr(qdict_get_try_str(response, "return"), ==, "OK\r\n");
|
||||||
"OK\r\n"));
|
|
||||||
QDECREF(response);
|
QDECREF(response);
|
||||||
|
|
||||||
qtest_end();
|
qtest_end();
|
||||||
|
|
Loading…
Reference in a new issue