Skip to content
Draft
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
233 changes: 4 additions & 229 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -472,239 +472,14 @@ add_executable(smb

target_link_libraries(smb smblib Threads::Threads)

##################
# Test framework
##################

# Download and unpack googletest at configure time
configure_file(CMakeLists-gtest.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . RESULT_VARIABLE result WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build . RESULT_VARIABLE result WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()

# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src ${CMAKE_CURRENT_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL)

set(TEST_LIB_FILES
test/integration/SampleDataUtils.cpp
test/integration/FFTanalysis.h
test/integration/FFTanalysis.cpp
test/sctp/SctpEndpoint.h
test/sctp/SctpEndpoint.cpp
test/transport/SrtpUnprotectJob.cpp
test/transport/SrtpUnprotectJob.h
test/transport/FakeNetwork.h
test/transport/FakeNetwork.cpp
test/transport/NetworkLink.h
test/transport/NetworkLink.cpp
test/integration/RtpDump.h
test/integration/RtpDump.cpp
test/integration/IntegrationTest.cpp
test/integration/IntegrationTest.h
test/integration/emulator/AudioSource.cpp
test/integration/emulator/AudioSource.h
test/integration/emulator/ApiChannel.h
test/integration/emulator/ApiChannel.cpp
test/integration/emulator/BaseChannel.h
test/integration/emulator/BaseChannel.cpp
test/integration/emulator/ColibriChannel.h
test/integration/emulator/ColibriChannel.cpp
test/integration/emulator/FakeVideoDecoder.h
test/integration/emulator/FakeVideoDecoder.cpp
test/integration/emulator/SfuClient.h
test/integration/emulator/SfuClientReceivers.h
test/integration/emulator/SfuGroupCall.h
test/integration/emulator/Conference.cpp
test/integration/emulator/Barbell.cpp
test/integration/emulator/HttpRequests.h
test/integration/emulator/HttpRequests.cpp
test/integration/emulator/TimeTurner.h
test/integration/emulator/TimeTurner.cpp
test/integration/emulator/FakeEndpointFactory.h
test/integration/emulator/FakeEndpointFactory.cpp
test/integration/emulator/FakeEndpointImpl.h
test/integration/emulator/FakeEndpointImpl.cpp
test/integration/emulator/FakeUdpEndpoint.h
test/integration/emulator/FakeUdpEndpoint.cpp
test/integration/emulator/FakeTcpEndpoint.h
test/integration/emulator/FakeTcpEndpoint.cpp
test/integration/emulator/FakeTcpServerEndpoint.h
test/integration/emulator/FakeTcpServerEndpoint.cpp
test/integration/emulator/Httpd.cpp
test/integration/emulator/JitterPacketSource.h
test/integration/emulator/JitterPacketSource.cpp
test/CsvWriter.h
test/CsvWriter.cpp
test/ResourceLoader.cpp
test/bwe/FakeAudioSource.h
test/bwe/FakeAudioSource.cpp
test/bwe/FakeVideoSource.h
test/bwe/FakeVideoSource.cpp
test/bwe/FakeCall.h
test/bwe/FakeCall.cpp
test/bwe/RcCall.h
test/bwe/RcCall.cpp
test/bwe/FakeMedia.h
test/bwe/FakeMedia.cpp
test/bwe/FakeCrossTraffic.h
test/bwe/FakeCrossTraffic.cpp
test/bwe/BwBurstTracker.h
test/bwe/BwBurstTracker.cpp
test/utils/ApiUtils.cpp
test/bridge/DummyRtcTransport.h
)

set(TEST_FILES
test/api/ParserTest.cpp
test/memory/MapTest.cpp
test/memory/PoolAllocatorTest.cpp
test/memory/RingAllocatorTest.cpp
test/utils/StringTokenizerTest.cpp
test/utils/TrackerTest.cpp
test/utils/StdExtensionsTest.cpp
test/utils/SocketAddressTest.cpp
test/memory/ListTest.cpp
test/memory/ArrayTest.cpp
test/jobmanager/JobManagerTest.cpp
test/jobmanager/JobTest.cpp
test/codec/OpusCodecTest.cpp
test/concurrency/ProcessIntervalTest.cpp

test/sctp/SctpBasicsTests.cpp
test/sctp/SctpTransferTests.cpp
test/transport/ice/IceCandidateTest.cpp
test/transport/SctpTest.cpp
test/transport/RtcpReportsProducerTest.cpp
test/transport/RtcTransportTest.cpp
test/transport/RtpTest.cpp
test/transport/IceIntegrationTest.cpp
test/transport/SctpIntegrationTest.cpp
test/transport/TransportIntegrationTest.cpp
test/transport/TransportIntegrationTest.h
test/transport/SrtpTest.cpp
test/transport/Ipv6Test.cpp
test/transport/JitterTest.cpp
test/transport/AdaptiveJitterTest.cpp
test/integration/TimeTurnerTest.cpp
test/config/ConfigTest.cpp
test/codec/AudioProcessingTest.cpp
test/concurrency/MpscTest.cpp
test/concurrency/MpmcMapTest.cpp
test/concurrency/LockFreeListTest.cpp
test/bwe/MatrixTests.cpp
test/bwe/RateControllerTest.cpp
test/transport/IceTest.cpp
test/utils/Crc32Test.cpp
test/utils/StringBuilderTest.cpp
test/utils/RandGeneratorTest.cpp
test/utils/TimeSourceTest.cpp
test/utils/ApiUtils.cpp
test/utils/SimpleJsonTest.cpp
test/legacyapi/ParserTest.cpp
test/legacyapi/GeneratorTest.cpp
test/math/FieldsTest.cpp
test/bridge/EngineStreamDirectorTest.cpp
test/codec/H264HeaderTest.cpp
test/codec/Vp8HeaderTest.cpp
test/bridge/ActiveMediaListTest.cpp
test/bridge/BarbellMessagesTest.cpp
test/rtp/RtcpFeedbackTest.cpp
test/bridge/PacketCacheTest.cpp
test/bridge/SsrcOutboundContextTest.cpp
test/rtp/RtcpNackBuilderTest.cpp
test/rtp/SendTimeTest.cpp
test/bridge/VideoMissingPacketsTrackerTest.cpp
test/bwe/BandwidthUtilsTest.cpp
test/bwe/EstimatorTestEasy.cpp
test/bwe/EstimatorReRun.cpp
test/crypto/AESTest.cpp
test/utils/Base64Test.cpp
test/crypto/AesIvGeneratorTest.cpp
test/transport/RecordingTransportTest.cpp
test/transport/recp/RecStartStopEventBuilderTest.cpp
test/transport/recp/RecStreamAddedEventBuilderTest.cpp
test/bridge/UnackedPacketsTrackerTest.cpp
test/bridge/VideoForwarderRtxReceiveJobTest.cpp
test/memory/PriorityQueueTest.cpp
test/memory/BacklogTest.cpp
test/memory/StackMapTest.cpp
test/bridge/ActiveMediaListTestLevels.h
test/bridge/MixerTest.cpp
test/bridge/VideoNackReceiveJobTest.cpp
test/utils/LogSpamTest.cpp
test/utils/FunctionTest.cpp
test/transport/JitterTest.cpp)


set(TEST_FILES2
test/integration/RealTimeTest.cpp
test/integration/RealTimeTest.h
test/integration/BarbellTest.cpp
test/integration/BarbellTest.h
test/integration/ConfIntegrationTest.cpp
test/integration/IntegrationLegApiTest.cpp
test/integration/IceTransportTest.cpp
test/integration/SrtpIntegrationTest.cpp
test/integration/IntegrationCallTypes.cpp
test/integration/IntegrationAudioTest.cpp
test/integration/FFTtest.cpp
)

set(LOAD_TEST_FILES
test/integration/IntegrationTest.cpp
test/integration/IntegrationTest.h
test/integration/RealTimeTest.cpp
test/integration/RealTimeTest.h
test/integration/LoadTestConfig.h
)


set(CMAKE_TEST_DIRECTORY "${CMAKE_BINARY_DIR}/test")
set(CMAKE_TEST_INCLUDE "${CMAKE_TEST_DIRECTORY}/include")
configure_file(test/TestConfig.h.in ${CMAKE_TEST_INCLUDE}/TestConfig.h)

add_library(testlib STATIC ${TEST_LIB_FILES})
target_include_directories(testlib PRIVATE ${CMAKE_TEST_INCLUDE} ${gtest_SOURCE_DIR}/include "test/include")
target_link_libraries(testlib PUBLIC smblib ${THIRD_PARTY_LIBS})

add_executable(UnitTest
${TEST_FILES} test/gtest_main.cpp)

target_include_directories(UnitTest PRIVATE ${CMAKE_TEST_INCLUDE} "test/include")

# Copy test Data
file(COPY "${CMAKE_SOURCE_DIR}/test/resources" DESTINATION "${CMAKE_TEST_DIRECTORY}")

target_link_libraries(UnitTest testlib gtest gmock)

add_executable(UnitTest2
${TEST_FILES2} test/gtest_main2.cpp)

target_include_directories(UnitTest2 PRIVATE ${CMAKE_TEST_INCLUDE} "test/include")

# Copy test Data
file(COPY "${CMAKE_SOURCE_DIR}/test/resources" DESTINATION "${CMAKE_TEST_DIRECTORY}")

target_link_libraries(UnitTest2 testlib gtest gmock)


add_test(AllUnitTests UnitTest)
add_test(AllUnitTests UnitTest2)

add_executable(LoadTest ${LOAD_TEST_FILES}
test/load_test_main.cpp)

target_link_libraries(LoadTest testlib gtest gmock)
add_subdirectory(test)
set_target_properties(UnitTest PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
Copy link
Contributor Author

@olofkallander olofkallander Nov 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to make Test executables end up in build top folder.
However, maybe we should consider allowing the build folder to be structured as cmake default:

build
  bin
  _deps
  libs

and put the binaries in bin folder

set_target_properties(UnitTest2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set_target_properties(LoadTest PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

if(APPLE)
source_group(TREE ${PROJECT_SOURCE_DIR} FILES ${FILES} ${TEST_FILES} ${TEST_FILES2})
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists-gtest.txt.in → test/CMakeLists-gtest.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project(googletest-download NONE)
include(ExternalProject)
ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.11.0
GIT_TAG v1.15.2
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
Expand Down
Loading
Loading