Re: [PATCH 2/3] tests: eventtest: Open code virtTestResult

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

 



On 09/30/2015 01:38 AM, Martin Kletzander wrote:
> On Tue, Sep 29, 2015 at 07:56:46PM -0400, Cole Robinson wrote:
>> These event tests aren't run synchronously, so there isn't an obvious
>> function to pass to virtTestRun. Instead, open code roughly what
>> virtTestResult did before: printing an error message if a test failed.
>> ---
>> tests/eventtest.c | 57 +++++++++++++++++++++++++++++++++++++++++++++----------
>> 1 file changed, 47 insertions(+), 10 deletions(-)
>>
>> diff --git a/tests/eventtest.c b/tests/eventtest.c
>> index 13adbf6..ab08181 100644
>> --- a/tests/eventtest.c
>> +++ b/tests/eventtest.c
>> @@ -63,6 +63,43 @@ enum {
>>     EV_ERROR_DATA,
>> };
>>
>> +struct testEventResultData {
>> +    bool failed;
>> +    const char *msg;
>> +};
>> +
>> +static int
>> +testEventResultCallback(const void *opaque)
>> +{
>> +    const struct testEventResultData *data = opaque;
>> +
>> +    if (data->failed && data->msg) {
>> +        fprintf(stderr, "%s", data->msg);
>> +    }
>> +    return data->failed;
>> +}
>> +
>> +static void
>> +ATTRIBUTE_FMT_PRINTF(3,4)
>> +testEventReport(const char *name, bool failed, const char *msg, ...)
>> +{
>> +    va_list vargs;
>> +    va_start(vargs, msg);
>> +    char *str = NULL;
>> +    struct testEventResultData data;
>> +
>> +    if (msg && virVasprintfQuiet(&str, msg, vargs) != 0) {
>> +        failed = true;
>> +    }
>> +
>> +    data.failed = failed;
>> +    data.msg = msg;
> 
> I think you meant data.msg = str; here.
> 
> ACK with that changed and your amendment squashed in.
> 

Changed locally, thanks for the review. I'll push after the release

> P.S.: If you'd really like, I think this test could be made to use
> virTestRun as well ;)

Maybe for another patch :)

- Cole

--
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]