summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2018-10-18 12:45:49 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2018-10-18 12:45:49 +0000
commite11a64ccdc06f5f316e458b9518264aff592e144 (patch)
tree9166cae95080892ce9b0b7e346d21a967767ba50
parent0f2d3f0128751e56346223b4d642e4ff0d8bb911 (diff)
parente188247d1634dc8051a9b07713479d63589e4990 (diff)
downloadgnutls-e11a64ccdc06f5f316e458b9518264aff592e144.tar.gz
Merge branch 'tmp-fix-global-init-override' into 'master'
SKIP tests/global-init-override if weak symbols don't work Closes #592 See merge request gnutls/gnutls!778
-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
}