提交 4977f19c 编写于 作者: P Peter Krempa

tests: uri: Run all test cases on a single URI

Determine whether the test has failed after running all the cases so
that we don't need to rerun it multiple times to see all problems.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 cd99bcf2
......@@ -51,6 +51,7 @@ static int testURIParse(const void *args)
const struct URIParseData *data = args;
char *uristr = NULL;
size_t i;
bool fail = false;
if (!(uri = virURIParse(data->uri)))
goto cleanup;
......@@ -58,60 +59,62 @@ static int testURIParse(const void *args)
if (STRNEQ(uri->scheme, data->scheme)) {
VIR_TEST_DEBUG("Expected scheme '%s', actual '%s'",
data->scheme, uri->scheme);
goto cleanup;
fail = true;
}
if (STRNEQ(uri->server, data->server)) {
VIR_TEST_DEBUG("Expected server '%s', actual '%s'",
data->server, uri->server);
goto cleanup;
fail = true;
}
if (uri->port != data->port) {
VIR_TEST_DEBUG("Expected port '%d', actual '%d'",
data->port, uri->port);
goto cleanup;
fail = true;
}
if (STRNEQ_NULLABLE(uri->path, data->path)) {
VIR_TEST_DEBUG("Expected path '%s', actual '%s'",
data->path, uri->path);
goto cleanup;
fail = true;
}
if (STRNEQ_NULLABLE(uri->query, data->query)) {
VIR_TEST_DEBUG("Expected query '%s', actual '%s'",
data->query, uri->query);
goto cleanup;
fail = true;
}
if (STRNEQ_NULLABLE(uri->fragment, data->fragment)) {
VIR_TEST_DEBUG("Expected fragment '%s', actual '%s'",
data->fragment, uri->fragment);
goto cleanup;
fail = true;
}
for (i = 0; data->params && data->params[i].name && i < uri->paramsCount; i++) {
if (STRNEQ_NULLABLE(data->params[i].name, uri->params[i].name)) {
VIR_TEST_DEBUG("Expected param name %zu '%s', actual '%s'",
i, data->params[i].name, uri->params[i].name);
goto cleanup;
fail = true;
}
if (STRNEQ_NULLABLE(data->params[i].value, uri->params[i].value)) {
VIR_TEST_DEBUG("Expected param value %zu '%s', actual '%s'",
i, data->params[i].value, uri->params[i].value);
goto cleanup;
fail = true;
}
}
if (data->params && data->params[i].name) {
VIR_TEST_DEBUG("Missing parameter %zu %s=%s",
i, data->params[i].name, data->params[i].value);
goto cleanup;
fail = true;
}
if (i != uri->paramsCount) {
VIR_TEST_DEBUG("Unexpected parameter %zu %s=%s",
i, uri->params[i].name, uri->params[i].value);
goto cleanup;
for (; i < uri->paramsCount; i++) {
VIR_TEST_DEBUG("Unexpected parameter %zu %s=%s",
i, uri->params[i].name, uri->params[i].value);
}
fail = true;
}
VIR_FREE(uri->query);
......@@ -123,9 +126,12 @@ static int testURIParse(const void *args)
if (STRNEQ(uristr, data->uri_out)) {
VIR_TEST_DEBUG("URI did not roundtrip, expect '%s', actual '%s'",
data->uri_out, uristr);
goto cleanup;
fail = true;
}
if (fail)
goto cleanup;
ret = 0;
cleanup:
VIR_FREE(uristr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册