[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 4/7] tests: Add QOM property unit tests
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH 4/7] tests: Add QOM property unit tests |
Date: |
Fri, 25 Sep 2015 08:58:12 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 09/25/2015 06:39 AM, Andreas Färber wrote:
> Add a test for parsing and setting a uint64 property.
>
> Signed-off-by: Andreas Färber <address@hidden>
> ---
> MAINTAINERS | 1 +
> tests/Makefile | 3 ++
> tests/check-qom-props.c | 120
> ++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 124 insertions(+)
> create mode 100644 tests/check-qom-props.c
>
> +static void test_dummy_uint64(void)
> +{
> + Error *err = NULL;
> + char *str;
> + DummyObject *dobj = DUMMY_OBJECT(object_new(TYPE_DUMMY));
> +
> + g_assert(dobj->u64val == 0);
> +
> + str = g_strdup_printf("%" PRIu64, UINT64_MAX);
> + object_property_parse(OBJECT(dobj), str, "u64val", &err);
> + g_free(str);
> + g_assert(!err);
Use &error_abort, then you don't need the g_assert(!err).
> + g_assert_cmpint(dobj->u64val, ==, UINT64_MAX);
> +
> + dobj->u64val = 0;
> + str = g_strdup_printf("0x%" PRIx64, UINT64_MAX);
> + object_property_parse(OBJECT(dobj), str, "u64val", &err);
> + g_free(str);
> + g_assert(!err);
> + g_assert_cmpint(dobj->u64val, ==, UINT64_MAX);
> +
> + object_unref(OBJECT(dobj));
As with other patches in this series, intentionally testing the behavior
of -1, and of (ULLONG_MAX+1), would be good.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH 0/7] visitor: Fix uint64 parsing for scsi-disk wwn, Andreas Färber, 2015/09/25
- [Qemu-devel] [PATCH 3/7] test-string-input-visitor: Add uint64 test, Andreas Färber, 2015/09/25
- [Qemu-devel] [PATCH 7/7] string-input-visitor: Use qemu_strto[u]ll(), Andreas Färber, 2015/09/25
- [Qemu-devel] [PATCH 2/7] test-string-input-visitor: Add int test case, Andreas Färber, 2015/09/25
- [Qemu-devel] [PATCH 1/7] string-input-visitor: Fix uint64 parsing, Andreas Färber, 2015/09/25
- [Qemu-devel] [PATCH 5/7] tests: Add scsi-disk test, Andreas Färber, 2015/09/25
- [Qemu-devel] [PATCH 4/7] tests: Add QOM property unit tests, Andreas Färber, 2015/09/25
- [Qemu-devel] [PATCH 6/7] cutils: Normalize qemu_strto[u]ll() signature, Andreas Färber, 2015/09/25
Re: [Qemu-devel] [PATCH 6/7] cutils: Normalize qemu_strto[u]ll() signature, Eric Blake, 2015/09/25