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:pwd@foo:80/b?c=d");
    test("gluster+tcp://user:pwd@foo: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