]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Drop function wrapping as it is redundant for now
authorMichał Kępień <michal@isc.org>
Mon, 28 Sep 2020 07:09:21 +0000 (09:09 +0200)
committerMichał Kępień <michal@isc.org>
Mon, 28 Sep 2020 07:09:21 +0000 (09:09 +0200)
As currently used in the BIND source tree, the --wrap linker option is
redundant because:

  - static builds are no longer supported,

  - there is no need to wrap around existing functions - what is
    actually required (at least for now) is to replace them altogether
    in unit tests,

  - only functions exposed by shared libraries linked into unit test
    binaries are currently being replaced.

Given the above, providing the alternative implementations of functions
to be overridden in lib/ns/tests/nstest.c is a much simpler alternative
to using the --wrap linker option.  Drop the code detecting support for
the latter from configure.ac, simplify the relevant Makefile.am, and
remove lib/ns/tests/wrap.c, updating lib/ns/tests/nstest.c accordingly
(it is harmless for unit tests which are not calling the overridden
functions).

configure.ac
lib/ns/tests/Makefile.am
lib/ns/tests/nstest.c
lib/ns/tests/wrap.c [deleted file]
util/copyrights

index be261f86468c742ccdb1a4675c82f3142ac8219c..441e150447110217f48cdc812c554f2079ff6bda 100644 (file)
@@ -1354,44 +1354,6 @@ AC_SUBST([CMOCKA_LIBS])
 
 AM_CONDITIONAL([HAVE_CMOCKA], [test "$with_cmocka" = "yes"])
 
-#
-# Check for -Wl,--wrap= support
-#
-
-LD_WRAP_TESTS=false
-AC_MSG_CHECKING([for linker support for --wrap option])
-AX_SAVE_FLAGS([wrap])
-LDFLAGS="-Wl,--wrap,exit"
-AC_RUN_IFELSE(
-    [AC_LANG_PROGRAM([[#include <stdlib.h>
-                      void __real_exit (int status);
-                      void __wrap_exit (int status) { __real_exit (0); }
-                     ]],
-                    [[exit (1);]])],
-    [LD_WRAP_TESTS=true
-     AC_MSG_RESULT([yes])],
-    [AC_MSG_RESULT([no])])
-AX_RESTORE_FLAGS([wrap])
-
-AM_CONDITIONAL([HAVE_LD_WRAP], [test "$LD_WRAP_TESTS" = "true"])
-
-WRAP_INTERPOSE=
-AC_MSG_CHECKING([for linker support for '-z interpose' option])
-AX_SAVE_FLAGS([interpose])
-LDFLAGS="-Wl,-z,interpose"
-AC_LINK_IFELSE(
-    [AC_LANG_PROGRAM([],[])],
-    [WRAP_INTERPOSE="-Wl,-z,interpose"
-     AC_MSG_RESULT([yes])],
-    [AC_MSG_RESULT([no])])
-AX_RESTORE_FLAGS([interpose])
-
-AC_SUBST([WRAP_INTERPOSE])
-
-WRAP_NAME=''
-AS_CASE([$host],[*-darwin*],[WRAP_NAME='${WRAP_NAME}'])
-AC_SUBST([WRAP_NAME])
-
 #
 # Check for i18n
 #
index 38903266d5db4f8572bf0aa1e7f2c1287ac58f37..31390fabfed4a0159d724cd3ecb0d7251c90f222 100644 (file)
@@ -13,37 +13,17 @@ LDADD +=                    \
        $(LIBNS_LIBS)
 
 check_LTLIBRARIES = libnstest.la
-libnstest_la_SOURCES = nstest.c nstest.h
+libnstest_la_SOURCES =         \
+       nstest.c                \
+       nstest.h
+
 check_PROGRAMS =               \
        listenlist_test         \
-       plugin_test
-
-TESTS = $(check_PROGRAMS)
-
-if HAVE_LD_WRAP
-
-check_PROGRAMS +=      \
-       notify_test     \
+       notify_test             \
+       plugin_test             \
        query_test
 
-notify_test_SOURCES =  \
-       notify_test.c   \
-       wrap.c
-
-notify_test_LDFLAGS =                  \
-       $(LDFLAGS)                      \
-       -Wl,--wrap=isc_nmhandle_attach  \
-       -Wl,--wrap=isc_nmhandle_detach
-
-query_test_SOURCES =   \
-       query_test.c    \
-       wrap.c
-
-query_test_LDFLAGS =                   \
-       $(LDFLAGS)                      \
-       -Wl,--wrap=isc_nmhandle_detach
-
-endif
+TESTS = $(check_PROGRAMS)
 
 unit-local: check
 
index 473c7a55b70f061e815f865606b20f58a19be3d2..9b7d7e04e98296612237c81b2859ab275b87e801 100644 (file)
@@ -78,12 +78,7 @@ atomic_uint_fast32_t client_refs[32];
 atomic_uintptr_t client_addrs[32];
 
 void
-__wrap_isc_nmhandle_attach(isc_nmhandle_t *source, isc_nmhandle_t **targetp);
-void
-__wrap_isc_nmhandle_detach(isc_nmhandle_t **handlep);
-
-void
-__wrap_isc_nmhandle_attach(isc_nmhandle_t *source, isc_nmhandle_t **targetp) {
+isc_nmhandle_attach(isc_nmhandle_t *source, isc_nmhandle_t **targetp) {
        ns_client_t *client = (ns_client_t *)source;
        int i;
 
@@ -102,7 +97,7 @@ __wrap_isc_nmhandle_attach(isc_nmhandle_t *source, isc_nmhandle_t **targetp) {
 }
 
 void
-__wrap_isc_nmhandle_detach(isc_nmhandle_t **handlep) {
+isc_nmhandle_detach(isc_nmhandle_t **handlep) {
        isc_nmhandle_t *handle = *handlep;
        ns_client_t *client = (ns_client_t *)handle;
        int i;
diff --git a/lib/ns/tests/wrap.c b/lib/ns/tests/wrap.c
deleted file mode 100644 (file)
index 4fe6ad9..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-/*! \file */
-
-#include <inttypes.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <isc/mem.h>
-#include <isc/netmgr.h>
-#include <isc/util.h>
-
-#include <dns/view.h>
-
-#include <ns/client.h>
-
-/*
- * This overrides calls to isc_nmhandle_attach/detach(), sending them to
- * __wrap_isc_nmhandle_attach/detach() instead, when libtool is in use
- * and LD_WRAP can't be used.
- */
-
-void
-__wrap_isc_nmhandle_attach(isc_nmhandle_t *source, isc_nmhandle_t **targetp);
-extern void
-__wrap_isc_nmhandle_detach(isc_nmhandle_t **handlep);
-
-void
-isc_nmhandle_attach(isc_nmhandle_t *source, isc_nmhandle_t **targetp) {
-       __wrap_isc_nmhandle_attach(source, targetp);
-}
-
-void
-isc_nmhandle_detach(isc_nmhandle_t **handlep) {
-       __wrap_isc_nmhandle_detach(handlep);
-}
index 95314a56795923c6d13253f60336150aebea3c6b..e7594997b18b09e35651c2b14b641de65e98d205 100644 (file)
 ./lib/ns/tests/plugin_test.c                   C       2019,2020
 ./lib/ns/tests/query_test.c                    C       2017,2018,2019,2020
 ./lib/ns/tests/testdata/notify/notify1.msg     X       2017,2018,2019,2020
-./lib/ns/tests/wrap.c                          C       2019,2020
 ./lib/ns/update.c                              C       2017,2018,2019,2020
 ./lib/ns/win32/DLLMain.c                       C       2017,2018,2019,2020
 ./lib/ns/win32/libns.def                       X       2017,2018,2019,2020