Re: [PATCH v3 2/2] virnetdevbandwidthtest: Introduce testVirNetDevBandwidthSet

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

 



On 01/28/2014 07:37 PM, Michal Privoznik wrote:
> The test tries to set some QoS limits and check if the commands
> that are actually executed are the expected ones.
> 
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  tests/virnetdevbandwidthtest.c | 76 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 76 insertions(+)
> 
> diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c
> index 989018e..044decd 100644
> --- a/tests/virnetdevbandwidthtest.c
> +++ b/tests/virnetdevbandwidthtest.c
> @@ -104,6 +112,48 @@ cleanup:
>  }
>  
>  static int
> +testVirNetDevBandwidthSet(const void *data)
> +{
> +    int ret = -1;
> +    const struct testSetStruct *info = data;
> +    const char *iface = info->iface;
> +    virNetDevBandwidthPtr band = NULL;
> +    virBuffer buf = VIR_BUFFER_INITIALIZER;
> +    char *actual_cmd = NULL;
> +
> +    PARSE(info->band, band);
> +
> +    if (!iface)
> +        iface = "eth0";
> +
> +    virCommandSetDryRun(&buf);
> +
> +    if (virNetDevBandwidthSet(iface, band, info->hierarchical_class) < 0)
> +        goto cleanup;
> +
> +    if (!(actual_cmd = virBufferContentAndReset(&buf))) {
> +        int err = virBufferError(&buf);
> +        if (err) {
> +            fprintf(stderr, "buffer's in error state: %d", err);
> +            goto cleanup;
> +        }
> +        /* This is interesting, no command has been executed.
> +         * Maybe that's expected, actually. */
> +    }
> +
> +    if (STRNEQ_NULLABLE(info->exp_cmd, actual_cmd)) {
> +        virtTestDifference(stderr, info->exp_cmd, actual_cmd);
> +        goto cleanup;
> +    }
> +
> +    ret = 0;
> +cleanup:

if virNetDevBandwidthSet executes some commands but fails, you should
virBufferFreeAndReset(&buf)
here

> +    virNetDevBandwidthFree(band);
> +    VIR_FREE(actual_cmd);
> +    return ret;
> +}
> +
> +static int
>  mymain(void)
>  {
>      int ret = 0;


ACK

Jan

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]