diff options
Diffstat (limited to 'deps/openssl/openssl/test/fatalerrtest.c')
-rw-r--r-- | deps/openssl/openssl/test/fatalerrtest.c | 77 |
1 files changed, 23 insertions, 54 deletions
diff --git a/deps/openssl/openssl/test/fatalerrtest.c b/deps/openssl/openssl/test/fatalerrtest.c index d52daa2de9..66731e6402 100644 --- a/deps/openssl/openssl/test/fatalerrtest.c +++ b/deps/openssl/openssl/test/fatalerrtest.c @@ -28,57 +28,49 @@ static int test_fatalerr(void) 0x17, 0x03, 0x03, 0x00, 0x05, 'D', 'u', 'm', 'm', 'y' }; - if (!create_ssl_ctx_pair(SSLv23_method(), SSLv23_method(), - SSL3_VERSION, TLS_MAX_VERSION, &sctx, &cctx, - cert, privkey)) { - printf("Failed to create SSL_CTX pair\n"); + if (!TEST_true(create_ssl_ctx_pair(TLS_method(), TLS_method(), + TLS1_VERSION, TLS_MAX_VERSION, + &sctx, &cctx, cert, privkey))) goto err; - } /* * Deliberately set the cipher lists for client and server to be different * to force a handshake failure. */ - if (!SSL_CTX_set_cipher_list(sctx, "AES128-SHA") - || !SSL_CTX_set_cipher_list(cctx, "AES256-SHA")) { - printf("Failed to set cipher lists\n"); - goto err; - } - - if (!create_ssl_objects(sctx, cctx, &sssl, &cssl, NULL, NULL)) { - printf("Failed to create SSL objectx\n"); + if (!TEST_true(SSL_CTX_set_cipher_list(sctx, "AES128-SHA")) + || !TEST_true(SSL_CTX_set_cipher_list(cctx, "AES256-SHA")) + || !TEST_true(SSL_CTX_set_ciphersuites(sctx, + "TLS_AES_128_GCM_SHA256")) + || !TEST_true(SSL_CTX_set_ciphersuites(cctx, + "TLS_AES_256_GCM_SHA384")) + || !TEST_true(create_ssl_objects(sctx, cctx, &sssl, &cssl, NULL, + NULL))) goto err; - } wbio = SSL_get_wbio(cssl); - if (wbio == NULL) { + if (!TEST_ptr(wbio)) { printf("Unexpected NULL bio received\n"); goto err; } - if (create_ssl_connection(sssl, cssl)) { - printf("Unexpected success creating a connection\n"); + /* Connection should fail */ + if (!TEST_false(create_ssl_connection(sssl, cssl, SSL_ERROR_NONE))) goto err; - } ERR_clear_error(); /* Inject a plaintext record from client to server */ - if (BIO_write(wbio, dummyrec, sizeof(dummyrec)) <= 0) { - printf("Unexpected failure injecting dummy record\n"); + if (!TEST_int_gt(BIO_write(wbio, dummyrec, sizeof(dummyrec)), 0)) goto err; - } /* SSL_read()/SSL_write should fail because of a previous fatal error */ - if ((len = SSL_read(sssl, buf, sizeof(buf) - 1)) > 0) { + if (!TEST_int_le(len = SSL_read(sssl, buf, sizeof(buf) - 1), 0)) { buf[len] = '\0'; - printf("Unexpected success reading data: %s\n", buf); + TEST_error("Unexpected success reading data: %s\n", buf); goto err; } - if (SSL_write(sssl, msg, strlen(msg)) > 0) { - printf("Unexpected success writing data\n"); + if (!TEST_int_le(SSL_write(sssl, msg, strlen(msg)), 0)) goto err; - } ret = 1; err: @@ -90,36 +82,13 @@ static int test_fatalerr(void) return ret; } -int main(int argc, char *argv[]) +int setup_tests(void) { - BIO *err = NULL; - int testresult = 1; - - if (argc != 3) { - printf("Invalid argument count\n"); - return 1; - } - - cert = argv[1]; - privkey = argv[2]; - - err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT); - - CRYPTO_set_mem_debug(1); - CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); + if (!TEST_ptr(cert = test_get_argument(0)) + || !TEST_ptr(privkey = test_get_argument(1))) + return 0; ADD_TEST(test_fatalerr); - testresult = run_tests(argv[0]); - -#ifndef OPENSSL_NO_CRYPTO_MDEBUG - if (CRYPTO_mem_leaks(err) <= 0) - testresult = 1; -#endif - BIO_free(err); - - if (!testresult) - printf("PASS\n"); - - return testresult; + return 1; } |