From 339f7a5fb9f1206a018cfafc5f010ee14a55711d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pa=C4=8Dek?= <petr.spacek@nic.cz> Date: Fri, 27 Jan 2017 10:02:11 +0100 Subject: [PATCH] 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,#' --- tests/contrib/test_base32hex.c | 28 ++++++------ tests/contrib/test_base64.c | 28 ++++++------ tests/contrib/test_hhash.c | 4 +- tests/contrib/test_sockaddr.c | 2 +- tests/libknot/test_control.c | 12 ++--- tests/libknot/test_cookies-client.c | 12 ++--- tests/libknot/test_cookies-opt.c | 16 +++---- tests/libknot/test_cookies-server.c | 32 ++++++------- tests/libknot/test_db.c | 6 +-- tests/libknot/test_edns.c | 20 ++++----- tests/libknot/test_pkt.c | 28 ++++++------ tests/libknot/test_rdataset.c | 4 +- tests/libknot/test_rrset-wire.c | 4 +- tests/libknot/test_yparser.c | 52 ++++++++++----------- tests/libknot/test_ypscheme.c | 16 +++---- tests/libknot/test_yptrafo.c | 36 +++++++-------- tests/test_acl.c | 2 +- tests/test_changeset.c | 14 +++--- tests/test_conf.c | 2 +- tests/test_conf_tools.c | 12 ++--- tests/test_confdb.c | 22 ++++----- tests/test_journal.c | 70 ++++++++++++++--------------- tests/test_process_query.c | 2 +- tests/test_query_module.c | 2 +- tests/test_server.c | 4 +- tests/test_zone-update.c | 22 ++++----- tests/test_zone_timers.c | 12 ++--- tests/utils/test_lookup.c | 10 ++--- 28 files changed, 237 insertions(+), 237 deletions(-) diff --git a/tests/contrib/test_base32hex.c b/tests/contrib/test_base32hex.c index 3e1341218d..813e266e81 100644 --- a/tests/contrib/test_base32hex.c +++ b/tests/contrib/test_base32hex.c @@ -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); diff --git a/tests/contrib/test_base64.c b/tests/contrib/test_base64.c index 2580220a2d..45e4e55621 100644 --- a/tests/contrib/test_base64.c +++ b/tests/contrib/test_base64.c @@ -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); diff --git a/tests/contrib/test_hhash.c b/tests/contrib/test_hhash.c index 707db6a119..245f1d24db 100644 --- a/tests/contrib/test_hhash.c +++ b/tests/contrib/test_hhash.c @@ -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"); diff --git a/tests/contrib/test_sockaddr.c b/tests/contrib/test_sockaddr.c index dcf5f0e10f..5f8050718b 100644 --- a/tests/contrib/test_sockaddr.c +++ b/tests/contrib/test_sockaddr.c @@ -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) diff --git a/tests/libknot/test_control.c b/tests/libknot/test_control.c index 9dc754ff36..3ec4daf66d 100644 --- a/tests/libknot/test_control.c +++ b/tests/libknot/test_control.c @@ -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"); diff --git a/tests/libknot/test_cookies-client.c b/tests/libknot/test_cookies-client.c index 712dbba758..c99b6db5f8 100644 --- a/tests/libknot/test_cookies-client.c +++ b/tests/libknot/test_cookies-client.c @@ -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"); } } diff --git a/tests/libknot/test_cookies-opt.c b/tests/libknot/test_cookies-opt.c index d0abd7387c..8cc0dfe5bf 100644 --- a/tests/libknot/test_cookies-opt.c +++ b/tests/libknot/test_cookies-opt.c @@ -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. */ diff --git a/tests/libknot/test_cookies-server.c b/tests/libknot/test_cookies-server.c index 66a54ba5f0..7cace84f18 100644 --- a/tests/libknot/test_cookies-server.c +++ b/tests/libknot/test_cookies-server.c @@ -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; } diff --git a/tests/libknot/test_db.c b/tests/libknot/test_db.c index 8ee5582a0f..49bd6e4f75 100644 --- a/tests/libknot/test_db.c +++ b/tests/libknot/test_db.c @@ -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; diff --git a/tests/libknot/test_edns.c b/tests/libknot/test_edns.c index 01779834ea..a2dd7b656c 100644 --- a/tests/libknot/test_edns.c +++ b/tests/libknot/test_edns.c @@ -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"); diff --git a/tests/libknot/test_pkt.c b/tests/libknot/test_pkt.c index 5db6461c06..1c9bd7f555 100644 --- a/tests/libknot/test_pkt.c +++ b/tests/libknot/test_pkt.c @@ -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); diff --git a/tests/libknot/test_rdataset.c b/tests/libknot/test_rdataset.c index 34573b9e76..9c6db841a9 100644 --- a/tests/libknot/test_rdataset.c +++ b/tests/libknot/test_rdataset.c @@ -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); diff --git a/tests/libknot/test_rrset-wire.c b/tests/libknot/test_rrset-wire.c index 996c3e42ff..e79870bbd5 100644 --- a/tests/libknot/test_rrset-wire.c +++ b/tests/libknot/test_rrset-wire.c @@ -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(); diff --git a/tests/libknot/test_yparser.c b/tests/libknot/test_yparser.c index eeda0dc8f2..71ce2e13f9 100644 --- a/tests/libknot/test_yparser.c +++ b/tests/libknot/test_yparser.c @@ -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); + is_int(KNOT_EOK, ret, "parse %i. key0 with second value", i); ok(yp->key_len == 1 && yp->key[0] == 'c' && yp->data_len == 1 && yp->data[0] == 'b' && yp->event == YP_EKEY0 && yp->line_count == line + i, @@ -143,7 +143,7 @@ int main(int argc, char *argv[]) line = 27; for (int i = 0; i < 2; i++) { ret = yp_parse(yp); - ok(ret == KNOT_EOK, "parse %i. id", i); + is_int(KNOT_EOK, ret, "parse %i. id", i); ok(yp->key_len == 1 && yp->key[0] == 'd' && yp->data_len == 1 && yp->data[0] == 'd' && yp->event == YP_EID && yp->line_count == line + i, @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) line = 30; ret = yp_parse(yp); - ok(ret == KNOT_EOK, "parse key0 with quoted value"); + is_int(KNOT_EOK, ret, "parse key0 with quoted value"); ok(yp->key_len == 1 && yp->key[0] == 'e' && yp->data_len == 10 && memcmp(yp->data, "a#b' c[d,]", yp->data_len) == 0 && yp->event == YP_EKEY0 && yp->line_count == line, @@ -160,7 +160,7 @@ int main(int argc, char *argv[]) line = 32; ret = yp_parse(yp); - ok(ret == KNOT_EOK, "parse key0"); + is_int(KNOT_EOK, ret, "parse key0"); ok(yp->key_len == 4 && strcmp(yp->key, "zone") == 0 && yp->data_len == 0 && yp->event == YP_EKEY0 && yp->line_count == line, @@ -169,13 +169,13 @@ int main(int argc, char *argv[]) line = 35; for (int i = 0; i < 2; i++) { ret = yp_parse(yp); - ok(ret == KNOT_EOK, "parse %i. id", i); + is_int(KNOT_EOK, ret, "parse %i. id", i); ok(yp->key_len == 6 && strcmp(yp->key, "domain") == 0 && yp->data_len == 8 && strcmp(yp->data, "example.") == 0 && yp->event == YP_EID && yp->line_count == line + 2 * i, "compare id"); ret = yp_parse(yp); - ok(ret == KNOT_EOK, "parse %i. key1", i); + is_int(KNOT_EOK, ret, "parse %i. key1", i); ok(yp->key_len == 6 && strcmp(yp->key, "master") == 0 && yp->data_len == 4 && strcmp(yp->data, "bind") == 0 && yp->event == YP_EKEY1 && yp->line_count == line + 2 * i + 1, @@ -184,50 +184,50 @@ int main(int argc, char *argv[]) line = 39; ret = yp_parse(yp); - ok(ret == KNOT_EOK, "parse key0"); + is_int(KNOT_EOK, ret, "parse key0"); ok(yp->key_len == 5 && strcmp(yp->key, "zone2") == 0 && yp->data_len == 0 && yp->event == YP_EKEY0 && yp->line_count == line, "compare key0 value"); ret = yp_parse(yp); - ok(ret == KNOT_EOK, "parse key1"); + is_int(KNOT_EOK, ret, "parse key1"); ok(yp->key_len == 1 && strcmp(yp->key, "a") == 0 && yp->data_len == 1 && strcmp(yp->data, "b") == 0 && yp->event == YP_EID && yp->line_count == line + 1, "compare key1 value"); ret = yp_parse(yp); - ok(ret == KNOT_EOF, "parse EOF"); + is_int(KNOT_EOF, ret, "parse EOF"); // Error input 1. ret = yp_set_input_string(yp, syntax_error1, strlen(syntax_error1)); - ok(ret == KNOT_EOK, "set error input string 1"); + is_int(KNOT_EOK, ret, "set error input string 1"); ret = yp_parse(yp); - ok(ret == KNOT_EOK, "parse key0"); + is_int(KNOT_EOK, ret, "parse key0"); ret = yp_parse(yp); - ok(ret == KNOT_EOK, "parse key1"); + is_int(KNOT_EOK, ret, "parse key1"); ret = yp_parse(yp); - ok(ret == KNOT_YP_EINVAL_INDENT, "parse key1 - invalid indentation"); + is_int(KNOT_YP_EINVAL_INDENT, ret, "parse key1 - invalid indentation"); // Error input 2. ret = yp_set_input_string(yp, syntax_error2, strlen(syntax_error2)); - ok(ret == KNOT_EOK, "set error input string 2"); + is_int(KNOT_EOK, ret, "set error input string 2"); ret = yp_parse(yp); - ok(ret == KNOT_EOK, "parse key0"); + is_int(KNOT_EOK, ret, "parse key0"); ret = yp_parse(yp); - ok(ret == KNOT_EOK, "parse key1"); + is_int(KNOT_EOK, ret, "parse key1"); ret = yp_parse(yp); - ok(ret == KNOT_YP_EINVAL_INDENT, "parse key1 - invalid indentation"); + is_int(KNOT_YP_EINVAL_INDENT, ret, "parse key1 - invalid indentation"); // Error input 3. ret = yp_set_input_string(yp, syntax_error3, strlen(syntax_error3)); - ok(ret == KNOT_EOK, "set error input string 3"); + is_int(KNOT_EOK, ret, "set error input string 3"); ret = yp_parse(yp); - ok(ret == KNOT_EOK, "parse key0"); + is_int(KNOT_EOK, ret, "parse key0"); ret = yp_parse(yp); - ok(ret == KNOT_EOK, "parse key1"); + is_int(KNOT_EOK, ret, "parse key1"); ret = yp_parse(yp); - ok(ret == KNOT_YP_EINVAL_INDENT, "parse key1 - invalid indentation"); + is_int(KNOT_YP_EINVAL_INDENT, ret, "parse key1 - invalid indentation"); yp_deinit(yp); diff --git a/tests/libknot/test_ypscheme.c b/tests/libknot/test_ypscheme.c index 1c59fbe4f3..e1d164e8da 100644 --- a/tests/libknot/test_ypscheme.c +++ b/tests/libknot/test_ypscheme.c @@ -72,7 +72,7 @@ static void scheme_find_test(void) yp_item_t *scheme = NULL; int ret = yp_scheme_copy(&scheme, static_scheme); - ok(ret == KNOT_EOK, "scheme copy"); + is_int(KNOT_EOK, ret, "scheme copy"); const yp_item_t *i = yp_scheme_find(C_OPT, NULL, scheme); ok(i != NULL, "scheme find"); @@ -100,20 +100,20 @@ error_scheme: #define SET_INPUT_STR(str) \ ret = yp_set_input_string(yp, str, strlen(str)); \ - ok(ret == KNOT_EOK, "set input string"); + is_int(KNOT_EOK, ret, "set input string"); #define PARSER_CHECK(depth) \ ret = yp_parse(yp); \ - ok(ret == KNOT_EOK, "parse"); \ + is_int(KNOT_EOK, ret, "parse"); \ ret = yp_scheme_check_parser(ctx, yp); \ - ok(ret == KNOT_EOK, "check parser"); \ + is_int(KNOT_EOK, ret, "check parser"); \ node = &ctx->nodes[ctx->current]; \ parent = node->parent; \ ok(ctx->current == depth, "depth check"); #define PARSER_RET_CHECK(code) \ ret = yp_parse(yp); \ - ok(ret == KNOT_EOK, "parse"); \ + is_int(KNOT_EOK, ret, "parse"); \ ret = yp_scheme_check_parser(ctx, yp); \ ok(ret == code, "return check parser"); @@ -127,7 +127,7 @@ static void parser_test(void) yp_init(yp); int ret = yp_scheme_copy(&scheme, static_scheme); - ok(ret == KNOT_EOK, "scheme copy"); + is_int(KNOT_EOK, ret, "scheme copy"); if (ret != KNOT_EOK) { goto error_parser; } @@ -243,7 +243,7 @@ error_parser: #define STR_CHECK(depth, key0, key1, id, data) \ ret = yp_scheme_check_str(ctx, key0, key1, id, data); \ - ok(ret == KNOT_EOK, "check str"); \ + is_int(KNOT_EOK, ret, "check str"); \ ok(ctx->current == depth, "depth check"); \ node = &ctx->nodes[ctx->current]; \ parent = node->parent; @@ -258,7 +258,7 @@ static void str_test(void) yp_check_ctx_t *ctx = NULL; int ret = yp_scheme_copy(&scheme, static_scheme); - ok(ret == KNOT_EOK, "scheme copy"); + is_int(KNOT_EOK, ret, "scheme copy"); if (ret != KNOT_EOK) { goto error_str; } diff --git a/tests/libknot/test_yptrafo.c b/tests/libknot/test_yptrafo.c index b1c0811dc9..28386ccb90 100644 --- a/tests/libknot/test_yptrafo.c +++ b/tests/libknot/test_yptrafo.c @@ -35,10 +35,10 @@ static void int_test(const char *txt, int64_t num, yp_style_t s, diag("integer \"%s\":", txt); ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len); - ok(ret == KNOT_EOK, "txt to bin"); + is_int(KNOT_EOK, ret, "txt to bin"); ok(yp_int(b) == num, "compare"); ret = yp_item_to_txt(&i, b, b_len, t, &t_len, s | YP_SNOQUOTE); - ok(ret == KNOT_EOK, "bin to txt"); + is_int(KNOT_EOK, ret, "bin to txt"); ok(strlen(t) == t_len, "txt ret length"); ok(strlen(txt) == t_len, "txt length"); ok(memcmp(txt, t, t_len) == 0, "compare"); @@ -68,10 +68,10 @@ static void bool_test(const char *txt, bool val) diag("boolean \"%s\":", txt); ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len); - ok(ret == KNOT_EOK, "txt to bin"); + is_int(KNOT_EOK, ret, "txt to bin"); ok(yp_bool(b) == val, "compare"); ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE); - ok(ret == KNOT_EOK, "bin to txt"); + is_int(KNOT_EOK, ret, "bin to txt"); ok(strlen(t) == t_len, "txt ret length"); ok(strlen(txt) == t_len, "txt length"); ok(memcmp(txt, t, t_len) == 0, "compare"); @@ -100,11 +100,11 @@ static void opt_test(const char *txt, unsigned val, const knot_lookup_t *opts) diag("option \"%s\":", txt); ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len); - ok(ret == KNOT_EOK, "txt to bin"); + is_int(KNOT_EOK, ret, "txt to bin"); ok(b_len == 1, "compare length"); ok(yp_opt(b) == val, "compare"); ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE); - ok(ret == KNOT_EOK, "bin to txt"); + is_int(KNOT_EOK, ret, "bin to txt"); ok(strlen(t) == t_len, "txt ret length"); ok(strlen(txt) == t_len, "txt length"); ok(memcmp(txt, t, t_len) == 0, "compare"); @@ -133,11 +133,11 @@ static void str_test(const char *txt, const char *val) diag("string \"%s\":", txt); ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len); - ok(ret == KNOT_EOK, "txt to bin"); + is_int(KNOT_EOK, ret, "txt to bin"); ok(b_len == strlen(txt) + 1, "compare length"); ok(memcmp(yp_str(b), val, b_len) == 0, "compare"); ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE); - ok(ret == KNOT_EOK, "bin to txt"); + is_int(KNOT_EOK, ret, "bin to txt"); ok(strlen(t) == t_len, "txt ret length"); ok(strlen(txt) == t_len, "txt length"); ok(memcmp(txt, t, t_len) == 0, "compare"); @@ -154,12 +154,12 @@ static void addr_test(const char *txt, bool port) diag("address \"%s\":", txt); ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len); - ok(ret == KNOT_EOK, "txt to bin"); + is_int(KNOT_EOK, ret, "txt to bin"); bool no_port; yp_addr(b, &no_port); ok(no_port == port, "compare port presence"); ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE); - ok(ret == KNOT_EOK, "bin to txt"); + is_int(KNOT_EOK, ret, "bin to txt"); ok(strlen(t) == t_len, "txt ret length"); ok(strlen(txt) == t_len, "txt length"); ok(memcmp(txt, t, t_len) == 0, "compare"); @@ -188,10 +188,10 @@ static void dname_test(const char *txt, const char *val) diag("dname \"%s\":", txt); ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len); - ok(ret == KNOT_EOK, "txt to bin"); + is_int(KNOT_EOK, ret, "txt to bin"); ok(memcmp(yp_dname(b), val, b_len) == 0, "compare"); ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE); - ok(ret == KNOT_EOK, "bin to txt"); + is_int(KNOT_EOK, ret, "bin to txt"); ok(strlen(t) == t_len, "txt ret length"); ok(strlen(txt) == t_len, "txt length"); ok(memcmp(txt, t, t_len) == 0, "compare"); @@ -212,10 +212,10 @@ static void hex_test(const char *txt, const char *val, const char *txt_out) diag("hex \"%s\":", txt); ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len); - ok(ret == KNOT_EOK, "txt to bin"); + is_int(KNOT_EOK, ret, "txt to bin"); ok(memcmp(yp_bin(b), val, yp_bin_len(b)) == 0, "compare"); ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE); - ok(ret == KNOT_EOK, "bin to txt"); + is_int(KNOT_EOK, ret, "bin to txt"); ok(strlen(t) == t_len, "txt ret length"); ok(strlen(txt_out) == t_len, "txt length"); ok(memcmp(txt_out, t, t_len) == 0, "compare"); @@ -244,10 +244,10 @@ static void base64_test(const char *txt, const char *val) diag("base64 \"%s\":", txt); ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len); - ok(ret == KNOT_EOK, "txt to bin"); + is_int(KNOT_EOK, ret, "txt to bin"); ok(memcmp(yp_bin(b), val, yp_bin_len(b)) == 0, "compare"); ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE); - ok(ret == KNOT_EOK, "bin to txt"); + is_int(KNOT_EOK, ret, "bin to txt"); ok(strlen(t) == t_len, "txt ret length"); ok(strlen(txt) == t_len, "txt length"); ok(memcmp(txt, t, t_len) == 0, "compare"); @@ -268,10 +268,10 @@ static void ref_test(const char *txt, bool val) diag("reference to boolean \"%s\":", txt); ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len); - ok(ret == KNOT_EOK, "txt to bin"); + is_int(KNOT_EOK, ret, "txt to bin"); ok(yp_bool(b) == val, "compare"); ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE); - ok(ret == KNOT_EOK, "bin to txt"); + is_int(KNOT_EOK, ret, "bin to txt"); ok(strlen(t) == t_len, "txt ret length"); ok(strlen(txt) == t_len, "txt length"); ok(memcmp(txt, t, t_len) == 0, "compare"); diff --git a/tests/test_acl.c b/tests/test_acl.c index dcf66ce38f..d592bf9b32 100644 --- a/tests/test_acl.c +++ b/tests/test_acl.c @@ -96,7 +96,7 @@ static void test_acl_allowed(void) " acl: [ acl_range_addr ]"; ret = test_conf(conf_str, NULL); - ok(ret == KNOT_EOK, "Prepare configuration"); + is_int(KNOT_EOK, ret, "Prepare configuration"); acl = conf_zone_get(conf(), C_ACL, zone_name); ok(acl.code == KNOT_EOK, "Get zone ACL"); diff --git a/tests/test_changeset.c b/tests/test_changeset.c index aa32fe9f47..cc491c8f58 100644 --- a/tests/test_changeset.c +++ b/tests/test_changeset.c @@ -53,10 +53,10 @@ int main(int argc, char *argv[]) knot_rrset_add_rdata(apex_txt_rr, data, sizeof(data), 3600, NULL); int ret = changeset_add_addition(ch, apex_txt_rr, CHANGESET_CHECK); - ok(ret == KNOT_EOK, "changeset: add RRSet"); + is_int(KNOT_EOK, ret, "changeset: add RRSet"); ok(changeset_size(ch) == 1, "changeset: size add"); ret = changeset_add_removal(ch, apex_txt_rr, CHANGESET_CHECK); - ok(ret == KNOT_EOK, "changeset: rem RRSet"); + is_int(KNOT_EOK, ret, "changeset: rem RRSet"); ok(changeset_size(ch) == 1, "changeset: size remove"); ok(!changeset_empty(ch), "changeset: empty"); changeset_add_addition(ch, apex_txt_rr, CHANGESET_CHECK); @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) assert(apex_spf_rr); knot_rrset_add_rdata(apex_spf_rr, data, sizeof(data), 3600, NULL); ret = changeset_add_addition(ch, apex_spf_rr, CHANGESET_CHECK); - ok(ret == KNOT_EOK, "changeset: add multiple"); + is_int(KNOT_EOK, ret, "changeset: add multiple"); // Add another node. knot_dname_free(&d, NULL); @@ -76,12 +76,12 @@ int main(int argc, char *argv[]) assert(other_rr); knot_rrset_add_rdata(other_rr, data, sizeof(data), 3600, NULL); ret = changeset_add_addition(ch, other_rr, CHANGESET_CHECK); - ok(ret == KNOT_EOK, "changeset: remove multiple"); + is_int(KNOT_EOK, ret, "changeset: remove multiple"); // Test add traversal. changeset_iter_t it; ret = changeset_iter_add(&it, ch); - ok(ret == KNOT_EOK, "changeset: create iter add"); + is_int(KNOT_EOK, ret, "changeset: create iter add"); // Order: non.terminals.test. TXT, SPF, here.come.more.non.terminals.test. TXT. knot_rrset_t iter = changeset_iter_next(&it); bool trav_ok = knot_rrset_equal(&iter, apex_txt_rr, KNOT_RRSET_COMPARE_WHOLE); @@ -101,7 +101,7 @@ int main(int argc, char *argv[]) // Test remove traversal. ret = changeset_iter_rem(&it, ch); - ok(ret == KNOT_EOK, "changeset: create iter rem"); + is_int(KNOT_EOK, ret, "changeset: create iter rem"); iter = changeset_iter_next(&it); ok(knot_rrset_equal(&iter, apex_txt_rr, KNOT_RRSET_COMPARE_WHOLE), "changeset: rem traversal"); @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) // Test all traversal - just count. ret = changeset_iter_all(&it, ch); - ok(ret == KNOT_EOK, "changest: create iter all"); + is_int(KNOT_EOK, ret, "changest: create iter all"); size_t size = 0; iter = changeset_iter_next(&it); while (!knot_rrset_empty(&iter)) { diff --git a/tests/test_conf.c b/tests/test_conf.c index 60fa074437..c5e6fc359d 100644 --- a/tests/test_conf.c +++ b/tests/test_conf.c @@ -134,7 +134,7 @@ static void test_conf_zonefile(void) " - domain: "ZONE_3LABEL"\n"; ret = test_conf(conf_str, NULL); - ok(ret == KNOT_EOK, "Prepare configuration"); + is_int(KNOT_EOK, ret, "Prepare configuration"); // Relative path with formatters. file = conf_zonefile(conf(), zone_arpa); diff --git a/tests/test_conf_tools.c b/tests/test_conf_tools.c index a9f617ae41..cd746059cf 100644 --- a/tests/test_conf_tools.c +++ b/tests/test_conf_tools.c @@ -37,10 +37,10 @@ static void mod_id_test(const char *txt, const char *val) diag("module id \"%s\":", txt); ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len); - ok(ret == KNOT_EOK, "txt to bin"); + is_int(KNOT_EOK, ret, "txt to bin"); ok(memcmp(b, val, b_len) == 0, "compare"); ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE); - ok(ret == KNOT_EOK, "bin to txt"); + is_int(KNOT_EOK, ret, "bin to txt"); ok(strlen(t) == t_len, "txt ret length"); ok(strlen(txt) == t_len, "txt length"); ok(memcmp(txt, t, t_len) == 0, "compare"); @@ -73,13 +73,13 @@ static void edns_opt_test(const char *txt, uint16_t code, const char *val) diag("edns option \"%s\":", txt); ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len); - ok(ret == KNOT_EOK, "txt to bin"); + is_int(KNOT_EOK, ret, "txt to bin"); uint64_t c = wire_read_u64(b); ok(c == code, "compare code"); ok(memcmp(yp_bin(b + sizeof(uint64_t)), val, yp_bin_len(b + sizeof(uint64_t))) == 0, "compare"); ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE); - ok(ret == KNOT_EOK, "bin to txt"); + is_int(KNOT_EOK, ret, "bin to txt"); ok(strlen(t) == t_len, "txt ret length"); ok(strlen(txt) == t_len, "txt length"); ok(memcmp(txt, t, t_len) == 0, "compare"); @@ -112,9 +112,9 @@ static void addr_range_test(const char *txt) diag("address range \"%s\":", txt); ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len); - ok(ret == KNOT_EOK, "txt to bin"); + is_int(KNOT_EOK, ret, "txt to bin"); ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE); - ok(ret == KNOT_EOK, "bin to txt"); + is_int(KNOT_EOK, ret, "bin to txt"); ok(strlen(t) == t_len, "txt ret length"); ok(strlen(txt) == t_len, "txt length"); ok(memcmp(txt, t, t_len) == 0, "compare"); diff --git a/tests/test_confdb.c b/tests/test_confdb.c index 5341229b14..e21c4c8c0c 100644 --- a/tests/test_confdb.c +++ b/tests/test_confdb.c @@ -54,12 +54,12 @@ static void check_code( case DB_GET: case DB_SET: ok(code == ref_code, "Compare DB code"); - ok(ret == KNOT_EOK, "Find DB code"); + is_int(KNOT_EOK, ret, "Find DB code"); ok(val.len == 1, "Compare DB code length"); ok(((uint8_t *)val.data)[0] == code, "Compare DB code value"); break; case DB_DEL: - ok(ret == KNOT_ENOENT, "Find item code"); + is_int(KNOT_ENOENT, ret, "Find item code"); break; } } @@ -306,11 +306,11 @@ static void check_unset( ret = conf->api->find(txn, &key, &val, 0); if (exp_data != NULL) { - ok(ret == KNOT_EOK, "Get deleted data"); + is_int(KNOT_EOK, ret, "Get deleted data"); ok(val.len == exp_data_len, "Compare data length"); ok(memcmp(val.data, exp_data, exp_data_len) == 0, "Compare data"); } else { - ok(ret == KNOT_ENOENT, "Get deleted data"); + is_int(KNOT_ENOENT, ret, "Get deleted data"); } check_db_content(conf, txn, -1); @@ -335,11 +335,11 @@ static void check_unset_key( uint8_t section_code, item_code; ret = db_code(conf, txn, KEY0_ROOT, key0, DB_GET, §ion_code); if (key1 == NULL && id_len == 0) { - ok(ret == KNOT_ENOENT, "Get DB section code"); + is_int(KNOT_ENOENT, ret, "Get DB section code"); } else { - ok(ret == KNOT_EOK, "Get DB section code"); + is_int(KNOT_EOK, ret, "Get DB section code"); ret = db_code(conf, txn, section_code, key1, DB_GET, &item_code); - ok(ret == KNOT_ENOENT, "Get DB item code"); + is_int(KNOT_ENOENT, ret, "Get DB item code"); } check_db_content(conf, txn, -1); @@ -412,7 +412,7 @@ static void test_conf_db_iter(conf_t *conf, knot_db_txn_t *txn) // Create section iterator. conf_iter_t iter; int ret = conf_db_iter_begin(conf, txn, C_RMT, &iter); - ok(ret == KNOT_EOK, "Create iterator"); + is_int(KNOT_EOK, ret, "Create iterator"); // Iterate through the section. size_t count = 0; @@ -421,7 +421,7 @@ static void test_conf_db_iter(conf_t *conf, knot_db_txn_t *txn) size_t id_len; id = NULL, id_len = 0; // prevents Wuinitialized ret = conf_db_iter_id(conf, &iter, &id, &id_len); - ok(ret == KNOT_EOK, "Get iteration id"); + is_int(KNOT_EOK, ret, "Get iteration id"); ok(id_len == strlen(names[count]), "Compare iteration id length"); ok(memcmp(id, names[count], id_len) == 0, "Compare iteration id"); @@ -430,12 +430,12 @@ static void test_conf_db_iter(conf_t *conf, knot_db_txn_t *txn) count++; ret = conf_db_iter_next(conf, &iter); } - ok(ret == KNOT_EOF, "Finished iteration"); + is_int(KNOT_EOF, ret, "Finished iteration"); ok(count == total, "Check iteration count"); // Check empty section. ret = conf_db_iter_begin(conf, txn, C_RMT, &iter); - ok(ret == KNOT_ENOENT, "Create iterator"); + is_int(KNOT_ENOENT, ret, "Create iterator"); // ERR non-iterable section. ok(conf_db_iter_begin(conf, txn, C_SERVER, &iter) == KNOT_ENOTSUP, "Create iterator"); diff --git a/tests/test_journal.c b/tests/test_journal.c index a5ddd87791..fff29f8e75 100644 --- a/tests/test_journal.c +++ b/tests/test_journal.c @@ -243,10 +243,10 @@ static void test_journal_db(void) int ret, ret2 = KNOT_EOK; ret = journal_db_init(&db, test_dir_name, 2 * 1024 * 1024); - ok(ret == KNOT_EOK, "journal: init db (%d)", ret); + is_int(KNOT_EOK, ret, "journal: init db (%d)", ret); ret = open_journal_db(&db); - ok(ret == KNOT_EOK, "journal: open db (%d)", ret); + is_int(KNOT_EOK, ret, "journal: open db (%d)", ret); journal_db_close(&db); ok(db == NULL, "journal: close and destroy db"); @@ -274,15 +274,15 @@ static void test_store_load(void) ret = journal_db_init(&db, test_dir_name, 1024 * 1024); if (ret == KNOT_EOK) ret2 = journal_open(j, &db, apex); - ok(ret == KNOT_EOK, "journal: open (%d, %d)", ret, ret2); + is_int(KNOT_EOK, ret, "journal: open (%d, %d)", ret, ret2); /* Save and load changeset. */ changeset_t *m_ch = changeset_new(apex); init_random_changeset(m_ch, 0, 1, 128, apex); ret = journal_store_changeset(j, m_ch); - ok(ret == KNOT_EOK, "journal: store changeset (%d)", ret); + is_int(KNOT_EOK, ret, "journal: store changeset (%d)", ret); ret = journal_check(j, JOURNAL_CHECK_INFO); - ok(ret == KNOT_EOK, "journal check (%d)", ret); + is_int(KNOT_EOK, ret, "journal check (%d)", ret); list_t l, k; init_list(&l); init_list(&k); @@ -290,16 +290,16 @@ static void test_store_load(void) add_tail(&k, &m_ch->n); ok(ret == KNOT_EOK && changesets_list_eq(&l, &k), "journal: load changeset (%d)", ret); ret = journal_check(j, JOURNAL_CHECK_INFO); - ok(ret == KNOT_EOK, "journal check (%d)", ret); + is_int(KNOT_EOK, ret, "journal check (%d)", ret); changesets_free(&l); changesets_free(&k); /* Flush the journal. */ ret = journal_flush(j); - ok(ret == KNOT_EOK, "journal: first and simple flush (%d)", ret); + is_int(KNOT_EOK, ret, "journal: first and simple flush (%d)", ret); ret = journal_check(j, JOURNAL_CHECK_INFO); - ok(ret == KNOT_EOK, "journal check (%d)", ret); + is_int(KNOT_EOK, ret, "journal check (%d)", ret); init_list(&l); init_list(&k); @@ -316,10 +316,10 @@ static void test_store_load(void) } add_tail(&k, &m_ch2->n); } - ok(ret == KNOT_EBUSY, "journal: overfill with changesets (%d inserted) (%d should= %d)", + is_int(KNOT_EBUSY, ret, "journal: overfill with changesets (%d inserted) (%d should= %d)", serial, ret, KNOT_EBUSY); ret = journal_check(j, JOURNAL_CHECK_INFO); - ok(ret == KNOT_EOK, "journal check (%d)", ret); + is_int(KNOT_EOK, ret, "journal check (%d)", ret); /* Load all changesets stored until now. */ ret = journal_load_changesets(j, &l, 1); @@ -335,9 +335,9 @@ static void test_store_load(void) /* Flush the journal. */ ret = journal_flush(j); - ok(ret == KNOT_EOK, "journal: second flush (%d)", ret); + is_int(KNOT_EOK, ret, "journal: second flush (%d)", ret); ret = journal_check(j, JOURNAL_CHECK_INFO); - ok(ret == KNOT_EOK, "journal check (%d)", ret); + is_int(KNOT_EOK, ret, "journal check (%d)", ret); /* Test whether the journal kept changesets after flush. */ ret = journal_load_changesets(j, &l, 1); @@ -354,21 +354,21 @@ static void test_store_load(void) init_random_changeset(&ch, serial, serial + 1, 128, apex); ret = journal_store_changeset(j, &ch); changeset_clear(&ch); - ok(ret == KNOT_EOK, "journal: store after flush (%d)", ret); + is_int(KNOT_EOK, ret, "journal: store after flush (%d)", ret); ret = journal_check(j, JOURNAL_CHECK_INFO); - ok(ret == KNOT_EOK, "journal check (%d)", ret); + is_int(KNOT_EOK, ret, "journal check (%d)", ret); /* Load last changesets. */ init_list(&l); ret = journal_load_changesets(j, &l, serial); changesets_free(&l); - ok(ret == KNOT_EOK, "journal: load changesets after flush (%d)", ret); + is_int(KNOT_EOK, ret, "journal: load changesets after flush (%d)", ret); /* Flush the journal again. */ ret = journal_flush(j); - ok(ret == KNOT_EOK, "journal: flush again (%d)", ret); + is_int(KNOT_EOK, ret, "journal: flush again (%d)", ret); ret = journal_check(j, JOURNAL_CHECK_INFO); - ok(ret == KNOT_EOK, "journal check (%d)", ret); + is_int(KNOT_EOK, ret, "journal check (%d)", ret); /* Fill the journal using a list. */ uint32_t m_serial = 1; @@ -378,9 +378,9 @@ static void test_store_load(void) add_tail(&l, &m_ch7->n); } ret = journal_store_changesets(j, &l); - ok(ret == KNOT_EOK, "journal: fill with changesets using a list (%d inserted)", m_serial); + is_int(KNOT_EOK, ret, "journal: fill with changesets using a list (%d inserted)", m_serial); ret = journal_check(j, JOURNAL_CHECK_INFO); - ok(ret == KNOT_EOK, "journal check (%d)", ret); + is_int(KNOT_EOK, ret, "journal check (%d)", ret); /* Cleanup. */ changesets_free(&l); @@ -398,9 +398,9 @@ static void test_store_load(void) changesets_free(&l); init_list(&l); ret = journal_flush(j); - ok(ret == KNOT_EOK, "journal: allways ok journal_flush 0"); + is_int(KNOT_EOK, ret, "journal: allways ok journal_flush 0"); ret = drop_journal(j, NULL); /* Clear the journal for the collision test */ - ok(ret == KNOT_EOK, "journal: allways ok drop_journal"); + is_int(KNOT_EOK, ret, "journal: allways ok drop_journal"); /* Test for serial number collision handling. We insert changesets * with valid serial sequence that overflows and then collides with itself. @@ -411,30 +411,30 @@ static void test_store_load(void) changeset_t *m_ch3 = changeset_new(apex); init_random_changeset(m_ch3, 0, 1, 128, apex); ret = journal_store_changeset(j, m_ch3); - ok(ret == KNOT_EOK, "journal: allways ok journal_store_changeset 1"); + is_int(KNOT_EOK, ret, "journal: allways ok journal_store_changeset 1"); changeset_set_soa_serials(m_ch3, 1, 2, apex); ret = journal_store_changeset(j, m_ch3); - ok(ret == KNOT_EOK, "journal: allways ok journal_store_changeset 2"); + is_int(KNOT_EOK, ret, "journal: allways ok journal_store_changeset 2"); changeset_set_soa_serials(m_ch3, 2, 2147483647, apex); add_tail(&k, &m_ch3->n); ret = journal_store_changeset(j, m_ch3); - ok(ret == KNOT_EOK, "journal: allways ok journal_store_changeset 3"); + is_int(KNOT_EOK, ret, "journal: allways ok journal_store_changeset 3"); changeset_t *m_ch4 = changeset_new(apex); init_random_changeset(m_ch4, 2147483647, 4294967294, 128, apex); add_tail(&k, &m_ch4->n); ret = journal_store_changeset(j, m_ch4); - ok(ret == KNOT_EOK, "journal: allways ok journal_store_changeset 4"); + is_int(KNOT_EOK, ret, "journal: allways ok journal_store_changeset 4"); changeset_t *m_ch5 = changeset_new(apex); init_random_changeset(m_ch5, 4294967294, 1, 128, apex); add_tail(&k, &m_ch5->n); ret = journal_store_changeset(j, m_ch5); - ok(ret == KNOT_EBUSY, "journal: allways ok journal_store_changeset 5"); + is_int(KNOT_EBUSY, ret, "journal: allways ok journal_store_changeset 5"); ret = journal_flush(j); - ok(ret == KNOT_EOK, "journal: allways ok journal_flush 1"); + is_int(KNOT_EOK, ret, "journal: allways ok journal_flush 1"); ret = journal_store_changeset(j, m_ch5); - ok(ret == KNOT_EOK, "journal: allways ok journal_store_changeset 6"); + is_int(KNOT_EOK, ret, "journal: allways ok journal_store_changeset 6"); ret = journal_flush(j); - ok(ret == KNOT_EOK, "journal: allways ok journal_flush 2"); + is_int(KNOT_EOK, ret, "journal: allways ok journal_flush 2"); ret = journal_load_changesets(j, &l, 0); ret2 = journal_load_changesets(j, &l, 1); int ret3 = journal_load_changesets(j, &l, 2); @@ -442,7 +442,7 @@ static void test_store_load(void) ok(ret == KNOT_ENOENT && ret2 == KNOT_ENOENT && ret3 == KNOT_EOK && changesets_list_eq(&l, &k), "journal: serial collision"); ret = journal_check(j, JOURNAL_CHECK_INFO); - ok(ret == KNOT_EOK, "journal check (%d)", ret); + is_int(KNOT_EOK, ret, "journal check (%d)", ret); /* Cleanup. */ changesets_free(&l); @@ -577,16 +577,16 @@ static void test_merge(void) ok(journal_merge_allowed(j), "journal: merge allowed"); ret = drop_journal(j, NULL); - ok(ret == KNOT_EOK, "journal: drop_journal must be ok"); + is_int(KNOT_EOK, ret, "journal: drop_journal must be ok"); // insert stuff and check the merge for (i = 0; !merged_present(); i++) { ret = journal_store_changeset(j, tm_chs(apex, i)); - ok(ret == KNOT_EOK, "journal: journal_store_changeset must be ok"); + is_int(KNOT_EOK, ret, "journal: journal_store_changeset must be ok"); } init_list(&l); ret = journal_load_changesets(j, &l, 0); - ok(ret == KNOT_EOK, "journal: journal_load_changesets must be ok"); + is_int(KNOT_EOK, ret, "journal: journal_load_changesets must be ok"); ok(list_size(&l) == 2, "journal: read the merged and one following"); changeset_t * mch = (changeset_t *)HEAD(l); ok(list_size(&l) >= 1 && tm_rrcnt(mch, 1) == 2, "journal: merged additions # = 2"); @@ -597,12 +597,12 @@ static void test_merge(void) journal_store_changeset(j, tm_chs(apex, i)); init_list(&l); ret = journal_load_changesets(j, &l, 0); - ok(ret == KNOT_EOK, "journal: journal_load_changesets2 must be ok"); + is_int(KNOT_EOK, ret, "journal: journal_load_changesets2 must be ok"); ok(list_size(&l) == 3, "journal: read merged together with new changeset"); changesets_free(&l); init_list(&l); ret = journal_load_changesets(j, &l, (uint32_t) (i - 3)); - ok(ret == KNOT_EOK, "journal: journal_load_changesets3 must be ok"); + is_int(KNOT_EOK, ret, "journal: journal_load_changesets3 must be ok"); ok(list_size(&l) == 4, "journal: read short history of merged/unmerged changesets"); changesets_free(&l); diff --git a/tests/test_process_query.c b/tests/test_process_query.c index 92d786ee66..7c273b08cf 100644 --- a/tests/test_process_query.c +++ b/tests/test_process_query.c @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) /* Create fake server environment. */ server_t server; int ret = create_fake_server(&server, proc.mm); - ok(ret == KNOT_EOK, "ns: fake server initialization"); + is_int(KNOT_EOK, ret, "ns: fake server initialization"); zone_t *zone = knot_zonedb_find(server.zone_db, ROOT_DNAME); diff --git a/tests/test_query_module.c b/tests/test_query_module.c index 15e25899b5..3f38f84863 100644 --- a/tests/test_query_module.c +++ b/tests/test_query_module.c @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) break; } } - ok(ret == KNOT_EOK, "query_plan: planned all steps"); + is_int(KNOT_EOK, ret, "query_plan: planned all steps"); /* Execute the plan. */ int state = 0, next_state = 0; diff --git a/tests/test_server.c b/tests/test_server.c index b476c67a40..e9663674b9 100644 --- a/tests/test_server.c +++ b/tests/test_server.c @@ -44,14 +44,14 @@ int main(int argc, char *argv[]) /* Test server for correct initialization */ ret = server_init(&server, 1); - ok(ret == KNOT_EOK, "server: initialized"); + is_int(KNOT_EOK, ret, "server: initialized"); if (ret != KNOT_EOK) { return 1; } /* Test server startup */ ret = server_start(&server, false); - ok(ret == KNOT_EOK, "server: started ok"); + is_int(KNOT_EOK, ret, "server: started ok"); if (ret != KNOT_EOK) { return 1; } diff --git a/tests/test_zone-update.c b/tests/test_zone-update.c index a50d64a82a..bf7cbfe26f 100644 --- a/tests/test_zone-update.c +++ b/tests/test_zone-update.c @@ -69,7 +69,7 @@ void test_full(zone_t *zone, zs_scanner_t *sc) zone_update_t update; /* Init update */ int ret = zone_update_init(&update, zone, UPDATE_FULL); - ok(ret == KNOT_EOK, "zone update: init full"); + is_int(KNOT_EOK, ret, "zone update: init full"); if (zs_set_input_string(sc, zone_str1, strlen(zone_str1)) != 0 || zs_parse_all(sc) != 0) { @@ -79,7 +79,7 @@ void test_full(zone_t *zone, zs_scanner_t *sc) /* First addition */ ret = zone_update_add(&update, &rrset); knot_rdataset_clear(&rrset.rrs, NULL); - ok(ret == KNOT_EOK, "full zone update: first addition"); + is_int(KNOT_EOK, ret, "full zone update: first addition"); if (zs_set_input_string(sc, zone_str2, strlen(zone_str2)) != 0 || zs_parse_all(sc) != 0) { @@ -134,7 +134,7 @@ void test_full(zone_t *zone, zs_scanner_t *sc) /* Test iteration */ zone_update_iter_t it; ret = zone_update_iter(&it, &update); - ok(ret == KNOT_EOK, "full zone update: init iter"); + is_int(KNOT_EOK, ret, "full zone update: init iter"); const zone_node_t *iter_node = zone_update_iter_val(&it); assert(iter_node); @@ -155,7 +155,7 @@ void test_full(zone_t *zone, zs_scanner_t *sc) knot_rdataset_clear(&rrset.rrs, NULL); ret = zone_update_iter_next(&it); - ok(ret == KNOT_EOK, "full zone update: iter next"); + is_int(KNOT_EOK, ret, "full zone update: iter next"); iter_node = zone_update_iter_val(&it); ok(iter_node == NULL, "full zone update: iter val past end"); @@ -198,7 +198,7 @@ void test_incremental(zone_t *zone, zs_scanner_t *sc) /* Addition */ ret = zone_update_add(&update, &rrset); knot_rdataset_clear(&rrset.rrs, NULL); - ok(ret == KNOT_EOK, "incremental zone update: addition"); + is_int(KNOT_EOK, ret, "incremental zone update: addition"); const zone_node_t *synth_node = zone_update_get_apex(&update); ok(synth_node && node_rdataset(synth_node, KNOT_RRTYPE_TXT)->rr_count == 2, @@ -210,7 +210,7 @@ void test_incremental(zone_t *zone, zs_scanner_t *sc) } /* Removal */ ret = zone_update_remove(&update, &rrset); - ok(ret == KNOT_EOK, "incremental zone update: removal"); + is_int(KNOT_EOK, ret, "incremental zone update: removal"); knot_rdataset_clear(&rrset.rrs, NULL); synth_node = zone_update_get_apex(&update); @@ -239,7 +239,7 @@ void test_incremental(zone_t *zone, zs_scanner_t *sc) /* Test iteration */ zone_update_iter_t it; ret = zone_update_iter(&it, &update); - ok(ret == KNOT_EOK, "incremental zone update: init iter"); + is_int(KNOT_EOK, ret, "incremental zone update: init iter"); if (zs_set_input_string(sc, del_str, strlen(del_str)) != 0 || zs_parse_all(sc) != 0) { @@ -262,9 +262,9 @@ void test_incremental(zone_t *zone, zs_scanner_t *sc) knot_rdataset_clear(&rrset.rrs, NULL); ret = zone_update_iter_next(&it); - ok(ret == KNOT_EOK, "incremental zone update: iter next"); + is_int(KNOT_EOK, ret, "incremental zone update: iter next"); ret = zone_update_iter_next(&it); - ok(ret == KNOT_EOK, "incremental zone update: iter next"); + is_int(KNOT_EOK, ret, "incremental zone update: iter next"); iter_node = zone_update_iter_val(&it); ok(iter_node == NULL, "incremental zone update: iter val past end"); @@ -299,11 +299,11 @@ int main(int argc, char *argv[]) /* Load test configuration. */ int ret = test_conf(conf_str, NULL); - ok(ret == KNOT_EOK, "load configuration"); + is_int(KNOT_EOK, ret, "load configuration"); server_t server; ret = server_init(&server, 1); - ok(ret == KNOT_EOK, "server init"); + is_int(KNOT_EOK, ret, "server init"); /* Set up empty zone */ knot_dname_t *apex = knot_dname_from_str_alloc("test"); diff --git a/tests/test_zone_timers.c b/tests/test_zone_timers.c index 4d0935d1ce..8da03ed97d 100644 --- a/tests/test_zone_timers.c +++ b/tests/test_zone_timers.c @@ -69,11 +69,11 @@ int main(int argc, char *argv[]) // Lookup nonexistent ret = zone_timers_read(db, zone, &timers); - ok(ret == KNOT_ENOENT, "zone_timer_read() nonexistent"); + is_int(KNOT_ENOENT, ret, "zone_timer_read() nonexistent"); // Write timers ret = zone_timers_write(db, zone, &timers, NULL); - ok(ret == KNOT_EOK, "zone_timers_write()"); + is_int(KNOT_EOK, ret, "zone_timers_write()"); // Read timers memset(&timers, 0, sizeof(timers)); @@ -82,15 +82,15 @@ int main(int argc, char *argv[]) // Sweep none ret = zone_timers_sweep(db, keep_all, NULL); - ok(ret == KNOT_EOK, "zone_timers_sweep() none"); + is_int(KNOT_EOK, ret, "zone_timers_sweep() none"); ret = zone_timers_read(db, zone, &timers); - ok(ret == KNOT_EOK, "zone_timers_read()"); + is_int(KNOT_EOK, ret, "zone_timers_read()"); // Sweep all ret = zone_timers_sweep(db, remove_all, NULL); - ok(ret == KNOT_EOK, "zone_timers_sweep() all"); + is_int(KNOT_EOK, ret, "zone_timers_sweep() all"); ret = zone_timers_read(db, zone, &timers); - ok(ret == KNOT_ENOENT, "zone_timers_read() nonexistent"); + is_int(KNOT_ENOENT, ret, "zone_timers_read() nonexistent"); // Clean up. zone_timers_close(db); diff --git a/tests/utils/test_lookup.c b/tests/utils/test_lookup.c index 70f7646f96..111eb26be5 100644 --- a/tests/utils/test_lookup.c +++ b/tests/utils/test_lookup.c @@ -25,7 +25,7 @@ static void check_search_ok(lookup_t *l, const char *in, const char *out) { diag("Search for '%s'", in); int ret = lookup_search(l, in, strlen(in)); - ok(ret == KNOT_EOK, "Check found"); + is_int(KNOT_EOK, ret, "Check found"); ok(strcmp(out, l->found.key) == 0, "Compare key"); ok(strcmp(out, l->found.data) == 0, "Compare data"); ok(l->iter.first_key == NULL, "Compare no first key"); @@ -37,7 +37,7 @@ static void check_search_multi(lookup_t *l, const char *in, const char *out, { diag("Search for '%s'", in); int ret = lookup_search(l, in, strlen(in)); - ok(ret == KNOT_EFEWDATA, "Check found multi"); + is_int(KNOT_EFEWDATA, ret, "Check found multi"); ok(strcmp(out, l->found.key) == 0, "Compare key"); ok(l->found.data == NULL, "Compare no data"); ok(strcmp(first, l->iter.first_key) == 0, "Compare first key"); @@ -48,7 +48,7 @@ static void check_search_none(lookup_t *l, const char *in) { diag("Search for '%s'", in); int ret = lookup_search(l, in, strlen(in)); - ok(ret == KNOT_ENOENT, "Check not found"); + is_int(KNOT_ENOENT, ret, "Check not found"); ok(l->found.key == NULL, "Check no key"); ok(l->found.data == NULL, "Check no data"); } @@ -56,11 +56,11 @@ static void check_search_none(lookup_t *l, const char *in) static void init(lookup_t *l, const char **table) { int ret = lookup_init(l); - ok(ret == KNOT_EOK, "Init"); + is_int(KNOT_EOK, ret, "Init"); while (*table != NULL) { ret = lookup_insert(l, *table, (void *)*table); - ok(ret == KNOT_EOK, "Insert '%s'", *table); + is_int(KNOT_EOK, ret, "Insert '%s'", *table); table++; } } -- GitLab