From 05da5c66bff21c0f1caa49b9adfd625f12e3f830 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Sun, 3 Dec 2023 17:28:34 +0100 Subject: [PATCH] CMake: Add bidirection TCP test --- .github/workflows/ci.yml | 5 +++++ cmake/CMakeLists.txt | 13 +++++++++++-- src/test_bidirectional_tcp.c | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c78fbfd..77bde21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f4eb631..f6f2ca0 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -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) @@ -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}) @@ -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) @@ -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}) @@ -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 @@ -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") diff --git a/src/test_bidirectional_tcp.c b/src/test_bidirectional_tcp.c index b8f1c01..0c3c635 100644 --- a/src/test_bidirectional_tcp.c +++ b/src/test_bidirectional_tcp.c @@ -1,4 +1,4 @@ -#ifdef WIN32 +#if defined(WIN32) || defined(_MSC_VER) #include #include #else