mirror of
https://gitea.invidious.io/iv-org/litespeed-quic.git
synced 2024-08-15 00:53:43 +00:00
f07b3eae43
* 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
77 lines
2 KiB
C
77 lines
2 KiB
C
/* Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc. See LICENSE. */
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#ifndef WIN32
|
|
#include <sys/time.h>
|
|
#endif
|
|
|
|
#include "lsquic.h"
|
|
#include "lsquic_types.h"
|
|
#include "lsquic_parse.h"
|
|
|
|
//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: */
|
|
struct wuf_test {
|
|
unsigned char buf[0x20];
|
|
size_t buf_len;
|
|
lsquic_stream_id_t stream_id;
|
|
uint64_t offset;
|
|
uint64_t error_code;
|
|
};
|
|
|
|
static const struct wuf_test wuf_tests[] = {
|
|
{
|
|
.buf = { 0x01, 0x00, 0x67, 0x45, 0x34, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x00, 0x00, 0x00, 0x03, },
|
|
.buf_len = GQUIC_RST_STREAM_SZ,
|
|
.stream_id = 0x674534,
|
|
.offset = 0x0102030405,
|
|
.error_code = 0x03,
|
|
},
|
|
|
|
{ .buf = { 0 }, }
|
|
};
|
|
|
|
|
|
static void
|
|
run_parse_tests (void)
|
|
{
|
|
const struct wuf_test *test;
|
|
for (test = wuf_tests; test->buf[0]; ++test)
|
|
{
|
|
lsquic_stream_id_t stream_id = ~0;
|
|
uint64_t offset = ~0, error_code = ~0;
|
|
int sz = pf->pf_parse_rst_frame(test->buf, test->buf_len, &stream_id, &offset, &error_code);
|
|
assert(sz == GQUIC_RST_STREAM_SZ);
|
|
assert(stream_id == test->stream_id);
|
|
assert(offset == test->offset);
|
|
assert(error_code == test->error_code);
|
|
}
|
|
}
|
|
|
|
|
|
static void
|
|
run_gen_tests (void)
|
|
{
|
|
const struct wuf_test *test;
|
|
for (test = wuf_tests; test->buf[0]; ++test)
|
|
{
|
|
unsigned char buf[0x100];
|
|
int sz = pf->pf_gen_rst_frame(buf, test->buf_len, test->stream_id, test->offset, test->error_code);
|
|
assert(sz == GQUIC_RST_STREAM_SZ);
|
|
assert(0 == memcmp(buf, test->buf, sz));
|
|
}
|
|
}
|
|
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
run_parse_tests();
|
|
run_gen_tests();
|
|
return 0;
|
|
}
|