]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
The runtime of rbt_test can exceed 5 minutes when running under TSAN testing.
authorMark Andrews <marka@isc.org>
Mon, 14 Sep 2020 02:38:37 +0000 (12:38 +1000)
committerMark Andrews <marka@isc.org>
Tue, 15 Sep 2020 02:15:27 +0000 (02:15 +0000)
Limit rbt_insert_and_remove subtest runtime to ~180 seconds which gives a total
runtime of ~270 seconds.

lib/dns/tests/rbt_test.c

index f1688408f0b75da5531f94b5694f3b52fc71027d..f318aae80028bcf3e85082bfb055eafeb5ecf1a4 100644 (file)
@@ -921,9 +921,11 @@ remove_nodes(dns_rbt_t *mytree, char **names,
 
                isc_mem_free(mctx, names[node]);
 
-               names[node] = names[*names_count - 1];
-               names[*names_count - 1] = NULL;
-               *names_count -= 1;
+               if (*names_count > 0) {
+                       names[node] = names[*names_count - 1];
+                       names[*names_count - 1] = NULL;
+                       *names_count -= 1;
+               }
        }
 }
 
@@ -971,6 +973,7 @@ rbt_insert_and_remove(void **state) {
        char *names[1024];
        size_t names_count;
        int i;
+       isc_time_t start, now;
 
        UNUSED(state);
 
@@ -987,8 +990,11 @@ rbt_insert_and_remove(void **state) {
        memset(names, 0, sizeof(names));
        names_count = 0;
 
-       /* Repeat the insert/remove test some 4096 times */
-       for (i = 0; i < 4096; i++) {
+       /* Repeat the insert/remove test for some 4096 times or 180 seconds. */
+       result = isc_time_now(&start);
+       assert_int_equal(result, ISC_R_SUCCESS);
+       now = start;
+       for (i = 0; i < 4096 && isc_time_microdiff(&now, &start) < 180000000; i++) {
                uint32_t num_names;
                isc_random_get(&num_names);
 
@@ -1012,6 +1018,8 @@ rbt_insert_and_remove(void **state) {
 
                remove_nodes(mytree, names, &names_count, num_names);
                check_tree(mytree, names, names_count);
+               result = isc_time_now(&now);
+               assert_int_equal(result, ISC_R_SUCCESS);
        }
 
        /* Remove the rest of the nodes */