diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..cf53a959d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/bin/test_config.h +/src/liblsquic/lsquic_versions_to_string.c +/build diff --git a/CMakeLists.txt b/CMakeLists.txt index f42dcc99d..5a6d64430 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,40 +152,48 @@ ELSE() ENDIF() IF (NOT DEFINED BORINGSSL_INCLUDE AND DEFINED BORINGSSL_DIR) - FIND_PATH(BORINGSSL_INCLUDE NAMES openssl/ssl.h - PATHS ${BORINGSSL_DIR}/include - NO_DEFAULT_PATH) + SET(BORINGSSL_INCLUDE "${BORINGSSL_DIR}/include") ENDIF() + # This must be done before adding other include directories to take # precedence over header files from other SSL installs. IF (BORINGSSL_INCLUDE) - MESSAGE(STATUS "BoringSSL include directory ${BORINGSSL_INCLUDE}") - INCLUDE_DIRECTORIES(${BORINGSSL_INCLUDE}) + MESSAGE(STATUS "BoringSSL include directory: ${BORINGSSL_INCLUDE}") + INCLUDE_DIRECTORIES(${BORINGSSL_INCLUDE}) ELSE() - MESSAGE(FATAL_ERROR "BoringSSL headers not found") + MESSAGE(FATAL_ERROR "BoringSSL headers not found") ENDIF() IF (NOT DEFINED BORINGSSL_LIB AND DEFINED BORINGSSL_DIR) - FOREACH(LIB_NAME ssl crypto decrepit) - IF (CMAKE_SYSTEM_NAME STREQUAL Windows) - FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} - NAMES ${LIB_NAME} - PATHS ${BORINGSSL_DIR}/${LIB_NAME} - PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo - NO_DEFAULT_PATH) - ELSE() - FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} - NAMES lib${LIB_NAME}${LIB_SUFFIX} - PATHS ${BORINGSSL_DIR}/${LIB_NAME} - NO_DEFAULT_PATH) - ENDIF() - IF(BORINGSSL_LIB_${LIB_NAME}) - MESSAGE(STATUS "Found ${LIB_NAME} library: ${BORINGSSL_LIB_${LIB_NAME}}") + FOREACH(LIB_NAME ssl crypto decrepit) + IF (CMAKE_SYSTEM_NAME STREQUAL Windows) + FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} + NAMES ${LIB_NAME} + PATHS ${BORINGSSL_DIR}/${LIB_NAME} + PATH_SUFFIXES Debug Release MinSizeRel RelWithDebInfo + NO_DEFAULT_PATH) + + IF(DEFINED BORINGSSL_DIR) + file(GLOB_RECURSE BORINGSSL_DLL_${LIB_NAME} + "${BORINGSSL_DIR}/**/${LIB_NAME}.dll") ELSE() - MESSAGE(STATUS "${LIB_NAME} library not found") + file(GLOB_RECURSE BORINGSSL_DLL_${LIB_NAME} + "${BORINGSSL_INCLUDE}/../**/${LIB_NAME}.dll") ENDIF() - ENDFOREACH() + ELSE() + FIND_LIBRARY(BORINGSSL_LIB_${LIB_NAME} + NAMES lib${LIB_NAME}${LIB_SUFFIX} + PATHS ${BORINGSSL_DIR}/${LIB_NAME} + NO_DEFAULT_PATH) + ENDIF() + + IF(BORINGSSL_LIB_${LIB_NAME}) + MESSAGE(STATUS "Found ${LIB_NAME} library: ${BORINGSSL_LIB_${LIB_NAME}}") + ELSE() + MESSAGE(STATUS "${LIB_NAME} library not found") + ENDIF() + ENDFOREACH() ELSE() @@ -221,19 +229,64 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") link_directories( /usr/local/lib ) ENDIF() -IF (CMAKE_SYSTEM_NAME STREQUAL Windows) - FIND_PATH(GETOPT_INCLUDE_DIR NAMES getopt.h) - IF (GETOPT_INCLUDE_DIR) - INCLUDE_DIRECTORIES(${GETOPT_INCLUDE_DIR}) - ELSE() - MESSAGE(FATAL_ERROR "getopt.h was not found") - ENDIF() - FIND_LIBRARY(GETOPT_LIB getopt) - IF(GETOPT_LIB) - MESSAGE(STATUS "Found getopt: ${GETOPT_LIB}") - ELSE() - MESSAGE(STATUS "getopt not found") - ENDIF() +IF (MSVC) + + IF(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) + SET(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + CACHE STRING "") + ELSEIF(NOT DEFINED ENV{VCPKG_ROOT} AND DEFINED CMAKE_TOOLCHAIN_FILE) + MESSAGE(STATUS "Attempting to guess VCPKG_ROOT...") + STRING(TOLOWER ${CMAKE_TOOLCHAIN_FILE} _VCPKG_ROOT) + STRING(REGEX REPLACE "^(.*)[\\/]scripts[\\/]buildsystems[\\/]vcpkg.cmake$" "\\1" + _VCPKG_ROOT "${_VCPKG_ROOT}") + SET(ENV{VCPKG_ROOT} "${_VCPKG_ROOT}") + ENDIF() + + MESSAGE(STATUS "VCPKG_ROOT: $ENV{VCPKG_ROOT}") + + # actually load vcpkg.cmake + MESSAGE(STATUS "Loading ${CMAKE_TOOLCHAIN_FILE}") + INCLUDE("${CMAKE_TOOLCHAIN_FILE}") + + IF(NOT DEFINED VCPKG_INSTALLED_DIR AND DEFINED _VCPKG_INSTALLED_DIR) + SET(VCPKG_INSTALLED_DIR "${_VCPKG_INSTALLED_DIR}") + ENDIF() + IF(NOT DEFINED VCPKG_INSTALLED_DIR AND DEFINED ENV{VCPKG_ROOT}) + SET(VCPKG_INSTALLED_DIR "$ENV{VCPKG_ROOT}/installed") + ENDIF() + MESSAGE(STATUS "VCPKG_INSTALLED_DIR: ${VCPKG_INSTALLED_DIR}") + + SET(VCPKG_INSTALLED_DIR_TRIPLET "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}") + + # add includes directory + MESSAGE(STATUS "Including ${VCPKG_INSTALLED_DIR_TRIPLET}/include") + INCLUDE_DIRECTORIES("${VCPKG_INSTALLED_DIR_TRIPLET}/include") + + SET(VCPKG_INSTALLED_DIR_X64_WINDOWS "${VCPKG_INSTALLED_DIR}/x64-windows") + + IF(CONFIG STREQUAL "Debug") + SET(VCPKG_DEBUG "/Debug") + ELSE() + SET(VCPKG_DEBUG "") + ENDIF() + + MESSAGE(STATUS "Looking for getopt.h (hint: ${VCPKG_INSTALLED_DIR_X64_WINDOWS}/include)") + # getopt is always shared on windows + FIND_PATH(GETOPT_INCLUDE_DIR NAMES getopt.h HINTS "${VCPKG_INSTALLED_DIR_X64_WINDOWS}/include") + + IF (GETOPT_INCLUDE_DIR) + INCLUDE_DIRECTORIES(${GETOPT_INCLUDE_DIR}) + ELSE() + MESSAGE(FATAL_ERROR "getopt.h was not found") + ENDIF() + + FIND_LIBRARY(GETOPT_LIB getopt PATHS "${VCPKG_INSTALLED_DIR_X64_WINDOWS}${VCPKG_DEBUG}/lib") + + IF(GETOPT_LIB) + MESSAGE(STATUS "Found getopt: ${GETOPT_LIB}") + ELSE() + MESSAGE(STATUS "getopt library was not found") + ENDIF() ENDIF() # Find zlib and libevent header files and library files @@ -246,6 +299,11 @@ ELSE() ENDIF() IF (CMAKE_SYSTEM_NAME STREQUAL Windows) FIND_LIBRARY(ZLIB_LIB zlib) + + # TODO: if zlib is not through vcpkg, need to do something else + IF (NOT VCPKG_TARGET_TRIPLET MATCHES "-static$" AND NOT EXISTS ${ZLIB_DLL}) + FILE(GLOB_RECURSE ZLIB_DLL "${VCPKG_INSTALLED_DIR_X64_WINDOWS}/bin/zlib1.dll") + ENDIF() ELSEIF(CMAKE_SYSTEM_NAME STREQUAL Darwin) # XXX somehow FIND_LIBRARY() does not find zlib on Travis? SET(ZLIB_LIB z) diff --git a/appveyor-linux.yml b/appveyor-linux.yml index 0fa15e159..50c52b4e0 100644 --- a/appveyor-linux.yml +++ b/appveyor-linux.yml @@ -2,22 +2,35 @@ version: 2.{branch}.{build} image: - Ubuntu2004 -- MacOS + +cache: +- $HOME/.apt +- boringssl -> boringssl-target.txt # we define the commit in here build: off init: -cache: -# - boringssl -> appveyor-linux.yml # we define the commit in here - install: - sh: >- - if [[ -e boringssl/CMakeLists.txt ]] ; then + if compgen -G "~/.apt/libevent-dev*.deb" ; then + + sudo apt install -y ~/.apt/libevent-dev*.deb + + else + + sudo apt update -qq - echo cached + sudo apt -y --no-install-recommends install libevent-dev + + fi + + + if [[ -f ./boringssl/include/openssl/ssl.h ]] ; then + + echo boringssl cached else @@ -25,24 +38,56 @@ install: cd boringssl - git checkout cf8d3ad3cea51cf7184307d54f465da62b7d8408 - - cmake . + git reset --hard $(<../boringssl-target.txt) - make -j4 + rm -rf .git cd .. fi + cd boringssl + + cmake . + + make -j2 crypto ssl decrepit + + cd .. + git submodule init - git submodule update --checkout --force --recursive + n=0 + + until git submodule update --checkout --force --recursive ; do + + [ "$n" -ge 10 ] && exit 1 + + n=$((n+1)) + + done + + mkdir -p $HOME/.apt + + sudo mv -v /var/cache/apt/archives/libevent-dev*.deb $HOME/.apt/ cmake -DBORINGSSL_DIR=$PWD/boringssl . - make + make -j2 lsquic build-tests test_script: -- sh: make test +- sh: >- + + make help + + make test + + make -j2 perf_server perf_client + + ./bin/perf_server -L notice -s ::1:8443 -c localhost,tests/localhost.pem,tests/localhost.key & + + PERF_SERVER_PID=$! + + time ./bin/perf_client -L info -s ::1:8443 -p 104857600:104857600 + + kill $PERF_SERVER_PID diff --git a/appveyor-macos.yml b/appveyor-macos.yml new file mode 100644 index 000000000..89aec3b0b --- /dev/null +++ b/appveyor-macos.yml @@ -0,0 +1,75 @@ +version: 2.{branch}.{build} + +image: +- MacOS + +cache: +- boringssl -> boringssl-target.txt # we define the commit in here + +build: off + +init: + +install: + +- sh: >- + + if [[ -f ./boringssl/include/openssl/ssl.h ]] ; then + + echo boringssl cached + + else + + git clone https://boringssl.googlesource.com/boringssl + + cd boringssl + + git reset --hard $(<../boringssl-target.txt) + + rm -rf .git + + cd .. + + fi + + cd boringssl + + cmake . + + make -j2 crypto ssl decrepit + + cd .. + + git submodule init + + n=0 + + until git submodule update --checkout --force --recursive ; do + + [ "$n" -ge 10 ] && exit 1 + + n=$((n+1)) + + done + + cmake -DBORINGSSL_DIR=$PWD/boringssl . + + make -j2 lsquic build-tests + +test_script: + +- sh: >- + + make help + + make test + + make -j2 perf_server perf_client + + ./bin/perf_server -L notice -s ::1:8443 -c localhost,tests/localhost.pem,tests/localhost.key & + + PERF_SERVER_PID=$! + + time ./bin/perf_client -L info -s ::1:8443 -p 104857600:104857600 + + kill $PERF_SERVER_PID diff --git a/appveyor-update-vcpkg.cmd b/appveyor-update-vcpkg.cmd new file mode 100644 index 000000000..c26899c1c --- /dev/null +++ b/appveyor-update-vcpkg.cmd @@ -0,0 +1,23 @@ +setlocal EnableDelayedExpansion + +pushd c:\tools\vcpkg + +git remote update + +git status -uno | findstr /c:"Your branch is up to date with 'origin/master'" + +if errorlevel 1 ( + + echo Updating vcpkg... + + git pull -q + + bootstrap-vcpkg.bat + +) + +git reset -q --hard HEAD + +git clean -fdx -e installed -e packages -e vcpkg.exe + +popd diff --git a/appveyor-windows-kill-tests.cmd b/appveyor-windows-kill-tests.cmd new file mode 100644 index 000000000..aaf9ec0c4 --- /dev/null +++ b/appveyor-windows-kill-tests.cmd @@ -0,0 +1,16 @@ +@echo off && setlocal +set timeout=0 +set /a timeout+=%~1 +set elapsed=0 + +:wait +if not exist killing-tests.tmp goto :eof +timeout /t 1 /nobreak >nul +set /a elapsed+=1 +if %elapsed% lss %timeout% goto :wait + +:loop +if not exist killing-tests.tmp goto :eof +taskkill /t /f /fi "imagename eq test_*" +timeout /t 5 /nobreak >nul +goto :loop \ No newline at end of file diff --git a/appveyor-windows-shared.cmd b/appveyor-windows-shared.cmd new file mode 100644 index 000000000..6418e4866 --- /dev/null +++ b/appveyor-windows-shared.cmd @@ -0,0 +1,47 @@ +setlocal EnableDelayedExpansion +for /f "usebackq delims=#" %%a in (`"%programfiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -latest -property installationPath`) do call "%%~a\VC\Auxiliary\Build\vcvars64.bat" + +set VCPKG_ROOT=c:/tools/vcpkg/ + +pushd c:\tools\vcpkg\ +dir /a /s /b *pcre*.h +popd + +vcpkg list + +for /f %%t in (boringssl-target.txt) do set BORINGSSL_TARGET=%%t + +if exist ".\boringssl\include\openssl\ssl.h" ( + echo boringssl cached +) else ( + git clone https://boringssl.googlesource.com/boringssl + cd boringssl + git checkout %BORINGSSL_TARGET% + rd /s /q .git + cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_GENERATOR_PLATFORM=x64 -DBUILD_SHARED_LIBS=ON -DOPENSSL_NO_ASM=1 . + msbuild /m crypto\crypto.vcxproj /v:m + if errorlevel 1 exit !errorlevel! + msbuild /m ssl\ssl.vcxproj /v:m + if errorlevel 1 exit !errorlevel! + msbuild /m decrepit\decrepit.vcxproj /v:m + if errorlevel 1 exit !errorlevel! + cd .. +) + +git submodule init + +set retry_submodule_update=0 +:retry_submodule_update +set /a retry_submodule_update+=1 +git submodule update --checkout --force --recursive +if %retry_submodule_update% gtr 10 exit !errorlevel! +if errorlevel 1 goto :retry_submodule_update + +cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_GENERATOR_PLATFORM=x64 -DLSQUIC_SHARED_LIB=ON -DBUILD_SHARED_LIBS=ON -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DBORINGSSL_DIR=%cd%\boringssl -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON . + +msbuild /m src\liblsquic\lsquic.vcxproj /v:m +if errorlevel 1 exit !errorlevel! + +msbuild /m tests\build-tests.vcxproj /v:m +if errorlevel 1 exit !errorlevel! + diff --git a/appveyor-windows-shared.yml b/appveyor-windows-shared.yml new file mode 100644 index 000000000..1581e5022 --- /dev/null +++ b/appveyor-windows-shared.yml @@ -0,0 +1,43 @@ +version: 1.{branch}.{build} + +image: Visual Studio 2022 + +cache: +- c:\tools\vcpkg -> c:\tools\vcpkg\.git\refs\heads\master +- boringssl -> boringssl-target.txt # we define the commit in here + +environment: + VCPKG_DISABLE_METRICS: 1 + +init: + +- cmd: '' + +install: + +- cmd: >- + + call appveyor-update-vcpkg.cmd + + vcpkg install zlib:x64-windows + + vcpkg install libevent:x64-windows + + vcpkg install pcre2:x64-windows + + vcpkg install getopt:x64-windows + + vcpkg integrate install + + if exist c:\tools\vcpkg\buildtrees rd /s /q c:\tools\vcpkg\buildtrees + + if exist c:\tools\vcpkg\downloads rd /s /q c:\tools\vcpkg\downloads + +build_script: + +- cmd: appveyor-windows-shared.cmd + +test_script: + +- cmd: appveyor-windows-test.cmd + diff --git a/appveyor-windows-test.cmd b/appveyor-windows-test.cmd new file mode 100644 index 000000000..adc2d8694 --- /dev/null +++ b/appveyor-windows-test.cmd @@ -0,0 +1,32 @@ +for /f "usebackq delims=#" %%a in (`"%programfiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -latest -property installationPath`) do call "%%~a\VC\Auxiliary\Build\vcvars64.bat" + +echo 1>killing-tests.tmp + +:: cmake test timeout doesn't seem to work right on windows? +:: force loop kill all the tests after 10 minutes (600 seconds) +start "" /b cmd /c "call appveyor-windows-kill-tests.cmd 600>nul" + +msbuild /m RUN_TESTS.vcxproj /v:m + +set testserror=%errorlevel% +set errorlevel=0 + +del /q killing-tests.tmp + +:: use ldd for diagnosing missing/incorrect shared (dll/so/dylib) libs +:: "C:\msys64\usr\bin\ldd.exe" "tests\Debug\test_cubic.exe" +msbuild /m bin\perf_server.vcxproj /v:m +msbuild /m bin\perf_client.vcxproj /v:m + +echo Starting perf_server +start "" /b cmd /c "bin\Debug\perf_server -L notice -s ::1:8443 -c localhost,tests/localhost.pem,tests/localhost.key" + +echo Starting perf_client +bin\Debug\perf_client -L info -s ::1:8443 -p 104857600:104857600 +echo perf_client exited with code %errorlevel% + +echo Perf run complete +tskill perf_server + +:after_perf_test +if %testserror% neq 0 exit %testserror% diff --git a/appveyor-windows.cmd b/appveyor-windows.cmd index fac703ff3..0f0630ff8 100644 --- a/appveyor-windows.cmd +++ b/appveyor-windows.cmd @@ -1,23 +1,46 @@ +setlocal EnableDelayedExpansion +for /f "usebackq delims=#" %%a in (`"%programfiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -latest -property installationPath`) do call "%%~a\VC\Auxiliary\Build\vcvars64.bat" + +set VCPKG_ROOT=c:/tools/vcpkg/ + +pushd c:\tools\vcpkg\ +dir /a /s /b *pcre*.h +popd + vcpkg list -if exist ".\boringssl\CMakeLists.txt" ( - echo cached +for /f %%t in (boringssl-target.txt) do set BORINGSSL_TARGET=%%t + +if exist ".\boringssl\include\openssl\ssl.h" ( + echo boringssl cached ) else ( git clone https://boringssl.googlesource.com/boringssl cd boringssl - git checkout cf8d3ad3cea51cf7184307d54f465da62b7d8408 - cmake -DCMAKE_GENERATOR_PLATFORM=x64 --config Debug -DBUILD_SHARED_LIBS=OFF -DOPENSSL_NO_ASM=1 . - msbuild /m ALL_BUILD.vcxproj + git checkout %BORINGSSL_TARGET% + rd /s /q .git + cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_GENERATOR_PLATFORM=x64 -DBUILD_SHARED_LIBS=OFF -DOPENSSL_NO_ASM=1 . + msbuild /m crypto\crypto.vcxproj /v:m + if errorlevel 1 exit !errorlevel! + msbuild /m ssl\ssl.vcxproj /v:m + if errorlevel 1 exit !errorlevel! + msbuild /m decrepit\decrepit.vcxproj /v:m + if errorlevel 1 exit !errorlevel! cd .. ) git submodule init +set retry_submodule_update=0 +:retry_submodule_update +set /a retry_submodule_update+=1 git submodule update --checkout --force --recursive +if %retry_submodule_update% gtr 10 exit !errorlevel! +if errorlevel 1 goto :retry_submodule_update -set VCPKG_ROOT=c:/tools/vcpkg/ - -cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DBUILD_SHARED_LIBS=OFF -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DGETOPT_INCLUDE_DIR=c:/tools/vcpkg/installed/x64-windows/include -DGETOPT_LIB=c:/tools/vcpkg/installed/x64-windows/lib/getopt.lib -DBORINGSSL_DIR=%cd%\boringssl . +cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_GENERATOR_PLATFORM=x64 -DBUILD_SHARED_LIBS=OFF -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DBORINGSSL_DIR=%cd%\boringssl . +msbuild /m src\liblsquic\lsquic.vcxproj /v:m +if errorlevel 1 exit !errorlevel! -msbuild /m ALL_BUILD.vcxproj +msbuild /m tests\build-tests.vcxproj /v:m +if errorlevel 1 exit !errorlevel! diff --git a/appveyor-windows.yml b/appveyor-windows.yml index 1aee700c7..6302d784c 100644 --- a/appveyor-windows.yml +++ b/appveyor-windows.yml @@ -1,6 +1,13 @@ version: 1.{branch}.{build} -image: Visual Studio 2017 +image: Visual Studio 2022 + +cache: +- c:\tools\vcpkg -> c:\tools\vcpkg\.git\refs\heads\master +- boringssl -> boringssl-target.txt # we define the commit in here + +environment: + VCPKG_DISABLE_METRICS: 1 init: @@ -10,19 +17,21 @@ install: - cmd: >- + call appveyor-update-vcpkg.cmd + vcpkg install zlib:x64-windows-static vcpkg install libevent:x64-windows-static - vcpkg install pcre:x64-windows-static + vcpkg install pcre2:x64-windows-static vcpkg install getopt:x64-windows vcpkg integrate install -cache: -- c:\tools\vcpkg\installed -- boringssl -> appveyor-windows.yml, appveyor-windows.cmd # we define the commit in here + if exist c:\tools\vcpkg\buildtrees rd /s /q c:\tools\vcpkg\buildtrees + + if exist c:\tools\vcpkg\downloads rd /s /q c:\tools\vcpkg\downloads build_script: @@ -30,4 +39,5 @@ build_script: test_script: -- cmd: msbuild /m RUN_TESTS.vcxproj +- cmd: appveyor-windows-test.cmd + diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index 28f2c756d..44a0cacad 100644 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -1,7 +1,68 @@ # Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc. See LICENSE. LIST(APPEND LIBS ${EVENT_LIB}) -IF(MSVC) +# not working in appveyor-windows; odl cmake and vcpkg? +INCLUDE(CheckIncludeFile) + +CHECK_INCLUDE_FILE(regex.h HAVE_REGEX) +IF(NOT HAVE_REGEX) + + #CHECK_INCLUDE_FILE(pcre2posix.h HAVE_PCRE2) + + MESSAGE(STATUS "Checking ${VCPKG_INSTALLED_DIR_TRIPLET}/include") + + FIND_PATH(PCRE2_INCLUDE_DIR NAMES pcre2posix.h HINTS "${VCPKG_INSTALLED_DIR_TRIPLET}/include") + + IF (PCRE2_INCLUDE_DIR) + INCLUDE_DIRECTORIES(${PCRE2_INCLUDE_DIR}) + SET(HAVE_PCRE2 1) + ENDIF() + + + IF(HAVE_PCRE2) + MESSAGE(STATUS "Found pcre2posix.h") + FIND_LIBRARY(PCRE_LIB NAMES pcre2-8 pcre2-8-static) + IF(PCRE_LIB) + MESSAGE(STATUS "Found pcre2-8: ${PCRE_LIB}") + IF(PCRE_LIB MATCHES "-static") + MESSAGE(STATUS "pcre2 is static") + ADD_DEFINITIONS(-DPCRE2_STATIC) + ENDIF() + LIST(APPEND LIBS ${PCRE_LIB}) + ELSE() + MESSAGE(STATUS "pcre2-8 not found: http_server won't work") + ENDIF() + + FIND_LIBRARY(PCREPOSIX_LIB NAMES pcre2-posix pcre2-posix-static) + IF(PCREPOSIX_LIB) + MESSAGE(STATUS "Found pcre2-posix: ${PCREPOSIX_LIB}") + LIST(APPEND LIBS ${PCREPOSIX_LIB}) + ELSE() + MESSAGE(STATUS "pcre2-posix not found: http_server won't work") + ENDIF() + + IF(MSVC AND NOT VCPKG_TARGET_TRIPLET MATCHES "-static$") + FIND_PATH(PCRE_DLL "pcre2-8.dll" HINTS "${VCPKG_INSTALLED_DIR_X64_WINDOWS}/bin" REQUIRED) + FIND_PATH(PCREPOSIX_DLL "pcre2-posix.dll" HINTS "${VCPKG_INSTALLED_DIR_X64_WINDOWS}/bin" REQUIRED) + SET(PCRE_DLL "${PCRE_DLL}/pcre2-8.dll") + SET(PCREPOSIX_DLL "${PCREPOSIX_DLL}/pcre2-posix.dll") + MESSAGE(STATUS "Found pcre2-8.dll: ${PCRE_DLL}") + MESSAGE(STATUS "Found pcre2-posix.dll: ${PCREPOSIX_DLL}") + ENDIF() + ELSE() + MESSAGE(STATUS "pcre2posix.h not found.") + # NOT HAVE_PCRE2 + #CHECK_INCLUDE_FILE(pcreposix.h HAVE_PCRE) + FIND_PATH(PCRE_INCLUDE_DIR NAMES pcreposix.h HINTS "${VCPKG_INSTALLED_DIR_TRIPLET}/include") + + IF (PCRE_INCLUDE_DIR) + INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIR}) + SET(HAVE_PCRE 1) + ENDIF() + IF(NOT HAVE_PCRE) + MESSAGE(FATAL_ERROR "no supported regex library found (regex, pcre, pcre2)") + ENDIF() + MESSAGE(STATUS "Found pcreposix.h") FIND_LIBRARY(PCRE_LIB pcre) IF(PCRE_LIB) MESSAGE(STATUS "Found pcre: ${PCRE_LIB}") @@ -9,6 +70,7 @@ IF(MSVC) ELSE() MESSAGE(STATUS "pcre not found: http_server won't work") ENDIF() + FIND_LIBRARY(PCREPOSIX_LIB pcreposix) IF(PCREPOSIX_LIB) MESSAGE(STATUS "Found pcreposix: ${PCREPOSIX_LIB}") @@ -16,57 +78,86 @@ IF(MSVC) ELSE() MESSAGE(STATUS "pcreposix not found: http_server won't work") ENDIF() + + IF(MSVC AND NOT VCPKG_TARGET_TRIPLET MATCHES "-static$") + FIND_PATH(PCRE_DLL "pcre.dll" HINTS "${VCPKG_INSTALLED_DIR_X64_WINDOWS}/bin" REQUIRED) + FIND_PATH(PCREPOSIX_DLL "pcreposix.dll" HINTS "${VCPKG_INSTALLED_DIR_X64_WINDOWS}/bin" REQUIRED) + SET(PCRE_DLL "${PCRE_DLL}/pcre.dll") + SET(PCREPOSIX_DLL "${PCRE_DLL}/pcreposix.dll") + MESSAGE(STATUS "Found pcre.dll: ${PCRE_DLL}") + MESSAGE(STATUS "Found pcreposix.dll: ${PCREPOSIX_DLL}") + ENDIF() + ENDIF() + + IF (HAVE_PCRE OR HAVE_PCRE2) + SET(HAVE_REGEX 1) + ENDIF() +ENDIF() + +IF(MSVC) LIST(APPEND LIBS ws2_32) LIST(APPEND LIBS iphlpapi) LIST(APPEND LIBS ${GETOPT_LIB}) ENDIF() -add_executable(http_server http_server.c prog.c test_common.c test_cert.c) -IF(NOT MSVC) # TODO: port MD5 server and client to Windows -add_executable(md5_server md5_server.c prog.c test_common.c test_cert.c) -add_executable(md5_client md5_client.c prog.c test_common.c test_cert.c) +list(APPEND bin_targets http_client) +list(APPEND bin_targets http_server) +list(APPEND bin_targets echo_server) +list(APPEND bin_targets echo_client) +list(APPEND bin_targets duck_server) +list(APPEND bin_targets duck_client) +list(APPEND bin_targets perf_client) +list(APPEND bin_targets perf_server) +IF(NOT MSVC) +list(APPEND bin_targets md5_server) +list(APPEND bin_targets md5_client) ENDIF() -add_executable(echo_server echo_server.c prog.c test_common.c test_cert.c) -add_executable(echo_client echo_client.c prog.c test_common.c test_cert.c) -add_executable(duck_server duck_server.c prog.c test_common.c test_cert.c) -add_executable(duck_client duck_client.c prog.c test_common.c test_cert.c) -add_executable(perf_client perf_client.c prog.c test_common.c test_cert.c) -add_executable(perf_server perf_server.c prog.c test_common.c test_cert.c) - - -IF (NOT MSVC) - -add_executable(http_client - http_client.c - prog.c - test_common.c - test_cert.c -) - -#MSVC -ELSE() -add_executable(http_client - http_client.c - prog.c - test_common.c - test_cert.c -) +#MESSAGE(STATUS "bin_targets: ${bin_targets}") +#MESSAGE(STATUS "bin_targets LIBS: ${LIBS}") -ENDIF() +FOREACH(bin_target IN LISTS bin_targets) + add_executable(${bin_target} ${bin_target}.c prog.c test_common.c test_cert.c) + TARGET_LINK_LIBRARIES(${bin_target} ${LIBS}) +ENDFOREACH() -TARGET_LINK_LIBRARIES(http_client ${LIBS}) -TARGET_LINK_LIBRARIES(http_server ${LIBS}) -IF(NOT MSVC) -TARGET_LINK_LIBRARIES(md5_server ${LIBS}) -TARGET_LINK_LIBRARIES(md5_client ${LIBS}) +IF(MSVC) + FOREACH(bin_target IN LISTS bin_targets) + # copy any dependencies local to the targets + ADD_CUSTOM_COMMAND(TARGET ${bin_target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy \"$\" \"$\" + COMMAND_EXPAND_LISTS + ) + ADD_CUSTOM_COMMAND(TARGET ${bin_target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy \"${VCPKG_INSTALLED_DIR_X64_WINDOWS}/bin/getopt.dll\" \"$\" + COMMAND_EXPAND_LISTS + ) + IF(EXISTS ${BORINGSSL_DLL_crypto}) + ADD_CUSTOM_COMMAND(TARGET ${bin_target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy \"${BORINGSSL_DLL_crypto}\" \"$\" + COMMAND_EXPAND_LISTS + ) + ENDIF() + IF(EXISTS ${BORINGSSL_DLL_ssl}) + ADD_CUSTOM_COMMAND(TARGET ${bin_target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy \"${BORINGSSL_DLL_ssl}\" \"$\" + COMMAND_EXPAND_LISTS + ) + ENDIF() + IF(EXISTS ${PCRE_DLL}) + ADD_CUSTOM_COMMAND(TARGET ${bin_target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy \"${PCRE_DLL}\" \"$\" + COMMAND_EXPAND_LISTS + ) + ENDIF() + IF(EXISTS ${ZLIB_DLL}) + ADD_CUSTOM_COMMAND(TARGET ${bin_target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy \"${ZLIB_DLL}\" \"$\" + COMMAND_EXPAND_LISTS + ) + ENDIF() + ENDFOREACH() ENDIF() -TARGET_LINK_LIBRARIES(echo_server ${LIBS}) -TARGET_LINK_LIBRARIES(echo_client ${LIBS}) -TARGET_LINK_LIBRARIES(duck_server ${LIBS}) -TARGET_LINK_LIBRARIES(duck_client ${LIBS}) -TARGET_LINK_LIBRARIES(perf_client ${LIBS}) -TARGET_LINK_LIBRARIES(perf_server ${LIBS}) INCLUDE(CheckFunctionExists) @@ -95,18 +186,13 @@ CHECK_SYMBOL_EXISTS( HAVE_PREADV ) -INCLUDE(CheckIncludeFiles) - -IF (MSVC AND PCRE_LIB) -FIND_PATH(EVENT_INCLUDE_DIR NAMES pcreposix.h) -IF (EVENT_INCLUDE_DIR) - MESSAGE(STATUS "found pcreposix.h") - SET(HAVE_REGEX 1) -ELSE() - MESSAGE(FATAL_ERROR "event2/event.h was not found") -ENDIF() -ELSE() -CHECK_INCLUDE_FILES(regex.h HAVE_REGEX) +IF (MSVC) + FIND_PATH(EVENT_INCLUDE_DIR NAMES event2/event.h) + IF (EVENT_INCLUDE_DIR) + MESSAGE(STATUS "found event2/event.h") + ELSE() + MESSAGE(FATAL_ERROR "event2/event.h was not found") + ENDIF() ENDIF() CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test_config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/test_config.h) diff --git a/bin/http_server.c b/bin/http_server.c index 3c2cc0776..e2a94400c 100644 --- a/bin/http_server.c +++ b/bin/http_server.c @@ -36,11 +36,18 @@ #include "test_cert.h" #include "prog.h" -#if HAVE_REGEX + #ifndef WIN32 +#if HAVE_REGEX #include +#endif #else +#if HAVE_PCRE2 +#include +#elif HAVE_PCRE #include +#else +#error Missing posix regular expression header. #endif #endif diff --git a/bin/test_common.c b/bin/test_common.c index 174fde748..bd2034181 100644 --- a/bin/test_common.c +++ b/bin/test_common.c @@ -31,11 +31,17 @@ #include "test_config.h" -#if HAVE_REGEX #ifndef WIN32 +#if HAVE_REGEX #include +#endif #else +#if HAVE_PCRE2 +#include +#elif HAVE_PCRE #include +#else +#error Missing posix regular expression header. #endif #endif diff --git a/bin/test_config.h.in b/bin/test_config.h.in index f7ea4a38c..0e61f879f 100644 --- a/bin/test_config.h.in +++ b/bin/test_config.h.in @@ -7,6 +7,8 @@ #cmakedefine HAVE_IP_DONTFRAG 1 #cmakedefine HAVE_IP_MTU_DISCOVER 1 #cmakedefine HAVE_REGEX 1 +#cmakedefine HAVE_PCRE 1 +#cmakedefine HAVE_PCRE2 1 #cmakedefine HAVE_PREADV 1 #define LSQUIC_DONTFRAG_SUPPORTED (HAVE_IP_DONTFRAG || HAVE_IP_MTU_DISCOVER) diff --git a/boringssl-target.txt b/boringssl-target.txt new file mode 100644 index 000000000..8e5f09a9d --- /dev/null +++ b/boringssl-target.txt @@ -0,0 +1 @@ +cf8d3ad3cea51cf7184307d54f465da62b7d8408 \ No newline at end of file diff --git a/src/liblsquic/ls-qpack b/src/liblsquic/ls-qpack index 7ba6f119e..c74cd4b2c 160000 --- a/src/liblsquic/ls-qpack +++ b/src/liblsquic/ls-qpack @@ -1 +1 @@ -Subproject commit 7ba6f119e56e3709e25933d73dbb13c7ed242331 +Subproject commit c74cd4b2c3f97c069584615dc37fdd22a9110c80 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7aee69b62..2cfc9d886 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -87,27 +87,50 @@ IF (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") LIST(APPEND TESTS h3_framing) ENDIF() +IF(NOT TARGET build-tests) + ADD_CUSTOM_TARGET(build-tests ALL) +ENDIF() FOREACH(TEST_NAME ${TESTS}) ADD_EXECUTABLE(test_${TEST_NAME} test_${TEST_NAME}.c ${ADDL_SOURCES}) + IF(NOT MSVC) - TARGET_LINK_LIBRARIES(test_${TEST_NAME} ${LIBS} ${LIB_FLAGS}) + 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") + TARGET_LINK_LIBRARIES(test_${TEST_NAME} ${LIBS} ${GETOPT_LIB} ${LIB_FLAGS}) + + # copy any dependencies local to the tests + ADD_CUSTOM_COMMAND(TARGET test_${TEST_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy \"$\" \"$\" + COMMAND_EXPAND_LISTS + ) + ADD_CUSTOM_COMMAND(TARGET test_${TEST_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy \"${VCPKG_INSTALLED_DIR_X64_WINDOWS}/bin/getopt.dll\" \"$\" + COMMAND_EXPAND_LISTS + ) + IF(EXISTS ${BORINGSSL_DLL_crypto}) + ADD_CUSTOM_COMMAND(TARGET test_${TEST_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy \"${BORINGSSL_DLL_crypto}\" \"$\" + COMMAND_EXPAND_LISTS + ) + ENDIF() + IF(EXISTS ${BORINGSSL_DLL_ssl}) + ADD_CUSTOM_COMMAND(TARGET test_${TEST_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy \"${BORINGSSL_DLL_ssl}\" \"$\" + COMMAND_EXPAND_LISTS + ) + ENDIF() + IF(EXISTS ${ZLIB_DLL}) ADD_CUSTOM_COMMAND(TARGET test_${TEST_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy \"$ENV{VCPKG_ROOT}/installed/x64-windows$<$:/debug>/bin/getopt.dll\" \"$\" + COMMAND ${CMAKE_COMMAND} -E copy \"${ZLIB_DLL}\" \"$\" COMMAND_EXPAND_LISTS ) - #ELSE() - # ADD_CUSTOM_COMMAND(TARGET test_${TEST_NAME} POST_BUILD - # COMMAND if not \"\"=="$" ${CMAKE_COMMAND} -E copy $ $ - # COMMAND_EXPAND_LISTS - # ) - #ENDIF() + ENDIF() ENDIF() + ADD_TEST(${TEST_NAME} test_${TEST_NAME}) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES TIMEOUT 300) + ADD_DEPENDENCIES(build-tests test_${TEST_NAME}) ENDFOREACH() ADD_EXECUTABLE(test_stream test_stream.c ${ADDL_SOURCES}) @@ -119,6 +142,7 @@ ADD_TEST(stream test_stream) ADD_TEST(stream_hash test_stream -h) ADD_TEST(stream_A test_stream -A) ADD_TEST(stream_hash_A test_stream -A -h) +ADD_DEPENDENCIES(build-tests test_stream) IF(NOT MSVC) ADD_EXECUTABLE(graph_cubic graph_cubic.c ${ADDL_SOURCES}) @@ -130,6 +154,7 @@ ENDIF() ADD_EXECUTABLE(test_min_heap test_min_heap.c ../src/liblsquic/lsquic_min_heap.c) ADD_TEST(min_heap test_min_heap) +ADD_DEPENDENCIES(build-tests test_min_heap) SET(MALO_SRC test_malo.c ../src/liblsquic/lsquic_malo.c) ADD_EXECUTABLE(test_malo_pooled ${MALO_SRC}) @@ -139,6 +164,7 @@ 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_DEPENDENCIES(build-tests test_malo_pooled) ADD_EXECUTABLE(test_malo_nopool ${MALO_SRC}) IF(MSVC) @@ -147,15 +173,19 @@ 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_DEPENDENCIES(build-tests 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_DEPENDENCIES(build-tests test_minmax) ADD_EXECUTABLE(test_rechist test_rechist.c ../src/liblsquic/lsquic_rechist.c) ADD_TEST(rechist test_rechist) +ADD_DEPENDENCIES(build-tests test_rechist) ADD_EXECUTABLE(test_trechist test_trechist.c ../src/liblsquic/lsquic_trechist.c) ADD_TEST(trechist test_trechist) +ADD_DEPENDENCIES(build-tests test_trechist) diff --git a/tests/localhost.key b/tests/localhost.key new file mode 100644 index 000000000..dc61a0052 --- /dev/null +++ b/tests/localhost.key @@ -0,0 +1,8 @@ +-----BEGIN EC PARAMETERS----- +BggqhkjOPQMBBw== +-----END EC PARAMETERS----- +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIKYZDgkl2uN2FqP8j0ZLaX9goZovbOU+Noa12JOqaIDQoAoGCCqGSM49 +AwEHoUQDQgAEWnNf81GlNs/qI6F1Fv8ied08380gifitwp6M1V7kJMvvTt0pak3s +/MvbsH3FXG2dHme3nPL9kBp4jFPiwVxtgg== +-----END EC PRIVATE KEY----- diff --git a/tests/localhost.pem b/tests/localhost.pem new file mode 100644 index 000000000..0290dd1ac --- /dev/null +++ b/tests/localhost.pem @@ -0,0 +1,11 @@ +-----BEGIN CERTIFICATE----- +MIIBqzCCAVKgAwIBAgIUB+6iEGqmXwkmwTeYgeU+Q+OSkfEwCgYIKoZIzj0EAwIw +ODEVMBMGA1UECgwMTG9jYWxob3N0IENBMQswCQYDVQQGEwJVUzESMBAGA1UEAwwJ +bG9jYWxob3N0MB4XDTIxMTIwNzE2MjczOVoXDTIyMTIwNzE2MjczOVowITELMAkG +A1UEBhMCVVMxEjAQBgNVBAMMCWxvY2FsaG9zdDBZMBMGByqGSM49AgEGCCqGSM49 +AwEHA0IABFpzX/NRpTbP6iOhdRb/InndPN/NIIn4rcKejNVe5CTL707dKWpN7PzL +27B9xVxtnR5nt5zy/ZAaeIxT4sFcbYKjUTBPMB8GA1UdIwQYMBaAFDD8bPRhSZvh +pr/ZyKZnSXGU2IH8MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgTwMBQGA1UdEQQNMAuC +CWxvY2FsaG9zdDAKBggqhkjOPQQDAgNHADBEAiA3bXM3LeDw4PylTdZS3T/RmsNX +R56BmIzYJ67lJqMJaQIgAYvKTd/N4scrWR37SKShAk6yhx0WuFWMGLlIAFb7pbA= +-----END CERTIFICATE----- diff --git a/tests/localhostCA.key b/tests/localhostCA.key new file mode 100644 index 000000000..d3ff56f84 --- /dev/null +++ b/tests/localhostCA.key @@ -0,0 +1,8 @@ +-----BEGIN EC PARAMETERS----- +BggqhkjOPQMBBw== +-----END EC PARAMETERS----- +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIPd9auFKb76x8PAmJpkJS3EpXta9gTdQD+sUHc631TReoAoGCCqGSM49 +AwEHoUQDQgAEuqX0ncb6eVo5Rxrnipmt5yzt1bKhqEqCWEd7UCkoZ5RGBDtqOh8v +s3wdFpOLiojBV0+CVbnJbdYg3U9BZI/Rzw== +-----END EC PRIVATE KEY----- diff --git a/tests/localhostCA.pem b/tests/localhostCA.pem new file mode 100644 index 000000000..824d162bd --- /dev/null +++ b/tests/localhostCA.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIBxTCCAWugAwIBAgIUekflpcz/KPPXHkAGiZl70KnlFb8wCgYIKoZIzj0EAwIw +ODEVMBMGA1UECgwMTG9jYWxob3N0IENBMQswCQYDVQQGEwJVUzESMBAGA1UEAwwJ +bG9jYWxob3N0MB4XDTIxMTIwNzE2MjcxMVoXDTIyMTIwNzE2MjcxMVowODEVMBMG +A1UECgwMTG9jYWxob3N0IENBMQswCQYDVQQGEwJVUzESMBAGA1UEAwwJbG9jYWxo +b3N0MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuqX0ncb6eVo5Rxrnipmt5yzt +1bKhqEqCWEd7UCkoZ5RGBDtqOh8vs3wdFpOLiojBV0+CVbnJbdYg3U9BZI/Rz6NT +MFEwHQYDVR0OBBYEFDD8bPRhSZvhpr/ZyKZnSXGU2IH8MB8GA1UdIwQYMBaAFDD8 +bPRhSZvhpr/ZyKZnSXGU2IH8MA8GA1UdEwEB/wQFMAMBAf8wCgYIKoZIzj0EAwID +SAAwRQIgY3QiG7YAanbIaTLk+NSTpnfwkJCoyPlLkrFNQ9y4EccCIQDlcTRS7KPh +9e7KyRyHr3wJ2QBgMoDR7ywDaT1UE86EVg== +-----END CERTIFICATE-----