- const char *basedomain;
- const char *CAfile;
- const char *tlsafile;
- const char *p;
- int ret = 1;
-
- progname = argv[0];
- if (argc != 4) {
- test_usage();
- EXIT(ret);
- }
- basedomain = argv[1];
- CAfile = argv[2];
- tlsafile = argv[3];
-
- bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
-
- p = getenv("OPENSSL_DEBUG_MEMORY");
- if (p != NULL && strcmp(p, "on") == 0)
- CRYPTO_set_mem_debug(1);
- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
-
- f = BIO_new_file(tlsafile, "r");
- if (f == NULL) {
- fprintf(stderr, "%s: Error opening tlsa record file: '%s': %s\n",
- progname, tlsafile, strerror(errno));
- EXIT(ret);
- }
-
- ctx = SSL_CTX_new(TLS_client_method());
- if (SSL_CTX_dane_enable(ctx) <= 0) {
- print_errors();
- goto end;
- }
- if (!SSL_CTX_load_verify_locations(ctx, CAfile, NULL)) {
- print_errors();
- goto end;
- }
- if ((SSL_CTX_dane_mtype_set(ctx, EVP_sha512(), 2, 1)) <= 0) {
- print_errors();
- goto end;
- }
- if ((SSL_CTX_dane_mtype_set(ctx, EVP_sha256(), 1, 2)) <= 0) {
- print_errors();
+ BIO *f = NULL;
+ int ret = 0;
+
+ if (!TEST_ptr(f = BIO_new_file(tlsafile, "r"))
+ || !TEST_ptr(ctx = SSL_CTX_new(TLS_client_method()))
+ || !TEST_int_gt(SSL_CTX_dane_enable(ctx), 0)
+ || !TEST_true(SSL_CTX_load_verify_locations(ctx, CAfile, NULL))
+ || !TEST_int_gt(SSL_CTX_dane_mtype_set(ctx, EVP_sha512(), 2, 1),
+ 0)
+ || !TEST_int_gt(SSL_CTX_dane_mtype_set(ctx, EVP_sha256(), 1, 2),
+ 0)
+ || !TEST_int_gt(test_tlsafile(ctx, basedomain, f, tlsafile), 0))