test/ctype_internal_test.c: portability fixup.
[openssl.git] / test / ssltestlib.c
index 9bce0d32d10f312ead6122eda13ebc1714843ac9..4473c670d7467e85b5b23b522312abf9d04d5857 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <string.h>
 
-#include "e_os.h"
+#include "internal/nelem.h"
 #include "ssltestlib.h"
 #include "testutil.h"
 
@@ -288,7 +288,7 @@ void bio_s_mempacket_test_free(void)
 static int mempacket_test_new(BIO *bio)
 {
     MEMPACKET_TEST_CTX *ctx;
-    
+
     if (!TEST_ptr(ctx = OPENSSL_zalloc(sizeof(*ctx))))
         return 0;
     if (!TEST_ptr(ctx->pkts = sk_MEMPACKET_new_null())) {
@@ -518,7 +518,7 @@ int create_ssl_ctx_pair(const SSL_METHOD *sm, const SSL_METHOD *cm,
     SSL_CTX *clientctx = NULL;
 
     if (!TEST_ptr(serverctx = SSL_CTX_new(sm))
-            || !TEST_ptr(clientctx = SSL_CTX_new(cm)))
+            || (cctx != NULL && !TEST_ptr(clientctx = SSL_CTX_new(cm))))
         goto err;
 
     if (!TEST_int_eq(SSL_CTX_use_certificate_file(serverctx, certfile,
@@ -533,7 +533,8 @@ int create_ssl_ctx_pair(const SSL_METHOD *sm, const SSL_METHOD *cm,
 #endif
 
     *sctx = serverctx;
-    *cctx = clientctx;
+    if (cctx != NULL)
+        *cctx = clientctx;
     return 1;
 
  err:
@@ -660,3 +661,11 @@ int create_ssl_connection(SSL *serverssl, SSL *clientssl, int want)
 
     return 1;
 }
+
+void shutdown_ssl_connection(SSL *serverssl, SSL *clientssl)
+{
+    SSL_shutdown(clientssl);
+    SSL_shutdown(serverssl);
+    SSL_free(serverssl);
+    SSL_free(clientssl);
+}