Skip to content

Commit

Permalink
Test that we send multiple datagrams in one go if appropriate
Browse files Browse the repository at this point in the history
If we have enough data for more than one datagram then we should send more
than one datagram
  • Loading branch information
mattcaswell committed Aug 21, 2023
1 parent 1fc67fa commit 26d6349
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions test/quicapitest.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,64 @@ static int test_back_pressure(void)
return testresult;
}


static int conn_close_ctr = 0;

static void conn_close_cb(int write_p, int version, int content_type,
const void *buf, size_t msglen, SSL *ssl, void *arg)
{
PACKET pkt;
uint64_t frame_type;

if (!write_p)
return;

if (content_type != SSL3_RT_QUIC_FRAME_FULL
&& content_type != SSL3_RT_QUIC_FRAME_HEADER)
return;

if (!PACKET_buf_init(&pkt, buf, msglen))
return;

if (!ossl_quic_wire_peek_frame_header(&pkt, &frame_type, NULL))
return;

if (frame_type == OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_TRANSPORT)
conn_close_ctr++;
}

/* Test that we only get one CONNECTION_CLOSE when we only expect one */
static int test_conn_close(void)
{
SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
SSL *clientquic = NULL;
QUIC_TSERVER *qtserv = NULL;
int testresult = 0;

if (!TEST_ptr(cctx)
|| !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert,
privkey, 0, &qtserv,
&clientquic, NULL))
|| !TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
goto err;

conn_close_ctr = 0;
SSL_set_msg_callback(clientquic, conn_close_cb);
SSL_shutdown(clientquic);
SSL_handle_events(clientquic);
if (!TEST_int_eq(conn_close_ctr, 1))
goto err;

testresult = 1;
err:
SSL_free(clientquic);
ossl_quic_tserver_free(qtserv);
SSL_CTX_free(cctx);

return testresult;
}


OPT_TEST_DECLARE_USAGE("provider config certsdir datadir\n")

int setup_tests(void)
Expand Down Expand Up @@ -1001,6 +1059,7 @@ int setup_tests(void)
ADD_ALL_TESTS(test_quic_set_fd, 3);
ADD_TEST(test_bio_ssl);
ADD_TEST(test_back_pressure);
ADD_TEST(test_conn_close);
return 1;
err:
cleanup_tests();
Expand Down

0 comments on commit 26d6349

Please sign in to comment.