- if (test_type != JUST_CRYPTO) {
- if (!shlib_sym(ssllib, TLS_METHOD, &tls_method_sym.sym)
- || !shlib_sym(ssllib, SSL_CTX_NEW, &ssl_ctx_new_sym.sym)
- || !shlib_sym(ssllib, SSL_CTX_FREE, &ssl_ctx_free_sym.sym)) {
- printf("Unable to load ssl symbols\n");
- return 1;
- }
-
- TLS_method = (TLS_method_t)tls_method_sym.func;
- SSL_CTX_new = (SSL_CTX_new_t)ssl_ctx_new_sym.func;
- SSL_CTX_free = (SSL_CTX_free_t)ssl_ctx_free_sym.func;
-
- ctx = SSL_CTX_new(TLS_method());
- if (ctx == NULL) {
- printf("Unable to create SSL_CTX\n");
- return 1;
+ if (!TEST_true(shlib_sym(cryptolib, "ERR_get_error", &symbols[0].sym))
+ || !TEST_true(shlib_sym(cryptolib, "OpenSSL_version_num",
+ &symbols[1].sym)))
+ goto end;
+ myERR_get_error = (ERR_get_error_t)symbols[0].func;
+ if (!TEST_int_eq(myERR_get_error(), 0))
+ goto end;
+
+ /*
+ * The bits that COMPATIBILITY_MASK lets through MUST be the same in
+ * the library and in the application.
+ * The bits that are masked away MUST be a larger or equal number in
+ * the library compared to the application.
+ */
+# define COMPATIBILITY_MASK 0xfff00000L
+ myOpenSSL_version_num = (OpenSSL_version_num_t)symbols[1].func;
+ if (!TEST_int_eq(myOpenSSL_version_num() & COMPATIBILITY_MASK,
+ OPENSSL_VERSION_NUMBER & COMPATIBILITY_MASK))
+ goto end;
+ if (!TEST_int_ge(myOpenSSL_version_num() & ~COMPATIBILITY_MASK,
+ OPENSSL_VERSION_NUMBER & ~COMPATIBILITY_MASK))
+ goto end;
+
+ if (test_type == DSO_REFTEST) {
+# ifdef DSO_DLFCN
+ DSO_dsobyaddr_t myDSO_dsobyaddr;
+ DSO_free_t myDSO_free;
+
+ /*
+ * This is resembling the code used in ossl_init_base() and
+ * OPENSSL_atexit() to block unloading the library after dlclose().
+ * We are not testing this on Windows, because it is done there in a
+ * completely different way. Especially as a call to DSO_dsobyaddr()
+ * will always return an error, because DSO_pathbyaddr() is not
+ * implemented there.
+ */
+ if (!TEST_true(shlib_sym(cryptolib, "DSO_dsobyaddr", &symbols[0].sym))
+ || !TEST_true(shlib_sym(cryptolib, "DSO_free",
+ &symbols[1].sym)))
+ goto end;
+
+ myDSO_dsobyaddr = (DSO_dsobyaddr_t)symbols[0].func;
+ myDSO_free = (DSO_free_t)symbols[1].func;
+
+ {
+ DSO *hndl;
+ /* use known symbol from crypto module */
+ if (!TEST_ptr(hndl = myDSO_dsobyaddr((void (*)(void))ERR_get_error, 0)))
+ goto end;
+ myDSO_free(hndl);