]> 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>
Tue, 27 Jan 2026 20:26:04 +0000 (07: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.

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

index bb4e0b99e97ca53d542454cb4217a1ce0215db25..f7056a4003fbeceead4128e93980f74039ab54d6 100644 (file)
@@ -100,7 +100,7 @@ file_path_to_groupname(const char *path, char *out, size_t outlen);
        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)
@@ -129,9 +129,9 @@ file_path_to_groupname(const char *path, char *out, size_t outlen);
        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); \
@@ -143,9 +143,9 @@ file_path_to_groupname(const char *path, char *out, size_t outlen);
        ;
 
 #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) {                                   \
@@ -158,7 +158,7 @@ file_path_to_groupname(const char *path, char *out, size_t outlen);
                isc_loop_setup(isc_loop_main(), loop_test_##name, state);   \
                isc_loopmgr_run();                                          \
        }                                                                   \
-       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 44c4b0ef29583386bd469de26d7b8855374e0a6d..33108634796259dd5eeaaf6dd8b4b9b296a0edf8 100644 (file)
@@ -80,10 +80,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) {
@@ -209,6 +210,7 @@ ISC_RUN_TEST_IMPL(isc_mutex_benchmark) {
 
        isc_mem_cput(isc_g_mctx, threads, workers, sizeof(*threads));
 }
+#endif
 
 ISC_TEST_LIST_START
 
index a26334c92aa6b0a58ce48333799e6759a9801a01..e193936d522939c4e4f9f58d9664b42df221900b 100644 (file)
@@ -55,9 +55,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
@@ -136,6 +138,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);
@@ -347,6 +350,7 @@ ISC_RUN_TEST_IMPL(isc_rwlock_benchmark) {
 
        isc_mem_cput(isc_g_mctx, threads, workers, sizeof(*threads));
 }
+#endif
 
 ISC_TEST_LIST_START
 
index bd9fc37d0d1cdbabb374341e27e15d0406209ce5..fbaeeee74bd4991983f78d7a153db79b3daee933 100644 (file)
@@ -86,6 +86,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;
 
@@ -220,6 +221,7 @@ ISC_RUN_TEST_IMPL(isc_spinlock_benchmark) {
 
        isc_mem_cput(isc_g_mctx, threads, workers, sizeof(*threads));
 }
+#endif
 
 ISC_TEST_LIST_START