tests: make the unit test result type CURLcode

Before this patch, the result code was a mixture of `int` and
`CURLcode`.

Also adjust casts and fix a couple of minor issues found along the way.

Cherry-picked from #13489
Closes #13600
This commit is contained in:
Viktor Szakats 2024-05-11 21:36:05 +02:00
parent dad03dc593
commit 25cbc2f79a
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
221 changed files with 619 additions and 616 deletions

View file

@ -57,13 +57,13 @@ struct dohrequest {
/* output */
const char *packet;
size_t size;
int rc;
DOHcode rc;
};
static const struct dohrequest req[] = {
{"test.host.name", DNS_TYPE_A, DNS_Q1, sizeof(DNS_Q1)-1, 0 },
{"test.host.name", DNS_TYPE_AAAA, DNS_Q2, sizeof(DNS_Q2)-1, 0 },
{"test.host.name", DNS_TYPE_A, DNS_Q1, sizeof(DNS_Q1)-1, DOH_OK },
{"test.host.name", DNS_TYPE_AAAA, DNS_Q2, sizeof(DNS_Q2)-1, DOH_OK },
{"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
".host.name",
DNS_TYPE_AAAA, NULL, 0, DOH_DNS_BAD_LABEL }
@ -76,7 +76,7 @@ struct dohresp {
DNStype type;
/* output */
int rc;
DOHcode rc;
const char *out;
};
@ -161,8 +161,8 @@ UNITTEST_START
unsigned char *p;
for(i = 0; i < sizeof(req) / sizeof(req[0]); i++) {
int rc = doh_encode(req[i].name, req[i].type,
buffer, sizeof(buffer), &size);
DOHcode rc = doh_encode(req[i].name, req[i].type,
buffer, sizeof(buffer), &size);
if(rc != req[i].rc) {
fprintf(stderr, "req %zu: Expected return code %d got %d\n", i,
req[i].rc, rc);
@ -185,7 +185,7 @@ UNITTEST_START
for(i = 0; i < sizeof(resp) / sizeof(resp[0]); i++) {
struct dohentry d;
int rc;
DOHcode rc;
char *ptr;
size_t len;
int u;
@ -243,7 +243,7 @@ UNITTEST_START
/* pass all sizes into the decoder until full */
for(i = 0; i < sizeof(full49)-1; i++) {
struct dohentry d;
int rc;
DOHcode rc;
memset(&d, 0, sizeof(d));
rc = doh_decode((const unsigned char *)full49, i, DNS_TYPE_A, &d);
if(!rc) {
@ -256,7 +256,7 @@ UNITTEST_START
/* and try all pieces from the other end of the packet */
for(i = 1; i < sizeof(full49); i++) {
struct dohentry d;
int rc;
DOHcode rc;
memset(&d, 0, sizeof(d));
rc = doh_decode((const unsigned char *)&full49[i], sizeof(full49)-i-1,
DNS_TYPE_A, &d);
@ -268,7 +268,7 @@ UNITTEST_START
}
{
int rc;
DOHcode rc;
struct dohentry d;
struct dohaddr *a;
memset(&d, 0, sizeof(d));