[libvirt] [PATCH] Add test suite for viralloc APIs

Ján Tomko jtomko at redhat.com
Mon Apr 14 17:13:57 UTC 2014


On 04/08/2014 04:48 PM, Daniel P. Berrange wrote:
> In debugging a crash on OOM, I thought that the virInsert APIs
> might be at fault, but couldn't isolate them as a cause. While
> the viralloc APIs are used in many test suites, this is as a
> side-effect, they are not directly tested :-)
> 
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
>  tests/Makefile.am    |   5 +
>  tests/viralloctest.c | 387 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 392 insertions(+)
>  create mode 100644 tests/viralloctest.c
> 

> +
> +
> +static int
> +testAllocArray(const void *opaque ATTRIBUTE_UNUSED)
> +{
> +    testDummyStruct *t;
> +    size_t nt = 10, i;
> +    int ret = -1;
> +
> +    if (VIR_ALLOC_N(t, nt) < 0)
> +        return -1;
> +
> +    if (t == NULL) {
> +        fprintf(stderr, "Allocation succeeded by pointer is NULL\n");

s/by pointer/but pointer/ in the whole file

> +        goto cleanup;
> +    }

ACK

Jan


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140414/012ee00a/attachment-0001.sig>


More information about the libvir-list mailing list