Unauthenticated DH client certificate fix.
[openssl.git] / ssl / heartbeat_test.c
index 287fc1682597e49f16bc31414a177e163c38eafc..c77e7f7065e789c7cf3c0768e7d2c4cdfa614891 100644 (file)
@@ -1,5 +1,5 @@
 /* test/heartbeat_test.c */
-/*
+/*-
  * Unit test for TLS heartbeats.
  *
  * Acts as a regression test against the Heartbleed bug (CVE-2014-0160).
  * http://mike-bland.com/tags/heartbleed.html
  */
 
-#include "../test/testutil.h"
+#define OPENSSL_UNIT_TEST
+
 #include "../ssl/ssl_locl.h"
+
+#include "testutil.h"
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#if !defined(OPENSSL_NO_HEARTBEATS) && !defined(OPENSSL_SYS_WINDOWS)
+#if !defined(OPENSSL_NO_HEARTBEATS) && !defined(OPENSSL_NO_UNIT_TEST)
 
 /* As per https://tools.ietf.org/html/rfc6520#section-4 */
 #define MIN_PADDING_SIZE       16
@@ -429,33 +432,24 @@ static int test_tls1_heartbleed_empty_payload()
 
 int main(int argc, char *argv[])
        {
-       int num_failed;
+       int result = 0;
 
        SSL_library_init();
        SSL_load_error_strings();
 
-       num_failed = test_dtls1_not_bleeding() +
-           test_dtls1_not_bleeding_empty_payload() +
-           test_dtls1_heartbleed() +
-           test_dtls1_heartbleed_empty_payload() +
-           /* The following test causes an assertion failure at
-            * ssl/d1_pkt.c:dtls1_write_bytes() in versions prior to 1.0.1g: */
-           (OPENSSL_VERSION_NUMBER >= 0x1000107fL ?
-            test_dtls1_heartbleed_excessive_plaintext_length() : 0) +
-           test_tls1_not_bleeding() +
-           test_tls1_not_bleeding_empty_payload() +
-           test_tls1_heartbleed() +
-           test_tls1_heartbleed_empty_payload() +
-           0;
-
+       ADD_TEST(test_dtls1_not_bleeding);
+       ADD_TEST(test_dtls1_not_bleeding_empty_payload);
+       ADD_TEST(test_dtls1_heartbleed);
+       ADD_TEST(test_dtls1_heartbleed_empty_payload);
+       ADD_TEST(test_dtls1_heartbleed_excessive_plaintext_length);
+       ADD_TEST(test_tls1_not_bleeding);
+       ADD_TEST(test_tls1_not_bleeding_empty_payload);
+       ADD_TEST(test_tls1_heartbleed);
+       ADD_TEST(test_tls1_heartbleed_empty_payload);
+
+       result = run_tests(argv[0]);
        ERR_print_errors_fp(stderr);
-
-       if (num_failed != 0)
-               {
-               printf("%d test%s failed\n", num_failed, num_failed != 1 ? "s" : "");
-               return EXIT_FAILURE;
-               }
-       return EXIT_SUCCESS;
+       return result;
        }
 
 #else /* OPENSSL_NO_HEARTBEATS*/