TESTS: quic: create first quic unittest
Define a first unit-test dedicated to QUIC. A single test for now ensures that variable length decoding is compliant. This should be extended in the future with new set of tests.
This commit is contained in:
parent
5e558c1727
commit
6f95d0dad0
2
Makefile
2
Makefile
@ -657,7 +657,7 @@ OPTIONS_OBJS += src/mux_quic.o src/h3.o src/quic_rx.o src/quic_tx.o \
|
|||||||
src/quic_cc_nocc.o src/quic_cc.o src/quic_pacing.o \
|
src/quic_cc_nocc.o src/quic_cc.o src/quic_pacing.o \
|
||||||
src/h3_stats.o src/quic_stats.o src/qpack-enc.o \
|
src/h3_stats.o src/quic_stats.o src/qpack-enc.o \
|
||||||
src/qpack-tbl.o src/quic_cc_drs.o src/quic_fctl.o \
|
src/qpack-tbl.o src/quic_cc_drs.o src/quic_fctl.o \
|
||||||
src/cbuf.o
|
src/cbuf.o src/quic_enc.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(USE_QUIC_OPENSSL_COMPAT:0=),)
|
ifneq ($(USE_QUIC_OPENSSL_COMPAT:0=),)
|
||||||
|
32
src/quic_enc.c
Normal file
32
src/quic_enc.c
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include <haproxy/quic_enc.h>
|
||||||
|
|
||||||
|
#include <haproxy/api.h>
|
||||||
|
|
||||||
|
int quic_enc_unittest(int argc, char **argv)
|
||||||
|
{
|
||||||
|
const uint8_t init = 4;
|
||||||
|
|
||||||
|
uint64_t val = 0;
|
||||||
|
struct buffer b;
|
||||||
|
char area[12];
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
int ret = 1;
|
||||||
|
|
||||||
|
b = b_make(area, sizeof(area), sizeof(area) - 2, 0);
|
||||||
|
/* encode an 8-bit integer as a 4 bytes long varint */
|
||||||
|
b_putblk(&b, (char[]){0x80, 0x00, 0x00, init}, 4);
|
||||||
|
/* ensure encoded data is wrapping inside buffer */
|
||||||
|
BUG_ON(b_data(&b) != b_contig_data(&b, b_head_ofs(&b)));
|
||||||
|
|
||||||
|
/* test that b_quic_dec_int() can decode a wrapping value */
|
||||||
|
b_quic_dec_int(&val, &b, &len);
|
||||||
|
if (val != init)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
out:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
REGISTER_UNITTEST("quic_enc", quic_enc_unittest);
|
18
tests/unit/quic/quic.sh
Executable file
18
tests/unit/quic/quic.sh
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
check() {
|
||||||
|
${HAPROXY_PROGRAM} -vv | grep -E '^Unit tests list :' | grep -q "quic"
|
||||||
|
}
|
||||||
|
|
||||||
|
run() {
|
||||||
|
${HAPROXY_PROGRAM} -U quic_enc
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"check")
|
||||||
|
check
|
||||||
|
;;
|
||||||
|
"run")
|
||||||
|
run
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
x
Reference in New Issue
Block a user