summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2022-09-15 12:29:10 +0100
committerHugo Landau <hlandau@openssl.org>2022-11-07 18:18:04 +0000
commitd77aea591650cd3bfe7c25cbb6955011bb21b416 (patch)
treecf8f436414c4d772c4ee112934c1434868f89ac5 /test
parentc282da8bc77500cb40ec63754b5230b4bc883242 (diff)
downloadopenssl-new-d77aea591650cd3bfe7c25cbb6955011bb21b416.tar.gz
QUIC TXPIM
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19206)
Diffstat (limited to 'test')
-rw-r--r--test/build.info6
-rw-r--r--test/quic_txpim_test.c67
-rw-r--r--test/recipes/70-test_quic_txpim.t19
3 files changed, 91 insertions, 1 deletions
diff --git a/test/build.info b/test/build.info
index cd72179be1..728fc11166 100644
--- a/test/build.info
+++ b/test/build.info
@@ -304,6 +304,10 @@ IF[{- !$disabled{tests} -}]
INCLUDE[quic_cfq_test]=../include ../apps/include
DEPEND[quic_cfq_test]=../libcrypto.a ../libssl.a libtestutil.a
+ SOURCE[quic_txpim_test]=quic_txpim_test.c
+ INCLUDE[quic_txpim_test]=../include ../apps/include
+ DEPEND[quic_txpim_test]=../libcrypto.a ../libssl.a libtestutil.a
+
SOURCE[asynctest]=asynctest.c
INCLUDE[asynctest]=../include ../apps/include
DEPEND[asynctest]=../libcrypto
@@ -1028,7 +1032,7 @@ ENDIF
ENDIF
IF[{- !$disabled{'quic'} -}]
- PROGRAMS{noinst}=quicapitest quic_wire_test quic_ackm_test quic_record_test quic_fc_test quic_stream_test quic_cfq_test
+ PROGRAMS{noinst}=quicapitest quic_wire_test quic_ackm_test quic_record_test quic_fc_test quic_stream_test quic_cfq_test quic_txpim_test
ENDIF
SOURCE[quicapitest]=quicapitest.c helpers/ssltestlib.c
diff --git a/test/quic_txpim_test.c b/test/quic_txpim_test.c
new file mode 100644
index 0000000000..84f870312b
--- /dev/null
+++ b/test/quic_txpim_test.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include "internal/packet.h"
+#include "internal/quic_txpim.h"
+#include "testutil.h"
+
+static int test_txpim(void)
+{
+ int testresult = 0;
+ QUIC_TXPIM *txpim;
+ size_t i, j;
+ QUIC_TXPIM_PKT *pkts[10] = {NULL};
+ QUIC_TXPIM_CHUNK chunks[3];
+ const QUIC_TXPIM_CHUNK *rchunks;
+
+ if (!TEST_ptr(txpim = ossl_quic_txpim_new()))
+ goto err;
+
+ for (i = 0; i < OSSL_NELEM(pkts); ++i) {
+ if (!TEST_ptr(pkts[i] = ossl_quic_txpim_pkt_alloc(txpim)))
+ goto err;
+
+ if (!TEST_size_t_eq(ossl_quic_txpim_pkt_get_num_chunks(pkts[i]), 0))
+ goto err;
+
+ for (j = 0; j < OSSL_NELEM(chunks); ++j) {
+ chunks[j].stream_id = 100 - j;
+ chunks[j].start = 1000 * i + j * 10;
+ chunks[j].end = chunks[j].start + 5;
+
+ if (!TEST_true(ossl_quic_txpim_pkt_append_chunk(pkts[i], chunks + j)))
+ goto err;
+ }
+
+ if (!TEST_size_t_eq(ossl_quic_txpim_pkt_get_num_chunks(pkts[i]),
+ OSSL_NELEM(chunks)))
+ goto err;
+
+ rchunks = ossl_quic_txpim_pkt_get_chunks(pkts[i]);
+ if (!TEST_uint64_t_eq(rchunks[0].stream_id, 98)
+ || !TEST_uint64_t_eq(rchunks[1].stream_id, 99)
+ || !TEST_uint64_t_eq(rchunks[2].stream_id, 100))
+ goto err;
+ }
+
+ testresult = 1;
+err:
+ for (i = 0; i < OSSL_NELEM(pkts); ++i)
+ if (txpim != NULL && pkts[i] != NULL)
+ ossl_quic_txpim_pkt_release(txpim, pkts[i]);
+
+ ossl_quic_txpim_free(txpim);
+ return testresult;
+}
+
+int setup_tests(void)
+{
+ ADD_TEST(test_txpim);
+ return 1;
+}
diff --git a/test/recipes/70-test_quic_txpim.t b/test/recipes/70-test_quic_txpim.t
new file mode 100644
index 0000000000..071394cec3
--- /dev/null
+++ b/test/recipes/70-test_quic_txpim.t
@@ -0,0 +1,19 @@
+#! /usr/bin/env perl
+# Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the Apache License 2.0 (the "License"). You may not use
+# this file except in compliance with the License. You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
+use OpenSSL::Test;
+use OpenSSL::Test::Utils;
+
+setup("test_quic_txpim");
+
+plan skip_all => "QUIC protocol is not supported by this OpenSSL build"
+ if disabled('quic');
+
+plan tests => 1;
+
+ok(run(test(["quic_txpim_test"])));