summaryrefslogtreecommitdiff
path: root/src/irmd/reg/tests
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2026-02-15 12:26:04 +0100
committerSander Vrijders <sander@ouroboros.rocks>2026-02-18 07:58:21 +0100
commit760e17f142eb5cc0f594f1383ae68bb63bebe9ee (patch)
treefe0734604c3546421df5bb9ed880ec42e779a980 /src/irmd/reg/tests
parent471700175766f5a7f0b2449e1fe320ee78e9e2af (diff)
downloadouroboros-760e17f142eb5cc0f594f1383ae68bb63bebe9ee.tar.gz
ouroboros-760e17f142eb5cc0f594f1383ae68bb63bebe9ee.zip
lib: Add struct llist for lists tracking len
The DHT uses a struct {struct list_head, size_t len} pattern, which is also useful in the registry and other places. Having a struct llist (defined in list.h) with consistent macros for addition/deletion etc removes a lot of duplication and boilerplate and reduces the risk of inconsistent updates. The list management is now a macro-only implementation. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/irmd/reg/tests')
-rw-r--r--src/irmd/reg/tests/name_test.c8
-rw-r--r--src/irmd/reg/tests/proc_test.c4
-rw-r--r--src/irmd/reg/tests/prog_test.c4
-rw-r--r--src/irmd/reg/tests/reg_test.c34
4 files changed, 25 insertions, 25 deletions
diff --git a/src/irmd/reg/tests/name_test.c b/src/irmd/reg/tests/name_test.c
index 4812fb9d..403c8a6c 100644
--- a/src/irmd/reg/tests/name_test.c
+++ b/src/irmd/reg/tests/name_test.c
@@ -88,7 +88,7 @@ static int test_reg_name_add_proc(void)
reg_name_del_proc(n, TEST_PID);
- if (n->procs.len != 0) {
+ if (!llist_is_empty(&n->procs)) {
printf("Proc not removed from list.\n");
goto fail;
}
@@ -138,7 +138,7 @@ static int test_reg_name_add_prog(void)
reg_name_del_prog(n, TEST_PROG);
- if (n->progs.len != 0) {
+ if (!llist_is_empty(&n->progs)) {
printf("Prog not removed from list.\n");
goto fail;
}
@@ -263,12 +263,12 @@ static int test_reg_name_add_active(enum pol_balance lb)
reg_name_del_proc(n, TEST_PID);
- if (n->procs.len != 0) {
+ if (!llist_is_empty(&n->procs)) {
printf("Procs list not cleared.\n");
goto fail;
}
- if (n->active.len != 0) {
+ if (!llist_is_empty(&n->active)) {
printf("Active list not cleared.\n");
goto fail;
}
diff --git a/src/irmd/reg/tests/proc_test.c b/src/irmd/reg/tests/proc_test.c
index 2e2649d7..a85f4039 100644
--- a/src/irmd/reg/tests/proc_test.c
+++ b/src/irmd/reg/tests/proc_test.c
@@ -77,7 +77,7 @@ static int test_reg_proc_add_name(void)
goto fail;
}
- if (proc->n_names != 1) {
+ if (proc->names.len != 1) {
printf("n_names not updated.\n");
goto fail;
}
@@ -89,7 +89,7 @@ static int test_reg_proc_add_name(void)
reg_proc_del_name(proc, name);
- if (proc->n_names != 0) {
+ if (!llist_is_empty(&proc->names)) {
printf("n_names not updated.\n");
goto fail;
}
diff --git a/src/irmd/reg/tests/prog_test.c b/src/irmd/reg/tests/prog_test.c
index 9c40de92..91264aba 100644
--- a/src/irmd/reg/tests/prog_test.c
+++ b/src/irmd/reg/tests/prog_test.c
@@ -73,7 +73,7 @@ static int test_reg_prog_add_name(void)
goto fail;
}
- if (prog->n_names != 1) {
+ if (prog->names.len != 1) {
printf("n_names not updated.\n");
goto fail;
}
@@ -85,7 +85,7 @@ static int test_reg_prog_add_name(void)
reg_prog_del_name(prog, name);
- if (prog->n_names != 0) {
+ if (!llist_is_empty(&prog->names)) {
printf("n_names not updated.\n");
goto fail;
}
diff --git a/src/irmd/reg/tests/reg_test.c b/src/irmd/reg/tests/reg_test.c
index 4eb75b03..4d7e30ef 100644
--- a/src/irmd/reg/tests/reg_test.c
+++ b/src/irmd/reg/tests/reg_test.c
@@ -89,7 +89,7 @@ static int test_reg_create_flow(void)
goto fail;
}
- if (reg.n_flows != 1) {
+ if (reg.flows.len != 1) {
printf("n_flows was not updated.\n");
goto fail;
}
@@ -104,8 +104,8 @@ static int test_reg_create_flow(void)
goto fail;
}
- if (reg.n_flows != 0) {
- printf("n_flows was not updated.\n");
+ if (!llist_is_empty(&reg.flows)) {
+ printf("flows.len was not updated.\n");
goto fail;
}
@@ -163,7 +163,7 @@ static int test_reg_allocate_flow_timeout(void)
reg_destroy_flow(info.id);
- if (reg.n_flows != 0) {
+ if (!llist_is_empty(&reg.flows)) {
printf("Flow did not destroy.\n");
goto fail;
}
@@ -517,7 +517,7 @@ static int test_reg_create_ipcp(void)
goto fail;
}
- if (reg.n_ipcps != 1) {
+ if (reg.ipcps.len != 1) {
printf("n_ipcps was not updated.\n");
goto fail;
}
@@ -532,8 +532,8 @@ static int test_reg_create_ipcp(void)
goto fail;
}
- if (reg.n_ipcps != 0) {
- printf("n_ipcps was not updated.\n");
+ if (reg.ipcps.len != 0) {
+ printf("ipcps.len was not updated.\n");
goto fail;
}
@@ -761,7 +761,7 @@ static int test_reg_create_name(void)
goto fail;
}
- if (reg.n_names != 1) {
+ if (reg.names.len != 1) {
printf("n_names was not updated.\n");
goto fail;
}
@@ -776,7 +776,7 @@ static int test_reg_create_name(void)
goto fail;
}
- if (reg.n_names != 0) {
+ if (!llist_is_empty(&reg.names)) {
printf("n_names was not updated.\n");
goto fail;
}
@@ -874,7 +874,7 @@ static int test_reg_create_proc(void)
goto fail;
}
- if (reg.n_procs != 1) {
+ if (reg.procs.len != 1) {
printf("n_procs was not updated.\n");
goto fail;
}
@@ -889,7 +889,7 @@ static int test_reg_create_proc(void)
goto fail;
}
- if (reg.n_procs != 0) {
+ if (!llist_is_empty(&reg.procs)) {
printf("n_procs was not updated.\n");
goto fail;
}
@@ -927,7 +927,7 @@ static int test_reg_spawned(void)
goto fail;
}
- if (reg.n_spawned != 1) {
+ if (reg.spawned.len != 1) {
printf("n_spawned was not updated.\n");
goto fail;
}
@@ -942,7 +942,7 @@ static int test_reg_spawned(void)
goto fail;
}
- if (reg.n_spawned != 0) {
+ if (!llist_is_empty(&reg.spawned)) {
printf("n_spawned was not updated.\n");
goto fail;
}
@@ -975,7 +975,7 @@ static int test_reg_create_prog(void)
goto fail;
}
- if (reg.n_progs != 1) {
+ if (reg.progs.len != 1) {
printf("n_progs was not updated.\n");
goto fail;
}
@@ -990,7 +990,7 @@ static int test_reg_create_prog(void)
goto fail;
}
- if (reg.n_progs != 0) {
+ if (!llist_is_empty(&reg.progs)) {
printf("n_progs was not updated.\n");
goto fail;
}
@@ -1521,8 +1521,8 @@ static int test_wait_ipcp_boot_fail(void)
goto fail;
}
- if (reg.n_ipcps != 0) {
- printf("n_ipcps was not updated.\n");
+ if (!llist_is_empty(&reg.ipcps)) {
+ printf("ipcps.len was not updated.\n");
goto fail;
}