From e188247d1634dc8051a9b07713479d63589e4990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Thu, 18 Oct 2018 11:09:09 +0200 Subject: SKIP tests/global-init-override if weak symbols don't work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tim Rühsen --- tests/global-init-override.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/tests/global-init-override.c b/tests/global-init-override.c index beeca03daa..bb72d7e5f5 100644 --- a/tests/global-init-override.c +++ b/tests/global-init-override.c @@ -34,24 +34,48 @@ #include #include +#include #include "utils.h" /* We test whether implicit global initialization can be overridden */ +static int weak_symbol_works; + +struct gnutls_subject_alt_names_st { + struct name_st *names; + unsigned int size; +}; + +/* gnutls_subject_alt_names_init() is called by gnutls_x509_crt_init(). + * We override it here to test if weak symbols work at all. + */ +__attribute__ ((visibility ("protected"))) +int gnutls_subject_alt_names_init(gnutls_subject_alt_names_t * sans) +{ + weak_symbol_works = 1; + + *sans = gnutls_calloc(1, sizeof(struct gnutls_subject_alt_names_st)); + if (*sans == NULL) { + return GNUTLS_E_MEMORY_ERROR; + } + + return 0; +} + GNUTLS_SKIP_GLOBAL_INIT void doit(void) { -#ifdef _WIN32 - /* weak symbols don't seem to work in windows */ - exit(77); -#else + int ret; gnutls_x509_crt_t crt; ret = gnutls_x509_crt_init(&crt); if (ret >= 0) { + if (!weak_symbol_works) + exit(77); + fail("Library is already initialized\n"); } @@ -64,5 +88,4 @@ void doit(void) gnutls_x509_crt_deinit(crt); gnutls_global_deinit(); -#endif } -- cgit v1.2.1