summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Rühsen <tim.ruehsen@gmx.de>2018-10-18 11:09:09 +0200
committerTim Rühsen <tim.ruehsen@gmx.de>2018-10-18 11:09:40 +0200
commite188247d1634dc8051a9b07713479d63589e4990 (patch)
tree9166cae95080892ce9b0b7e346d21a967767ba50
parent0f2d3f0128751e56346223b4d642e4ff0d8bb911 (diff)
downloadgnutls-tmp-fix-global-init-override.tar.gz
SKIP tests/global-init-override if weak symbols don't worktmp-fix-global-init-override
Signed-off-by: Tim Rühsen <tim.ruehsen@gmx.de>
-rw-r--r--tests/global-init-override.c33
1 files 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 <gnutls/gnutls.h>
#include <gnutls/x509.h>
+#include <gnutls/x509-ext.h>
#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
}