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 [email protected] +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/libvir-list
