mirror of
https://gitea.invidious.io/iv-org/litespeed-quic.git
synced 2024-08-15 00:53:43 +00:00
[WIP] use vcpkg for getopt; build windows shared lib enhancements (#350)
* fix MSVC compiler shared library issues - mostly around 'extern const' * add vcpkg install getopt to appveyor-windows.yml show appveyor where to get getopt from vcpkg (non-static lib to avoid LGPL violation) * add missing else case in lsquic_shared_support.h for windows static lib path * have cmake spit out it's version have cmake copy dependent dlls to build dir for tests on windows (getopt.dll) * copy getopt.dll dep for tests added commented version that requires >= 3.21 but handles any dll deps * try caching boringssl dir to reduce CI build time since it's always same commit specified in config file define VCPKG_ROOT in env since I can't seem to find it by VCPKG_ROOT or VCPKG_INSTALLED_DIR in appveyor's cmake v3.16 + vcpkg * make windows cache dependent on yml and cmd * sync up with changes to ls-qpack
This commit is contained in:
parent
df67278304
commit
f07b3eae43
42 changed files with 1182 additions and 2124 deletions
|
@ -6,7 +6,6 @@ ENABLE_TESTING()
|
|||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLSQUIC_TEST=1")
|
||||
|
||||
IF (MSVC)
|
||||
SET(ADDL_SOURCES ../wincompat/getopt.c ../wincompat/getopt1.c)
|
||||
SET(LIB_FLAGS "-FORCE:MULTIPLE")
|
||||
ELSE()
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-value")
|
||||
|
@ -91,12 +90,31 @@ ENDIF()
|
|||
|
||||
FOREACH(TEST_NAME ${TESTS})
|
||||
ADD_EXECUTABLE(test_${TEST_NAME} test_${TEST_NAME}.c ${ADDL_SOURCES})
|
||||
TARGET_LINK_LIBRARIES(test_${TEST_NAME} ${LIBS} ${LIB_FLAGS})
|
||||
IF(NOT MSVC)
|
||||
TARGET_LINK_LIBRARIES(test_${TEST_NAME} ${LIBS} ${LIB_FLAGS})
|
||||
ELSE()
|
||||
TARGET_LINK_LIBRARIES(test_${TEST_NAME} ${LIBS} ${GETOPT_LIB} ${LIB_FLAGS})
|
||||
# copy any dependencies local to the tests
|
||||
#IF (${CMAKE_VERSION} VERSION_LESS "3.21.0")
|
||||
ADD_CUSTOM_COMMAND(TARGET test_${TEST_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy \"$ENV{VCPKG_ROOT}/installed/x64-windows$<$<CONFIG:Debug>:/debug>/bin/getopt.dll\" \"$<TARGET_FILE_DIR:test_${TEST_NAME}>\"
|
||||
COMMAND_EXPAND_LISTS
|
||||
)
|
||||
#ELSE()
|
||||
# ADD_CUSTOM_COMMAND(TARGET test_${TEST_NAME} POST_BUILD
|
||||
# COMMAND if not \"\"=="$<TARGET_RUNTIME_DLLS:test_${TEST_NAME}>" ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:test_${TEST_NAME}> $<TARGET_FILE_DIR:test_${TEST_NAME}>
|
||||
# COMMAND_EXPAND_LISTS
|
||||
# )
|
||||
#ENDIF()
|
||||
ENDIF()
|
||||
ADD_TEST(${TEST_NAME} test_${TEST_NAME})
|
||||
ENDFOREACH()
|
||||
|
||||
ADD_EXECUTABLE(test_stream test_stream.c ${ADDL_SOURCES})
|
||||
TARGET_LINK_LIBRARIES(test_stream ${LIBS} ${LIB_FLAGS})
|
||||
IF(MSVC)
|
||||
TARGET_LINK_LIBRARIES(test_stream ${GETOPT_LIB})
|
||||
ENDIF()
|
||||
ADD_TEST(stream test_stream)
|
||||
ADD_TEST(stream_hash test_stream -h)
|
||||
ADD_TEST(stream_A test_stream -A)
|
||||
|
@ -114,20 +132,26 @@ ADD_EXECUTABLE(test_min_heap test_min_heap.c ../src/liblsquic/lsquic_min_heap.c)
|
|||
ADD_TEST(min_heap test_min_heap)
|
||||
|
||||
SET(MALO_SRC test_malo.c ../src/liblsquic/lsquic_malo.c)
|
||||
IF(MSVC)
|
||||
LIST(APPEND MALO_SRC ../wincompat/getopt.c)
|
||||
ENDIF()
|
||||
ADD_EXECUTABLE(test_malo_pooled ${MALO_SRC})
|
||||
IF(MSVC)
|
||||
TARGET_LINK_LIBRARIES(test_malo_pooled ${GETOPT_LIB})
|
||||
ENDIF()
|
||||
SET_TARGET_PROPERTIES(test_malo_pooled
|
||||
PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLSQUIC_USE_POOLS=1")
|
||||
ADD_TEST(malo_pooled test_malo_pooled)
|
||||
|
||||
ADD_EXECUTABLE(test_malo_nopool ${MALO_SRC})
|
||||
IF(MSVC)
|
||||
TARGET_LINK_LIBRARIES(test_malo_nopool ${GETOPT_LIB})
|
||||
ENDIF()
|
||||
SET_TARGET_PROPERTIES(test_malo_nopool
|
||||
PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -DLSQUIC_USE_POOLS=0")
|
||||
ADD_TEST(malo_nopool test_malo_nopool)
|
||||
|
||||
ADD_EXECUTABLE(test_minmax test_minmax.c ../src/liblsquic/lsquic_minmax.c)
|
||||
IF(MSVC)
|
||||
TARGET_LINK_LIBRARIES(test_minmax ${GETOPT_LIB})
|
||||
ENDIF()
|
||||
ADD_TEST(minmax test_minmax)
|
||||
|
||||
ADD_EXECUTABLE(test_rechist test_rechist.c ../src/liblsquic/lsquic_rechist.c)
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
#include "lsquic_logger.h"
|
||||
#include "lsquic.h"
|
||||
|
||||
static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043);
|
||||
//static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043); // will not work on MSVC
|
||||
#define pf ((const struct parse_funcs *const)select_pf_by_ver(LSQVER_043))
|
||||
|
||||
static void
|
||||
test1 (void) /* Inverse of quic_framer_test.cc -- NewAckFrameOneAckBlock */
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
|
||||
static struct lsquic_conn lconn = LSCONN_INITIALIZER_CIDLEN(lconn, 0);
|
||||
|
||||
static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043);
|
||||
//static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043); // will not work on MSVC
|
||||
#define pf ((const struct parse_funcs *const)select_pf_by_ver(LSQVER_043))
|
||||
|
||||
|
||||
static lsquic_packno_t
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
|
||||
static struct lsquic_conn lconn = LSCONN_INITIALIZER_CIDLEN(lconn, 0);
|
||||
|
||||
static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_ID27);
|
||||
//static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_ID27); // will not work on MSVC
|
||||
#define pf ((const struct parse_funcs *const)select_pf_by_ver(LSQVER_ID27))
|
||||
|
||||
|
||||
static void
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
#include "lsquic_types.h"
|
||||
#include "lsquic_parse.h"
|
||||
|
||||
static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043);
|
||||
//static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043); // will not work on MSVC
|
||||
#define pf ((const struct parse_funcs *const)select_pf_by_ver(LSQVER_043))
|
||||
|
||||
|
||||
/* The test is both for generation and parsing: */
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
#include "lsquic_types.h"
|
||||
#include "lsquic_parse.h"
|
||||
|
||||
static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043);
|
||||
//static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043); // will not work on MSVC
|
||||
#define pf ((const struct parse_funcs *const)select_pf_by_ver(LSQVER_043))
|
||||
|
||||
|
||||
struct conn_close_parse_test {
|
||||
|
|
|
@ -29,44 +29,6 @@ struct test {
|
|||
char out[0x100];
|
||||
};
|
||||
|
||||
|
||||
static const struct test tests[] = {
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.offset = 0,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
{ /* Type */ 0x06,
|
||||
/* Offset */ 0x00,
|
||||
/* Size */ 0x0A,
|
||||
/* Data */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 1 + 1 + 10,
|
||||
.min_sz = 1 + 1 + 1 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.offset = 500,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
{ /* Type */ 0x06,
|
||||
/* Offset */ 0x41, 0xF4,
|
||||
/* Size */ 0x0A,
|
||||
/* Data */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 1 + 10,
|
||||
.min_sz = 1 + 2 + 1 + 1,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct test_ctx {
|
||||
const struct test *test;
|
||||
unsigned off;
|
||||
|
@ -94,9 +56,8 @@ init_ctx (struct test_ctx *test_ctx, const struct test *test)
|
|||
|
||||
|
||||
static void
|
||||
run_test (int i)
|
||||
run_test (const struct test *const test)
|
||||
{
|
||||
const struct test *const test = &tests[i];
|
||||
|
||||
int len;
|
||||
size_t min;
|
||||
|
@ -139,8 +100,44 @@ run_test (int i)
|
|||
int
|
||||
main (void)
|
||||
{
|
||||
const struct test tests[] = {
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.offset = 0,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
{ /* Type */ 0x06,
|
||||
/* Offset */ 0x00,
|
||||
/* Size */ 0x0A,
|
||||
/* Data */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 1 + 1 + 10,
|
||||
.min_sz = 1 + 1 + 1 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.offset = 500,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
{ /* Type */ 0x06,
|
||||
/* Offset */ 0x41, 0xF4,
|
||||
/* Size */ 0x0A,
|
||||
/* Data */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 1 + 10,
|
||||
.min_sz = 1 + 2 + 1 + 1,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
|
||||
run_test(i);
|
||||
run_test(&tests[i]);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
#include "lsquic_packet_common.h"
|
||||
#include "lsquic_packet_out.h"
|
||||
|
||||
static const struct cong_ctl_if *const cci = &lsquic_cong_cubic_if;
|
||||
//static const struct cong_ctl_if *const cci = &lsquic_cong_cubic_if; // will not work on MSVC
|
||||
#define cci ((const struct cong_ctl_if *const)&lsquic_cong_cubic_if)
|
||||
|
||||
static void
|
||||
test_post_quiescence_explosion (void)
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
#include "lsquic_logger.h"
|
||||
|
||||
|
||||
static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043);
|
||||
//static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043); // will not work on MSVC
|
||||
#define pf ((const struct parse_funcs *const)select_pf_by_ver(LSQVER_043))
|
||||
|
||||
static struct {
|
||||
unsigned char buf[0x1000];
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
#include "lsquic_types.h"
|
||||
#include "lsquic_parse.h"
|
||||
|
||||
static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043);
|
||||
//static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043); // will not work on MSVC
|
||||
#define pf ((const struct parse_funcs *const)select_pf_by_ver(LSQVER_043))
|
||||
|
||||
|
||||
struct goaway_parse_test {
|
||||
|
|
|
@ -335,6 +335,7 @@ main (int argc, char **argv)
|
|||
for (n = 0; n < sizeof(test_specs) / sizeof(test_specs[0]); ++n)
|
||||
run_test(&test_specs[n]);
|
||||
|
||||
#ifndef NDEBUG
|
||||
lsquic_hpi_set_heap_test(LSQUIC_HPI_HEAP_TEST_STACK_OK);
|
||||
for (n = 0; n < sizeof(test_specs) / sizeof(test_specs[0]); ++n)
|
||||
run_test(&test_specs[n]);
|
||||
|
@ -346,6 +347,7 @@ main (int argc, char **argv)
|
|||
lsquic_hpi_set_heap_test(0);
|
||||
for (n = 0; n < sizeof(test_specs) / sizeof(test_specs[0]); ++n)
|
||||
run_test(&test_specs[n]);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
|
||||
#include "lsquic_minmax.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "vc_compat.h"
|
||||
#endif
|
||||
|
||||
/* Convert milliseconds to lsquic_time_t, which is microseconds */
|
||||
#define ms(val) ((val) * 1000)
|
||||
|
||||
|
|
|
@ -606,8 +606,11 @@ run_test (const struct test_spec *spec, enum lsquic_version version)
|
|||
LSQ_INFO("Running test on line %d: %s", spec->lineno, spec->desc);
|
||||
if (spec->versions && !(spec->versions & (1 << version)))
|
||||
{
|
||||
LSQ_INFO("Not applicable to version %s, skip",
|
||||
lsquic_ver2str[version]);
|
||||
#ifndef _MSC_VER
|
||||
LSQ_INFO("Not applicable to version %s, skip", lsquic_ver2str[version]);
|
||||
#else
|
||||
LSQ_INFO("Not applicable to version %d, skip", version);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -765,7 +768,11 @@ main (int argc, char **argv)
|
|||
{
|
||||
if (!((1 << version) & LSQUIC_DF_VERSIONS))
|
||||
continue;
|
||||
#ifndef _MSC_VER
|
||||
LSQ_INFO("testing version %s", lsquic_ver2str[version]);
|
||||
#else
|
||||
LSQ_INFO("testing version %d", version);
|
||||
#endif
|
||||
for (spec = test_specs; spec < test_specs + sizeof(test_specs) / sizeof(test_specs[0]); ++spec)
|
||||
run_test(spec, version);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
#include "lsquic_parse.h"
|
||||
|
||||
|
||||
static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043);
|
||||
//static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043); // will not work on MSVC
|
||||
#define pf ((const struct parse_funcs *const)select_pf_by_ver(LSQVER_043))
|
||||
|
||||
|
||||
struct packno_bits_test {
|
||||
|
@ -205,7 +206,6 @@ static const struct packno_bits_test pb_tests[] = {
|
|||
static void
|
||||
run_pbt (int i)
|
||||
{
|
||||
const struct parse_funcs *pf = select_pf_by_ver(LSQVER_043);
|
||||
const struct packno_bits_test *const pbt = &pb_tests[i];
|
||||
enum packno_bits packno_bits = pf->pf_calc_packno_bits(pbt->pbt_packno,
|
||||
pbt->pbt_least_unacked, pbt->pbt_n_in_flight);
|
||||
|
|
|
@ -22,8 +22,10 @@ static int s_eight;
|
|||
static void
|
||||
bloom_test (unsigned count, unsigned miss_searches, unsigned hit_searches)
|
||||
{
|
||||
struct lsquic_purga *purga;
|
||||
#ifndef NDEBUG
|
||||
struct purga_bloom_stats *stats;
|
||||
#endif
|
||||
struct lsquic_purga *purga;
|
||||
struct purga_el *puel;
|
||||
lsquic_cid_t *cids, cid;
|
||||
unsigned i, j;
|
||||
|
@ -73,10 +75,12 @@ bloom_test (unsigned count, unsigned miss_searches, unsigned hit_searches)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
stats = lsquic_purga_get_bloom_stats(purga);
|
||||
LSQ_NOTICE("searches: %lu, false hits: %lu, false hit ratio: %lf",
|
||||
stats->searches, stats->false_hits,
|
||||
(double) stats->false_hits / (double) stats->searches);
|
||||
#endif
|
||||
|
||||
lsquic_purga_destroy(purga);
|
||||
free(cids);
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
#include "lsquic_parse.h"
|
||||
|
||||
|
||||
static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043);
|
||||
//static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043); // will not work on MSVC
|
||||
#define pf ((const struct parse_funcs *const)select_pf_by_ver(LSQVER_043))
|
||||
|
||||
struct float_test {
|
||||
uint64_t long_time;
|
||||
|
|
|
@ -41,163 +41,10 @@ struct test {
|
|||
};
|
||||
|
||||
|
||||
static const struct test tests[] = {
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0x0102030405060708UL,
|
||||
.nonce = NULL,
|
||||
.packno = 0x01020304,
|
||||
.bits = GQUIC_PACKNO_LEN_4,
|
||||
.len = 1 + 8 + 0 + 4,
|
||||
.out = { (0 << 2) /* Nonce present */
|
||||
| 0x08 /* Connection ID present */
|
||||
| 0x20 /* Packet number length */
|
||||
,
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Connection ID */
|
||||
0x01, 0x02, 0x03, 0x04, /* Packet number */
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0x0102030405060708UL,
|
||||
.nonce = NULL,
|
||||
.packno = 0x00,
|
||||
.bits = GQUIC_PACKNO_LEN_1,
|
||||
.len = 1 + 8 + 0 + 1,
|
||||
.out = { (0 << 2) /* Nonce present */
|
||||
| 0x08 /* Connection ID present */
|
||||
| 0x00 /* Packet number length */
|
||||
,
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Connection ID */
|
||||
0x00, /* Packet number */
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0x0102030405060708UL,
|
||||
.nonce = NULL,
|
||||
.packno = 0x09,
|
||||
.bits = GQUIC_PACKNO_LEN_1,
|
||||
.ver.buf= { 'Q', '0', '4', '3', },
|
||||
.len = 1 + 8 + 4 + 0 + 1,
|
||||
.out = { (0 << 2) /* Nonce present */
|
||||
| 0x01 /* Version present */
|
||||
| 0x08 /* Connection ID present */
|
||||
| 0x00 /* Packet number length */
|
||||
,
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Connection ID */
|
||||
'Q', '0', '4', '3',
|
||||
0x09, /* Packet number */
|
||||
},
|
||||
},
|
||||
|
||||
#define NONCENSE "0123456789abcdefghijklmnopqrstuv"
|
||||
#define NONCENSE_BYTES '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v'
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0x0102030405060708UL,
|
||||
.nonce = NONCENSE,
|
||||
.packno = 0x00,
|
||||
.bits = GQUIC_PACKNO_LEN_1,
|
||||
.len = 1 + 8 + 32 + 1,
|
||||
.out = { (1 << 2) /* Nonce present */
|
||||
| 0x08 /* Connection ID present */
|
||||
| 0x00 /* Packet number length */
|
||||
,
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Connection ID */
|
||||
NONCENSE_BYTES,
|
||||
0x00, /* Packet number */
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0, /* Do not set connection ID */
|
||||
.nonce = NONCENSE,
|
||||
.packno = 0x00,
|
||||
.bits = GQUIC_PACKNO_LEN_1,
|
||||
.len = 1 + 0 + 32 + 1,
|
||||
.out = { (1 << 2) /* Nonce present */
|
||||
| 0x00 /* Packet number length */
|
||||
,
|
||||
NONCENSE_BYTES,
|
||||
0x00, /* Packet number */
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0x0102030405060708UL,
|
||||
.nonce = NONCENSE,
|
||||
.packno = 0x00,
|
||||
.bits = GQUIC_PACKNO_LEN_1,
|
||||
.ver.buf= { 'Q', '0', '4', '3', },
|
||||
.len = 1 + 8 + 4 + 32 + 1,
|
||||
.out = { (1 << 2) /* Nonce present */
|
||||
| 0x01 /* Version present */
|
||||
| 0x08 /* Connection ID present */
|
||||
| 0x00 /* Packet number length */
|
||||
,
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Connection ID */
|
||||
'Q', '0', '4', '3',
|
||||
NONCENSE_BYTES,
|
||||
0x00, /* Packet number */
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0x0102030405060708UL,
|
||||
.nonce = NONCENSE,
|
||||
.packno = 0xA0A1A2A3A4A5A6A7UL,
|
||||
.bits = GQUIC_PACKNO_LEN_6,
|
||||
.len = 1 + 8 + 32 + 6,
|
||||
.out = { (1 << 2) /* Nonce present */
|
||||
| 0x08 /* Connection ID present */
|
||||
| 0x30 /* Packet number length */
|
||||
,
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Connection ID */
|
||||
NONCENSE_BYTES,
|
||||
0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0x0102030405060708UL,
|
||||
.nonce = NONCENSE,
|
||||
.packno = 0xA0A1A2A3A4A5A6A7UL,
|
||||
.bits = GQUIC_PACKNO_LEN_6,
|
||||
.len = 1 + 8 + 32 + 6,
|
||||
.out = { (1 << 2) /* Nonce present */
|
||||
| 0x08 /* Connection ID present */
|
||||
| 0x30 /* Packet number length */
|
||||
,
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Connection ID */
|
||||
NONCENSE_BYTES,
|
||||
0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
|
||||
},
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
run_test (int i)
|
||||
run_test (const struct test *const test)
|
||||
{
|
||||
const struct test *const test = &tests[i];
|
||||
|
||||
struct lsquic_packet_out packet_out =
|
||||
{
|
||||
|
@ -233,8 +80,159 @@ run_test (int i)
|
|||
int
|
||||
main (void)
|
||||
{
|
||||
const struct test tests[] = {
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0x0102030405060708UL,
|
||||
.nonce = NULL,
|
||||
.packno = 0x01020304,
|
||||
.bits = GQUIC_PACKNO_LEN_4,
|
||||
.len = 1 + 8 + 0 + 4,
|
||||
.out = { (0 << 2) /* Nonce present */
|
||||
| 0x08 /* Connection ID present */
|
||||
| 0x20 /* Packet number length */
|
||||
,
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Connection ID */
|
||||
0x01, 0x02, 0x03, 0x04, /* Packet number */
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0x0102030405060708UL,
|
||||
.nonce = NULL,
|
||||
.packno = 0x00,
|
||||
.bits = GQUIC_PACKNO_LEN_1,
|
||||
.len = 1 + 8 + 0 + 1,
|
||||
.out = { (0 << 2) /* Nonce present */
|
||||
| 0x08 /* Connection ID present */
|
||||
| 0x00 /* Packet number length */
|
||||
,
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Connection ID */
|
||||
0x00, /* Packet number */
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0x0102030405060708UL,
|
||||
.nonce = NULL,
|
||||
.packno = 0x09,
|
||||
.bits = GQUIC_PACKNO_LEN_1,
|
||||
.ver.buf= { 'Q', '0', '4', '3', },
|
||||
.len = 1 + 8 + 4 + 0 + 1,
|
||||
.out = { (0 << 2) /* Nonce present */
|
||||
| 0x01 /* Version present */
|
||||
| 0x08 /* Connection ID present */
|
||||
| 0x00 /* Packet number length */
|
||||
,
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Connection ID */
|
||||
'Q', '0', '4', '3',
|
||||
0x09, /* Packet number */
|
||||
},
|
||||
},
|
||||
|
||||
#define NONCENSE "0123456789abcdefghijklmnopqrstuv"
|
||||
#define NONCENSE_BYTES '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v'
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0x0102030405060708UL,
|
||||
.nonce = NONCENSE,
|
||||
.packno = 0x00,
|
||||
.bits = GQUIC_PACKNO_LEN_1,
|
||||
.len = 1 + 8 + 32 + 1,
|
||||
.out = { (1 << 2) /* Nonce present */
|
||||
| 0x08 /* Connection ID present */
|
||||
| 0x00 /* Packet number length */
|
||||
,
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Connection ID */
|
||||
NONCENSE_BYTES,
|
||||
0x00, /* Packet number */
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0, /* Do not set connection ID */
|
||||
.nonce = NONCENSE,
|
||||
.packno = 0x00,
|
||||
.bits = GQUIC_PACKNO_LEN_1,
|
||||
.len = 1 + 0 + 32 + 1,
|
||||
.out = { (1 << 2) /* Nonce present */
|
||||
| 0x00 /* Packet number length */
|
||||
,
|
||||
NONCENSE_BYTES,
|
||||
0x00, /* Packet number */
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0x0102030405060708UL,
|
||||
.nonce = NONCENSE,
|
||||
.packno = 0x00,
|
||||
.bits = GQUIC_PACKNO_LEN_1,
|
||||
.ver.buf= { 'Q', '0', '4', '3', },
|
||||
.len = 1 + 8 + 4 + 32 + 1,
|
||||
.out = { (1 << 2) /* Nonce present */
|
||||
| 0x01 /* Version present */
|
||||
| 0x08 /* Connection ID present */
|
||||
| 0x00 /* Packet number length */
|
||||
,
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Connection ID */
|
||||
'Q', '0', '4', '3',
|
||||
NONCENSE_BYTES,
|
||||
0x00, /* Packet number */
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0x0102030405060708UL,
|
||||
.nonce = NONCENSE,
|
||||
.packno = 0xA0A1A2A3A4A5A6A7UL,
|
||||
.bits = GQUIC_PACKNO_LEN_6,
|
||||
.len = 1 + 8 + 32 + 6,
|
||||
.out = { (1 << 2) /* Nonce present */
|
||||
| 0x08 /* Connection ID present */
|
||||
| 0x30 /* Packet number length */
|
||||
,
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Connection ID */
|
||||
NONCENSE_BYTES,
|
||||
0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.bufsz = GQUIC_MAX_PUBHDR_SZ,
|
||||
.cid = 0x0102030405060708UL,
|
||||
.nonce = NONCENSE,
|
||||
.packno = 0xA0A1A2A3A4A5A6A7UL,
|
||||
.bits = GQUIC_PACKNO_LEN_6,
|
||||
.len = 1 + 8 + 32 + 6,
|
||||
.out = { (1 << 2) /* Nonce present */
|
||||
| 0x08 /* Connection ID present */
|
||||
| 0x30 /* Packet number length */
|
||||
,
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Connection ID */
|
||||
NONCENSE_BYTES,
|
||||
0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
|
||||
},
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
|
||||
run_test(i);
|
||||
run_test(&tests[i]);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
#include "lsquic_types.h"
|
||||
#include "lsquic_parse.h"
|
||||
|
||||
static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043);
|
||||
//static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043); // will not work on MSVC
|
||||
#define pf ((const struct parse_funcs *const)select_pf_by_ver(LSQVER_043))
|
||||
|
||||
|
||||
/* The test is both for generation and parsing: */
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "vc_compat.h"
|
||||
#endif
|
||||
#include "lsquic_int_types.h"
|
||||
#include "lsquic_senhist.h"
|
||||
#include "lsquic_types.h"
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
#include "lsquic_types.h"
|
||||
#include "lsquic_parse.h"
|
||||
|
||||
static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043);
|
||||
//static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043); // will not work on MSVC
|
||||
#define pf ((const struct parse_funcs *const)select_pf_by_ver(LSQVER_043))
|
||||
|
||||
|
||||
struct parse_test {
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
#include "lsquic_hq.h"
|
||||
#include "lsquic_data_in_if.h"
|
||||
|
||||
static const struct parse_funcs *g_pf = select_pf_by_ver(LSQVER_043);
|
||||
static const struct parse_funcs *g_pf; // = select_pf_by_ver(LSQVER_043); // will not work on MSVC, moved init to main()
|
||||
|
||||
static int g_use_crypto_ctor;
|
||||
|
||||
|
@ -1295,6 +1295,7 @@ test_loc_RST_rem_FIN (struct test_objs *tobjs)
|
|||
* Stream B is reset. We should get a gapless sequence
|
||||
* of packets 1, 2.
|
||||
*/
|
||||
#ifndef NDEBUG
|
||||
static void
|
||||
test_gapless_elision_middle (struct test_objs *tobjs)
|
||||
{
|
||||
|
@ -1368,7 +1369,6 @@ test_gapless_elision_middle (struct test_objs *tobjs)
|
|||
lsquic_stream_destroy(streamB);
|
||||
}
|
||||
|
||||
|
||||
/* Test that when stream frame is elided and the packet is dropped,
|
||||
* the send controller produces a gapless sequence.
|
||||
*
|
||||
|
@ -1456,6 +1456,7 @@ test_gapless_elision_beginning (struct test_objs *tobjs)
|
|||
lsquic_stream_destroy(streamA);
|
||||
lsquic_stream_destroy(streamB);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -1599,8 +1600,10 @@ test_termination (void)
|
|||
{ 1, 1, test_loc_data_rem_RST, },
|
||||
{ 0, 1, test_loc_data_rem_SS, },
|
||||
{ 1, 0, test_loc_RST_rem_FIN, },
|
||||
#ifndef NDEBUG
|
||||
{ 1, 1, test_gapless_elision_beginning, },
|
||||
{ 1, 1, test_gapless_elision_middle, },
|
||||
#endif
|
||||
}, *tf;
|
||||
|
||||
for (tf = test_funcs; tf < test_funcs + sizeof(test_funcs) / sizeof(test_funcs[0]); ++tf)
|
||||
|
@ -2998,6 +3001,7 @@ test_bad_packbits_guess_3 (void)
|
|||
static void
|
||||
test_resize_buffered (void)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
ssize_t nw;
|
||||
struct test_objs tobjs;
|
||||
struct lsquic_stream *streams[1];
|
||||
|
@ -3046,6 +3050,7 @@ test_resize_buffered (void)
|
|||
lsquic_stream_destroy(streams[0]);
|
||||
deinit_test_objs(&tobjs);
|
||||
lsquic_send_ctl_set_max_bpq_count(10);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -3059,6 +3064,7 @@ test_resize_buffered (void)
|
|||
static void
|
||||
test_resize_scheduled (void)
|
||||
{
|
||||
#ifndef NDEBUG // lsquic_send_ctl_set_max_bpq_count is debug only
|
||||
ssize_t nw;
|
||||
struct test_objs tobjs;
|
||||
struct lsquic_stream *streams[1];
|
||||
|
@ -3107,6 +3113,7 @@ test_resize_scheduled (void)
|
|||
lsquic_stream_destroy(streams[0]);
|
||||
deinit_test_objs(&tobjs);
|
||||
lsquic_send_ctl_set_max_bpq_count(10);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -3671,7 +3678,9 @@ main_test_packetization (void)
|
|||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
g_pf = select_pf_by_ver(LSQVER_043);
|
||||
|
||||
int opt;
|
||||
|
||||
lsquic_global_init(LSQUIC_GLOBAL_SERVER);
|
||||
|
||||
|
|
|
@ -41,360 +41,6 @@ struct test {
|
|||
};
|
||||
|
||||
|
||||
static const struct test tests[] = {
|
||||
/*
|
||||
* Big-endian:
|
||||
*/
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 1, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x1C | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x00, 0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 8 + 2 + 10,
|
||||
.min_sz = 1 + 2 + 8 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x1C | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x00, 0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 8 + 2 + 10,
|
||||
.min_sz = 1 + 2 + 8 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 1, 0, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x1C | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x00, 0x00, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 8 + 2,
|
||||
.min_sz = 1 + 2 + 8 + 2,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 1, 0, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x21,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x1C | 0x00,
|
||||
0x21, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x00, 0x00, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 1 + 8 + 2,
|
||||
.min_sz = 1 + 1 + 8 + 2,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0x77,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x04 | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
0x00, 0x77, /* Offset */
|
||||
0x00, 0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 2 + 2 + 10,
|
||||
.min_sz = 1 + 2 + 2 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0x0,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x00 | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
/* Offset */
|
||||
0x00, 0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 0 + 2 + 10,
|
||||
.min_sz = 1 + 2 + 0 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 1, },
|
||||
.offset = 0x0,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 1,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x00 | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
/* Offset */
|
||||
0x00, 0x01, /* Data length */
|
||||
'0',
|
||||
},
|
||||
.len = 1 + 2 + 0 + 2 + 1,
|
||||
.min_sz = 1 + 2 + 0 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0xFFFFFF,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x08 | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
0xFF, 0xFF, 0xFF, /* Offset */
|
||||
0x00, 0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 3 + 2 + 10,
|
||||
.min_sz = 1 + 2 + 3 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0xFFFFFF + 1,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x0C | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
0x01, 0x00, 0x00, 0x00, /* Offset */
|
||||
0x00, 0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 4 + 2 + 10,
|
||||
.min_sz = 1 + 2 + 4 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0xFFFFFF + 1,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 10,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x00 | 0x0C | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
0x01, 0x00, 0x00, 0x00, /* Offset */
|
||||
'0', '1', '2',
|
||||
},
|
||||
.len = 1 + 2 + 4 + 0 + 3,
|
||||
.min_sz = 1 + 2 + 4 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 1, 0, },
|
||||
.offset = 0xB4,
|
||||
.stream_id = 0x01,
|
||||
.data_sz = 0,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x04 | 0x00,
|
||||
0x01, /* Stream ID */
|
||||
0x00, 0xB4, /* Offset */
|
||||
0x00, 0x00, /* Data length */
|
||||
},
|
||||
.len = 6,
|
||||
.min_sz = 6,
|
||||
},
|
||||
|
||||
/*
|
||||
* IETF QUIC Internet-Draft 17:
|
||||
*/
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.fin = { 0, 1, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x08 | 1<<2 | 1<<1 | 1<<0,
|
||||
0x42, 0x10, /* Stream ID */
|
||||
0xC8, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 8 + 1 + 10,
|
||||
.min_sz = 1 + 2 + 8 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x08 | 0<<2 | 1<<1 | 0<<0,
|
||||
0x42, 0x10, /* Stream ID */
|
||||
0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 0 + 1 + 10,
|
||||
.min_sz = 1 + 2 + 0 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0,
|
||||
.stream_id = 0x21,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 12,
|
||||
.out =
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x08 | 0<<2 | 0<<1 | 0<<0,
|
||||
0x21, /* Stream ID */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 1 + 0 + 0 + 10,
|
||||
.min_sz = 1 + 1 + 0 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x08 | 1<<2 | 1<<1 | 0<<0,
|
||||
0x42, 0x10, /* Stream ID */
|
||||
0xC8, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 8 + 1 + 10,
|
||||
.min_sz = 1 + 2 + 8 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.fin = { 1, 0, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 0,
|
||||
.data = "0123456789",
|
||||
.avail = 11,
|
||||
.out =
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x08 | 1<<2 | 0<<1 | 1<<0,
|
||||
0x42, 0x10, /* Stream ID */
|
||||
0xC8, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
},
|
||||
.len = 1 + 2 + 8,
|
||||
.min_sz = 1 + 2 + 8,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.fin = { 1, 0, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 0,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x08 | 1<<2 | 1<<1 | 1<<0,
|
||||
0x42, 0x10, /* Stream ID */
|
||||
0xC8, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x00, /* Data length */
|
||||
},
|
||||
.len = 1 + 2 + 8 + 1,
|
||||
.min_sz = 1 + 2 + 8,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
|
||||
static struct test_ctx {
|
||||
const struct test *test;
|
||||
int next_fin;
|
||||
|
@ -440,9 +86,8 @@ reset_ctx (const struct test *test)
|
|||
|
||||
|
||||
static void
|
||||
run_test (int i)
|
||||
run_test (const struct test *const test)
|
||||
{
|
||||
const struct test *const test = &tests[i];
|
||||
|
||||
unsigned char out[0x100];
|
||||
int len;
|
||||
|
@ -488,8 +133,361 @@ run_test (int i)
|
|||
int
|
||||
main (void)
|
||||
{
|
||||
const struct test tests[] = {
|
||||
/*
|
||||
* Big-endian:
|
||||
*/
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 1, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x1C | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x00, 0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 8 + 2 + 10,
|
||||
.min_sz = 1 + 2 + 8 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x1C | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x00, 0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 8 + 2 + 10,
|
||||
.min_sz = 1 + 2 + 8 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 1, 0, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x1C | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x00, 0x00, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 8 + 2,
|
||||
.min_sz = 1 + 2 + 8 + 2,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 1, 0, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x21,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x1C | 0x00,
|
||||
0x21, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x00, 0x00, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 1 + 8 + 2,
|
||||
.min_sz = 1 + 1 + 8 + 2,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0x77,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x04 | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
0x00, 0x77, /* Offset */
|
||||
0x00, 0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 2 + 2 + 10,
|
||||
.min_sz = 1 + 2 + 2 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0x0,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x00 | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
/* Offset */
|
||||
0x00, 0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 0 + 2 + 10,
|
||||
.min_sz = 1 + 2 + 0 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 1, },
|
||||
.offset = 0x0,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 1,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x00 | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
/* Offset */
|
||||
0x00, 0x01, /* Data length */
|
||||
'0',
|
||||
},
|
||||
.len = 1 + 2 + 0 + 2 + 1,
|
||||
.min_sz = 1 + 2 + 0 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0xFFFFFF,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x08 | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
0xFF, 0xFF, 0xFF, /* Offset */
|
||||
0x00, 0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 3 + 2 + 10,
|
||||
.min_sz = 1 + 2 + 3 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0xFFFFFF + 1,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x0C | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
0x01, 0x00, 0x00, 0x00, /* Offset */
|
||||
0x00, 0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 4 + 2 + 10,
|
||||
.min_sz = 1 + 2 + 4 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0xFFFFFF + 1,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 10,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x00 | 0x0C | 0x01,
|
||||
0x02, 0x10, /* Stream ID */
|
||||
0x01, 0x00, 0x00, 0x00, /* Offset */
|
||||
'0', '1', '2',
|
||||
},
|
||||
.len = 1 + 2 + 4 + 0 + 3,
|
||||
.min_sz = 1 + 2 + 4 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_043),
|
||||
.fin = { 1, 0, },
|
||||
.offset = 0xB4,
|
||||
.stream_id = 0x01,
|
||||
.data_sz = 0,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x04 | 0x00,
|
||||
0x01, /* Stream ID */
|
||||
0x00, 0xB4, /* Offset */
|
||||
0x00, 0x00, /* Data length */
|
||||
},
|
||||
.len = 6,
|
||||
.min_sz = 6,
|
||||
},
|
||||
|
||||
/*
|
||||
* IETF QUIC Internet-Draft 17:
|
||||
*/
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.fin = { 0, 1, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x08 | 1<<2 | 1<<1 | 1<<0,
|
||||
0x42, 0x10, /* Stream ID */
|
||||
0xC8, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 8 + 1 + 10,
|
||||
.min_sz = 1 + 2 + 8 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x08 | 0<<2 | 1<<1 | 0<<0,
|
||||
0x42, 0x10, /* Stream ID */
|
||||
0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 0 + 1 + 10,
|
||||
.min_sz = 1 + 2 + 0 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0,
|
||||
.stream_id = 0x21,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 12,
|
||||
.out =
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x08 | 0<<2 | 0<<1 | 0<<0,
|
||||
0x21, /* Stream ID */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 1 + 0 + 0 + 10,
|
||||
.min_sz = 1 + 1 + 0 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.fin = { 0, 0, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 10,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x08 | 1<<2 | 1<<1 | 0<<0,
|
||||
0x42, 0x10, /* Stream ID */
|
||||
0xC8, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x0A, /* Data length */
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
},
|
||||
.len = 1 + 2 + 8 + 1 + 10,
|
||||
.min_sz = 1 + 2 + 8 + 0 + 1,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.fin = { 1, 0, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 0,
|
||||
.data = "0123456789",
|
||||
.avail = 11,
|
||||
.out =
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x08 | 1<<2 | 0<<1 | 1<<0,
|
||||
0x42, 0x10, /* Stream ID */
|
||||
0xC8, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
},
|
||||
.len = 1 + 2 + 8,
|
||||
.min_sz = 1 + 2 + 8,
|
||||
},
|
||||
|
||||
{ .lineno = __LINE__,
|
||||
.pf = select_pf_by_ver(LSQVER_ID27),
|
||||
.fin = { 1, 0, },
|
||||
.offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_sz = 0,
|
||||
.data = "0123456789",
|
||||
.avail = 0x100,
|
||||
.out =
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x08 | 1<<2 | 1<<1 | 1<<0,
|
||||
0x42, 0x10, /* Stream ID */
|
||||
0xC8, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x00, /* Data length */
|
||||
},
|
||||
.len = 1 + 2 + 8 + 1,
|
||||
.min_sz = 1 + 2 + 8,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
|
||||
run_test(i);
|
||||
run_test(&tests[i]);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -30,389 +30,6 @@ struct test {
|
|||
int should_succeed;
|
||||
};
|
||||
|
||||
static const struct test tests[] = {
|
||||
|
||||
/*
|
||||
* Big-endian tests
|
||||
*/
|
||||
{ "Balls to the wall: every possible bit is set",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x1C | 0x3,
|
||||
0x00, 0x00, 0x02, 0x10, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x01, 0xC4, /* Data length */
|
||||
},
|
||||
1 + 2 + 8 + 4,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_frame.df_size = 0x1C4,
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Balls to the wall #2: every possible bit is set, except FIN",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x1C | 0x3,
|
||||
0x00, 0x00, 0x02, 0x10, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x01, 0xC4, /* Data length */
|
||||
},
|
||||
1 + 2 + 8 + 4,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_frame.df_size = 0x1C4,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Data length is zero",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x00 | 0x1C | 0x3,
|
||||
0x00, 0x00, 0x02, 0x10, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0xC4, 0x01, /* Data length: note this does not matter */
|
||||
},
|
||||
1 + 0 + 8 + 4,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_frame.df_size = 0x200 - (1 + 8 + 4),
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Stream ID length is 1",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x1C | 0x0,
|
||||
0xF0, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x01, 0xC4, /* Data length */
|
||||
},
|
||||
1 + 2 + 8 + 1,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x0807060504030201UL,
|
||||
.stream_id = 0xF0,
|
||||
.data_frame.df_size = 0x1C4,
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "All bits are zero save offset length",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x00 | 0x04 | 0x0,
|
||||
0xF0, /* Stream ID */
|
||||
0x02, 0x55, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, /* Offset */
|
||||
0xC4, 0x01, /* Data length */
|
||||
},
|
||||
1 + 0 + 2 + 1,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x255,
|
||||
.stream_id = 0xF0,
|
||||
.data_frame.df_size = 0x200 - 4,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Sanity check: either FIN must be set or data length is not zero #1",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x00 | 0x04 | 0x0,
|
||||
0xF0, /* Stream ID */
|
||||
0x02, 0x55, /* Offset */
|
||||
},
|
||||
1 + 0 + 2 + 1,
|
||||
4, /* Same as buffer size: in the absense of explicit data
|
||||
* length in the header, this would mean that data
|
||||
* length is zero.
|
||||
*/
|
||||
{ .data_frame.df_offset = 0x255,
|
||||
.stream_id = 0xF0,
|
||||
.data_frame.df_size = 0x200 - 4,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
0,
|
||||
},
|
||||
|
||||
{ "Sanity check: either FIN must be set or data length is not zero #2",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x04 | 0x0,
|
||||
0xF0, /* Stream ID */
|
||||
0x02, 0x55, /* Offset */
|
||||
0x00, 0x00,
|
||||
},
|
||||
1 + 2 + 2 + 1,
|
||||
200,
|
||||
{ .data_frame.df_offset = 0x255,
|
||||
.stream_id = 0xF0,
|
||||
.data_frame.df_size = 0x200 - 4,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
0,
|
||||
},
|
||||
|
||||
{ "Sanity check: either FIN must be set or data length is not zero #3",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x04 | 0x0,
|
||||
0xF0, /* Stream ID */
|
||||
0x02, 0x55, /* Offset */
|
||||
0x00, 0x00,
|
||||
},
|
||||
1 + 2 + 2 + 1,
|
||||
200,
|
||||
{ .data_frame.df_offset = 0x255,
|
||||
.stream_id = 0xF0,
|
||||
.data_frame.df_size = 0x0,
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Check data bounds #1",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x04 | 0x0,
|
||||
0xF0, /* Stream ID */
|
||||
0x02, 0x55, /* Offset */
|
||||
0x01, 0xFA, /* Data length */
|
||||
},
|
||||
1 + 2 + 2 + 1,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x255,
|
||||
.stream_id = 0xF0,
|
||||
.data_frame.df_size = 0x1FA,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Check data bounds #2",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x04 | 0x0,
|
||||
0xF0, /* Stream ID */
|
||||
0x02, 0x55, /* Offset */
|
||||
0x01, 0xFB, /* <--- One byte too many */
|
||||
},
|
||||
1 + 2 + 2 + 1,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x255,
|
||||
.stream_id = 0xF0,
|
||||
.data_frame.df_size = 0x1FA,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
0,
|
||||
},
|
||||
|
||||
/*
|
||||
* IETF QUIC Internet-Draft 14 Tests.
|
||||
*/
|
||||
|
||||
{ "Balls to the wall: every possible bit is set",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 1<<1 | 1<<0,
|
||||
0x41, 0x23, /* Stream ID */
|
||||
0x08, /* Offset */
|
||||
0x41, 0xC4, /* Data length */
|
||||
},
|
||||
1 + 2 + 1 + 2,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x08,
|
||||
.stream_id = 0x123,
|
||||
.data_frame.df_size = 0x1C4,
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Balls to the wall #2: every possible bit is set except FIN",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 1<<1 | 0<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0xF0, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, /* Offset */
|
||||
0x41, 0xC4, /* Data length */
|
||||
},
|
||||
1 + 4 + 8 + 2,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x301234567890ABCDull,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0x1C4,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Data length is zero",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 0<<1 | 0<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0xF0, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, /* Offset */
|
||||
},
|
||||
1 + 4 + 8 + 0,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x301234567890ABCDull,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0x200 - 1 - 4 - 8,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Sanity check: what happens when data length is zero #1",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 1<<1 | 0<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0xF0, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, /* Offset */
|
||||
0x40, 0x00, /* Data length */
|
||||
},
|
||||
1 + 4 + 8 + 2,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x301234567890ABCDull,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Sanity check: what happens when data length is zero #2",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 1<<1 | 0<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0x00, /* Offset */
|
||||
0x40, 0x00, /* Data length */
|
||||
},
|
||||
1 + 4 + 1 + 2,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Sanity check: what happens when data length is zero #3",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 0<<2 | 1<<1 | 0<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0x40, 0x00, /* Data length */
|
||||
},
|
||||
1 + 4 + 0 + 2,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Sanity check: what happens when data length is zero #3",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 1<<1 | 1<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0x12, /* Offset */
|
||||
0x00, /* Data length */
|
||||
},
|
||||
1 + 4 + 1 + 1,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x12,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0,
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Check data bounds #1",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 1<<1 | 1<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0x12, /* Offset */
|
||||
0x41, 0xF8, /* Data length */
|
||||
},
|
||||
1 + 4 + 1 + 2,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x12,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0x200 - 1 - 4 - 1 - 2,
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Check data bounds #2",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 1<<1 | 1<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0x12, /* Offset */
|
||||
0x41, 0xF9, /* Data length */
|
||||
},
|
||||
1 + 4 + 1 + 2,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x12,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0x200 - 1 - 4 - 1 - 2,
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
run_test (const struct test *test)
|
||||
{
|
||||
|
@ -443,6 +60,389 @@ run_test (const struct test *test)
|
|||
int
|
||||
main (void)
|
||||
{
|
||||
|
||||
const struct test tests[] = {
|
||||
|
||||
/*
|
||||
* Big-endian tests
|
||||
*/
|
||||
{ "Balls to the wall: every possible bit is set",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x1C | 0x3,
|
||||
0x00, 0x00, 0x02, 0x10, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x01, 0xC4, /* Data length */
|
||||
},
|
||||
1 + 2 + 8 + 4,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_frame.df_size = 0x1C4,
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Balls to the wall #2: every possible bit is set, except FIN",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x1C | 0x3,
|
||||
0x00, 0x00, 0x02, 0x10, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x01, 0xC4, /* Data length */
|
||||
},
|
||||
1 + 2 + 8 + 4,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_frame.df_size = 0x1C4,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Data length is zero",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x00 | 0x1C | 0x3,
|
||||
0x00, 0x00, 0x02, 0x10, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0xC4, 0x01, /* Data length: note this does not matter */
|
||||
},
|
||||
1 + 0 + 8 + 4,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x0807060504030201UL,
|
||||
.stream_id = 0x210,
|
||||
.data_frame.df_size = 0x200 - (1 + 8 + 4),
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Stream ID length is 1",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x1C | 0x0,
|
||||
0xF0, /* Stream ID */
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, /* Offset */
|
||||
0x01, 0xC4, /* Data length */
|
||||
},
|
||||
1 + 2 + 8 + 1,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x0807060504030201UL,
|
||||
.stream_id = 0xF0,
|
||||
.data_frame.df_size = 0x1C4,
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "All bits are zero save offset length",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x00 | 0x04 | 0x0,
|
||||
0xF0, /* Stream ID */
|
||||
0x02, 0x55, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, /* Offset */
|
||||
0xC4, 0x01, /* Data length */
|
||||
},
|
||||
1 + 0 + 2 + 1,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x255,
|
||||
.stream_id = 0xF0,
|
||||
.data_frame.df_size = 0x200 - 4,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Sanity check: either FIN must be set or data length is not zero #1",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x00 | 0x04 | 0x0,
|
||||
0xF0, /* Stream ID */
|
||||
0x02, 0x55, /* Offset */
|
||||
},
|
||||
1 + 0 + 2 + 1,
|
||||
4, /* Same as buffer size: in the absense of explicit data
|
||||
* length in the header, this would mean that data
|
||||
* length is zero.
|
||||
*/
|
||||
{ .data_frame.df_offset = 0x255,
|
||||
.stream_id = 0xF0,
|
||||
.data_frame.df_size = 0x200 - 4,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
0,
|
||||
},
|
||||
|
||||
{ "Sanity check: either FIN must be set or data length is not zero #2",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x04 | 0x0,
|
||||
0xF0, /* Stream ID */
|
||||
0x02, 0x55, /* Offset */
|
||||
0x00, 0x00,
|
||||
},
|
||||
1 + 2 + 2 + 1,
|
||||
200,
|
||||
{ .data_frame.df_offset = 0x255,
|
||||
.stream_id = 0xF0,
|
||||
.data_frame.df_size = 0x200 - 4,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
0,
|
||||
},
|
||||
|
||||
{ "Sanity check: either FIN must be set or data length is not zero #3",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x40 | 0x20 | 0x04 | 0x0,
|
||||
0xF0, /* Stream ID */
|
||||
0x02, 0x55, /* Offset */
|
||||
0x00, 0x00,
|
||||
},
|
||||
1 + 2 + 2 + 1,
|
||||
200,
|
||||
{ .data_frame.df_offset = 0x255,
|
||||
.stream_id = 0xF0,
|
||||
.data_frame.df_size = 0x0,
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Check data bounds #1",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x04 | 0x0,
|
||||
0xF0, /* Stream ID */
|
||||
0x02, 0x55, /* Offset */
|
||||
0x01, 0xFA, /* Data length */
|
||||
},
|
||||
1 + 2 + 2 + 1,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x255,
|
||||
.stream_id = 0xF0,
|
||||
.data_frame.df_size = 0x1FA,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Check data bounds #2",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_043),
|
||||
/* 1 f d ooo ss 1fdoooss */
|
||||
/* TYPE FIN DLEN OLEN SLEN */
|
||||
{ 0x80 | 0x00 | 0x20 | 0x04 | 0x0,
|
||||
0xF0, /* Stream ID */
|
||||
0x02, 0x55, /* Offset */
|
||||
0x01, 0xFB, /* <--- One byte too many */
|
||||
},
|
||||
1 + 2 + 2 + 1,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x255,
|
||||
.stream_id = 0xF0,
|
||||
.data_frame.df_size = 0x1FA,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
0,
|
||||
},
|
||||
|
||||
/*
|
||||
* IETF QUIC Internet-Draft 14 Tests.
|
||||
*/
|
||||
|
||||
{ "Balls to the wall: every possible bit is set",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 1<<1 | 1<<0,
|
||||
0x41, 0x23, /* Stream ID */
|
||||
0x08, /* Offset */
|
||||
0x41, 0xC4, /* Data length */
|
||||
},
|
||||
1 + 2 + 1 + 2,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x08,
|
||||
.stream_id = 0x123,
|
||||
.data_frame.df_size = 0x1C4,
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Balls to the wall #2: every possible bit is set except FIN",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 1<<1 | 0<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0xF0, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, /* Offset */
|
||||
0x41, 0xC4, /* Data length */
|
||||
},
|
||||
1 + 4 + 8 + 2,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x301234567890ABCDull,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0x1C4,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Data length is zero",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 0<<1 | 0<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0xF0, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, /* Offset */
|
||||
},
|
||||
1 + 4 + 8 + 0,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x301234567890ABCDull,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0x200 - 1 - 4 - 8,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Sanity check: what happens when data length is zero #1",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 1<<1 | 0<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0xF0, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, /* Offset */
|
||||
0x40, 0x00, /* Data length */
|
||||
},
|
||||
1 + 4 + 8 + 2,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x301234567890ABCDull,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Sanity check: what happens when data length is zero #2",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 1<<1 | 0<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0x00, /* Offset */
|
||||
0x40, 0x00, /* Data length */
|
||||
},
|
||||
1 + 4 + 1 + 2,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Sanity check: what happens when data length is zero #3",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 0<<2 | 1<<1 | 0<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0x40, 0x00, /* Data length */
|
||||
},
|
||||
1 + 4 + 0 + 2,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0,
|
||||
.data_frame.df_fin = 0,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Sanity check: what happens when data length is zero #3",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 1<<1 | 1<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0x12, /* Offset */
|
||||
0x00, /* Data length */
|
||||
},
|
||||
1 + 4 + 1 + 1,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x12,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0,
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Check data bounds #1",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 1<<1 | 1<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0x12, /* Offset */
|
||||
0x41, 0xF8, /* Data length */
|
||||
},
|
||||
1 + 4 + 1 + 2,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x12,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0x200 - 1 - 4 - 1 - 2,
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
1,
|
||||
},
|
||||
|
||||
{ "Check data bounds #2",
|
||||
__LINE__,
|
||||
select_pf_by_ver(LSQVER_ID27),
|
||||
/* TYPE OFF DLEN FIN */
|
||||
{ 0x10 | 1<<2 | 1<<1 | 1<<0,
|
||||
0x81, 0x23, 0x00, 0xE4, /* Stream ID */
|
||||
0x12, /* Offset */
|
||||
0x41, 0xF9, /* Data length */
|
||||
},
|
||||
1 + 4 + 1 + 2,
|
||||
0x200,
|
||||
{ .data_frame.df_offset = 0x12,
|
||||
.stream_id = 0x12300E4,
|
||||
.data_frame.df_size = 0x200 - 1 - 4 - 1 - 2,
|
||||
.data_frame.df_fin = 1,
|
||||
},
|
||||
0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
unsigned i;
|
||||
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
|
||||
run_test(&tests[i]);
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
|
||||
#include "lsquic_varint.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "vc_compat.h"
|
||||
#endif
|
||||
|
||||
#define MAX_INPUT_SZ 8
|
||||
|
||||
struct test_read_varint
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
#include "lsquic_types.h"
|
||||
#include "lsquic_parse.h"
|
||||
|
||||
static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043);
|
||||
//static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043); // will not work on MSVC
|
||||
#define pf ((const struct parse_funcs *const)select_pf_by_ver(LSQVER_043))
|
||||
|
||||
|
||||
/* The test is both for generation and parsing: */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue