aboutsummaryrefslogtreecommitdiff
path: root/test/quicapitest.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/quicapitest.c')
-rw-r--r--test/quicapitest.c95
1 files changed, 9 insertions, 86 deletions
diff --git a/test/quicapitest.c b/test/quicapitest.c
index f665c511bb72..4e887c13d14c 100644
--- a/test/quicapitest.c
+++ b/test/quicapitest.c
@@ -428,91 +428,6 @@ static int test_version(void)
}
#if defined(DO_SSL_TRACE_TEST)
-static void strip_line_ends(char *str)
-{
- size_t i;
-
- for (i = strlen(str);
- i > 0 && (str[i - 1] == '\n' || str[i - 1] == '\r');
- i--);
-
- str[i] = '\0';
-}
-
-static int compare_with_file(BIO *membio)
-{
- BIO *file = NULL, *newfile = NULL;
- char buf1[8192], buf2[8192];
- char *reffile;
- int ret = 0;
- size_t i;
-
-#ifdef OPENSSL_NO_ZLIB
- reffile = test_mk_file_path(datadir, "ssltraceref.txt");
-#else
- reffile = test_mk_file_path(datadir, "ssltraceref-zlib.txt");
-#endif
- if (!TEST_ptr(reffile))
- goto err;
-
- file = BIO_new_file(reffile, "rb");
- if (!TEST_ptr(file))
- goto err;
-
- newfile = BIO_new_file("ssltraceref-new.txt", "wb");
- if (!TEST_ptr(newfile))
- goto err;
-
- while (BIO_gets(membio, buf2, sizeof(buf2)) > 0)
- if (BIO_puts(newfile, buf2) <= 0) {
- TEST_error("Failed writing new file data");
- goto err;
- }
-
- if (!TEST_int_ge(BIO_seek(membio, 0), 0))
- goto err;
-
- while (BIO_gets(file, buf1, sizeof(buf1)) > 0) {
- size_t line_len;
-
- if (BIO_gets(membio, buf2, sizeof(buf2)) <= 0) {
- TEST_error("Failed reading mem data");
- goto err;
- }
- strip_line_ends(buf1);
- strip_line_ends(buf2);
- line_len = strlen(buf1);
- if (line_len > 0 && buf1[line_len - 1] == '?') {
- /* Wildcard at the EOL means ignore anything after it */
- if (strlen(buf2) > line_len)
- buf2[line_len] = '\0';
- }
- if (line_len != strlen(buf2)) {
- TEST_error("Actual and ref line data length mismatch");
- TEST_info("%s", buf1);
- TEST_info("%s", buf2);
- goto err;
- }
- for (i = 0; i < line_len; i++) {
- /* '?' is a wild card character in the reference text */
- if (buf1[i] == '?')
- buf2[i] = '?';
- }
- if (!TEST_str_eq(buf1, buf2))
- goto err;
- }
- if (!TEST_true(BIO_eof(file))
- || !TEST_true(BIO_eof(membio)))
- goto err;
-
- ret = 1;
- err:
- OPENSSL_free(reffile);
- BIO_free(file);
- BIO_free(newfile);
- return ret;
-}
-
/*
* Tests that the SSL_trace() msg_callback works as expected with a QUIC
* connection. This also provides testing of the msg_callback at the same time.
@@ -524,6 +439,7 @@ static int test_ssl_trace(void)
QUIC_TSERVER *qtserv = NULL;
int testresult = 0;
BIO *bio = NULL;
+ char *reffile = NULL;
if (!TEST_ptr(cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method()))
|| !TEST_ptr(bio = BIO_new(BIO_s_mem()))
@@ -547,7 +463,13 @@ static int test_ssl_trace(void)
if (!TEST_int_gt(BIO_pending(bio), 0))
goto err;
} else {
- if (!TEST_true(compare_with_file(bio)))
+
+# ifdef OPENSSL_NO_ZLIB
+ reffile = test_mk_file_path(datadir, "ssltraceref.txt");
+# else
+ reffile = test_mk_file_path(datadir, "ssltraceref-zlib.txt");
+# endif
+ if (!TEST_true(compare_with_reference_file(bio, reffile)))
goto err;
}
@@ -557,6 +479,7 @@ static int test_ssl_trace(void)
SSL_free(clientquic);
SSL_CTX_free(cctx);
BIO_free(bio);
+ OPENSSL_free(reffile);
return testresult;
}