[libvirt] [RFC PATCH 6/6] tests: Use virBitmap for qemu command line caps
Eric Blake
eblake at redhat.com
Wed Feb 9 17:33:01 UTC 2011
On 02/09/2011 09:02 AM, Jiri Denemark wrote:
> This needs to be squashed into the previous patch but is provided
> separately for easier review.
> ---
> src/qemu/qemu_capabilities.c | 14 +
> src/qemu/qemu_capabilities.h | 2 +
> tests/qemuhelptest.c | 727 +++++++++++++++++++++---------------------
> tests/qemuxml2argvtest.c | 468 ++++++++++++++--------------
> 4 files changed, 617 insertions(+), 594 deletions(-)
>
> void
> +qemuCapsSetList(virBitmapPtr caps, ...)
> +{
> + va_list list;
> + int flag;
> +
> + va_start(list, caps);
> + while ((flag = va_arg(list, int)) < QEMU_CAPS_LAST)
> + ignore_value(virBitmapSetBit(caps, flag));
> + va_end(list);
QEMU_CAPS_LAST as a terminal seems a bit awkward. Would it be any
better to require 0 to be the terminal? Then again, since it would be 0
and not NULL, we can't use ATTRIBUTE_SENTINEL as a compile-time aid that
we remembered to use the sentinel.
> @@ -124,364 +137,358 @@ mymain(int argc, char **argv)
> if (!abs_srcdir)
> abs_srcdir = getcwd(cwd, sizeof(cwd));
>
> -# define DO_TEST(name, flags, version, is_kvm, kvm_version) \
> - do { \
> - const struct testInfo info = { name, flags, version, is_kvm, kvm_version }; \
> - if (virtTestRun("QEMU Help String Parsing " name, \
> - 1, testHelpStrParsing, &info) < 0) \
> - ret = -1; \
> +# define DO_TEST(name, version, is_kvm, kvm_version, ...) \
> + do { \
> + struct testInfo info = { \
> + name, NULL, version, is_kvm, kvm_version \
> + }; \
> + if (!(info.flags = qemuCapsNew())) \
> + return EXIT_FAILURE; \
> + qemuCapsSetList(info.flags, __VA_ARGS__, QEMU_CAPS_LAST); \
And this is a nice trick for encapsulating the sentinel in only one place.
> - DO_TEST("qemu-0.9.1",
> - QEMU_CAPS_KQEMU |
> - QEMU_CAPS_VNC_COLON |
> - QEMU_CAPS_NO_REBOOT |
> - QEMU_CAPS_DRIVE |
> + DO_TEST("qemu-0.9.1", 9001, 0, 0,
> + QEMU_CAPS_KQEMU,
> + QEMU_CAPS_VNC_COLON,
> + QEMU_CAPS_NO_REBOOT,
> + QEMU_CAPS_DRIVE,
> + QEMU_CAPS_NAME);
> + DO_TEST("kvm-74", 9001, 1, 74,
> + QEMU_CAPS_VNC_COLON,
> + QEMU_CAPS_NO_REBOOT,
> + QEMU_CAPS_DRIVE,
> + QEMU_CAPS_DRIVE_BOOT,
> QEMU_CAPS_NAME,
How nice of git to mess up the context. But the change you made looks
obvious.
ACK.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110209/cc4a94b3/attachment-0001.sig>
More information about the libvir-list
mailing list