aboutsummaryrefslogtreecommitdiff
path: root/tests/qtest
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2024-03-05 15:59:15 +0100
committerMarkus Armbruster <armbru@redhat.com>2024-03-12 13:54:01 +0100
commitef6783d3f7d06cf185971afbb30ff35209e9db49 (patch)
tree68d527ae4a59964330e76b1b615c57fab6c65e1a /tests/qtest
parent05ec974671200814fa5c1d5db710e0e4b88a40af (diff)
downloadqemu-ef6783d3f7d06cf185971afbb30ff35209e9db49.zip
qemu-ef6783d3f7d06cf185971afbb30ff35209e9db49.tar.gz
qemu-ef6783d3f7d06cf185971afbb30ff35209e9db49.tar.bz2
target: Simplify type checks for CpuModelInfo member @props
CpuModelInfo member @props is semantically a mapping from name to value, and syntactically a JSON object on the wire. This translates to QDict in C. Since the QAPI schema language lacks the means to express 'object', we use 'any' instead. This is QObject in C. Commands taking a CpuModelInfo argument need to check the QObject is a QDict. For arm, riscv, and s390x, the code checks right before passing the QObject to visit_start_struct(). visit_start_struct() then checks again. Delete the first check. The error message for @props that are not an object changes slightly to the the message we get for this kind of type error in other contexts. Minor improvement. Additionally, error messages about members of @props now refer to 'props.prop-name' instead of just 'prop-name'. Another minor improvement. Both changes are visible in tests/qtest/arm-cpu-features.c. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240305145919.2186971-2-armbru@redhat.com> Acked-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> [Drop #include now superfluous]
Diffstat (limited to 'tests/qtest')
-rw-r--r--tests/qtest/arm-cpu-features.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
index a8a4c66..1daceb2 100644
--- a/tests/qtest/arm-cpu-features.c
+++ b/tests/qtest/arm-cpu-features.c
@@ -79,7 +79,7 @@ static const char *resp_get_error(QDict *resp)
g_assert(_resp); \
_error = resp_get_error(_resp); \
g_assert(_error); \
- g_assert(g_str_equal(_error, expected_error)); \
+ g_assert_cmpstr(_error, ==, expected_error); \
qobject_unref(_resp); \
})
@@ -194,8 +194,8 @@ static void assert_type_full(QTestState *qts)
g_assert(resp);
error = resp_get_error(resp);
g_assert(error);
- g_assert(g_str_equal(error,
- "The requested expansion type is not supported"));
+ g_assert_cmpstr(error, ==,
+ "The requested expansion type is not supported");
qobject_unref(resp);
}
@@ -212,8 +212,8 @@ static void assert_bad_props(QTestState *qts, const char *cpu_type)
g_assert(resp);
error = resp_get_error(resp);
g_assert(error);
- g_assert(g_str_equal(error,
- "Invalid parameter type for 'props', expected: dict"));
+ g_assert_cmpstr(error, ==,
+ "Invalid parameter type for 'props', expected: object");
qobject_unref(resp);
}
@@ -446,7 +446,7 @@ static void test_query_cpu_model_expansion(const void *data)
assert_bad_props(qts, "max");
assert_error(qts, "foo", "The CPU type 'foo' is not a recognized "
"ARM CPU type", NULL);
- assert_error(qts, "max", "Parameter 'not-a-prop' is unexpected",
+ assert_error(qts, "max", "Parameter 'props.not-a-prop' is unexpected",
"{ 'not-a-prop': false }");
assert_error(qts, "host", "The CPU type 'host' requires KVM", NULL);