Use testutil registry in heartbeat_test
authorMike Bland <mbland@acm.org>
Tue, 15 Jul 2014 22:55:55 +0000 (18:55 -0400)
committerMatt Caswell <matt@openssl.org>
Sat, 19 Jul 2014 18:24:35 +0000 (19:24 +0100)
Reviewed-by: Tim Hudson <tjh@openssl.org>
ssl/heartbeat_test.c
test/Makefile

index 287fc1682597e49f16bc31414a177e163c38eafc..2fb0d460d7ff3af0462425c2eb91772fd7990b7e 100644 (file)
@@ -429,33 +429,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*/
index 2b00ba2b0d9050e9869ea3c49f4ec1fcea84bcf4..40898fc04081f6bd353991018c87c5c8164cd532 100644 (file)
@@ -129,7 +129,8 @@ OBJ=        $(BNTEST).o $(ECTEST).o  $(ECDSATEST).o $(ECDHTEST).o $(IDEATEST).o \
        $(FIPS_TEST_SUITE).o $(FIPS_DHVS).o $(FIPS_ECDSAVS).o \
        $(FIPS_ECDHVS).o $(FIPS_CMACTEST).o $(FIPS_ALGVS).o \
        $(EVPTEST).o $(IGETEST).o $(JPAKETEST).o $(V3NAMETEST).o \
-       $(GOST2814789TEST).o $(HEARTBEATTEST).o $(P5_CRPT2_TEST).o
+       $(GOST2814789TEST).o $(HEARTBEATTEST).o $(P5_CRPT2_TEST).o \
+       testutil.o
 
 SRC=   $(BNTEST).c $(ECTEST).c  $(ECDSATEST).c $(ECDHTEST).c $(IDEATEST).c \
        $(MD2TEST).c  $(MD4TEST).c $(MD5TEST).c \
@@ -145,7 +146,8 @@ SRC=        $(BNTEST).c $(ECTEST).c  $(ECDSATEST).c $(ECDHTEST).c $(IDEATEST).c \
        $(FIPS_TEST_SUITE).c $(FIPS_DHVS).c $(FIPS_ECDSAVS).c \
        $(FIPS_ECDHVS).c $(FIPS_CMACTEST).c $(FIPS_ALGVS).c \
        $(EVPTEST).c $(IGETEST).c $(JPAKETEST).c $(V3NAMETEST).c \
-       $(GOST2814789TEST).c $(HEARTBEATTEST).c $(P5_CRPT2_TEST).c
+       $(GOST2814789TEST).c $(HEARTBEATTEST).c $(P5_CRPT2_TEST).c \
+       testutil.c
 
 EXHEADER= 
 HEADER=        $(EXHEADER)
@@ -416,14 +418,14 @@ BUILD_CMD=shlib_target=; if [ -n "$(SHARED_LIBS)" ]; then \
        fi; \
        LIBRARIES="$(LIBSSL) $(LIBCRYPTO) $(LIBKRB5)"; \
        $(MAKE) -f $(TOP)/Makefile.shared -e \
-               APPNAME=$$target$(EXE_EXT) OBJECTS="$$target.o" \
+               APPNAME=$$target$(EXE_EXT) OBJECTS="$$target.o $$testutil" \
                LIBDEPS="$(PEX_LIBS) $$LIBRARIES $(EX_LIBS)" \
                link_app.$${shlib_target}
 
 BUILD_CMD_STATIC=shlib_target=; \
        LIBRARIES="$(DLIBSSL) $(DLIBCRYPTO) $(LIBKRB5)"; \
        $(MAKE) -f $(TOP)/Makefile.shared -e \
-               APPNAME=$$target$(EXE_EXT) OBJECTS="$$target.o" \
+               APPNAME=$$target$(EXE_EXT) OBJECTS="$$target.o $$testutil" \
                LIBDEPS="$(PEX_LIBS) $$LIBRARIES $(EX_LIBS)" \
                link_app.$${shlib_target}
 
@@ -624,8 +626,8 @@ $(SRPTEST)$(EXE_EXT): $(SRPTEST).o $(DLIBCRYPTO)
 $(V3NAMETEST)$(EXE_EXT): $(V3NAMETEST).o $(DLIBCRYPTO)
        @target=$(V3NAMETEST); $(BUILD_CMD)
 
-$(HEARTBEATTEST)$(EXE_EXT): $(HEARTBEATTEST).o $(DLIBCRYPTO)
-       @target=$(HEARTBEATTEST); $(BUILD_CMD_STATIC)
+$(HEARTBEATTEST)$(EXE_EXT): $(HEARTBEATTEST).o $(DLIBCRYPTO) testutil.o
+       @target=$(HEARTBEATTEST) testutil=testutil.o; $(BUILD_CMD_STATIC)
 
 #$(AESTEST).o: $(AESTEST).c
 #      $(CC) -c $(CFLAGS) -DINTERMEDIATE_VALUE_KAT -DTRACE_KAT_MCT $(AESTEST).c