summaryrefslogtreecommitdiff
path: root/tests/test-x86-cpuid-compat.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2017-06-07 20:35:58 +0400
committerMarkus Armbruster <armbru@redhat.com>2017-06-20 14:31:31 +0200
commit01b2ffcedd94ad7b42bc870e4c6936c87ad03429 (patch)
tree39bbadfbbaa229bfbda245840a256fe0132b2390 /tests/test-x86-cpuid-compat.c
parent58634047b7deeab36e4b07c4744e44d698975561 (diff)
qapi: merge QInt and QFloat in QNum
We would like to use a same QObject type to represent numbers, whether they are int, uint, or floats. Getters will allow some compatibility between the various types if the number fits other representations. Add a few more tests while at it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20170607163635.17635-7-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [parse_stats_intervals() simplified a bit, comment in test_visitor_in_int_overflow() tidied up, suppress bogus warnings] Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'tests/test-x86-cpuid-compat.c')
-rw-r--r--tests/test-x86-cpuid-compat.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c
index 4166ce54b7..58a2dd9fe8 100644
--- a/tests/test-x86-cpuid-compat.c
+++ b/tests/test-x86-cpuid-compat.c
@@ -1,9 +1,8 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
-#include "qapi/qmp/qlist.h"
-#include "qapi/qmp/qstring.h"
+#include "qapi/error.h"
#include "qapi/qmp/qdict.h"
-#include "qapi/qmp/qint.h"
+#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qbool.h"
#include "libqtest.h"
@@ -57,12 +56,14 @@ static void test_cpuid_prop(const void *data)
{
const CpuidTestArgs *args = data;
char *path;
- QInt *value;
+ QNum *value;
+ int64_t val;
qtest_start(args->cmdline);
path = get_cpu0_qom_path();
- value = qobject_to_qint(qom_get(path, args->property));
- g_assert_cmpint(qint_get_int(value), ==, args->expected_value);
+ value = qobject_to_qnum(qom_get(path, args->property));
+ g_assert(qnum_get_try_int(value, &val));
+ g_assert_cmpint(val, ==, args->expected_value);
qtest_end();
QDECREF(value);
@@ -109,12 +110,15 @@ static uint32_t get_feature_word(QList *features, uint32_t eax, uint32_t ecx,
uint32_t reax = qdict_get_int(w, "cpuid-input-eax");
bool has_ecx = qdict_haskey(w, "cpuid-input-ecx");
uint32_t recx = 0;
+ int64_t val;
if (has_ecx) {
recx = qdict_get_int(w, "cpuid-input-ecx");
}
if (eax == reax && (!has_ecx || ecx == recx) && !strcmp(rreg, reg)) {
- return qint_get_int(qobject_to_qint(qdict_get(w, "features")));
+ g_assert(qnum_get_try_int(qobject_to_qnum(qdict_get(w, "features")),
+ &val));
+ return val;
}
}
return 0;