Re: [PATCH v5 1/6] tests: Add mock for virRandomBytes

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

 



On Thu, May 19, 2016 at 16:29:00 -0400, John Ferlan wrote:
> Create a mock for virRandomBytes to generate a not so random value.
> This should be usable by other tests that need a not so random number
> to be generated by including the virrandommock at preload.
> 
> The "random number" generated is based upon the size of the expected
> stream of bytes being returned where each byte in the result gets
> the index of the array - hence a 4 byte array returns 0x00010203.
> 
> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
> ---
>  tests/Makefile.am     | 12 +++++++
>  tests/virrandommock.c | 39 +++++++++++++++++++++++
>  tests/virrandomtest.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 137 insertions(+)
>  create mode 100644 tests/virrandommock.c
>  create mode 100644 tests/virrandomtest.c

[...]

> diff --git a/tests/virrandomtest.c b/tests/virrandomtest.c
> new file mode 100644
> index 0000000..f76911f
> --- /dev/null
> +++ b/tests/virrandomtest.c
> @@ -0,0 +1,86 @@

[...]

> +
> +    for (i = 0; i < datalen; i++) {
> +        if (data[i] != i) {
> +            fprintf(stderr,
> +                    "virRandomBytes data[%zu]='%x' not in seqence\n"

This is a very amusing test :). Also this is basically meta-testing
since it's testing that the tests test correctly.

> +                    i, data[i]);
> +            goto cleanup;

ACK

Attachment: signature.asc
Description: 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]