summaryrefslogtreecommitdiffstats
path: root/tests/libknot
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-12 04:45:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-12 04:45:07 +0000
commit0335817ced71e8355806ea0445aa3b105a22364c (patch)
treedffe735f2668a4728d8567feaf7ccb2d73076bac /tests/libknot
parentAdding upstream version 3.3.9. (diff)
downloadknot-upstream/3.4.0.tar.xz
knot-upstream/3.4.0.zip
Adding upstream version 3.4.0.upstream/3.4.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/libknot')
-rw-r--r--tests/libknot/test_control.c4
-rw-r--r--tests/libknot/test_xdp_tcp.c49
-rw-r--r--tests/libknot/test_yptrafo.c7
3 files changed, 38 insertions, 22 deletions
diff --git a/tests/libknot/test_control.c b/tests/libknot/test_control.c
index 3846f31..3467be4 100644
--- a/tests/libknot/test_control.c
+++ b/tests/libknot/test_control.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2024 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -109,7 +109,7 @@ static void ctl_server(const char *socket, size_t argc, knot_ctl_data_t *argv)
knot_ctl_t *ctl = knot_ctl_alloc();
ok(ctl != NULL, "Allocate control");
- int ret = knot_ctl_bind(ctl, socket);
+ int ret = knot_ctl_bind(ctl, socket, 5);
is_int(KNOT_EOK, ret, "Bind control socket");
ret = knot_ctl_accept(ctl);
diff --git a/tests/libknot/test_xdp_tcp.c b/tests/libknot/test_xdp_tcp.c
index 7f3b994..4e02f57 100644
--- a/tests/libknot/test_xdp_tcp.c
+++ b/tests/libknot/test_xdp_tcp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2024 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -213,7 +213,7 @@ void test_syn(void)
knot_xdp_msg_t msg;
knot_tcp_relay_t rl = { 0 };
prepare_msg(&msg, KNOT_XDP_MSG_SYN, 1, 2);
- int ret = knot_tcp_recv(&rl, &msg, 1, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ int ret = knot_tcp_recv(&rl, &msg, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
is_int(KNOT_EOK, ret, "SYN: relay OK");
ret = knot_tcp_send(test_sock, &rl, 1, 1);
is_int(KNOT_EOK, ret, "SYN: send OK");
@@ -241,7 +241,7 @@ void test_syn_ack_no(void)
knot_xdp_msg_t msg;
knot_tcp_relay_t rl = { 0 };
prepare_msg(&msg, KNOT_XDP_MSG_SYN | KNOT_XDP_MSG_ACK, 1, 2);
- int ret = knot_tcp_recv(&rl, &msg, 1, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ int ret = knot_tcp_recv(&rl, &msg, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
is_int(KNOT_EOK, ret, "SYN+ACK deny: relay OK");
is_int(XDP_TCP_NOOP, rl.auto_answer, "SYN+ACK deny: no auto answer");
is_int(XDP_TCP_NOOP, rl.answer, "SYN+ACK deny: no answer");
@@ -256,7 +256,7 @@ void test_establish(void)
knot_tcp_relay_t rl = { 0 };
prepare_msg(&msg, KNOT_XDP_MSG_ACK, 1, 2);
prepare_seqack(&msg, 0, 1);
- int ret = knot_tcp_recv(&rl, &msg, 1, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ int ret = knot_tcp_recv(&rl, &msg, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
is_int(KNOT_EOK, ret, "establish: relay OK");
is_int(0, test_syn_table->usage, "SYN: no connection in SYN table");
is_int(1, test_table->usage, "SYN: one connection in normal table");
@@ -274,7 +274,7 @@ void test_syn_ack(void)
knot_xdp_msg_t msg;
knot_tcp_relay_t rl = { 0 };
prepare_msg(&msg, KNOT_XDP_MSG_SYN | KNOT_XDP_MSG_ACK, 1000, 2000);
- int ret = knot_tcp_recv(&rl, &msg, 1, test_table, NULL, XDP_TCP_IGNORE_NONE);
+ int ret = knot_tcp_recv(&rl, &msg, test_table, NULL, XDP_TCP_IGNORE_NONE);
is_int(KNOT_EOK, ret, "SYN+ACK: relay OK");
ret = knot_tcp_send(test_sock, &rl, 1, 1);
is_int(KNOT_EOK, ret, "SYN+ACK: send OK");
@@ -315,7 +315,10 @@ void test_data_fragments(void)
prepare_data(&msgs[3], "\x02""AB""\xff\xff""abcdefghijklmnopqrstuvwxyz...", 34);
assert(test_table);
- int ret = knot_tcp_recv(rls, msgs, CONNS, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ int ret = KNOT_EOK;
+ for (int i = 0; i < CONNS && ret == KNOT_EOK; i++) {
+ ret = knot_tcp_recv(&rls[i], &msgs[i], test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ }
is_int(KNOT_EOK, ret, "fragments: relay OK");
assert(test_sock);
ret = knot_tcp_send(test_sock, rls, CONNS, CONNS);
@@ -374,7 +377,7 @@ void test_close(void)
knot_xdp_msg_t wrong = msg;
wrong.seqno += INT32_MAX;
wrong.ackno += INT32_MAX;
- int ret = knot_tcp_recv(&rl, &wrong, 1, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ int ret = knot_tcp_recv(&rl, &wrong, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
is_int(KNOT_EOK, ret, "close: relay 0 OK");
is_int(KNOT_XDP_MSG_RST, rl.auto_answer, "close: reset wrong ackno");
is_int(rl.auto_seqno, wrong.ackno, "close: reset seqno");
@@ -383,7 +386,7 @@ void test_close(void)
check_sent(0, 1, 0, 0);
is_int(sent_seqno, wrong.ackno, "close: reset seqno sent");
- ret = knot_tcp_recv(&rl, &msg, 1, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ ret = knot_tcp_recv(&rl, &msg, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
is_int(KNOT_EOK, ret, "close: relay 1 OK");
ret = knot_tcp_send(test_sock, &rl, 1, 1);
is_int(KNOT_EOK, ret, "close: send OK");
@@ -395,7 +398,7 @@ void test_close(void)
msg.flags &= ~KNOT_XDP_MSG_FIN;
prepare_seqack(&msg, 0, 0);
- ret = knot_tcp_recv(&rl, &msg, 1, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ ret = knot_tcp_recv(&rl, &msg, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
is_int(KNOT_EOK, ret, "close: relay 2 OK");
ret = knot_tcp_send(test_sock, &rl, 1, 1);
is_int(KNOT_EOK, ret, "close: send 2 OK");
@@ -418,7 +421,10 @@ void test_many(void)
}
knot_tcp_relay_t *rls = malloc(CONNS * sizeof(*rls));
- int ret = knot_tcp_recv(rls, msgs, CONNS, test_table, NULL, XDP_TCP_IGNORE_NONE);
+ int ret = KNOT_EOK;
+ for (int i = 0; i < CONNS && ret == KNOT_EOK; i++) {
+ ret = knot_tcp_recv(&rls[i], &msgs[i], test_table, NULL, XDP_TCP_IGNORE_NONE);
+ }
is_int(KNOT_EOK, ret, "many: relay OK");
ret = knot_tcp_send(test_sock, rls, CONNS, CONNS);
is_int(KNOT_EOK, ret, "many: relay send OK");
@@ -435,7 +441,7 @@ void test_many(void)
fix_seqack(survive);
prepare_data(survive, "\x00\x00", 2);
assert(test_table);
- ret = knot_tcp_recv(&surv_rl, survive, 1, test_table, NULL, XDP_TCP_IGNORE_NONE);
+ ret = knot_tcp_recv(&surv_rl, survive, test_table, NULL, XDP_TCP_IGNORE_NONE);
is_int(KNOT_EOK, ret, "many/survivor: OK");
clean_sent();
@@ -479,7 +485,10 @@ void test_ibufs_size(void)
for (int i = 0; i < CONNS; i++) {
prepare_msg(&msgs[i], KNOT_XDP_MSG_SYN, i + 2000, 1);
}
- int ret = knot_tcp_recv(rls, msgs, CONNS, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ int ret = KNOT_EOK;
+ for (int i = 0; i < CONNS && ret == KNOT_EOK; i++) {
+ ret = knot_tcp_recv(&rls[i], &msgs[i], test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ }
is_int(KNOT_EOK, ret, "ibufs: open OK");
ret = knot_tcp_send(test_sock, rls, CONNS, CONNS);
is_int(KNOT_EOK, ret, "ibufs: first send OK");
@@ -488,14 +497,16 @@ void test_ibufs_size(void)
msgs[i].flags = KNOT_XDP_MSG_TCP | KNOT_XDP_MSG_ACK;
}
fix_seqacks(msgs, CONNS);
- (void)knot_tcp_recv(rls, msgs, CONNS, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ for (int i = 0; i < CONNS && ret == KNOT_EOK; i++) {
+ ret = knot_tcp_recv(&rls[i], &msgs[i], test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ }
is_int(0, test_table->inbufs_total, "inbufs: initial total zero");
// first connection will start a fragment buf then finish it
fix_seqack(&msgs[0]);
prepare_data(&msgs[0], "\x00\x0a""lorem", 7);
- ret = knot_tcp_recv(&rls[0], &msgs[0], 1, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ ret = knot_tcp_recv(&rls[0], &msgs[0], test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
is_int(KNOT_EOK, ret, "ibufs: must be OK");
ret = knot_tcp_send(test_sock, &rls[0], 1, 1);
is_int(KNOT_EOK, ret, "ibufs: must send OK");
@@ -509,7 +520,9 @@ void test_ibufs_size(void)
prepare_data(&msgs[1], "\x00\xff""12345", 7);
prepare_data(&msgs[2], "\xff\xff""abcde", 7);
prepare_data(&msgs[3], "\xff\xff""abcde", 7);
- ret = knot_tcp_recv(rls, msgs, CONNS, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ for (int i = 0; i < CONNS && ret == KNOT_EOK; i++) {
+ ret = knot_tcp_recv(&rls[i], &msgs[i], test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ }
is_int(KNOT_EOK, ret, "inbufs: relay OK");
ret = knot_tcp_send(test_sock, rls, CONNS, CONNS);
is_int(KNOT_EOK, ret, "inbufs: send OK");
@@ -546,11 +559,11 @@ void test_obufs(void)
knot_tcp_relay_t rl = { 0 };
prepare_msg(&msg, KNOT_XDP_MSG_SYN, 1, 2);
- (void)knot_tcp_recv(&rl, &msg, 1, test_table, test_syn_table, XDP_TCP_IGNORE_NONE); // SYN
+ (void)knot_tcp_recv(&rl, &msg, test_table, test_syn_table, XDP_TCP_IGNORE_NONE); // SYN
(void)knot_tcp_send(test_sock, &rl, 1, 1); // SYN+ACK
prepare_msg(&msg, KNOT_XDP_MSG_ACK, 1, 2);
prepare_seqack(&msg, 0, 1);
- (void)knot_tcp_recv(&rl, &msg, 1, test_table, test_syn_table, XDP_TCP_IGNORE_NONE); // ACK
+ (void)knot_tcp_recv(&rl, &msg, test_table, test_syn_table, XDP_TCP_IGNORE_NONE); // ACK
size_t TEST_MSS = 1111;
size_t DATA_LEN = 65535; // with 2-byte len prefix, this is > 64k == window_size
@@ -588,7 +601,7 @@ void test_obufs(void)
memset(&rl, 0, sizeof(rl));
prepare_seqack(&msg, 0, TEST_MSS);
- ret = knot_tcp_recv(&rl, &msg, 1, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
+ ret = knot_tcp_recv(&rl, &msg, test_table, test_syn_table, XDP_TCP_IGNORE_NONE);
is_int(KNOT_EOK, ret, "obufs: ACKed data");
assert(rl.conn);
rl.conn->window_size = 65536;
diff --git a/tests/libknot/test_yptrafo.c b/tests/libknot/test_yptrafo.c
index cd26632..d76dbc4 100644
--- a/tests/libknot/test_yptrafo.c
+++ b/tests/libknot/test_yptrafo.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2024 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -326,7 +326,10 @@ int main(int argc, char *argv[])
int_test("11s", 11LL * 1, YP_STIME, min, max);
int_test("11m", 11LL * 60, YP_STIME, min, max);
int_test("11h", 11LL * 3600, YP_STIME, min, max);
- int_test("11d", 11LL * 24 * 3600, YP_STIME, min, max);
+ int_test("6d", 6LL * 24 * 3600, YP_STIME, min, max);
+ int_test("4w", 4LL * 7 * 24 * 3600, YP_STIME, min, max);
+ int_test("11M", 11LL * 30 * 24 * 3600, YP_STIME, min, max);
+ int_test("2y", 2LL * 365 * 24 * 3600, YP_STIME, min, max);
int_test("1025B", 1025LL, YP_SSIZE, min, max);
int_test("61s", 61LL, YP_STIME, min, max);
int_bad_test("20000000001", KNOT_ERANGE, YP_SNONE, min, max);