Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,18 @@ jobs:
message(FATAL_ERROR "Bad exit status")
endif()
execute_process(COMMAND ccache -s)
- name: Test
shell: cmake -P {0}
run: |
# NOTE: run from inside "build" rather than with "--test-dir", which the
# pinned CMake ($ENV{CMAKE_VERSION}) predates (it arrived in 3.20).
execute_process(
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/ctest
--output-on-failure
-C $ENV{BUILD_TYPE}
WORKING_DIRECTORY build
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Tests failed")
endif()
40 changes: 38 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ set(COMMON src/common)
option(NORM_BUILD_EXAMPLES "Enables building of the examples in /examples." OFF)
set(NORM_CUSTOM_PROTOLIB_VERSION OFF CACHE STRING "Set a custom protolib version to use, ./protolib to use the local version")

# Build self-checking tests by default only when NORM is the top-level project.
# Self-checking tests build by default only when NORM is the top-level project, so
# projects that add_subdirectory() NORM don't grow an extra binary unasked.
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(NORM_BUILD_TESTING_DEFAULT ON)
else()
set(NORM_BUILD_TESTING_DEFAULT OFF)
endif()
option(NORM_BUILD_TESTING "Enables building NORM self-checking tests." ${NORM_BUILD_TESTING_DEFAULT})
option(NORM_BUILD_TESTING "Enables building of the self-checking tests in /examples." ${NORM_BUILD_TESTING_DEFAULT})
if(NORM_BUILD_TESTING)
enable_testing()
endif()
Expand Down Expand Up @@ -72,9 +73,20 @@ if(NORM_PROTOKIT_GIT_TAG)
GIT_TAG ${NORM_PROTOKIT_GIT_TAG}
)
FetchContent_MakeAvailable(protokit)
FetchContent_GetProperties(protokit SOURCE_DIR PROTOKIT_SRC_DIR)
else()
message(STATUS "Building protokit from ${NORM_CUSTOM_PROTOLIB_VERSION}")
add_subdirectory(protolib)
set(PROTOKIT_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/protolib)
endif()

if (MINGW AND TARGET protokit)
target_sources(protokit PRIVATE
${PROTOKIT_SRC_DIR}/src/win32/win32Net.cpp
${PROTOKIT_SRC_DIR}/src/win32/win32RouteMgr.cpp
)
target_link_libraries(protokit PUBLIC ws2_32 iphlpapi user32 gdi32 Advapi32 ntdll)
target_compile_definitions(protokit PUBLIC _CRT_SECURE_NO_WARNINGS)
endif()


Expand Down Expand Up @@ -140,6 +152,12 @@ if(BUILD_SHARED_LIBS)
set_target_properties(norm PROPERTIES SOVERSION 1.5.10)
if(WIN32)
target_compile_definitions(norm PUBLIC NORM_USE_DLL)
# NORM_USE_DLL alone makes NORM_API_LINKAGE "dllimport" everywhere, which is
# what consumers want but is wrong inside the DLL itself: the classes marked
# with it (NormEncoder/NormDecoder) define members in normEncoder.cpp, and
# MSVC rejects defining a member of a dllimport class. normApi.cpp defines
# this itself for the non-CMake builds; the whole library needs it.
target_compile_definitions(norm PRIVATE _NORM_API_BUILD)
endif()
endif()

Expand Down Expand Up @@ -233,9 +251,27 @@ if(NORM_BUILD_EXAMPLES)
add_executable(${example} examples/${example}.cpp examples/normSocket.cpp)
target_link_libraries(${example} PRIVATE norm protokit::protokit)
endforeach()

endif()

if(NORM_BUILD_TESTING)
add_executable(normRatelessTest examples/normRatelessTest.cpp)
target_link_libraries(normRatelessTest PRIVATE norm protokit::protokit)
add_test(NAME normRatelessTest COMMAND normRatelessTest)
add_test(NAME normCustomFecTest COMMAND normRatelessTest)
set_tests_properties(normCustomFecTest PROPERTIES ENVIRONMENT "NORM_FEC_ID=132")
add_test(NAME normRatelessExhaustionTest COMMAND normRatelessTest)
set_tests_properties(normRatelessExhaustionTest PROPERTIES ENVIRONMENT
"NORM_FORCE_DECODE_FAILURE=1;NORM_NDATA=4;NORM_NPARITY=4;NORM_DATA_LEN=2000;NORM_RX_LOSS=50")
add_test(NAME normRatelessReNackTest COMMAND normRatelessTest)
set_tests_properties(normRatelessReNackTest PROPERTIES ENVIRONMENT
"NORM_DECODE_SHORT_COUNT=1;NORM_NDATA=4;NORM_NPARITY=8;NORM_DATA_LEN=2000;NORM_RX_LOSS=30")
add_test(NAME normRatelessReNackMultiTest COMMAND normRatelessTest)
set_tests_properties(normRatelessReNackMultiTest PROPERTIES ENVIRONMENT
"NORM_DECODE_SHORT_COUNT=8;NORM_NDATA=8;NORM_NPARITY=32;NORM_DATA_LEN=20000;NORM_RX_LOSS=40")
set_tests_properties(normRatelessTest normCustomFecTest normRatelessExhaustionTest
normRatelessReNackTest normRatelessReNackMultiTest
PROPERTIES RUN_SERIAL TRUE TIMEOUT 75)
# This test exercises internal sender repair state and message generation,
# so compile it with the implementation sources instead of depending on
# symbols hidden by shared-library builds.
Expand Down
Loading
Loading