]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Always initialize the workers in the libtest
authorOndřej Surý <ondrej@isc.org>
Thu, 30 Mar 2023 07:14:21 +0000 (09:14 +0200)
committerOndřej Surý <ondrej@isc.org>
Fri, 21 Apr 2023 07:04:24 +0000 (09:04 +0200)
The workers variable might be needed even to tests not using
loopmgr. Split the workers initialization into setup_workers() function
and always call it from the default main loop.

tests/include/tests/isc.h
tests/libtest/isc.c

index 391a64454becfea6aea47c7dbadcc90a3c0132ee..add574ffb31f6b80d463137a41ba53fd1a6497f6 100644 (file)
@@ -42,6 +42,9 @@ setup_mctx(void **state);
 int
 teardown_mctx(void **state);
 
+int
+setup_workers(void **state);
+
 int
 setup_loopmgr(void **state);
 int
@@ -172,8 +175,8 @@ teardown_managers(void **state);
                                                                     \
                signal(SIGPIPE, SIG_IGN);                           \
                                                                     \
-               isc_mem_debugging |= ISC_MEM_DEBUGRECORD;           \
-               isc_mem_create(&mctx);                              \
+               setup_mctx(NULL);                                   \
+               setup_workers(NULL);                                \
                                                                     \
                r = cmocka_run_group_tests(tests, setup, teardown); \
                                                                     \
index 777d2508eec87cdf0ae5055ff6eaed4f7c8b1fc9..324fc1d7cf3b84a3b272f2c093da6265691858e9 100644 (file)
@@ -51,6 +51,24 @@ adjustnofile(void) {
        }
 }
 
+int
+setup_workers(void **state ISC_ATTR_UNUSED) {
+       char *env_workers = getenv("ISC_TASK_WORKERS");
+       if (env_workers != NULL) {
+               workers = atoi(env_workers);
+       } else {
+               workers = isc_os_ncpus();
+
+               /* We always need at least two loops for some of the tests */
+               if (workers < 2) {
+                       workers = 2;
+               }
+       }
+       INSIST(workers != 0);
+
+       return (0);
+}
+
 int
 setup_mctx(void **state ISC_ATTR_UNUSED) {
        isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
@@ -68,23 +86,9 @@ teardown_mctx(void **state ISC_ATTR_UNUSED) {
 
 int
 setup_loopmgr(void **state ISC_ATTR_UNUSED) {
-       char *env_workers = NULL;
-
        REQUIRE(mctx != NULL);
 
-       env_workers = getenv("ISC_TASK_WORKERS");
-       if (env_workers != NULL) {
-               workers = atoi(env_workers);
-       }
-
-       if (workers == 0) {
-               workers = isc_os_ncpus();
-
-               /* We always need at least two loops for some of the tests */
-               if (workers < 2) {
-                       workers = 2;
-               }
-       }
+       setup_workers(state);
 
        isc_loopmgr_create(mctx, workers, &loopmgr);
        mainloop = isc_loop_main(loopmgr);