Re: [PATCH 1/7] Introduce a new set of helper macros for mocking symbols

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/12/2014 07:21 AM, Daniel P. Berrange wrote:
> Introduce virmock.h which provides some macros to assist in
> creation of LD_PRELOAD overrides. When these are used, the
> LD_PRELOAD code simply has some stubs which forward to a
> wrapper function inside the main test case. This means that
> logic for the test no longer has to be split between the
> virXXXtest.c and virXXXmock.c files. It will also make it
> possible to provide some common reusable modules for mocking
> code like DBus.
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  tests/Makefile.am |   3 +-
>  tests/virmock.h   | 298 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 300 insertions(+), 1 deletion(-)
>  create mode 100644 tests/virmock.h
> 
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 3267ad3..459e104 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -123,7 +123,8 @@ EXTRA_DIST =		\
>  	xml2sexprdata \
>  	xml2vmxdata \
>  	vmwareverdata \
> -	.valgrind.supp
> +	.valgrind.supp \
> +	virmock.h

Unusual sorting, and maybe a chance to add $(NULL) to this list.


> +
> +# define VIR_MOCK_COUNT_ARGS(...) VIR_MOCK_ARG21(__VA_ARGS__, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
> +# define VIR_MOCK_ARG21(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, ...) _21
> +# define VIR_MOCK_ARG_PASTE(a, b, ...) a##b(__VA_ARGS__)

Long lines - worth using \-newline breaks?

> +/*
> + * The VIR_MOCK_LINK_NNN_MMM() macros are intended for use in
> + * LD_PRELOAD based wrappers. They provide a replacement for
> + * for an existing shared library symbol export. They will
> + * then lookup the same symbol name but with 'wrap_' prefixed
> + * on it, and call that.
> + *
> + * The actual test suite should provide the implemention of

s/implemention/implementation/

> +/**
> + * VIR_MOCK_LINK_RET_ARGS:

Are you missing VIR_MOCK_LINK_VOID_VOID?

ACK.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]