]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
ISC_RUN_TEST_IMPL should use a static declaration
authorMark Andrews <marka@isc.org>
Fri, 23 Jan 2026 04:57:42 +0000 (15:57 +1100)
committerMark Andrews <marka@isc.org>
Wed, 28 Jan 2026 13:26:35 +0000 (00:26 +1100)
These functions don't need to be called from multiple places and
by making them static we will detect when they are not added to the
list functions to be tested.

(cherry picked from commit 22d664aa152f089d5890cd400364400d2aa8e3ae)

tests/include/tests/isc.h
tests/isc/mutex_test.c
tests/isc/rwlock_test.c
tests/isc/spinlock_test.c

index db80233070d84f2d66ed20796c95a4519d37ee6c..33a510c364744a6bde933fb404e019c0b154b747 100644 (file)
@@ -94,7 +94,7 @@ teardown_managers(void **state);
        int setup_test_##name(void **state ISC_ATTR_UNUSED);
 
 #define ISC_RUN_TEST_DECLARE(name) \
-       void run_test_##name(void **state ISC_ATTR_UNUSED);
+       static void run_test_##name(void **state ISC_ATTR_UNUSED);
 
 #define ISC_TEARDOWN_TEST_DECLARE(name) \
        int teardown_test_##name(void **state ISC_ATTR_UNUSED)
@@ -123,9 +123,9 @@ teardown_managers(void **state);
        int setup_test_##name(void **state ISC_ATTR_UNUSED); \
        int setup_test_##name(void **state ISC_ATTR_UNUSED)
 
-#define ISC_RUN_TEST_IMPL(name)                             \
-       void run_test_##name(void **state ISC_ATTR_UNUSED); \
-       void run_test_##name(void **state ISC_ATTR_UNUSED)
+#define ISC_RUN_TEST_IMPL(name)                                    \
+       static void run_test_##name(void **state ISC_ATTR_UNUSED); \
+       static void run_test_##name(void **state ISC_ATTR_UNUSED)
 
 #define ISC_TEARDOWN_TEST_IMPL(name)                            \
        int teardown_test_##name(void **state ISC_ATTR_UNUSED); \
@@ -137,9 +137,9 @@ teardown_managers(void **state);
        ;
 
 #define ISC_LOOP_TEST_CUSTOM_IMPL(name, setup, teardown)                   \
-       void run_test_##name(void **state ISC_ATTR_UNUSED);                \
-       void loop_test_##name(void *arg ISC_ATTR_UNUSED);                  \
-       void run_test_##name(void **state ISC_ATTR_UNUSED) {               \
+       static void run_test_##name(void **state ISC_ATTR_UNUSED);         \
+       static void loop_test_##name(void *arg ISC_ATTR_UNUSED);           \
+       static void run_test_##name(void **state ISC_ATTR_UNUSED) {        \
                isc_job_cb setup_loop = setup;                             \
                isc_job_cb teardown_loop = teardown;                       \
                if (setup_loop != NULL) {                                  \
@@ -151,7 +151,7 @@ teardown_managers(void **state);
                isc_loop_setup(mainloop, loop_test_##name, state);         \
                isc_loopmgr_run(loopmgr);                                  \
        }                                                                  \
-       void loop_test_##name(void *arg ISC_ATTR_UNUSED)
+       static void loop_test_##name(void *arg ISC_ATTR_UNUSED)
 
 #define ISC_LOOP_TEST_IMPL(name) ISC_LOOP_TEST_CUSTOM_IMPL(name, NULL, NULL)
 
index d45c694abab7fb6eb2b5b7e1ddba84d00a222267..551030fe705e6518c716dcfd4301ddfe3990b79a 100644 (file)
@@ -77,10 +77,11 @@ ISC_RUN_TEST_IMPL(isc_mutex) {
 #define CNT_MIN 800
 #define CNT_MAX 1600
 
-static size_t shared_counter = 0;
-static size_t expected_counter = SIZE_MAX;
+#if !defined(__SANITIZE_THREAD__)
 static isc_mutex_t lock;
 static pthread_mutex_t mutex;
+static size_t expected_counter = SIZE_MAX;
+static size_t shared_counter = 0;
 
 static void *
 pthread_mutex_thread(void *arg) {
@@ -203,6 +204,7 @@ ISC_RUN_TEST_IMPL(isc_mutex_benchmark) {
 
        isc_mem_cput(mctx, threads, workers, sizeof(*threads));
 }
+#endif
 
 ISC_TEST_LIST_START
 
index 2fae39256d8bad18b779755b16560a2ccb68b2e9..b6569979192864625b0f9fc4969b8f72ae4e09d7 100644 (file)
@@ -52,9 +52,11 @@ static isc_barrier_t barrier2;
 #define CNT_MIN 800
 #define CNT_MAX 1600
 
+#if !defined(__SANITIZE_THREAD__)
 static size_t shared_counter = 0;
 static size_t expected_counter = SIZE_MAX;
 static uint8_t boundary = 0;
+#endif
 static uint8_t *rnd;
 
 static int
@@ -133,6 +135,7 @@ ISC_RUN_TEST_IMPL(isc_rwlock_wrlock) {
 /*
  * Simple single-threaded lock/tryupgrade/unlock test
  */
+#if !defined(__SANITIZE_THREAD__)
 ISC_RUN_TEST_IMPL(isc_rwlock_tryupgrade) {
        isc_result_t result;
        isc_rwlock_lock(&rwlock, isc_rwlocktype_read);
@@ -341,6 +344,7 @@ ISC_RUN_TEST_IMPL(isc_rwlock_benchmark) {
 
        isc_mem_cput(mctx, threads, workers, sizeof(*threads));
 }
+#endif
 
 ISC_TEST_LIST_START
 
index 89db2887741f34dff37935095b82f62d07d3e0ca..169dc41b8114d39e5a820bd8e699a22ef5debc71 100644 (file)
@@ -82,6 +82,7 @@ ISC_RUN_TEST_IMPL(isc_spinlock) {
 #define CNT_MIN 800
 #define CNT_MAX 1600
 
+#if !defined(__SANITIZE_THREAD__)
 static size_t shared_counter = 0;
 static size_t expected_counter = SIZE_MAX;
 
@@ -213,6 +214,7 @@ ISC_RUN_TEST_IMPL(isc_spinlock_benchmark) {
 
        isc_mem_cput(mctx, threads, workers, sizeof(*threads));
 }
+#endif
 
 ISC_TEST_LIST_START