Skip to content

Commit

Permalink
CMake: Add bidirection TCP test
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesLorenz committed Dec 3, 2023
1 parent fe2229a commit 05da5c6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,8 @@ jobs:
cd bld\
cmake ..\cmake -DCMAKE_BUILD_TYPE=Release
cmake --build . --target all_build --config Release
- name: Run tests
shell: pwsh
run: |
cd bld\
ctest
13 changes: 11 additions & 2 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ if (WITH_TOOLS)
endif()
if (WITH_TESTS)
set(TESTLO testlo)
set(TESTTCP test_bidirectional_tcp)
set(SUBTEST subtest)
if (WITH_CPP_TESTS)
set(CPPTEST cpp_test)
Expand All @@ -94,7 +95,7 @@ if (WITH_EXAMPLES)
endif()

set(TOOLS ${OSCDUMP} ${OSCSEND} ${OSCSENDFILE})
set(TESTS ${TESTLO} ${SUBTEST})
set(TESTS ${TESTLO} ${TESTTCP} ${SUBTEST})
list(APPEND TESTS ${CPPTEST})
set(EXAMPLES ${EXAMPLE_CLIENT} ${EXAMPLE_SERVER}
${EXAMPLE_TCP_ECHO_SERVER} ${NONBLOCKING_SERVER_EXAMPLE})
Expand Down Expand Up @@ -130,6 +131,7 @@ set(OSCDUMP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../src/tools/oscdump.c)
set(OSCSEND_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../src/tools/oscsend.c)
set(OSCSENDFILE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../src/tools/oscsendfile.c)
set(TESTLO_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../src/testlo.c)
set(TESTTCP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../src/test_bidirectional_tcp.c)
set(SUBTEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../src/subtest.c)
if (WITH_CPP_TESTS)
set(CPPTEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../src/cpp_test.cpp)
Expand Down Expand Up @@ -174,7 +176,7 @@ set(BUILD_LANGUAGE C CACHE STRING "Build language (C or CXX)")
mark_as_advanced(BUILD_LANGUAGE)
set_source_files_properties(
${LIBRARY_SOURCES} ${OSCDUMP_SOURCES} ${OSCSEND_SOURCES} ${OSCSENDFILE_SOURCES}
${TESTLO_SOURCES} ${EXAMPLE_CLIENT_SOURCES}
${TESTLO_SOURCES} ${TESTTCP_SOURCES} ${EXAMPLE_CLIENT_SOURCES}
${EXAMPLE_SERVER_SOURCES} ${EXAMPLE_TCP_ECHO_SERVER_SOURCES}
${NONBLOCKING_SERVER_EXAMPLE_SOURCES}
PROPERTIES LANGUAGE ${BUILD_LANGUAGE})
Expand All @@ -201,10 +203,16 @@ endif()
if (WITH_TESTS)
add_executable(${TESTLO} ${TESTLO_SOURCES})
add_executable(${SUBTEST} ${SUBTEST_SOURCES})
add_executable(${TESTTCP} ${TESTTCP_SOURCES})
target_link_libraries(${TESTLO} PRIVATE Threads::Threads)
target_link_libraries(${TESTTCP} PRIVATE Threads::Threads)
add_test(${TESTLO} tests/${TESTLO})
add_test("test-bidirectional-tcp" tests/${TESTTCP})
enable_testing()
endif()
if (WITH_CPP_TESTS)
add_executable(${CPPTEST} ${CPPTEST_SOURCES})
add_test(${CPPTEST} tests/${CPPTEST})
endif()

# Examples
Expand Down Expand Up @@ -237,6 +245,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
endif()
target_link_libraries(${NONBLOCKING_SERVER_EXAMPLE} PRIVATE "wsock32")
target_link_libraries(${TESTLO} PRIVATE "wsock32")
target_link_libraries(${TESTTCP} PRIVATE "wsock32")

set_target_properties(${LIBRARY_SHARED} PROPERTIES
COMPILE_DEFINITIONS "LIBLO_DLL")
Expand Down
2 changes: 1 addition & 1 deletion src/test_bidirectional_tcp.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef WIN32
#if defined(WIN32) || defined(_MSC_VER)
#include <process.h>
#include <windows.h>
#else
Expand Down

0 comments on commit 05da5c6

Please sign in to comment.