diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/qtest/ahci-test.c | 1 | ||||
-rw-r--r-- | tests/qtest/drive_del-test.c | 2 | ||||
-rw-r--r-- | tests/qtest/ipmi-kcs-test.c | 3 | ||||
-rw-r--r-- | tests/qtest/libqos/libqtest.h | 4 | ||||
-rw-r--r-- | tests/qtest/libqtest.c | 2 | ||||
-rw-r--r-- | tests/qtest/qmp-cmd-test.c | 16 | ||||
-rw-r--r-- | tests/qtest/qmp-test.c | 32 | ||||
-rw-r--r-- | tests/qtest/tpm-tests.c | 4 | ||||
-rw-r--r-- | tests/qtest/tpm-util.c | 10 | ||||
-rw-r--r-- | tests/test-qga.c | 2 |
10 files changed, 39 insertions, 37 deletions
diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c index ca4294f..5e19548 100644 --- a/tests/qtest/ahci-test.c +++ b/tests/qtest/ahci-test.c @@ -1443,6 +1443,7 @@ static int prepare_iso(size_t size, unsigned char **buf, char **name) ssize_t ret; int fd = mkstemp(cdrom_path); + g_assert(fd != -1); g_assert(buf); g_assert(name); patt = g_malloc(size); diff --git a/tests/qtest/drive_del-test.c b/tests/qtest/drive_del-test.c index 2ab11ad..2d76586 100644 --- a/tests/qtest/drive_del-test.c +++ b/tests/qtest/drive_del-test.c @@ -103,7 +103,7 @@ static void test_after_failed_device_add(void) " 'drive': 'drive0'" "}}", driver); g_assert(response); - qmp_assert_error_class(response, "GenericError"); + qmp_expect_error_and_unref(response, "GenericError"); /* Delete the drive */ drive_del(qts); diff --git a/tests/qtest/ipmi-kcs-test.c b/tests/qtest/ipmi-kcs-test.c index 693a6aa..fc0a918 100644 --- a/tests/qtest/ipmi-kcs-test.c +++ b/tests/qtest/ipmi-kcs-test.c @@ -81,7 +81,8 @@ static void kcs_wait_obf(void) { unsigned int count = 1000; while (IPMI_KCS_CMDREG_GET_OBF() == 0) { - g_assert(--count != 0); + --count; + g_assert(count != 0); } } diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h index f5cf93c..a6ee165 100644 --- a/tests/qtest/libqos/libqtest.h +++ b/tests/qtest/libqos/libqtest.h @@ -704,13 +704,13 @@ void qtest_qmp_device_del(QTestState *qts, const char *id); bool qmp_rsp_is_err(QDict *rsp); /** - * qmp_assert_error_class: + * qmp_expect_error_and_unref: * @rsp: QMP response to check for error * @class: an error class * * Assert the response has the given error class and discard @rsp. */ -void qmp_assert_error_class(QDict *rsp, const char *class); +void qmp_expect_error_and_unref(QDict *rsp, const char *class); /** * qtest_probe_child: diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 26f1223..58f58e1 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1359,7 +1359,7 @@ bool qmp_rsp_is_err(QDict *rsp) return !!error; } -void qmp_assert_error_class(QDict *rsp, const char *class) +void qmp_expect_error_and_unref(QDict *rsp, const char *class) { QDict *error = qdict_get_qdict(rsp, "error"); diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index f34e688..3109a9f 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -210,19 +210,19 @@ static void test_object_add_failure_modes(void) resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':" " {'qom-type': 'memory-backend-ram', 'id': 'ram1' } }"); g_assert_nonnull(resp); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); /* attempt to create an object without qom-type */ resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':" " {'id': 'ram1' } }"); g_assert_nonnull(resp); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); /* attempt to delete an object that does not exist */ resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':" " {'id': 'ram1' } }"); g_assert_nonnull(resp); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); /* attempt to create 2 objects with duplicate id */ resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':" @@ -236,7 +236,7 @@ static void test_object_add_failure_modes(void) " {'qom-type': 'memory-backend-ram', 'id': 'ram1'," " 'props': {'size': 1048576 } } }"); g_assert_nonnull(resp); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); /* delete ram1 object */ resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':" @@ -251,7 +251,7 @@ static void test_object_add_failure_modes(void) " 'props': {'size': '1048576' } } }"); g_assert_nonnull(resp); /* now do it right */ - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':" " {'qom-type': 'memory-backend-ram', 'id': 'ram1'," @@ -272,7 +272,7 @@ static void test_object_add_failure_modes(void) " {'qom-type': 'memory-backend-ram'," " 'props': {'size': 1048576 } } }"); g_assert_nonnull(resp); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); /* now do it right */ resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':" @@ -294,7 +294,7 @@ static void test_object_add_failure_modes(void) " {'qom-type': 'memory-backend-ram', 'id': 'ram1'," " 'props': {'sized': 1048576 } } }"); g_assert_nonnull(resp); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); /* now do it right */ resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':" @@ -321,7 +321,7 @@ static void test_object_add_failure_modes(void) resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':" " {'id': 'ram1' } }"); g_assert_nonnull(resp); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); qtest_quit(qts); } diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c index 5950c3e..e1032c5 100644 --- a/tests/qtest/qmp-test.c +++ b/tests/qtest/qmp-test.c @@ -38,7 +38,7 @@ static void assert_recovered(QTestState *qts) QDict *resp; resp = qtest_qmp(qts, "{ 'execute': 'no-such-cmd' }"); - qmp_assert_error_class(resp, "CommandNotFound"); + qmp_expect_error_and_unref(resp, "CommandNotFound"); } static void test_malformed(QTestState *qts) @@ -48,58 +48,58 @@ static void test_malformed(QTestState *qts) /* syntax error */ qtest_qmp_send_raw(qts, "{]\n"); resp = qtest_qmp_receive(qts); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); assert_recovered(qts); /* lexical error: impossible byte outside string */ qtest_qmp_send_raw(qts, "{\xFF"); resp = qtest_qmp_receive(qts); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); assert_recovered(qts); /* lexical error: funny control character outside string */ qtest_qmp_send_raw(qts, "{\x01"); resp = qtest_qmp_receive(qts); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); assert_recovered(qts); /* lexical error: impossible byte in string */ qtest_qmp_send_raw(qts, "{'bad \xFF"); resp = qtest_qmp_receive(qts); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); assert_recovered(qts); /* lexical error: control character in string */ qtest_qmp_send_raw(qts, "{'execute': 'nonexistent', 'id':'\n"); resp = qtest_qmp_receive(qts); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); assert_recovered(qts); /* lexical error: interpolation */ qtest_qmp_send_raw(qts, "%%p"); resp = qtest_qmp_receive(qts); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); assert_recovered(qts); /* Not even a dictionary */ resp = qtest_qmp(qts, "null"); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); /* No "execute" key */ resp = qtest_qmp(qts, "{}"); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); /* "execute" isn't a string */ resp = qtest_qmp(qts, "{ 'execute': true }"); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); /* "arguments" isn't a dictionary */ resp = qtest_qmp(qts, "{ 'execute': 'no-such-cmd', 'arguments': [] }"); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); /* extra key */ resp = qtest_qmp(qts, "{ 'execute': 'no-such-cmd', 'extra': true }"); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); } static void test_qmp_protocol(void) @@ -121,7 +121,7 @@ static void test_qmp_protocol(void) /* Test valid command before handshake */ resp = qtest_qmp(qts, "{ 'execute': 'query-version' }"); - qmp_assert_error_class(resp, "CommandNotFound"); + qmp_expect_error_and_unref(resp, "CommandNotFound"); /* Test malformed commands before handshake */ test_malformed(qts); @@ -134,7 +134,7 @@ static void test_qmp_protocol(void) /* Test repeated handshake */ resp = qtest_qmp(qts, "{ 'execute': 'qmp_capabilities' }"); - qmp_assert_error_class(resp, "CommandNotFound"); + qmp_expect_error_and_unref(resp, "CommandNotFound"); /* Test valid command */ resp = qtest_qmp(qts, "{ 'execute': 'query-version' }"); @@ -154,7 +154,7 @@ static void test_qmp_protocol(void) /* Test command failure with 'id' */ resp = qtest_qmp(qts, "{ 'execute': 'human-monitor-command', 'id': 2 }"); g_assert_cmpint(qdict_get_int(resp, "id"), ==, 2); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); qtest_quit(qts); } @@ -327,7 +327,7 @@ static void test_qmp_missing_any_arg(void) resp = qtest_qmp(qts, "{'execute': 'qom-set', 'arguments':" " { 'path': '/machine', 'property': 'rtc-time' } }"); g_assert_nonnull(resp); - qmp_assert_error_class(resp, "GenericError"); + qmp_expect_error_and_unref(resp, "GenericError"); qtest_quit(qts); } diff --git a/tests/qtest/tpm-tests.c b/tests/qtest/tpm-tests.c index a2f2838..70c80f8 100644 --- a/tests/qtest/tpm-tests.c +++ b/tests/qtest/tpm-tests.c @@ -59,7 +59,7 @@ void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx, tpm_util_startup(s, tx); tpm_util_pcrextend(s, tx); - unsigned char tpm_pcrread_resp[] = + static const unsigned char tpm_pcrread_resp[] = "\x80\x01\x00\x00\x00\x3e\x00\x00\x00\x00\x00\x00\x00\x16\x00\x00" "\x00\x01\x00\x0b\x03\x00\x04\x00\x00\x00\x00\x01\x00\x20\xf6\x85" "\x98\xe5\x86\x8d\xe6\x8b\x97\x29\x99\x60\xf2\x71\x7d\x17\x67\x89" @@ -107,7 +107,7 @@ void tpm_test_swtpm_migration_test(const char *src_tpm_path, tpm_util_startup(src_qemu, tx); tpm_util_pcrextend(src_qemu, tx); - unsigned char tpm_pcrread_resp[] = + static const unsigned char tpm_pcrread_resp[] = "\x80\x01\x00\x00\x00\x3e\x00\x00\x00\x00\x00\x00\x00\x16\x00\x00" "\x00\x01\x00\x0b\x03\x00\x04\x00\x00\x00\x00\x01\x00\x20\xf6\x85" "\x98\xe5\x86\x8d\xe6\x8b\x97\x29\x99\x60\xf2\x71\x7d\x17\x67\x89" diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c index e2b29ef..3ed6c85 100644 --- a/tests/qtest/tpm-util.c +++ b/tests/qtest/tpm-util.c @@ -98,9 +98,9 @@ void tpm_util_tis_transfer(QTestState *s, void tpm_util_startup(QTestState *s, tx_func *tx) { unsigned char buffer[1024]; - unsigned char tpm_startup[] = + static const unsigned char tpm_startup[] = "\x80\x01\x00\x00\x00\x0c\x00\x00\x01\x44\x00\x00"; - unsigned char tpm_startup_resp[] = + static const unsigned char tpm_startup_resp[] = "\x80\x01\x00\x00\x00\x0a\x00\x00\x00\x00"; tx(s, tpm_startup, sizeof(tpm_startup), buffer, sizeof(buffer)); @@ -112,14 +112,14 @@ void tpm_util_startup(QTestState *s, tx_func *tx) void tpm_util_pcrextend(QTestState *s, tx_func *tx) { unsigned char buffer[1024]; - unsigned char tpm_pcrextend[] = + static const unsigned char tpm_pcrextend[] = "\x80\x02\x00\x00\x00\x41\x00\x00\x01\x82\x00\x00\x00\x0a\x00\x00" "\x00\x09\x40\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00" "\x0b\x74\x65\x73\x74\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00"; - unsigned char tpm_pcrextend_resp[] = + static const unsigned char tpm_pcrextend_resp[] = "\x80\x02\x00\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x01\x00\x00"; @@ -133,7 +133,7 @@ void tpm_util_pcrread(QTestState *s, tx_func *tx, const unsigned char *exp_resp, size_t exp_resp_size) { unsigned char buffer[1024]; - unsigned char tpm_pcrread[] = + static const unsigned char tpm_pcrread[] = "\x80\x01\x00\x00\x00\x14\x00\x00\x01\x7e\x00\x00\x00\x01\x00\x0b" "\x03\x00\x04\x00"; diff --git a/tests/test-qga.c b/tests/test-qga.c index 4ac4c22..65d7992 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -246,7 +246,7 @@ static void test_qga_invalid_oob(gconstpointer fix) ret = qmp_fd(fixture->fd, "{'exec-oob': 'guest-ping'}"); g_assert_nonnull(ret); - qmp_assert_error_class(ret, "GenericError"); + qmp_expect_error_and_unref(ret, "GenericError"); } static void test_qga_invalid_args(gconstpointer fix) |