diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/check-qjson.c | 11 | ||||
-rw-r--r-- | tests/qemu-iotests/051.out | 8 | ||||
-rw-r--r-- | tests/test-hbitmap.c | 38 | ||||
-rw-r--r-- | tests/test-opts-visitor.c | 3 | ||||
-rw-r--r-- | tests/test-qemu-opts.c | 2 | ||||
-rw-r--r-- | tests/test-qmp-event.c | 4 | ||||
-rw-r--r-- | tests/test-qmp-output-visitor.c | 6 |
7 files changed, 52 insertions, 20 deletions
diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 60e5b22a98..1cfffa5934 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -1013,7 +1013,7 @@ static void keyword_literal(void) g_assert(qobject_type(obj) == QTYPE_QBOOL); qbool = qobject_to_qbool(obj); - g_assert(qbool_get_int(qbool) != 0); + g_assert(qbool_get_bool(qbool) == true); str = qobject_to_json(obj); g_assert(strcmp(qstring_get_str(str), "true") == 0); @@ -1026,7 +1026,7 @@ static void keyword_literal(void) g_assert(qobject_type(obj) == QTYPE_QBOOL); qbool = qobject_to_qbool(obj); - g_assert(qbool_get_int(qbool) == 0); + g_assert(qbool_get_bool(qbool) == false); str = qobject_to_json(obj); g_assert(strcmp(qstring_get_str(str), "false") == 0); @@ -1039,16 +1039,17 @@ static void keyword_literal(void) g_assert(qobject_type(obj) == QTYPE_QBOOL); qbool = qobject_to_qbool(obj); - g_assert(qbool_get_int(qbool) == 0); + g_assert(qbool_get_bool(qbool) == false); QDECREF(qbool); - obj = qobject_from_jsonf("%i", true); + /* Test that non-zero values other than 1 get collapsed to true */ + obj = qobject_from_jsonf("%i", 2); g_assert(obj != NULL); g_assert(qobject_type(obj) == QTYPE_QBOOL); qbool = qobject_to_qbool(obj); - g_assert(qbool_get_int(qbool) != 0); + g_assert(qbool_get_bool(qbool) == true); QDECREF(qbool); diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out index 652dd63bf8..23c282357c 100644 --- a/tests/qemu-iotests/051.out +++ b/tests/qemu-iotests/051.out @@ -52,7 +52,6 @@ QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=qcow2,format=qcow2: Cannot specif Testing: -device virtio-scsi-pci -device scsi-hd QEMU X.Y.Z monitor - type 'help' for more information (qemu) QEMU_PROG: -device scsi-hd: drive property not set -QEMU_PROG: -device scsi-hd: Device 'scsi-hd' could not be initialized === Overriding backing file === @@ -128,7 +127,6 @@ QEMU_PROG: Initialization of device ide-hd failed: Device initialization failed. Testing: -drive if=virtio QEMU X.Y.Z monitor - type 'help' for more information (qemu) QEMU_PROG: -drive if=virtio: Device needs media, but drive is empty -QEMU_PROG: -drive if=virtio: Device 'virtio-blk-pci' could not be initialized Testing: -drive if=scsi QEMU X.Y.Z monitor - type 'help' for more information @@ -146,23 +144,19 @@ Testing: -drive if=none,id=disk -device ide-drive,drive=disk QEMU X.Y.Z monitor - type 'help' for more information (qemu) QEMU_PROG: -device ide-drive,drive=disk: Device needs media, but drive is empty QEMU_PROG: -device ide-drive,drive=disk: Device initialization failed. -QEMU_PROG: -device ide-drive,drive=disk: Device 'ide-drive' could not be initialized Testing: -drive if=none,id=disk -device ide-hd,drive=disk QEMU X.Y.Z monitor - type 'help' for more information (qemu) QEMU_PROG: -device ide-hd,drive=disk: Device needs media, but drive is empty QEMU_PROG: -device ide-hd,drive=disk: Device initialization failed. -QEMU_PROG: -device ide-hd,drive=disk: Device 'ide-hd' could not be initialized Testing: -drive if=none,id=disk -device lsi53c895a -device scsi-disk,drive=disk QEMU X.Y.Z monitor - type 'help' for more information (qemu) QEMU_PROG: -device scsi-disk,drive=disk: Device needs media, but drive is empty -QEMU_PROG: -device scsi-disk,drive=disk: Device 'scsi-disk' could not be initialized Testing: -drive if=none,id=disk -device lsi53c895a -device scsi-hd,drive=disk QEMU X.Y.Z monitor - type 'help' for more information (qemu) QEMU_PROG: -device scsi-hd,drive=disk: Device needs media, but drive is empty -QEMU_PROG: -device scsi-hd,drive=disk: Device 'scsi-hd' could not be initialized === Read-only === @@ -204,13 +198,11 @@ Testing: -drive file=TEST_DIR/t.qcow2,if=none,id=disk,readonly=on -device ide-dr QEMU X.Y.Z monitor - type 'help' for more information (qemu) QEMU_PROG: -device ide-drive,drive=disk: Can't use a read-only drive QEMU_PROG: -device ide-drive,drive=disk: Device initialization failed. -QEMU_PROG: -device ide-drive,drive=disk: Device 'ide-drive' could not be initialized Testing: -drive file=TEST_DIR/t.qcow2,if=none,id=disk,readonly=on -device ide-hd,drive=disk QEMU X.Y.Z monitor - type 'help' for more information (qemu) QEMU_PROG: -device ide-hd,drive=disk: Can't use a read-only drive QEMU_PROG: -device ide-hd,drive=disk: Device initialization failed. -QEMU_PROG: -device ide-hd,drive=disk: Device 'ide-hd' could not be initialized Testing: -drive file=TEST_DIR/t.qcow2,if=none,id=disk,readonly=on -device lsi53c895a -device scsi-disk,drive=disk QEMU X.Y.Z monitor - type 'help' for more information diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c index 9f41b5fd2e..161eeb496d 100644 --- a/tests/test-hbitmap.c +++ b/tests/test-hbitmap.c @@ -184,6 +184,23 @@ static void hbitmap_test_reset(TestHBitmapData *data, } } +static void hbitmap_test_reset_all(TestHBitmapData *data) +{ + size_t n; + + hbitmap_reset_all(data->hb); + + n = (data->size + BITS_PER_LONG - 1) / BITS_PER_LONG; + if (n == 0) { + n = 1; + } + memset(data->bits, 0, n * sizeof(unsigned long)); + + if (data->granularity == 0) { + hbitmap_test_check(data, 0); + } +} + static void hbitmap_test_check_get(TestHBitmapData *data) { uint64_t count = 0; @@ -364,6 +381,26 @@ static void test_hbitmap_reset(TestHBitmapData *data, hbitmap_test_set(data, L3 / 2, L3); } +static void test_hbitmap_reset_all(TestHBitmapData *data, + const void *unused) +{ + hbitmap_test_init(data, L3 * 2, 0); + hbitmap_test_set(data, L1 - 1, L1 + 2); + hbitmap_test_reset_all(data); + hbitmap_test_set(data, 0, L1 * 3); + hbitmap_test_reset_all(data); + hbitmap_test_set(data, L2, L1); + hbitmap_test_reset_all(data); + hbitmap_test_set(data, L2, L3 - L2 + 1); + hbitmap_test_reset_all(data); + hbitmap_test_set(data, L3 - 1, 3); + hbitmap_test_reset_all(data); + hbitmap_test_set(data, 0, L3 * 2); + hbitmap_test_reset_all(data); + hbitmap_test_set(data, L3 / 2, L3); + hbitmap_test_reset_all(data); +} + static void test_hbitmap_granularity(TestHBitmapData *data, const void *unused) { @@ -627,6 +664,7 @@ int main(int argc, char **argv) hbitmap_test_add("/hbitmap/set/overlap", test_hbitmap_set_overlap); hbitmap_test_add("/hbitmap/reset/empty", test_hbitmap_reset_empty); hbitmap_test_add("/hbitmap/reset/general", test_hbitmap_reset); + hbitmap_test_add("/hbitmap/reset/all", test_hbitmap_reset_all); hbitmap_test_add("/hbitmap/granularity", test_hbitmap_granularity); hbitmap_test_add("/hbitmap/truncate/nop", test_hbitmap_truncate_nop); diff --git a/tests/test-opts-visitor.c b/tests/test-opts-visitor.c index ebeee5d589..1c753d9824 100644 --- a/tests/test-opts-visitor.c +++ b/tests/test-opts-visitor.c @@ -39,7 +39,8 @@ setup_fixture(OptsVisitorFixture *f, gconstpointer test_data) QemuOpts *opts; OptsVisitor *ov; - opts = qemu_opts_parse(qemu_find_opts("userdef"), opts_string, 0); + opts = qemu_opts_parse(qemu_find_opts("userdef"), opts_string, false, + NULL); g_assert(opts != NULL); ov = opts_visitor_new(opts); diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c index da564923d0..0c1136d1b2 100644 --- a/tests/test-qemu-opts.c +++ b/tests/test-qemu-opts.c @@ -323,7 +323,7 @@ static void test_qemu_opt_unset(void) int ret; /* dynamically initialized (parsed) opts */ - opts = qemu_opts_parse(&opts_list_03, "key=value", 0); + opts = qemu_opts_parse(&opts_list_03, "key=value", false, NULL); g_assert(opts != NULL); /* check default/parsed value */ diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index cb354e6e81..1ee40e148a 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -60,8 +60,8 @@ void qdict_cmp_do_simple(const char *key, QObject *obj1, void *opaque) switch (qobject_type(obj1)) { case QTYPE_QBOOL: - d->result = (qbool_get_int(qobject_to_qbool(obj1)) == - qbool_get_int(qobject_to_qbool(obj2))); + d->result = (qbool_get_bool(qobject_to_qbool(obj1)) == + qbool_get_bool(qobject_to_qbool(obj2))); return; case QTYPE_QINT: d->result = (qint_get_int(qobject_to_qint(obj1)) == diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c index f8c9367e48..87ba350b43 100644 --- a/tests/test-qmp-output-visitor.c +++ b/tests/test-qmp-output-visitor.c @@ -72,7 +72,7 @@ static void test_visitor_out_bool(TestOutputVisitorData *data, obj = qmp_output_get_qobject(data->qov); g_assert(obj != NULL); g_assert(qobject_type(obj) == QTYPE_QBOOL); - g_assert(qbool_get_int(qobject_to_qbool(obj)) == value); + g_assert(qbool_get_bool(qobject_to_qbool(obj)) == value); qobject_decref(obj); } @@ -223,7 +223,7 @@ static void test_visitor_out_struct(TestOutputVisitorData *data, qdict = qobject_to_qdict(obj); g_assert_cmpint(qdict_size(qdict), ==, 3); g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, 42); - g_assert_cmpint(qdict_get_bool(qdict, "boolean"), ==, 0); + g_assert_cmpint(qdict_get_bool(qdict, "boolean"), ==, false); g_assert_cmpstr(qdict_get_str(qdict, "string"), ==, "foo"); QDECREF(qdict); @@ -662,7 +662,7 @@ static void check_native_list(QObject *qobj, tmp = qlist_peek(qlist); g_assert(tmp); qvalue = qobject_to_qbool(tmp); - g_assert_cmpint(qbool_get_int(qvalue), ==, (i % 3 == 0) ? 1 : 0); + g_assert_cmpint(qbool_get_bool(qvalue), ==, i % 3 == 0); qobject_decref(qlist_pop(qlist)); } break; |