]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: test-data-stack: Run each test with the same data stack state
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 27 May 2021 08:18:05 +0000 (11:18 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 1 Jun 2021 10:44:55 +0000 (10:44 +0000)
src/lib/test-data-stack.c

index 61a7d8e3c0c5786a308d620f321b0df71cc61318..d37cf5ac7fbbb15088c2b3c87ee844204edce32d 100644 (file)
@@ -221,8 +221,9 @@ static void test_ds_recurse(int depth, int number, size_t size)
        test_assert_idx(t_pop(&t_id), depth);
 }
 
-static void test_ds_recursive(int count, int depth)
+static void test_ds_recursive(void)
 {
+       int count = 20, depth = 80;
        int i;
 
        test_begin("data-stack recursive");
@@ -282,12 +283,21 @@ static void test_ds_pass_str(void)
 
 void test_data_stack(void)
 {
-       test_ds_grow_event();
-       test_ds_get_bytes_available();
-       test_ds_buffers();
-       test_ds_realloc();
-       test_ds_recursive(20, 80);
-       test_ds_pass_str();
+       void (*tests[])(void) = {
+               test_ds_grow_event,
+               test_ds_get_bytes_available,
+               test_ds_buffers,
+               test_ds_realloc,
+               test_ds_recursive,
+               test_ds_pass_str,
+       };
+       for (unsigned int i = 0; i < N_ELEMENTS(tests); i++) {
+               ds_grow_event_count = 0;
+               data_stack_free_unused();
+               T_BEGIN {
+                       tests[i]();
+               } T_END;
+       }
 }
 
 enum fatal_test_state fatal_data_stack(unsigned int stage)