Commit 339f7a5f authored by Petr Špaček's avatar Petr Špaček Committed by Daniel Salzman

tests: replace ok(ret == KNOT_E???) with is_int(KNOT_E???, ret) to ease debugging

Throwing away unexpected retun codes makes debugging harder.
TAP function is_int can nicely log mismatches which makes debugging easier.

To make our lives easier I replaced all ok(ret == KNOT_E???) checks with
is_int() calls. It was done using following command
+ manual review and reverts in libknot/test_control.c.

$ find -name '*.c' | xargs sed -i 's#ok(ret == \(KNOT_E[0-9A-Z_]\+\),#is_int(\1, ret,#'
parent cba5e77a
......@@ -36,36 +36,36 @@ int main(int argc, char *argv[])
// 0. test invalid input
ret = base32hex_encode(NULL, 0, out, BUF_LEN);
ok(ret == KNOT_EINVAL, "base32hex_encode: NULL input buffer");
is_int(KNOT_EINVAL, ret, "base32hex_encode: NULL input buffer");
ret = base32hex_encode(in, BUF_LEN, NULL, 0);
ok(ret == KNOT_EINVAL, "base32hex_encode: NULL output buffer");
is_int(KNOT_EINVAL, ret, "base32hex_encode: NULL output buffer");
ret = base32hex_encode(in, MAX_BIN_DATA_LEN + 1, out, BUF_LEN);
ok(ret == KNOT_ERANGE, "base32hex_encode: input buffer too large");
is_int(KNOT_ERANGE, ret, "base32hex_encode: input buffer too large");
ret = base32hex_encode(in, BUF_LEN, out, BUF_LEN);
ok(ret == KNOT_ERANGE, "base32hex_encode: output buffer too small");
is_int(KNOT_ERANGE, ret, "base32hex_encode: output buffer too small");
ret = base32hex_encode_alloc(NULL, 0, &out3);
ok(ret == KNOT_EINVAL, "base32hex_encode_alloc: NULL input buffer");
is_int(KNOT_EINVAL, ret, "base32hex_encode_alloc: NULL input buffer");
ret = base32hex_encode_alloc(in, MAX_BIN_DATA_LEN + 1, &out3);
ok(ret == KNOT_ERANGE, "base32hex_encode_alloc: input buffer too large");
is_int(KNOT_ERANGE, ret, "base32hex_encode_alloc: input buffer too large");
ret = base32hex_encode_alloc(in, BUF_LEN, NULL);
ok(ret == KNOT_EINVAL, "base32hex_encode_alloc: NULL output buffer");
is_int(KNOT_EINVAL, ret, "base32hex_encode_alloc: NULL output buffer");
ret = base32hex_decode(NULL, 0, out, BUF_LEN);
ok(ret == KNOT_EINVAL, "base32hex_decode: NULL input buffer");
is_int(KNOT_EINVAL, ret, "base32hex_decode: NULL input buffer");
ret = base32hex_decode(in, BUF_LEN, NULL, 0);
ok(ret == KNOT_EINVAL, "base32hex_decode: NULL output buffer");
is_int(KNOT_EINVAL, ret, "base32hex_decode: NULL output buffer");
ret = base32hex_decode(in, UINT32_MAX, out, BUF_LEN);
ok(ret == KNOT_ERANGE, "base32hex_decode: input buffer too large");
is_int(KNOT_ERANGE, ret, "base32hex_decode: input buffer too large");
ret = base32hex_decode(in, BUF_LEN, out, 0);
ok(ret == KNOT_ERANGE, "base32hex_decode: output buffer too small");
is_int(KNOT_ERANGE, ret, "base32hex_decode: output buffer too small");
ret = base32hex_decode_alloc(NULL, 0, &out3);
ok(ret == KNOT_EINVAL, "base32hex_decode_alloc: NULL input buffer");
is_int(KNOT_EINVAL, ret, "base32hex_decode_alloc: NULL input buffer");
ret = base32hex_decode_alloc(in, UINT32_MAX, &out3);
ok(ret == KNOT_ERANGE, "base32hex_decode_aloc: input buffer too large");
is_int(KNOT_ERANGE, ret, "base32hex_decode_aloc: input buffer too large");
ret = base32hex_decode_alloc(in, BUF_LEN, NULL);
ok(ret == KNOT_EINVAL, "base32hex_decode_alloc: NULL output buffer");
is_int(KNOT_EINVAL, ret, "base32hex_decode_alloc: NULL output buffer");
// 1. test vector -> ENC -> DEC
strlcpy((char *)in, "", BUF_LEN);
......
......@@ -36,36 +36,36 @@ int main(int argc, char *argv[])
// 0. test invalid input
ret = base64_encode(NULL, 0, out, BUF_LEN);
ok(ret == KNOT_EINVAL, "base64_encode: NULL input buffer");
is_int(KNOT_EINVAL, ret, "base64_encode: NULL input buffer");
ret = base64_encode(in, BUF_LEN, NULL, 0);
ok(ret == KNOT_EINVAL, "base64_encode: NULL output buffer");
is_int(KNOT_EINVAL, ret, "base64_encode: NULL output buffer");
ret = base64_encode(in, MAX_BIN_DATA_LEN + 1, out, BUF_LEN);
ok(ret == KNOT_ERANGE, "base64_encode: input buffer too large");
is_int(KNOT_ERANGE, ret, "base64_encode: input buffer too large");
ret = base64_encode(in, BUF_LEN, out, BUF_LEN);
ok(ret == KNOT_ERANGE, "base64_encode: output buffer too small");
is_int(KNOT_ERANGE, ret, "base64_encode: output buffer too small");
ret = base64_encode_alloc(NULL, 0, &out3);
ok(ret == KNOT_EINVAL, "base64_encode_alloc: NULL input buffer");
is_int(KNOT_EINVAL, ret, "base64_encode_alloc: NULL input buffer");
ret = base64_encode_alloc(in, MAX_BIN_DATA_LEN + 1, &out3);
ok(ret == KNOT_ERANGE, "base64_encode_alloc: input buffer too large");
is_int(KNOT_ERANGE, ret, "base64_encode_alloc: input buffer too large");
ret = base64_encode_alloc(in, BUF_LEN, NULL);
ok(ret == KNOT_EINVAL, "base64_encode_alloc: NULL output buffer");
is_int(KNOT_EINVAL, ret, "base64_encode_alloc: NULL output buffer");
ret = base64_decode(NULL, 0, out, BUF_LEN);
ok(ret == KNOT_EINVAL, "base64_decode: NULL input buffer");
is_int(KNOT_EINVAL, ret, "base64_decode: NULL input buffer");
ret = base64_decode(in, BUF_LEN, NULL, 0);
ok(ret == KNOT_EINVAL, "base64_decode: NULL output buffer");
is_int(KNOT_EINVAL, ret, "base64_decode: NULL output buffer");
ret = base64_decode(in, UINT32_MAX, out, BUF_LEN);
ok(ret == KNOT_ERANGE, "base64_decode: input buffer too large");
is_int(KNOT_ERANGE, ret, "base64_decode: input buffer too large");
ret = base64_decode(in, BUF_LEN, out, 0);
ok(ret == KNOT_ERANGE, "base64_decode: output buffer too small");
is_int(KNOT_ERANGE, ret, "base64_decode: output buffer too small");
ret = base64_decode_alloc(NULL, 0, &out3);
ok(ret == KNOT_EINVAL, "base64_decode_alloc: NULL input buffer");
is_int(KNOT_EINVAL, ret, "base64_decode_alloc: NULL input buffer");
ret = base64_decode_alloc(in, UINT32_MAX, &out3);
ok(ret == KNOT_ERANGE, "base64_decode_aloc: input buffer too large");
is_int(KNOT_ERANGE, ret, "base64_decode_aloc: input buffer too large");
ret = base64_decode_alloc(in, BUF_LEN, NULL);
ok(ret == KNOT_EINVAL, "base64_decode_alloc: NULL output buffer");
is_int(KNOT_EINVAL, ret, "base64_decode_alloc: NULL output buffer");
// 1. test vector -> ENC -> DEC
strlcpy((char *)in, "", BUF_LEN);
......
......@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
/* Insert single element. */
ret = hhash_insert(tbl, key, KEY_LEN(key), val);
ok(ret == KNOT_EOK, "hhash: insert single element");
is_int(KNOT_EOK, ret, "hhash: insert single element");
/* Retrieve nonexistent element. */
cur = "nokey";
......@@ -161,7 +161,7 @@ int main(int argc, char *argv[])
/* Delete key and retrieve it. */
ret = hhash_del(tbl, key, KEY_LEN(key));
ok(ret == KNOT_EOK, "hhash: remove key");
is_int(KNOT_EOK, ret, "hhash: remove key");
rval = hhash_find(tbl, key, KEY_LEN(key));
ok(rval == NULL, "hhash: find removed element");
......
......@@ -54,7 +54,7 @@ static void check_sockaddr_set(struct sockaddr_storage *ss, int family,
const char *straddr, int port)
{
int ret = sockaddr_set(ss, family, straddr, port);
ok(ret == KNOT_EOK, "set address '%s'", straddr);
is_int(KNOT_EOK, ret, "set address '%s'", straddr);
}
static void test_net_match(void)
......
......@@ -110,10 +110,10 @@ static void ctl_server(const char *socket, size_t argc, knot_ctl_data_t *argv)
ok(ctl != NULL, "Allocate control");
int ret = knot_ctl_bind(ctl, socket);
ok(ret == KNOT_EOK, "Bind control socket");
is_int(KNOT_EOK, ret, "Bind control socket");
ret = knot_ctl_accept(ctl);
ok(ret == KNOT_EOK, "Accept a connection");
is_int(KNOT_EOK, ret, "Accept a connection");
diag("BEGIN: Server <- Client");
......@@ -143,7 +143,7 @@ static void ctl_server(const char *socket, size_t argc, knot_ctl_data_t *argv)
}
count++;
}
ok(ret == KNOT_EOK, "Receive OK check");
is_int(KNOT_EOK, ret, "Receive OK check");
ok(type == KNOT_CTL_TYPE_END, "Receive EOF type");
ok(count == argc, "Server compare input count '%zu'", argc);
......@@ -155,16 +155,16 @@ static void ctl_server(const char *socket, size_t argc, knot_ctl_data_t *argv)
if (argv[i][KNOT_CTL_IDX_CMD] != NULL &&
argv[i][KNOT_CTL_IDX_CMD][0] == '\0') {
ret = knot_ctl_send(ctl, KNOT_CTL_TYPE_BLOCK, NULL);
ok(ret == KNOT_EOK, "Client send data block end type");
is_int(KNOT_EOK, ret, "Client send data block end type");
} else {
ret = knot_ctl_send(ctl, KNOT_CTL_TYPE_DATA, &argv[i]);
ok(ret == KNOT_EOK, "Server send data %zu", i);
is_int(KNOT_EOK, ret, "Server send data %zu", i);
}
}
}
ret = knot_ctl_send(ctl, KNOT_CTL_TYPE_END, NULL);
ok(ret == KNOT_EOK, "Server send final data");
is_int(KNOT_EOK, ret, "Server send final data");
diag("END: Server -> Client");
......
......@@ -175,13 +175,13 @@ int main(int argc, char *argv[])
cc_in.secret_len = sizeof(secret);
{
ret = knot_cc_check(NULL, 0, &cc_in, &knot_cc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 client cookie check no cookie");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 client cookie check no cookie");
}
{
uint8_t cookie[] = { 0xaf, 0xe5, 0x17, 0x94, 0x80, 0xa6, 0x0c, 0x33 };
ret = knot_cc_check(cookie, sizeof(cookie), NULL, &knot_cc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 client cookie check no input");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 client cookie check no input");
}
memset(&cc_in, 0, sizeof(cc_in));
......@@ -192,7 +192,7 @@ int main(int argc, char *argv[])
{
uint8_t cookie[] = { 0xaf, 0xe5, 0x17, 0x94, 0x80, 0xa6, 0x0c, 0x33 };
ret = knot_cc_check(cookie, sizeof(cookie), &cc_in, NULL);
ok(ret == KNOT_EINVAL, "cookies: FNV64 client cookie check no algorithm");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 client cookie check no algorithm");
}
memset(&cc_in, 0, sizeof(cc_in));
......@@ -203,7 +203,7 @@ int main(int argc, char *argv[])
{
uint8_t cookie[] = { 0xaf, 0xe5, 0x17, 0x94, 0x80, 0xa6, 0x0c, 0x33 };
ret = knot_cc_check(cookie, sizeof(cookie), &cc_in, &knot_cc_alg_fnv64);
ok(ret == KNOT_EOK, "cookies: FNV64 client good cookie check");
is_int(KNOT_EOK, ret, "cookies: FNV64 client good cookie check");
}
memset(&cc_in, 0, sizeof(cc_in));
......@@ -214,7 +214,7 @@ int main(int argc, char *argv[])
{
uint8_t cookie[] = { 0xaf, 0xe5, 0x17, 0x94, 0x80, 0xa6, 0x0c, 0x33 };
ret = knot_cc_check(cookie, sizeof(cookie) - 1, &cc_in, &knot_cc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 client cookie check invalid length");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 client cookie check invalid length");
}
memset(&cc_in, 0, sizeof(cc_in));
......@@ -225,6 +225,6 @@ int main(int argc, char *argv[])
{
uint8_t cookie[] = { 0xaf, 0xe5, 0x17, 0x94, 0x80, 0xa6, 0x0c, 0x32 };
ret = knot_cc_check(cookie, sizeof(cookie), &cc_in, &knot_cc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 client cookie check invalid cookie");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 client cookie check invalid cookie");
}
}
......@@ -76,37 +76,37 @@ int main(int argc, char *argv[])
ok(data != NULL, "cookies: EDNS OPT data");
ret = knot_edns_opt_cookie_parse(NULL, 0, NULL, NULL, NULL, NULL);
ok(ret == KNOT_EINVAL, "cookies: EDNS OPT parse NULL");
is_int(KNOT_EINVAL, ret, "cookies: EDNS OPT parse NULL");
/* Malformed cookies. */
get_opt_data(ROPT(0), &data, &data_len);
ret = knot_edns_opt_cookie_parse(data, data_len, NULL, NULL, NULL, NULL);
ok(ret == KNOT_EMALF, "cookies: EDNS OPT parse zero length");
is_int(KNOT_EMALF, ret, "cookies: EDNS OPT parse zero length");
get_opt_data(ROPT(1), &data, &data_len);
ret = knot_edns_opt_cookie_parse(data, data_len, &cc, &cc_len, &sc, &sc_len);
ok(ret == KNOT_EMALF, "cookies: EDNS OPT parse 1B (short) cookie");
is_int(KNOT_EMALF, ret, "cookies: EDNS OPT parse 1B (short) cookie");
get_opt_data(ROPT(2), &data, &data_len);
ret = knot_edns_opt_cookie_parse(data, data_len, &cc, &cc_len, &sc, &sc_len);
ok(ret == KNOT_EMALF, "cookies: EDNS OPT parse 7B (short) cookie");
is_int(KNOT_EMALF, ret, "cookies: EDNS OPT parse 7B (short) cookie");
get_opt_data(ROPT(3), &data, &data_len);
ret = knot_edns_opt_cookie_parse(data, data_len, &cc, &cc_len, &sc, &sc_len);
ok(ret == KNOT_EMALF, "cookies: EDNS OPT parse 9B (short) cookie");
is_int(KNOT_EMALF, ret, "cookies: EDNS OPT parse 9B (short) cookie");
get_opt_data(ROPT(4), &data, &data_len);
ret = knot_edns_opt_cookie_parse(data, data_len, &cc, &cc_len, &sc, &sc_len);
ok(ret == KNOT_EMALF, "cookies: EDNS OPT parse 15B (short) cookie");
is_int(KNOT_EMALF, ret, "cookies: EDNS OPT parse 15B (short) cookie");
get_opt_data(ROPT(5), &data, &data_len);
ret = knot_edns_opt_cookie_parse(data, data_len, &cc, &cc_len, &sc, &sc_len);
ok(ret == KNOT_EMALF, "cookies: EDNS OPT parse 41B (long) cookie");
is_int(KNOT_EMALF, ret, "cookies: EDNS OPT parse 41B (long) cookie");
get_opt_data(ROPT(5), &data, &data_len);
ret = knot_edns_opt_cookie_parse(data, data_len, &cc, &cc_len, &sc, &sc_len);
ok(ret == KNOT_EMALF, "cookies: EDNS OPT parse 41B (long) cookie");
is_int(KNOT_EMALF, ret, "cookies: EDNS OPT parse 41B (long) cookie");
/* Testing combination of output parameters. */
......
......@@ -288,13 +288,13 @@ int main(int argc, char *argv[])
const int DUMMYVAL = 1;
ret = knot_sc_parse(0, NULL, 0, &sc_content);
ok(ret == KNOT_EINVAL, "cookies: parse server cookie no cookie");
is_int(KNOT_EINVAL, ret, "cookies: parse server cookie no cookie");
ret = knot_sc_parse(0, sc0, sizeof(sc0), NULL);
ok(ret == KNOT_EINVAL, "cookies: parse server cookie no content");
is_int(KNOT_EINVAL, ret, "cookies: parse server cookie no content");
ret = knot_sc_parse(sizeof(sc0), sc0, sizeof(sc0), &sc_content);
ok(ret == KNOT_EINVAL, "cookies: parse server cookie too large nonce");
is_int(KNOT_EINVAL, ret, "cookies: parse server cookie too large nonce");
sc_content.nonce = sc_content.hash = DUMMYPTR;
sc_content.nonce_len = sc_content.hash_len = DUMMYVAL;
......@@ -317,21 +317,21 @@ int main(int argc, char *argv[])
srvr_data.secret_data = secret;
srvr_data.secret_len = sizeof(secret);
ret = knot_sc_check(1, &cookies, &srvr_data, &knot_sc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie check - wrong nonce length");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 server cookie check - wrong nonce length");
get_opt_cookies(ROPT(1), &cookies);
srvr_data.clnt_sockaddr = (struct sockaddr *)&c6_sa;
srvr_data.secret_data = secret;
srvr_data.secret_len = sizeof(secret);
ret = knot_sc_check(17, &cookies, &srvr_data, &knot_sc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie check - too long nonce");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 server cookie check - too long nonce");
get_opt_cookies(ROPT(1), &cookies);
srvr_data.clnt_sockaddr = (struct sockaddr *)&c6_sa;
srvr_data.secret_data = secret;
srvr_data.secret_len = sizeof(secret);
ret = knot_sc_check(0, NULL, &srvr_data, &knot_sc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie check - no cookies");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 server cookie check - no cookies");
get_opt_cookies(ROPT(1), &cookies);
cookies.cc = NULL;
......@@ -340,7 +340,7 @@ int main(int argc, char *argv[])
srvr_data.secret_data = secret;
srvr_data.secret_len = sizeof(secret);
ret = knot_sc_check(0, NULL, &srvr_data, &knot_sc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie check - no client cookie");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 server cookie check - no client cookie");
get_opt_cookies(ROPT(1), &cookies);
cookies.sc = NULL;
......@@ -349,63 +349,63 @@ int main(int argc, char *argv[])
srvr_data.secret_data = secret;
srvr_data.secret_len = sizeof(secret);
ret = knot_sc_check(0, NULL, &srvr_data, &knot_sc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie check - no server cookie");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 server cookie check - no server cookie");
get_opt_cookies(ROPT(1), &cookies);
srvr_data.clnt_sockaddr = NULL;
srvr_data.secret_data = secret;
srvr_data.secret_len = sizeof(secret);
ret = knot_sc_check(0, NULL, &srvr_data, &knot_sc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie check - no socket address");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 server cookie check - no socket address");
get_opt_cookies(ROPT(1), &cookies);
srvr_data.clnt_sockaddr = (struct sockaddr *)&c6_sa;
srvr_data.secret_data = NULL;
srvr_data.secret_len = 0;
ret = knot_sc_check(0, &cookies, &srvr_data, &knot_sc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie check - no secret");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 server cookie check - no secret");
get_opt_cookies(ROPT(0), &cookies);
srvr_data.clnt_sockaddr = (struct sockaddr *)&c6_sa;
srvr_data.secret_data = secret;
srvr_data.secret_len = sizeof(secret);
ret = knot_sc_check(0, &cookies, &srvr_data, &knot_sc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie check - bad server cookie");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 server cookie check - bad server cookie");
get_opt_cookies(ROPT(1), &cookies);
srvr_data.clnt_sockaddr = (struct sockaddr *)&unspec_sa;
srvr_data.secret_data = secret;
srvr_data.secret_len = sizeof(secret);
ret = knot_sc_check(0, &cookies, &srvr_data, &knot_sc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie check - bad socket");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 server cookie check - bad socket");
get_opt_cookies(ROPT(1), &cookies);
srvr_data.clnt_sockaddr = (struct sockaddr *)&c6_sa;
srvr_data.secret_data = secret;
srvr_data.secret_len = sizeof(secret) - 1;
ret = knot_sc_check(0, &cookies, &srvr_data, &knot_sc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie check - bad secret");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 server cookie check - bad secret");
get_opt_cookies(ROPT(1), &cookies);
srvr_data.clnt_sockaddr = (struct sockaddr *)&c6_sa;
srvr_data.secret_data = secret;
srvr_data.secret_len = sizeof(secret);
ret = knot_sc_check(0, &cookies, &srvr_data, &knot_sc_alg_fnv64);
ok(ret == KNOT_EOK, "cookies: FNV64 server cookie check");
is_int(KNOT_EOK, ret, "cookies: FNV64 server cookie check");
get_opt_cookies(ROPT(2), &cookies);
srvr_data.clnt_sockaddr = (struct sockaddr *)&c6_sa;
srvr_data.secret_data = secret;
srvr_data.secret_len = sizeof(secret);
ret = knot_sc_check(8, &cookies, &srvr_data, &knot_sc_alg_fnv64);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie check - bad server cookie");
is_int(KNOT_EINVAL, ret, "cookies: FNV64 server cookie check - bad server cookie");
get_opt_cookies(ROPT(3), &cookies);
srvr_data.clnt_sockaddr = (struct sockaddr *)&c6_sa;
srvr_data.secret_data = secret;
srvr_data.secret_len = sizeof(secret);
ret = knot_sc_check(8, &cookies, &srvr_data, &knot_sc_alg_fnv64);
ok(ret == KNOT_EOK, "cookies: FNV64 server cookie check");
is_int(KNOT_EOK, ret, "cookies: FNV64 server cookie check");
return 0;
}
......@@ -66,7 +66,7 @@ static void knot_db_test_set(unsigned nkeys, char **keys, void *opts,
/* Start WR transaction. */
knot_db_txn_t txn;
ret = api->txn_begin(db, &txn, 0);
ok(ret == KNOT_EOK, "%s: txn_begin(WR)", api->name);
is_int(KNOT_EOK, ret, "%s: txn_begin(WR)", api->name);
/* Insert keys */
knot_db_val_t key, val;
......@@ -86,11 +86,11 @@ static void knot_db_test_set(unsigned nkeys, char **keys, void *opts,
/* Commit WR transaction. */
ret = api->txn_commit(&txn);
ok(ret == KNOT_EOK, "%s: txn_commit(WR)", api->name);
is_int(KNOT_EOK, ret, "%s: txn_commit(WR)", api->name);
/* Start RD transaction. */
ret = api->txn_begin(db, &txn, KNOT_DB_RDONLY);
ok(ret == KNOT_EOK, "%s: txn_begin(RD)", api->name);
is_int(KNOT_EOK, ret, "%s: txn_begin(RD)", api->name);
/* Lookup all keys */
passed = true;
......
......@@ -217,31 +217,31 @@ static void test_setters(knot_rrset_t *opt_rr)
/* Proper option. */
int ret = knot_edns_add_option(opt_rr, KNOT_EDNS_OPTION_NSID,
E_NSID_LEN, (uint8_t *)E_NSID_STR, NULL);
ok(ret == KNOT_EOK, "OPT RR setters: add option with data (ret = %s)",
is_int(KNOT_EOK, ret, "OPT RR setters: add option with data (ret = %s)",
knot_strerror(ret));
/* Wrong argument: no OPT RR. */
ret = knot_edns_add_option(NULL, E_OPT3_CODE, E_OPT3_FAKE_LEN,
(uint8_t *)E_OPT3_FAKE_DATA, NULL);
ok(ret == KNOT_EINVAL, "OPT RR setters: add option (rr == NULL) "
is_int(KNOT_EINVAL, ret, "OPT RR setters: add option (rr == NULL) "
"(ret = %s)", knot_strerror(ret));
/* Wrong argument: option length != 0 && data == NULL. */
ret = knot_edns_add_option(opt_rr, E_OPT3_CODE, E_OPT3_FAKE_LEN, NULL,
NULL);
ok(ret == KNOT_EINVAL, "OPT RR setters: add option (data == NULL, "
is_int(KNOT_EINVAL, ret, "OPT RR setters: add option (data == NULL, "
"len != 0) (ret = %s)", knot_strerror(ret));
/* Empty OPTION (length 0, data != NULL). */
ret = knot_edns_add_option(opt_rr, E_OPT3_CODE, E_OPT3_LEN,
(uint8_t *)E_OPT3_FAKE_DATA, NULL);
ok(ret == KNOT_EOK, "OPT RR setters: add empty option 1 (ret = %s)",
is_int(KNOT_EOK, ret, "OPT RR setters: add empty option 1 (ret = %s)",
knot_strerror(ret));
/* Empty OPTION (length 0, data == NULL). */
ret = knot_edns_add_option(opt_rr, E_OPT4_CODE, E_OPT4_LEN,
(uint8_t *)E_OPT4_DATA, NULL);
ok(ret == KNOT_EOK, "OPT RR setters: add empty option 2 (ret = %s)",
is_int(KNOT_EOK, ret, "OPT RR setters: add empty option 2 (ret = %s)",
knot_strerror(ret));
knot_rdata_t *rdata = knot_rdataset_at(&opt_rr->rrs, 0);
......@@ -759,13 +759,13 @@ static void test_keepalive(void)
uint8_t wire[8] = { 0 };
int ret = knot_edns_keepalive_write(wire, sizeof(wire), t->val);
ok(ret == KNOT_EOK, "%s: %s, write, return", __func__, t->msg);
is_int(KNOT_EOK, ret, "%s: %s, write, return", __func__, t->msg);
ok(memcmp(wire, t->opt, t->opt_len) == 0, "%s: %s, write, value",
__func__, t->msg);
uint16_t timeout = 0;
ret = knot_edns_keepalive_parse(&timeout, (uint8_t *)t->opt, t->opt_len);
ok(ret == KNOT_EOK, "%s: %s, parse, return", __func__, t->msg);
is_int(KNOT_EOK, ret, "%s: %s, parse, return", __func__, t->msg);
ok(timeout == t->val, "%s: %s, parse, value", __func__, t->msg);
}
......@@ -808,13 +808,13 @@ static void test_chain(void)
uint8_t wire[8] = { 0 };
int ret = knot_edns_chain_write(wire, sizeof(wire), t->dname);
ok(ret == KNOT_EOK, "%s: dname %s, write, return", __func__, t->msg);
is_int(KNOT_EOK, ret, "%s: dname %s, write, return", __func__, t->msg);
ok(memcmp(wire, t->dname, t->opt_len) == 0, "%s: dname %s, write, value",
__func__, t->msg);
knot_dname_t *dname = NULL;
ret = knot_edns_chain_parse(&dname, (uint8_t *)t->dname, t->opt_len);
ok(ret == KNOT_EOK, "%s: dname %s, parse, return", __func__, t->msg);
is_int(KNOT_EOK, ret, "%s: dname %s, parse, return", __func__, t->msg);
ok(knot_dname_cmp(dname, t->dname) == 0, "%s: dname %s, parse, value",
__func__, t->msg);
knot_dname_free(&dname, NULL);
......@@ -847,7 +847,7 @@ int main(int argc, char *argv[])
knot_rrset_t opt_rr;
int ret = knot_edns_init(&opt_rr, E_MAX_PLD, E_RCODE, E_VERSION, NULL);
ok(ret == KNOT_EOK, "OPT RR: init");
is_int(KNOT_EOK, ret, "OPT RR: init");
/* Check initialized values (no NSID yet). */
check_header(&opt_rr, E_MAX_PLD, E_VERSION, 0, E_RCODE, "OPT RR: check header");
......
......@@ -88,12 +88,12 @@ int main(int argc, char *argv[])
/* Create OPT RR. */
knot_rrset_t opt_rr = { 0 };
ret = knot_edns_init(&opt_rr, 1024, 0, 0, &mm);
ok(ret == KNOT_EOK, "initialize OPT RR");
is_int(KNOT_EOK, ret, "initialize OPT RR");
/* Add NSID */
ret = knot_edns_add_option(&opt_rr, KNOT_EDNS_OPTION_NSID,
strlen((char *)edns_str), edns_str, &mm);
ok(ret == KNOT_EOK, "initialize NSID in OPT RR");
is_int(KNOT_EOK, ret, "initialize NSID in OPT RR");
/*
* Packet writer tests.
......@@ -115,30 +115,30 @@ int main(int argc, char *argv[])
tsig_key.secret.data = (uint8_t *)strdup(tsig_secret);
tsig_key.secret.size = strlen(tsig_secret);
ret = knot_pkt_reserve(out, knot_tsig_wire_size(&tsig_key));
ok(ret == KNOT_EOK, "pkt: set TSIG key");
is_int(KNOT_EOK, ret, "pkt: set TSIG key");
/* Write question. */
ret = knot_pkt_put_question(out, dnames[0], KNOT_CLASS_IN, KNOT_RRTYPE_A);
ok(ret == KNOT_EOK, "pkt: put question");
is_int(KNOT_EOK, ret, "pkt: put question");
/* Add OPT to packet (empty NSID). */
ret = knot_pkt_reserve(out, knot_edns_wire_size(&opt_rr));
ok(ret == KNOT_EOK, "pkt: reserve OPT RR");
is_int(KNOT_EOK, ret, "pkt: reserve OPT RR");
/* Begin ANSWER section. */
ret = knot_pkt_begin(out, KNOT_ANSWER);
ok(ret == KNOT_EOK, "pkt: begin ANSWER");
is_int(KNOT_EOK, ret, "pkt: begin ANSWER");
/* Write ANSWER section. */
rrsets[0] = knot_rrset_new(dnames[0], KNOT_RRTYPE_A, KNOT_CLASS_IN, NULL);
knot_dname_free(&dnames[0], NULL);
knot_rrset_add_rdata(rrsets[0], RDVAL(0), RDLEN(0), TTL, NULL);
ret = knot_pkt_put(out, KNOT_COMPR_HINT_QNAME, rrsets[0], 0);
ok(ret == KNOT_EOK, "pkt: write ANSWER");
is_int(KNOT_EOK, ret, "pkt: write ANSWER");
/* Begin AUTHORITY. */
ret = knot_pkt_begin(out, KNOT_AUTHORITY);
ok(ret == KNOT_EOK, "pkt: begin AUTHORITY");
is_int(KNOT_EOK, ret, "pkt: begin AUTHORITY");
/* Write rest to AUTHORITY. */
ret = KNOT_EOK;
......@@ -148,15 +148,15 @@ int main(int argc, char *argv[])
knot_rrset_add_rdata(rrsets[i], RDVAL(i), RDLEN(i), TTL, NULL);
ret |= knot_pkt_put(out, KNOT_COMPR_HINT_NONE, rrsets[i], 0);
}
ok(ret == KNOT_EOK, "pkt: write AUTHORITY(%u)", NAMECOUNT - 1);
is_int(KNOT_EOK, ret, "pkt: write AUTHORITY(%u)", NAMECOUNT - 1);
/* Begin ADDITIONALS */
ret = knot_pkt_begin(out, KNOT_ADDITIONAL);
ok(ret == KNOT_EOK, "pkt: begin ADDITIONALS");
is_int(KNOT_EOK, ret, "pkt: begin ADDITIONALS");
/* Encode OPT RR. */
ret = knot_pkt_put(out, KNOT_COMPR_HINT_NONE, &opt_rr, 0);
ok(ret == KNOT_EOK, "pkt: write OPT RR");
is_int(KNOT_EOK, ret, "pkt: write OPT RR");
/*
* Packet reader tests.
......@@ -168,11 +168,11 @@ int main(int argc, char *argv[])
/* Read packet header. */
ret = knot_pkt_parse_question(in);
ok(ret == KNOT_EOK, "pkt: read header");
is_int(KNOT_EOK, ret, "pkt: read header");
/* Read packet payload. */
ret = knot_pkt_parse_payload(in, 0);
ok(ret == KNOT_EOK, "pkt: read payload");
is_int(KNOT_EOK, ret, "pkt: read payload");
/* Compare parsed packet to written packet. */
packet_match(in, out);
......@@ -182,7 +182,7 @@ int main(int argc, char *argv[])
*/
knot_pkt_t *copy = knot_pkt_new(NULL, in->max_size, &in->mm);
ret = knot_pkt_copy(copy, in);
ok(ret == KNOT_EOK, "pkt: create packet copy");
is_int(KNOT_EOK, ret, "pkt: create packet copy");
/* Compare copied packet to original. */
packet_match(in, copy);
......
......@@ -41,7 +41,7 @@ int main(int argc, char *argv[])
knot_rdata_init(rdata_gt, 4, (uint8_t *)"wxyz", 3600);
int ret = knot_rdataset_add(NULL, NULL, NULL);
ok(ret == KNOT_EINVAL, "rdataset: add NULL.");
is_int(KNOT_EINVAL, ret, "rdataset: add NULL.");
ret = knot_rdataset_add(&rdataset, rdata_gt, NULL);
bool add_ok = ret == KNOT_EOK && rdataset.rr_count == 1 &&
knot_rdata_cmp(rdata_gt, rdataset.data) == 0;
......@@ -184,7 +184,7 @@ int main(int argc, char *argv[])
ok(subtract_ok, "rdataset: subtract last.");
ret = knot_rdataset_reserve(&rdataset, 65536, NULL);
ok(ret == KNOT_EINVAL, "rdataset: reserve too much");
is_int(KNOT_EINVAL, ret, "rdataset: reserve too much");
RDATASET_INIT_WITH(rdataset, rdata_gt);
......
......@@ -211,7 +211,7 @@ static void check_canon(uint8_t *wire, size_t size, size_t pos, bool canon,
knot_rrset_init_empty(&rrset);
int ret = knot_rrset_rr_from_wire(wire, &pos, size, NULL, &rrset, canon);
ok(ret == KNOT_EOK, "OK %s canonization", canon ? "with" : "without");
is_int(KNOT_EOK, ret, "OK %s canonization", canon ? "with" : "without");
ok(memcmp(rrset.owner, qname, knot_dname_size(qname)) == 0, "compare owner");
uint8_t *rdata = knot_rdata_data(knot_rdataset_at(&rrset.rrs, 0));
......@@ -252,7 +252,7 @@ int main(int argc, char *argv[])
diag("Test NULL parameters");
int ret = knot_rrset_rr_from_wire(NULL, NULL, 0, NULL, NULL, true);
ok(ret == KNOT_EINVAL, "rr wire: Invalid params");
is_int(KNOT_EINVAL, ret, "rr wire: Invalid params");
diag("Test various inputs");
test_inputs();
......
......@@ -92,12 +92,12 @@ int main(int argc, char *argv[])
// OK input.
ret = yp_set_input_string(yp, syntax_ok, strlen(syntax_ok));
ok(ret == KNOT_EOK, "set input string");
is_int(KNOT_EOK, ret, "set input string");
line = 3;
for (int i = 0; i < 3; i++) {
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse %i. key0", i);
is_int(KNOT_EOK, ret, "parse %i. key0", i);
ok(yp->key_len == 1 && yp->key[0] == 'a' &&
yp->data_len == 0 && yp->event == YP_EKEY0 &&
yp->line_count == line + i, "compare %i. key0", i);
......@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
line = 7;
for (int i = 0; i < 6; i++) {
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse %i. key0 with value", i);
is_int(KNOT_EOK, ret, "parse %i. key0 with value", i);
ok(yp->key_len == 1 && yp->key[0] == 'b' &&
yp->data_len == 1 && yp->data[0] == 'b' &&
yp->event == YP_EKEY0 && yp->line_count == line + i,
......@@ -116,7 +116,7 @@ int main(int argc, char *argv[])
line = 14;
for (int i = 0; i < 6; i++) {
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse %i. key1 with value", i);
is_int(KNOT_EOK, ret, "parse %i. key1 with value", i);
ok(yp->key_len == 1 && yp->key[0] == 'f' &&
yp->data_len == 1 && yp->data[0] == 'f' &&
yp->event == YP_EKEY1 && yp->line_count == line + i,
......@@ -126,14 +126,14 @@ int main(int argc, char *argv[])
line = 21;
for (int i = 0; i < 5; i++) {
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse %i. key0 with first value", i);
is_int(KNOT_EOK, ret, "parse %i. key0 with first value", i);
ok(yp->key_len == 1 && yp->key[0] == 'c' &&
yp->data_len == 1 && yp->data[0] == 'a' &&
yp->event == YP_EKEY0 && yp->line_count == line + i,
"compare %i. key0 with first value", i);
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse %i. key0 with second value", i);