summaryrefslogtreecommitdiffstats
path: root/test/helpers
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2023-09-19 17:40:25 +0200
committerMatt Caswell <matt@openssl.org>2023-09-22 14:56:43 +0200
commit8d8c0a901e5d65d68070fbe812d7e8c1449381e1 (patch)
tree406aef9b4a2ecab41ff0372f5f5e6db98b94ac48 /test/helpers
parentExtend the noisy dgram test so that packets are also affected by noise (diff)
downloadopenssl-8d8c0a901e5d65d68070fbe812d7e8c1449381e1.tar.xz
openssl-8d8c0a901e5d65d68070fbe812d7e8c1449381e1.zip
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/helpers')
-rw-r--r--test/helpers/quictestlib.c17
-rw-r--r--test/helpers/quictestlib.h5
2 files changed, 19 insertions, 3 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);