summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2023-09-19 16:40:25 +0100
committerMatt Caswell <matt@openssl.org>2023-09-22 13:56:43 +0100
commit8d8c0a901e5d65d68070fbe812d7e8c1449381e1 (patch)
tree406aef9b4a2ecab41ff0372f5f5e6db98b94ac48 /test
parentb1584a85d07fdf1cfaa7423392fba439f7b6b0ac (diff)
Add the ability to do client side tracing in quictestlib.c
We add a new flag QTEST_FLAG_CLIENT_TRACE to get debug tracing output if required. Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22157)
Diffstat (limited to 'test')
-rw-r--r--test/helpers/quictestlib.c17
-rw-r--r--test/helpers/quictestlib.h5
-rw-r--r--test/quic_newcid_test.c2
-rw-r--r--test/quicapitest.c24
-rw-r--r--test/quicfaultstest.c8
5 files changed, 37 insertions, 19 deletions
diff --git a/test/helpers/quictestlib.c b/test/helpers/quictestlib.c
index 3c3cb73f96..bb2ae9b3ba 100644
--- a/test/helpers/quictestlib.c
+++ b/test/helpers/quictestlib.c
@@ -77,7 +77,7 @@ static OSSL_TIME fake_now_cb(void *arg)
int qtest_create_quic_objects(OSSL_LIB_CTX *libctx, SSL_CTX *clientctx,
SSL_CTX *serverctx, char *certfile, char *keyfile,
int flags, QUIC_TSERVER **qtserv, SSL **cssl,
- QTEST_FAULT **fault)
+ QTEST_FAULT **fault, BIO **tracebio)
{
/* ALPN value as recognised by QUIC_TSERVER */
unsigned char alpn[] = { 8, 'o', 's', 's', 'l', 't', 'e', 's', 't' };
@@ -85,6 +85,7 @@ int qtest_create_quic_objects(OSSL_LIB_CTX *libctx, SSL_CTX *clientctx,
BIO *cbio = NULL, *sbio = NULL, *fisbio = NULL;
BIO_ADDR *peeraddr = NULL;
struct in_addr ina = {0};
+ BIO *tmpbio = NULL;
*qtserv = NULL;
if (fault != NULL)
@@ -96,6 +97,17 @@ int qtest_create_quic_objects(OSSL_LIB_CTX *libctx, SSL_CTX *clientctx,
return 0;
}
+ if ((flags & QTEST_FLAG_CLIENT_TRACE) != 0) {
+ tmpbio = BIO_new_fp(stdout, BIO_NOCLOSE);
+ if (!TEST_ptr(tmpbio))
+ goto err;
+
+ SSL_set_msg_callback(*cssl, SSL_trace);
+ SSL_set_msg_callback_arg(*cssl, tmpbio);
+ }
+ if (tracebio != NULL)
+ *tracebio = tmpbio;
+
/* SSL_set_alpn_protos returns 0 for success! */
if (!TEST_false(SSL_set_alpn_protos(*cssl, alpn, sizeof(alpn))))
goto err;
@@ -224,6 +236,9 @@ int qtest_create_quic_objects(OSSL_LIB_CTX *libctx, SSL_CTX *clientctx,
ossl_quic_tserver_free(*qtserv);
if (fault != NULL)
OPENSSL_free(*fault);
+ BIO_free(tmpbio);
+ if (tracebio != NULL)
+ *tracebio = NULL;
return 0;
}
diff --git a/test/helpers/quictestlib.h b/test/helpers/quictestlib.h
index 4e61b8965d..e5190c62b1 100644
--- a/test/helpers/quictestlib.h
+++ b/test/helpers/quictestlib.h
@@ -34,7 +34,8 @@ typedef struct qtest_fault_encrypted_extensions {
#define QTEST_FLAG_NOISE (1 << 2)
/* Split datagrams such that each datagram contains one packet */
#define QTEST_FLAG_PACKET_SPLIT (1 << 3)
-
+/* Turn on client side tracing */
+#define QTEST_FLAG_CLIENT_TRACE (1 << 4)
/*
* Given an SSL_CTX for the client and filenames for the server certificate and
* keyfile, create a server and client instances as well as a fault injector
@@ -43,7 +44,7 @@ typedef struct qtest_fault_encrypted_extensions {
int qtest_create_quic_objects(OSSL_LIB_CTX *libctx, SSL_CTX *clientctx,
SSL_CTX *serverctx, char *certfile, char *keyfile,
int flags, QUIC_TSERVER **qtserv, SSL **cssl,
- QTEST_FAULT **fault);
+ QTEST_FAULT **fault, BIO **tracebio);
/* Where QTEST_FLAG_FAKE_TIME is used, add millis to the current time */
void qtest_add_time(uint64_t millis);
diff --git a/test/quic_newcid_test.c b/test/quic_newcid_test.c
index cda55abca3..80a15e1b7a 100644
--- a/test/quic_newcid_test.c
+++ b/test/quic_newcid_test.c
@@ -68,7 +68,7 @@ static int test_ncid_frame(int fail)
goto err;
if (!TEST_true(qtest_create_quic_objects(NULL, cctx, NULL, cert, privkey, 0,
- &qtserv, &cssl, &fault)))
+ &qtserv, &cssl, &fault, NULL)))
goto err;
if (!TEST_true(qtest_create_quic_connection(qtserv, cssl)))
diff --git a/test/quicapitest.c b/test/quicapitest.c
index cd006b4703..94562f3a5b 100644
--- a/test/quicapitest.c
+++ b/test/quicapitest.c
@@ -69,7 +69,7 @@ static int test_quic_write_read(int idx)
? QTEST_FLAG_BLOCK
: 0,
&qtserv, &clientquic,
- NULL))
+ NULL, NULL))
|| !TEST_true(SSL_set_tlsext_host_name(clientquic, "localhost")))
goto end;
@@ -220,7 +220,7 @@ static int test_fin_only_blocking(void)
cert, privkey,
QTEST_FLAG_BLOCK,
&qtserv, &clientquic,
- NULL))
+ NULL, NULL))
|| !TEST_true(SSL_set_tlsext_host_name(clientquic, "localhost")))
goto end;
@@ -380,7 +380,7 @@ static int test_version(void)
if (!TEST_ptr(cctx)
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert,
privkey, 0, &qtserv,
- &clientquic, NULL))
+ &clientquic, NULL, NULL))
|| !TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto err;
@@ -502,7 +502,7 @@ static int test_ssl_trace(void)
privkey,
QTEST_FLAG_FAKE_TIME,
&qtserv,
- &clientquic, NULL)))
+ &clientquic, NULL, NULL)))
goto err;
SSL_set_msg_callback(clientquic, SSL_trace);
@@ -829,7 +829,8 @@ static int test_bio_ssl(void)
goto err;
if (!TEST_true(qtest_create_quic_objects(libctx, NULL, NULL, cert, privkey,
- 0, &qtserv, &clientquic, NULL)))
+ 0, &qtserv, &clientquic, NULL,
+ NULL)))
goto err;
msglen = strlen(msg);
@@ -946,7 +947,7 @@ static int test_back_pressure(void)
if (!TEST_ptr(cctx)
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert,
privkey, 0, &qtserv,
- &clientquic, NULL))
+ &clientquic, NULL, NULL))
|| !TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto err;
@@ -1024,7 +1025,7 @@ static int test_multiple_dgrams(void)
|| !TEST_ptr(buf)
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert,
privkey, 0, &qtserv,
- &clientquic, NULL))
+ &clientquic, NULL, NULL))
|| !TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto err;
@@ -1088,7 +1089,8 @@ static int test_non_io_retry(int idx)
flags = (idx >= 1) ? QTEST_FLAG_BLOCK : 0;
if (!TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert, privkey,
- flags, &qtserv, &clientquic, NULL))
+ flags, &qtserv, &clientquic, NULL,
+ NULL))
|| !TEST_true(qtest_create_quic_connection_ex(qtserv, clientquic,
SSL_ERROR_WANT_RETRY_VERIFY))
|| !TEST_int_eq(SSL_want(clientquic), SSL_RETRY_VERIFY)
@@ -1156,7 +1158,7 @@ static int test_quic_psk(void)
/* No cert or private key for the server, i.e. PSK only */
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, NULL,
NULL, 0, &qtserv,
- &clientquic, NULL)))
+ &clientquic, NULL, NULL)))
goto end;
SSL_set_psk_use_session_callback(clientquic, use_session_cb);
@@ -1215,7 +1217,7 @@ static int test_alpn(int idx)
privkey,
QTEST_FLAG_FAKE_TIME,
&qtserv,
- &clientquic, NULL)))
+ &clientquic, NULL, NULL)))
goto err;
if (idx == 0) {
@@ -1328,7 +1330,7 @@ static int test_noisy_dgram(int idx)
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert,
privkey, flags,
&qtserv,
- &clientquic, NULL)))
+ &clientquic, NULL, NULL)))
goto err;
if (!TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
diff --git a/test/quicfaultstest.c b/test/quicfaultstest.c
index a6ba0dc053..28f52cd6f2 100644
--- a/test/quicfaultstest.c
+++ b/test/quicfaultstest.c
@@ -35,7 +35,7 @@ static int test_basic(void)
goto err;
if (!TEST_true(qtest_create_quic_objects(NULL, cctx, NULL, cert, privkey, 0,
- &qtserv, &cssl, NULL)))
+ &qtserv, &cssl, NULL, NULL)))
goto err;
if (!TEST_true(qtest_create_quic_connection(qtserv, cssl)))
@@ -105,7 +105,7 @@ static int test_unknown_frame(void)
goto err;
if (!TEST_true(qtest_create_quic_objects(NULL, cctx, NULL, cert, privkey, 0,
- &qtserv, &cssl, &fault)))
+ &qtserv, &cssl, &fault, NULL)))
goto err;
if (!TEST_true(qtest_create_quic_connection(qtserv, cssl)))
@@ -187,7 +187,7 @@ static int test_drop_extensions(int idx)
goto err;
if (!TEST_true(qtest_create_quic_objects(NULL, cctx, NULL, cert, privkey, 0,
- &qtserv, &cssl, &fault)))
+ &qtserv, &cssl, &fault, NULL)))
goto err;
if (idx == 0) {
@@ -275,7 +275,7 @@ static int test_corrupted_data(int idx)
if (!TEST_true(qtest_create_quic_objects(NULL, cctx, NULL, cert, privkey,
QTEST_FLAG_FAKE_TIME, &qtserv,
- &cssl, &fault)))
+ &cssl, &fault, NULL)))
goto err;
if (idx == 0) {