qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v10 3/5] qemu: URI parsing library


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v10 3/5] qemu: URI parsing library
Date: Fri, 28 Sep 2012 11:47:13 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1

Il 28/09/2012 10:39, Daniel P. Berrange ha scritto:
>>> > > IMHO, you should also be importing the URI code test suite from libvirt
>>> > > to verify that the way you merged/changed the codebases did not break
>>> > > anything.
>> > 
>> > Yes, can be done separately though.
> In this case I disagree.  The URI parsing code here is complex enough that
> I don't think any reviewer can credibly claim to spot flaws that might
> have been introduced when combing the libvirt + libxml2 URI code parts.
> A test suite is the only way to validate this kind of complex code IMHO
> and so should be included in this patch.

The libvirt testsuite has ~10 testcases for URI, one of them for
IPv6-specific behavior that is not part of uri.c, and 13 for parsing
query parameters.  At least for the URI part, this would be false safety.

FWIW, this is what I had "tested" the code with:

void test(const char *x)
{
    URI *uri = uri_parse(x);
    QueryParams *qp;
    char *out;

    if (!uri) {
        printf ("INVALID: %s\n", x);
        return;
    }

    /* Escape the parameters.  */
    qp = query_params_parse(uri->query);
    g_free(uri->query);
    uri->query = query_params_to_string(qp);
    query_params_free(qp);

    out = uri_to_string(uri);
    uri_free(uri);
    printf("VALID: %s\n", out);
    g_free(out);
}

int main()
{
    test("gluster+unix:///b?c=d");
    test("gluster+tcp://user:address@hidden:80/b?c=d");
    test("gluster+tcp://user:address@hidden:8b0/b?c=d");
    test("http://a/b?c=d";);
    test("http://a/b?c=/d/e";);
    test("http://a/b?c=/d/e&f";);
    test("http://a/b?c=/d/e&f=&&ggg";);
    return 0;
}

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]