diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a08c19c8a..a584bde21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,9 +34,22 @@ jobs: - name: Build repository run: | mkdir build && cd build - sh -c 'cmake .. -DBUILD_TEST=TRUE;cmake .. -DBUILD_TEST=TRUE' + cmake .. -DBUILD_TEST=TRUE + make + - name: Run tests + run: | + cd build + ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + - name: Build With ALIGNED_MEMORY_MODEL and FIXUP_ANNEX_B_TRAILING_NALU_ZERO definitions TRUE + run: | + rm -rf build + mkdir build && cd build + cmake .. -DBUILD_TEST=TRUE -DALIGNED_MEMORY_MODEL=TRUE -DFIXUP_ANNEX_B_TRAILING_NALU_ZERO=TRUE make - ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + - name: Run tests + run: | + cd build + ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" mac-os-build-clang: runs-on: macos-latest env: @@ -47,9 +60,22 @@ jobs: - name: Build repository run: | mkdir build && cd build - sh -c 'cmake .. -DBUILD_TEST=TRUE -DCOMPILER_WARNINGS=TRUE;cmake .. -DBUILD_TEST=TRUE -DCOMPILER_WARNINGS=TRUE' + cmake .. -DBUILD_TEST=TRUE -DCOMPILER_WARNINGS=TRUE make - ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + - name: Run tests + run: | + cd build + ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + - name: Build With ALIGNED_MEMORY_MODEL and FIXUP_ANNEX_B_TRAILING_NALU_ZERO definitions TRUE + run: | + rm -rf build + mkdir build && cd build + cmake .. -DBUILD_TEST=TRUE -DALIGNED_MEMORY_MODEL=TRUE -DFIXUP_ANNEX_B_TRAILING_NALU_ZERO=TRUE + make + - name: Run tests + run: | + cd build + ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" mac-os-m1-build-clang: runs-on: macos-13-xlarge env: @@ -61,9 +87,22 @@ jobs: run: | brew unlink openssl mkdir build && cd build - sh -c 'cmake .. -DBUILD_TEST=TRUE -DCMAKE_C_COMPILER=$(brew --prefix llvm@15)/bin/clang -DCMAKE_CXX_COMPILER=$(brew --prefix llvm@15)/bin/clang++;cmake .. -DBUILD_TEST=TRUE -DCMAKE_C_COMPILER=$(brew --prefix llvm@15)/bin/clang -DCMAKE_CXX_COMPILER=$(brew --prefix llvm@15)/bin/clang++' + cmake .. -DBUILD_TEST=TRUE -DCMAKE_C_COMPILER=$(brew --prefix llvm@15)/bin/clang -DCMAKE_CXX_COMPILER=$(brew --prefix llvm@15)/bin/clang++ make - ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + - name: Run tests + run: | + cd build + ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + - name: Build With ALIGNED_MEMORY_MODEL and FIXUP_ANNEX_B_TRAILING_NALU_ZERO definitions TRUE + run: | + rm -rf build + mkdir build && cd build + cmake .. -DBUILD_TEST=TRUE -DALIGNED_MEMORY_MODEL=TRUE -DFIXUP_ANNEX_B_TRAILING_NALU_ZERO=TRUE -DCMAKE_C_COMPILER=$(brew --prefix llvm@15)/bin/clang -DCMAKE_CXX_COMPILER=$(brew --prefix llvm@15)/bin/clang++ + make + - name: Run tests + run: | + cd build + ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" mac-os-m1-build-gcc: runs-on: macos-13-xlarge env: @@ -77,9 +116,22 @@ jobs: run: | brew unlink openssl mkdir build && cd build - sh -c 'cmake .. -DBUILD_TEST=TRUE;cmake .. -DBUILD_TEST=TRUE' + cmake .. -DBUILD_TEST=TRUE make - ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + - name: Run tests + run: | + cd build + ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + - name: Build With ALIGNED_MEMORY_MODEL and FIXUP_ANNEX_B_TRAILING_NALU_ZERO definitions TRUE + run: | + rm -rf build + mkdir build && cd build + cmake .. -DBUILD_TEST=TRUE -DALIGNED_MEMORY_MODEL=TRUE -DFIXUP_ANNEX_B_TRAILING_NALU_ZERO=TRUE + make + - name: Run tests + run: | + cd build + ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" linux-gcc-code-coverage: runs-on: ubuntu-latest env: @@ -92,8 +144,22 @@ jobs: mkdir build && cd build cmake .. -DCODE_COVERAGE=TRUE -DBUILD_TEST=TRUE make + - name: Run tests + run: | + cd build + ulimit -c unlimited -S + timeout --signal=SIGABRT 40m ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + - name: Build With ALIGNED_MEMORY_MODEL and FIXUP_ANNEX_B_TRAILING_NALU_ZERO definitions TRUE + run: | + rm -rf build + mkdir build && cd build + cmake .. -DCODE_COVERAGE=TRUE -DBUILD_TEST=TRUE -DALIGNED_MEMORY_MODEL=TRUE -DFIXUP_ANNEX_B_TRAILING_NALU_ZERO=TRUE + make + - name: Run tests + run: | + cd build ulimit -c unlimited -S - timeout --signal=SIGABRT 40m ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + timeout --signal=SIGABRT 40m ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" - name: Code coverage run: | for test_file in $(find CMakeFiles/kvspic.dir CMakeFiles/kvspicClient.dir CMakeFiles/kvspicState.dir CMakeFiles/kvspicUtils.dir -name '*.gcno'); do gcov $test_file; done @@ -110,14 +176,27 @@ jobs: mkdir build && cd build cmake .. -DBUILD_TEST=TRUE -DADDRESS_SANITIZER=TRUE make + - name: Run tests + run: | + cd build ulimit -c unlimited -S - timeout --signal=SIGABRT 40m ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + timeout --signal=SIGABRT 40m ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + - name: Build With ALIGNED_MEMORY_MODEL and FIXUP_ANNEX_B_TRAILING_NALU_ZERO definitions TRUE + run: | + rm -rf build + mkdir build && cd build + cmake .. -DBUILD_TEST=TRUE -DADDRESS_SANITIZER=TRUE -DALIGNED_MEMORY_MODEL=TRUE -DFIXUP_ANNEX_B_TRAILING_NALU_ZERO=TRUE + make + - name: Run tests + run: | + cd build + timeout --signal=SIGABRT 40m ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" undefined-behavior-sanitizer: runs-on: ubuntu-latest env: CC: clang CXX: clang++ - UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1:suppressions=../src/utils/tst/suppressions/UBSAN.supp + UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1:suppressions=../../tst/suppressions/UBSAN.supp AWS_KVS_LOG_LEVEL: 2 steps: - name: Clone repository @@ -131,8 +210,21 @@ jobs: mkdir build && cd build cmake .. -DBUILD_TEST=TRUE -DUNDEFINED_BEHAVIOR_SANITIZER=TRUE make + - name: Run tests + run: | + cd build ulimit -c unlimited -S - timeout --signal=SIGABRT 40m ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + timeout --signal=SIGABRT 40m ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + - name: Build With ALIGNED_MEMORY_MODEL and FIXUP_ANNEX_B_TRAILING_NALU_ZERO definitions TRUE + run: | + rm -rf build + mkdir build && cd build + cmake .. -DBUILD_TEST=TRUE -DUNDEFINED_BEHAVIOR_SANITIZER=TRUE -DALIGNED_MEMORY_MODEL=TRUE -DFIXUP_ANNEX_B_TRAILING_NALU_ZERO=TRUE + make + - name: Run tests + run: | + cd build + timeout --signal=SIGABRT 40m ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" linux-gcc-4_4: runs-on: ubuntu-20.04 env: @@ -155,8 +247,21 @@ jobs: mkdir build && cd build cmake .. -DBUILD_TEST=TRUE make + - name: Run tests + run: | + cd build ulimit -c unlimited -S - timeout --signal=SIGABRT 40m ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + timeout --signal=SIGABRT 40m ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + - name: Build With ALIGNED_MEMORY_MODEL and FIXUP_ANNEX_B_TRAILING_NALU_ZERO definitions TRUE + run: | + rm -rf build + mkdir build && cd build + cmake .. -DBUILD_TEST=TRUE -DALIGNED_MEMORY_MODEL=TRUE -DFIXUP_ANNEX_B_TRAILING_NALU_ZERO=TRUE + make + - name: Run tests + run: | + cd build + timeout --signal=SIGABRT 40m ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" # memory-sanitizer: # runs-on: ubuntu-18.04 # env: @@ -176,14 +281,14 @@ jobs: # cmake .. -DBUILD_TEST=TRUE -DMEMORY_SANITIZER=TRUE # make # ulimit -c unlimited -S - # timeout --signal=SIGABRT 40m ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + # timeout --signal=SIGABRT 40m ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" # thread-sanitizer: # runs-on: ubuntu-18.04 # env: # CC: clang-7 # CXX: clang++-7 # AWS_KVS_LOG_LEVEL: 2 - # TSAN_OPTIONS: halt_on_error=1:suppressions=../src/utils/tst/suppressions/TSAN.supp + # TSAN_OPTIONS: halt_on_error=1:suppressions=../../tst/suppressions/TSAN.supp # steps: # - name: Clone repository # uses: actions/checkout@v2 @@ -196,7 +301,7 @@ jobs: # mkdir build && cd build # cmake .. -DBUILD_TEST=TRUE -DTHREAD_SANITIZER=TRUE # make - # ./kvspic_test --gtest_break_on_failure --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*:ThreadFunctionalityTest.ThreadCreateAndCancel" + # ./tst/kvspic_test --gtest_break_on_failure --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*:ThreadFunctionalityTest.ThreadCreateAndCancel" windows-msvc: runs-on: windows-2022 env: @@ -207,7 +312,9 @@ jobs: - name: Build and run run: | .github/build_windows.bat - D:\a\amazon-kinesis-video-streams-pic\amazon-kinesis-video-streams-pic\build\kvspic_test.exe --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*:PermutatedStreamInfo/StateTransitionFunctionalityTest.ControlPlaneServiceCallExhaustRetry*:PermutatedStreamInfo/IntermittentProducerAutomaticStreamingTest.ValidateTimerInvokedBeforeTime*:PermutatedStreamInfo/IntermittentProducerAutomaticStreamingTest.ValidateTimerInvokedAfterFirstPeriod*:PermutatedStreamInfo/IntermittentProducerAutomaticStreamingTest.ValidateLastUpdateTimeOfStreamUpdated*:PermutatedStreamInfo/IntermittentProducerAutomaticStreamingTest.MultiTrackVerifyNoInvocationsWithSingleTrackProducer*:PermutatedStreamInfo/IntermittentProducerAutomaticStreamingTest.ValidateNoConsecutiveEOFR*:PermutatedStreamInfo/IntermittentProducerAutomaticStreamingTest.ValidateErrorOnForceConsecutiveEOFR*:*StreamStateTransitionsTest*:*PermutatedStreamInfo/StateTransitionFunctionalityTest.StreamTerminatedAndGoToGetEndpointState*:*PermutatedStreamInfo/StateTransitionFunctionalityTest.StreamTerminatedAndGoToDescribeState*:*PermutatedStreamInfo/StateTransitionFunctionalityTest*" + - name: Run tests + run: | + D:\a\amazon-kinesis-video-streams-pic\amazon-kinesis-video-streams-pic\build\tst\kvspic_test.exe --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*:PermutatedStreamInfo/StateTransitionFunctionalityTest.ControlPlaneServiceCallExhaustRetry*:PermutatedStreamInfo/IntermittentProducerAutomaticStreamingTest.ValidateTimerInvokedBeforeTime*:PermutatedStreamInfo/IntermittentProducerAutomaticStreamingTest.ValidateTimerInvokedAfterFirstPeriod*:PermutatedStreamInfo/IntermittentProducerAutomaticStreamingTest.ValidateLastUpdateTimeOfStreamUpdated*:PermutatedStreamInfo/IntermittentProducerAutomaticStreamingTest.MultiTrackVerifyNoInvocationsWithSingleTrackProducer*:PermutatedStreamInfo/IntermittentProducerAutomaticStreamingTest.ValidateNoConsecutiveEOFR*:PermutatedStreamInfo/IntermittentProducerAutomaticStreamingTest.ValidateErrorOnForceConsecutiveEOFR*:*StreamStateTransitionsTest*:*PermutatedStreamInfo/StateTransitionFunctionalityTest.StreamTerminatedAndGoToGetEndpointState*:*PermutatedStreamInfo/StateTransitionFunctionalityTest.StreamTerminatedAndGoToDescribeState*:*PermutatedStreamInfo/StateTransitionFunctionalityTest*" arm64-cross-compilation: runs-on: ubuntu-latest env: diff --git a/CMakeLists.txt b/CMakeLists.txt index d0e97c88c..0514f2720 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.6.3) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}") include(Utilities) -project(pic_project) +project(pic_project LANGUAGES C) include(GNUInstallDirs) @@ -111,8 +111,6 @@ file(GLOB PIC_UTILS_SOURCE_FILES "src/utils/src/*.c") file(GLOB PIC_VIEW_SOURCE_FILES "src/view/src/*.c") -file(GLOB PIC_TEST_SOURCE_FILES "src/*/tst/*.cpp") - file(GLOB PIC_HEADERS "${KINESIS_VIDEO_PIC_SRC}/src/*/include") include_directories(${PIC_HEADERS}) @@ -194,32 +192,5 @@ install( DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") if(BUILD_TEST) - set(CMAKE_CXX_STANDARD 11) - - if (OPEN_SRC_INSTALL_PREFIX) - find_package(GTest REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX}) - else() - find_package(GTest REQUIRED) - endif() - - SET(GTEST_LIBNAME GTest::gtest) - if (TARGET GTest::GTest) - SET(GTEST_LIBNAME GTest::GTest) - endif() - - add_executable(kvspic_test ${PIC_TEST_SOURCE_FILES} - ${PIC_CLIENT_SOURCE_FILES} - ${PIC_DURATION_SOURCE_FILES} - ${PIC_HEAP_SOURCE_FILES} - ${PIC_MKVGEN_SOURCE_FILES} - ${PIC_STATE_SOURCE_FILES} - ${PIC_TRACE_SOURCE_FILES} - ${PIC_UTILS_SOURCE_FILES} - ${PIC_VIEW_SOURCE_FILES}) - target_compile_definitions(kvspic_test PRIVATE ALIGNED_MEMORY_MODEL=TRUE FIXUP_ANNEX_B_TRAILING_NALU_ZERO=TRUE) - target_link_libraries(kvspic_test ${GTEST_LIBNAME} ${CMAKE_DL_LIBS} Threads::Threads) - if(UNIX AND NOT APPLE) - # rt needed for clock_gettime - target_link_libraries(kvspic_test rt) - endif() + add_subdirectory(tst) endif() diff --git a/README.md b/README.md index f82953bda..d95c8b057 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ If you wish to cross-compile `CC` and `CXX` are respected when building the libr You can pass the following options to `cmake ..` * `-DBUILD_DEPENDENCIES` -- Whether or not to build depending libraries from source -* `-DBUILD_TEST=TRUE` -- Build unit/integration tests, may be useful for confirm support for your device. `./kvspic_test` +* `-DBUILD_TEST=TRUE` -- Build unit/integration tests, may be useful for confirm support for your device. `./tst/kvspic_test` * `-DCODE_COVERAGE` -- Enable coverage reporting * `-DCOMPILER_WARNINGS` -- Enable all compiler warnings * `-DADDRESS_SANITIZER` -- Build with AddressSanitizer diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index fd1be3304..f4a1dd1c6 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.6.3) -project(client) +project(client LANGUAGES C) kinesis_video_library_setup(${PROJECT_NAME}) target_link_libraries(client mkvgen heap view utils state) kinesis_video_library_install() diff --git a/src/client/tst/CMakeLists.txt b/src/client/tst/CMakeLists.txt deleted file mode 100644 index 704d331d6..000000000 --- a/src/client/tst/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -project(PlatformIndependentNativeRepository LANGUAGES CXX) -get_filename_component(ROOT "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") - -project (clientTest) -file (GLOB ClientTestSources *.cpp) - -add_executable(${PROJECT_NAME} ${ClientTestSources}) -target_link_libraries(${PROJECT_NAME} state) -target_link_libraries(${PROJECT_NAME} client) -target_link_libraries(${PROJECT_NAME} gtest gtest_main) - -add_test(${PROJECT_NAME} ${PROJECT_NAME}) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 7265fdbb8..e5f4608dd 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.6.3) -project(common) +project(common LANGUAGES C) set(LIBRARY_NAME ${PROJECT_NAME}) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION . diff --git a/src/common/include/com/amazonaws/kinesis/video/common/CommonDefs.h b/src/common/include/com/amazonaws/kinesis/video/common/CommonDefs.h index fe9824945..75595c790 100644 --- a/src/common/include/com/amazonaws/kinesis/video/common/CommonDefs.h +++ b/src/common/include/com/amazonaws/kinesis/video/common/CommonDefs.h @@ -79,8 +79,10 @@ extern "C" { #if defined __APPLE__ #define __LLP64__ #else +#ifndef __LP64__ #define __LP64__ // Linux uses LP64 data model #endif +#endif #else #define SIZE_32 #endif @@ -232,6 +234,9 @@ typedef UINT64 MUTEX; #if defined __WINDOWS_BUILD__ typedef PCONDITION_VARIABLE CVAR; #else +#if defined(__linux__) && !defined(_GNU_SOURCE) +#define _GNU_SOURCE +#endif #include #include typedef pthread_cond_t* CVAR; diff --git a/src/duration/CMakeLists.txt b/src/duration/CMakeLists.txt index 6605f7817..073c2eca3 100644 --- a/src/duration/CMakeLists.txt +++ b/src/duration/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.6.3) -project(duration) +project(duration LANGUAGES C) kinesis_video_library_setup(${PROJECT_NAME}) kinesis_video_library_install() diff --git a/src/duration/tst/CMakeLists.txt b/src/duration/tst/CMakeLists.txt deleted file mode 100644 index a2ad22433..000000000 --- a/src/duration/tst/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required (VERSION 2.6) - -project (durationTest) -file (GLOB DurationTestSources *.cpp) - -add_executable(${PROJECT_NAME} ${DurationTestSources}) - -target_link_libraries(${PROJECT_NAME} duration) -target_link_libraries(${PROJECT_NAME} utils) -target_link_libraries(${PROJECT_NAME} gtest gtest_main) - -add_test(${PROJECT_NAME} ${PROJECT_NAME}) diff --git a/src/heap/CMakeLists.txt b/src/heap/CMakeLists.txt index c1d54419f..e218940ac 100644 --- a/src/heap/CMakeLists.txt +++ b/src/heap/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.6.3) -project(heap) +project(heap LANGUAGES C) kinesis_video_library_setup(${PROJECT_NAME}) target_link_libraries(heap utils) kinesis_video_library_install() \ No newline at end of file diff --git a/src/heap/src/HybridFileHeap.c b/src/heap/src/HybridFileHeap.c index e401ae8d3..70cb89b55 100644 --- a/src/heap/src/HybridFileHeap.c +++ b/src/heap/src/HybridFileHeap.c @@ -186,6 +186,7 @@ DEFINE_HEAP_ALLOC(hybridFileHeapAlloc) CHAR filePath[MAX_PATH_LEN + 1]; ALLOCATION_HEADER allocationHeader; ALLOCATION_HANDLE handle; + INT32 retCode; // Call the base class for the accounting retStatus = commonHeapAlloc(pHeap, size, pHandle); @@ -213,7 +214,9 @@ DEFINE_HEAP_ALLOC(hybridFileHeapAlloc) DLOGS("Allocating from File heap"); // Try to allocate from file storage - SPRINTF(filePath, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, pHybridHeap->handleNum); + retCode = + SNPRINTF(filePath, MAX_PATH_LEN + 1, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, pHybridHeap->handleNum); + CHK(retCode <= MAX_PATH_LEN, STATUS_PATH_TOO_LONG); // Create a file with the overall size CHK_STATUS(createFile(filePath, allocationSize)); @@ -268,7 +271,8 @@ DEFINE_HEAP_FREE(hybridFileHeapFree) DLOGS("Indirect allocation"); // Convert the handle and create the file path fileHandle = TO_FILE_HANDLE(handle); - SPRINTF(filePath, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); + retCode = SNPRINTF(filePath, MAX_PATH_LEN + 1, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); + CHK(retCode <= MAX_PATH_LEN, STATUS_PATH_TOO_LONG); retCode = FREMOVE(filePath); @@ -303,6 +307,7 @@ DEFINE_HEAP_GET_ALLOC_SIZE(hybridFileHeapGetAllocSize) ALLOCATION_HEADER allocationHeader; CHAR filePath[MAX_PATH_LEN + 1]; UINT32 fileHandle; + INT32 retCode; // Call the base class to ensure the params are ok and set the default ret values CHK_STATUS(commonHeapGetAllocSize(pHeap, handle, pAllocSize)); @@ -320,7 +325,9 @@ DEFINE_HEAP_GET_ALLOC_SIZE(hybridFileHeapGetAllocSize) fileHandle = TO_FILE_HANDLE(handle); DLOGS("File heap allocation. Handle 0x%016" PRIx64 " File handle 0x%08x", handle, fileHandle); - SPRINTF(filePath, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); + retCode = SNPRINTF(filePath, MAX_PATH_LEN + 1, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); + CHK(retCode <= MAX_PATH_LEN, STATUS_PATH_TOO_LONG); + CHK_STATUS(readFileSegment(filePath, TRUE, (PBYTE) &allocationHeader, 0, FILE_ALLOCATION_HEADER_SIZE)); // Set the values and return @@ -344,6 +351,7 @@ DEFINE_HEAP_SET_ALLOC_SIZE(hybridFileHeapSetAllocSize) CHAR filePath[MAX_PATH_LEN + 1]; UINT32 fileHandle; UINT64 overallSize; + INT32 retCode; // Call the base class to ensure the params are ok and set the default ret values CHK_STATUS(commonHeapSetAllocSize(pHeap, pHandle, size, newSize)); @@ -369,8 +377,8 @@ DEFINE_HEAP_SET_ALLOC_SIZE(hybridFileHeapSetAllocSize) fileHandle = TO_FILE_HANDLE(handle); DLOGS("Sets new allocation size %\" PRIu64 \" for handle 0x%016" PRIx64, newSize, handle); - SPRINTF(filePath, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); - + retCode = SNPRINTF(filePath, MAX_PATH_LEN + 1, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); + CHK(retCode <= MAX_PATH_LEN, STATUS_PATH_TOO_LONG); // Set the file size CHK_STATUS(setFileLength(filePath, overallSize)); @@ -405,6 +413,7 @@ DEFINE_HEAP_MAP(hybridFileHeapMap) UINT32 fileHandle; PALLOCATION_HEADER pAllocation = NULL; UINT64 fileLength; + INT32 retCode; // Call the base class to ensure the params are ok and set the default ret values CHK_STATUS(commonHeapMap(pHeap, handle, ppAllocation, pSize)); @@ -422,7 +431,8 @@ DEFINE_HEAP_MAP(hybridFileHeapMap) fileHandle = TO_FILE_HANDLE(handle); DLOGS("File heap allocation. Handle 0x%016" PRIx64 " File handle 0x%08x", handle, fileHandle); - SPRINTF(filePath, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); + retCode = SNPRINTF(filePath, MAX_PATH_LEN + 1, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); + CHK(retCode <= MAX_PATH_LEN, STATUS_PATH_TOO_LONG); // Get the file size, allocate and read the entire file into memory CHK_STATUS(getFileLength(filePath, &fileLength)); @@ -457,6 +467,7 @@ DEFINE_HEAP_UNMAP(hybridFileHeapUnmap) PHybridFileHeap pHybridHeap = (PHybridFileHeap) pHeap; PALLOCATION_HEADER pHeader = (PALLOCATION_HEADER) pAllocation - 1; CHAR filePath[MAX_PATH_LEN + 1]; + INT32 retCode; // Call the base class to ensure the params are ok CHK_STATUS(commonHeapUnmap(pHeap, pAllocation)); @@ -473,7 +484,9 @@ DEFINE_HEAP_UNMAP(hybridFileHeapUnmap) } DLOGS("Indirect allocation"); - SPRINTF(filePath, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, pHeader->fileHandle); + retCode = + SNPRINTF(filePath, MAX_PATH_LEN + 1, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, pHeader->fileHandle); + CHK(retCode <= MAX_PATH_LEN, STATUS_PATH_TOO_LONG); // Un-maping in this case is simply writing the content into the file storage and releasing the mapped memory CHK_STATUS(writeFile(filePath, TRUE, FALSE, (PBYTE) pHeader, pHeader->size + FILE_ALLOCATION_HEADER_SIZE)); @@ -507,6 +520,7 @@ DEFINE_ALLOC_SIZE(hybridFileGetAllocationSize) UINT32 fileHandle; ALLOCATION_HEADER allocationHeader; UINT64 memSizes, fileSizes, memHeapAllocationSize; + INT32 retCode; CHECK_EXT(pHeap != NULL, "Internal error with file heap being null"); @@ -521,7 +535,10 @@ DEFINE_ALLOC_SIZE(hybridFileGetAllocationSize) // In case of File allocation we need to read the header and get the size fileHandle = TO_FILE_HANDLE(handle); - SPRINTF(filePath, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); + retCode = SNPRINTF(filePath, MAX_PATH_LEN + 1, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); + if (retCode > MAX_PATH_LEN) { + DLOGW("filepath length has exceeded the maximum allowed"); + } // Read the header to get the size info so we can allocate enough storage if (STATUS_FAILED(readFileSegment(filePath, TRUE, (PBYTE) &allocationHeader, 0, FILE_ALLOCATION_HEADER_SIZE))) { diff --git a/src/heap/tst/CMakeLists.txt b/src/heap/tst/CMakeLists.txt deleted file mode 100644 index 470cb6e9f..000000000 --- a/src/heap/tst/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required (VERSION 2.6) - -project (heapTest) -file (GLOB HeapTestSources *.cpp) - -add_executable(${PROJECT_NAME} ${HeapTestSources}) - -target_link_libraries(${PROJECT_NAME} heap) -target_link_libraries(${PROJECT_NAME} utils) -target_link_libraries(${PROJECT_NAME} gtest gtest_main) - -add_test(${PROJECT_NAME} ${PROJECT_NAME}) diff --git a/src/mkvgen/CMakeLists.txt b/src/mkvgen/CMakeLists.txt index df3a42f0c..a1164533b 100644 --- a/src/mkvgen/CMakeLists.txt +++ b/src/mkvgen/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.6.3) -project(mkvgen) +project(mkvgen LANGUAGES C) kinesis_video_library_setup(${PROJECT_NAME}) target_link_libraries(mkvgen utils) kinesis_video_library_install() diff --git a/src/mkvgen/tst/CMakeLists.txt b/src/mkvgen/tst/CMakeLists.txt deleted file mode 100644 index afac93411..000000000 --- a/src/mkvgen/tst/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -project (mkvgenTest) -file (GLOB MkvgenTestSources *.cpp) -file(COPY samples DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - -add_executable(${PROJECT_NAME} ${MkvgenTestSources}) -target_link_libraries(${PROJECT_NAME} mkvgen) -target_link_libraries(${PROJECT_NAME} gtest gtest_main) - -add_test(${PROJECT_NAME} ${PROJECT_NAME}) diff --git a/src/state/CMakeLists.txt b/src/state/CMakeLists.txt index 9e38df1fa..4aa7edea0 100644 --- a/src/state/CMakeLists.txt +++ b/src/state/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.6.3) -project(state) +project(state LANGUAGES C) kinesis_video_library_setup(${PROJECT_NAME}) target_link_libraries(state mkvgen) kinesis_video_library_install() diff --git a/src/state/tst/CMakeLists.txt b/src/state/tst/CMakeLists.txt deleted file mode 100644 index 31c9a761c..000000000 --- a/src/state/tst/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -project (stateTest) -file (GLOB StateTestSources *.cpp) - -add_executable(${PROJECT_NAME} ${StateTestSources}) -target_link_libraries(${PROJECT_NAME} state) -target_link_libraries(${PROJECT_NAME} client) -target_link_libraries(${PROJECT_NAME} gtest gtest_main) - -add_test(${PROJECT_NAME} ${PROJECT_NAME}) diff --git a/src/trace/CMakeLists.txt b/src/trace/CMakeLists.txt index 8d2a7bcbb..6506e5707 100644 --- a/src/trace/CMakeLists.txt +++ b/src/trace/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.6.3) -project(trace) +project(trace LANGUAGES C) kinesis_video_library_setup(${PROJECT_NAME}) target_link_libraries(trace utils) kinesis_video_library_install() diff --git a/src/trace/tst/CMakeLists.txt b/src/trace/tst/CMakeLists.txt deleted file mode 100644 index 46c56028c..000000000 --- a/src/trace/tst/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -project (traceTest) -file (GLOB TraceTestSources *.cpp) - -add_executable(${PROJECT_NAME} ${TraceTestSources}) -target_link_libraries(${PROJECT_NAME} trace) -target_link_libraries(${PROJECT_NAME} gtest gtest_main) - -add_test(${PROJECT_NAME} ${PROJECT_NAME}) diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 13697d1e7..14800f8d1 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.6.3) -project(utils) +project(utils LANGUAGES C) kinesis_video_library_setup(${PROJECT_NAME}) target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS}) kinesis_video_library_install() diff --git a/src/utils/include/com/amazonaws/kinesis/video/utils/Include.h b/src/utils/include/com/amazonaws/kinesis/video/utils/Include.h index 7a6aeebef..a96d6f5b5 100644 --- a/src/utils/include/com/amazonaws/kinesis/video/utils/Include.h +++ b/src/utils/include/com/amazonaws/kinesis/video/utils/Include.h @@ -68,6 +68,7 @@ extern "C" { #define STATUS_EXPONENTIAL_BACKOFF_INVALID_STATE STATUS_UTILS_BASE + 0x0000002a #define STATUS_EXPONENTIAL_BACKOFF_RETRIES_EXHAUSTED STATUS_UTILS_BASE + 0x0000002b #define STATUS_THREADPOOL_MAX_COUNT STATUS_UTILS_BASE + 0x0000002c +#define STATUS_THREADPOOL_INTERNAL_ERROR STATUS_UTILS_BASE + 0x0000002d /** * Base64 encode/decode functionality diff --git a/src/utils/src/Allocators.c b/src/utils/src/Allocators.c index f402a9b98..6016eadb8 100644 --- a/src/utils/src/Allocators.c +++ b/src/utils/src/Allocators.c @@ -53,7 +53,7 @@ VOID dumpMemoryHex(PVOID pMem, UINT32 size) PCHAR pCur = buf; PBYTE pByte = (PBYTE) pMem; for (UINT32 i = 0; i < size; i++) { - SPRINTF(pCur, "%02x ", *pByte++); + SNPRINTF(pCur, 2, "%02x ", *pByte++); pCur += 3; if ((i + 1) % 16 == 0) { DLOGS("%s", buf); diff --git a/src/utils/src/Thread.c b/src/utils/src/Thread.c index 0cfe68942..b4fa7f2ec 100644 --- a/src/utils/src/Thread.c +++ b/src/utils/src/Thread.c @@ -122,7 +122,7 @@ PUBLIC_API STATUS defaultDetachThread(TID threadId) PUBLIC_API STATUS defaultGetThreadName(TID thread, PCHAR name, UINT32 len) { - UINT32 retValue; + INT32 retValue; if (NULL == name) { return STATUS_NULL_ARG; diff --git a/src/utils/src/Threadpool.c b/src/utils/src/Threadpool.c index 72af3dc27..edb38c473 100644 --- a/src/utils/src/Threadpool.c +++ b/src/utils/src/Threadpool.c @@ -141,25 +141,20 @@ STATUS threadpoolCreate(PThreadpool* ppThreadpool, UINT32 minThreads, UINT32 max STATUS retStatus = STATUS_SUCCESS; UINT32 i = 0; PThreadpool pThreadpool = NULL; - BOOL poolCreated = FALSE, mutexCreated = FALSE, listCreated = FALSE, queueCreated = FALSE; CHK(ppThreadpool != NULL, STATUS_NULL_ARG); CHK(minThreads <= maxThreads && minThreads > 0 && maxThreads > 0, STATUS_INVALID_ARG); pThreadpool = (PThreadpool) MEMCALLOC(1, SIZEOF(Threadpool)); CHK(pThreadpool != NULL, STATUS_NOT_ENOUGH_MEMORY); - poolCreated = TRUE; ATOMIC_STORE_BOOL(&pThreadpool->terminate, FALSE); ATOMIC_STORE(&pThreadpool->availableThreads, 0); pThreadpool->listMutex = MUTEX_CREATE(FALSE); - mutexCreated = TRUE; CHK_STATUS(safeBlockingQueueCreate(&pThreadpool->taskQueue)); - queueCreated = TRUE; CHK_STATUS(stackQueueCreate(&pThreadpool->threadList)); - listCreated = TRUE; pThreadpool->minThreads = minThreads; pThreadpool->maxThreads = maxThreads; @@ -206,7 +201,7 @@ STATUS threadpoolInternalCreateThread(PThreadpool pThreadpool) MUTEX_UNLOCK(pThreadpool->listMutex); locked = FALSE; - CHK_STATUS(THREAD_CREATE(&thread, threadpoolActor, data)); + CHK_STATUS(THREAD_CREATE(&thread, threadpoolActor, (PVOID) data)); CHK_STATUS(THREAD_DETACH(thread)); CleanUp: @@ -418,7 +413,7 @@ STATUS threadpoolInternalInactiveThreadCount(PThreadpool pThreadpool, PSIZE_T pC CHK_STATUS(safeBlockingQueueGetCount(pThreadpool->taskQueue, &pendingTasks)); unblockedThreads = (SIZE_T) ATOMIC_LOAD(&pThreadpool->availableThreads); - *pCount = unblockedThreads - (SIZE_T) pendingTasks; + *pCount = unblockedThreads > (SIZE_T) pendingTasks ? (unblockedThreads - (SIZE_T) pendingTasks) : 0; CleanUp: return retStatus; diff --git a/src/utils/tst/CMakeLists.txt b/src/utils/tst/CMakeLists.txt deleted file mode 100644 index 768217019..000000000 --- a/src/utils/tst/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -project (utilsTest) -file (GLOB UtilsTestSources *.cpp) - -add_executable(${PROJECT_NAME} ${UtilsTestSources}) -if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - target_link_libraries(${PROJECT_NAME} utils gtest gtest_main rt) -else() - target_link_libraries(${PROJECT_NAME} utils gtest gtest_main) -endif() -add_test(${PROJECT_NAME} ${PROJECT_NAME}) diff --git a/src/view/CMakeLists.txt b/src/view/CMakeLists.txt index 7e21be9a9..05f62f549 100644 --- a/src/view/CMakeLists.txt +++ b/src/view/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.6.3) -project(view) +project(view LANGUAGES C) kinesis_video_library_setup(${PROJECT_NAME}) target_link_libraries(view heap utils) kinesis_video_library_install() diff --git a/src/view/tst/CMakeLists.txt b/src/view/tst/CMakeLists.txt deleted file mode 100644 index 729b65606..000000000 --- a/src/view/tst/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -project (viewTest) -file (GLOB ViewTestSources *.cpp) - -add_executable(${PROJECT_NAME} ${ViewTestSources}) -target_link_libraries(${PROJECT_NAME} view) -target_link_libraries(${PROJECT_NAME} gtest gtest_main) - -add_test(${PROJECT_NAME} ${PROJECT_NAME}) diff --git a/tst/CMakeLists.txt b/tst/CMakeLists.txt new file mode 100644 index 000000000..403c10629 --- /dev/null +++ b/tst/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.6.3) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}") +include(Utilities) +project(pic_project_tests LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") + +if (OPEN_SRC_INSTALL_PREFIX) + find_package(GTest REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX}) +else() + find_package(GTest REQUIRED) +endif() + +SET(GTEST_LIBNAME GTest::gtest) +if (TARGET GTest::GTest) + SET(GTEST_LIBNAME GTest::GTest) +endif() + +file(GLOB PIC_TEST_SOURCE_FILES "*/*.cpp") + +# the root CMakeLists uses add_definitions if ALIGNED_MEMORY_MODEL or FIXUP_ANNEX_B_TRAILING_NALU_ZERO is set +# https://cmake.org/cmake/help/latest/command/add_definitions.html we build the test project by calling add_directory(tst) +# hence those definitions will be propagated to the test project as well to match the pic build, hence a rebuild +# of pic inside of the test project is not necessary + +add_executable(kvspic_test ${PIC_TEST_SOURCE_FILES}) +target_link_libraries(kvspic_test kvspic ${GTEST_LIBNAME} ${CMAKE_DL_LIBS} Threads::Threads) +if(UNIX AND NOT APPLE) + # rt needed for clock_gettime + target_link_libraries(kvspic_test rt) +endif() + +add_test(${PROJECT_NAME} ${PROJECT_NAME}) \ No newline at end of file diff --git a/src/client/tst/AcksFunctionalityTest.cpp b/tst/client/AcksFunctionalityTest.cpp similarity index 99% rename from src/client/tst/AcksFunctionalityTest.cpp rename to tst/client/AcksFunctionalityTest.cpp index d1e441810..3e048812d 100644 --- a/src/client/tst/AcksFunctionalityTest.cpp +++ b/tst/client/AcksFunctionalityTest.cpp @@ -21,7 +21,7 @@ class AcksFunctionalityTest : public ClientTestBase, mStreamInfo.streamCaps.replayDuration = (UINT64) replayDuration; } }; - +#ifdef ALIGNED_MEMORY_MODEL //Submit various types of error ACKs, Ensure the rollback is done from the ACK error time. TEST_P(AcksFunctionalityTest, CheckRollbackFromErrorAckTime) { @@ -306,3 +306,4 @@ TEST_P(AcksFunctionalityTest, CreateStreamSubmitACKsTerminatedUploadHandle) { INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, AcksFunctionalityTest, Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); +#endif \ No newline at end of file diff --git a/src/client/tst/CallbacksAndPressuresFunctionalityTest.cpp b/tst/client/CallbacksAndPressuresFunctionalityTest.cpp similarity index 99% rename from src/client/tst/CallbacksAndPressuresFunctionalityTest.cpp rename to tst/client/CallbacksAndPressuresFunctionalityTest.cpp index 3df3558f5..fd39e5f61 100644 --- a/src/client/tst/CallbacksAndPressuresFunctionalityTest.cpp +++ b/tst/client/CallbacksAndPressuresFunctionalityTest.cpp @@ -22,7 +22,7 @@ class CallbacksAndPressuresFunctionalityTest : public ClientTestBase, mStreamInfo.streamCaps.replayDuration = (UINT64) replayDuration; } }; - +#ifdef ALIGNED_MEMORY_MODEL TEST_P(CallbacksAndPressuresFunctionalityTest, CreateStreamLatencyPressureCallbackCalledSuccess) { BOOL didPutFrame; UINT64 currentTime, streamStopTime; @@ -213,3 +213,4 @@ TEST_P(CallbacksAndPressuresFunctionalityTest, CheckBlockedOfflinePutFrameReturn INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, CallbacksAndPressuresFunctionalityTest, Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); +#endif \ No newline at end of file diff --git a/src/client/tst/ClientApiFunctionalityTest.cpp b/tst/client/ClientApiFunctionalityTest.cpp similarity index 100% rename from src/client/tst/ClientApiFunctionalityTest.cpp rename to tst/client/ClientApiFunctionalityTest.cpp diff --git a/src/client/tst/ClientApiTest.cpp b/tst/client/ClientApiTest.cpp similarity index 99% rename from src/client/tst/ClientApiTest.cpp rename to tst/client/ClientApiTest.cpp index 74d697f6b..8ed78b387 100644 --- a/src/client/tst/ClientApiTest.cpp +++ b/tst/client/ClientApiTest.cpp @@ -419,13 +419,19 @@ TEST_F(ClientApiTest, kinesisVideoClientCreateSync_Store_Alloc) mClientSyncMode = TRUE; mDeviceInfo.clientInfo.createClientTimeout = 20 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; +#ifdef ALIGNED_MEMORY_MODEL mDeviceInfo.storageInfo.storageType = DEVICE_STORAGE_TYPE_IN_MEM_CONTENT_STORE_ALLOC; +#else + mDeviceInfo.storageInfo.storageType = DEVICE_STORAGE_TYPE_IN_MEM; +#endif EXPECT_EQ(STATUS_SUCCESS, createKinesisVideoClientSync(&mDeviceInfo, &mClientCallbacks, &clientHandle)); EXPECT_TRUE(IS_VALID_CLIENT_HANDLE(clientHandle)); +#ifdef ALIGNED_MEMORY_MODEL // Allocating another should fail EXPECT_NE(STATUS_SUCCESS, createKinesisVideoClientSync(&mDeviceInfo, &mClientCallbacks, &failedClientHandle)); EXPECT_FALSE(IS_VALID_CLIENT_HANDLE(failedClientHandle)); +#endif // Free the client and re-try EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoClient(&clientHandle)); diff --git a/src/client/tst/ClientFunctionalityTest.cpp b/tst/client/ClientFunctionalityTest.cpp similarity index 99% rename from src/client/tst/ClientFunctionalityTest.cpp rename to tst/client/ClientFunctionalityTest.cpp index af902c051..98367d8a7 100644 --- a/src/client/tst/ClientFunctionalityTest.cpp +++ b/tst/client/ClientFunctionalityTest.cpp @@ -20,6 +20,11 @@ class ClientFunctionalityTest : public ClientTestBase, mStreamInfo.streamCaps.streamingType = streamingType; mStreamInfo.streamCaps.fragmentAcks = enableAck; mStreamInfo.streamCaps.replayDuration = (UINT64) replayDuration; +#ifndef ALIGNED_MEMORY_MODEL + if (storageType == DEVICE_STORAGE_TYPE_IN_MEM_CONTENT_STORE_ALLOC) { + storageType = DEVICE_STORAGE_TYPE_IN_MEM; + } +#endif mDeviceInfo.storageInfo.storageType = storageType; } }; @@ -123,7 +128,7 @@ TEST_P(ClientFunctionalityTest, CreateClientCreateStreamSyncStopStreamFreeClient EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoClient(&mClientHandle)); EXPECT_TRUE(!IS_VALID_CLIENT_HANDLE(mClientHandle)); } - +#ifdef ALIGNED_MEMORY_MODEL //Create Producer, Create Streams, Await Ready, Put Frame, Free Producer TEST_P(ClientFunctionalityTest, CreateClientCreateStreamPutFrameFreeClient) { @@ -257,7 +262,7 @@ TEST_P(ClientFunctionalityTest, CreateClientCreateStreamSyncPutFrameStopStreamFr EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoClient(&mClientHandle)); EXPECT_TRUE(!IS_VALID_CLIENT_HANDLE(mClientHandle)); } - +#endif //Create producer, create streams sync, create same stream and fail, free client TEST_P(ClientFunctionalityTest, CreateClientCreateStreamSyncCreateSameStreamAndFailFreeClient) { diff --git a/src/client/tst/ClientTestFixture.cpp b/tst/client/ClientTestFixture.cpp similarity index 100% rename from src/client/tst/ClientTestFixture.cpp rename to tst/client/ClientTestFixture.cpp diff --git a/src/client/tst/ClientTestFixture.h b/tst/client/ClientTestFixture.h similarity index 99% rename from src/client/tst/ClientTestFixture.h rename to tst/client/ClientTestFixture.h index 95b23dab3..334a245e6 100644 --- a/src/client/tst/ClientTestFixture.h +++ b/tst/client/ClientTestFixture.h @@ -72,6 +72,7 @@ #define TEST_DEFAULT_PRODUCER_CONFIG_FRAME_SIZE 50000 #define TEST_DEFAULT_PRODUCER_CONFIG_FRAME_RATE 20 + #define PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE() \ if ((mStreamInfo.retention == 0 || !mStreamInfo.streamCaps.fragmentAcks) && mStreamInfo.streamCaps.streamingType == STREAMING_TYPE_OFFLINE) { \ EXPECT_EQ(STATUS_OFFLINE_MODE_WITH_ZERO_RETENTION, createKinesisVideoStreamSync(mClientHandle, &mStreamInfo, &mStreamHandle)); \ diff --git a/src/client/tst/FrameOrderCoordinatorTest.cpp b/tst/client/FrameOrderCoordinatorTest.cpp similarity index 100% rename from src/client/tst/FrameOrderCoordinatorTest.cpp rename to tst/client/FrameOrderCoordinatorTest.cpp diff --git a/src/client/tst/IntermittentProducerAutomaticStreamingTest.cpp b/tst/client/IntermittentProducerAutomaticStreamingTest.cpp similarity index 99% rename from src/client/tst/IntermittentProducerAutomaticStreamingTest.cpp rename to tst/client/IntermittentProducerAutomaticStreamingTest.cpp index d2f6824d1..b32b56f37 100644 --- a/src/client/tst/IntermittentProducerAutomaticStreamingTest.cpp +++ b/tst/client/IntermittentProducerAutomaticStreamingTest.cpp @@ -76,6 +76,8 @@ STATUS timerCallbackPreHook(UINT64 hookCustomData) return retStatus; }; +#ifdef ALIGNED_MEMORY_MODEL + TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerInvokedBeforeTime) { // Create new client so param value of callbackPeriod can be applied ASSERT_EQ(STATUS_SUCCESS, CreateClient()); @@ -138,7 +140,7 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerInvokedAfterFirs frame.frameData = temp; EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFrame(mStreamHandle, &frame)); - THREAD_SLEEP(INTERMITTENT_PRODUCER_TIMER_START_DELAY + 1.20 * mDeviceInfo.clientInfo.reservedCallbackPeriod); + THREAD_SLEEP(INTERMITTENT_PRODUCER_TIMER_START_DELAY + 1.50 * mDeviceInfo.clientInfo.reservedCallbackPeriod); EXPECT_EQ(2, ATOMIC_LOAD(&mTimerCallbackFuncCount)); } @@ -705,3 +707,5 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateMultiStream) { INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, IntermittentProducerAutomaticStreamingTest, Combine(Values(1000,2000,3000), Values(0, CLIENT_INFO_CURRENT_VERSION))); + +#endif \ No newline at end of file diff --git a/src/client/tst/IntermittentProducerFunctionalityTest.cpp b/tst/client/IntermittentProducerFunctionalityTest.cpp similarity index 99% rename from src/client/tst/IntermittentProducerFunctionalityTest.cpp rename to tst/client/IntermittentProducerFunctionalityTest.cpp index 823711111..8a5f172d0 100644 --- a/src/client/tst/IntermittentProducerFunctionalityTest.cpp +++ b/tst/client/IntermittentProducerFunctionalityTest.cpp @@ -21,7 +21,7 @@ class IntermittentProducerFunctionalityTest : public ClientTestBase, mStreamInfo.streamCaps.replayDuration = (UINT64) replayDuration; } }; - +#ifdef ALIGNED_MEMORY_MODEL TEST_P(IntermittentProducerFunctionalityTest, CreateSyncStreamWithLargeBufferAwaitForLastAckStopSyncFreeSuccess) { UINT64 currentTime, testTerminationTime, endPutFrameTime; BOOL didPutFrame, gotStreamData, submittedAck; @@ -132,3 +132,4 @@ TEST_P(IntermittentProducerFunctionalityTest, RepeatedCreateSyncStopSyncFree) INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, IntermittentProducerFunctionalityTest, Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); +#endif \ No newline at end of file diff --git a/src/client/tst/MockConsumer.cpp b/tst/client/MockConsumer.cpp similarity index 100% rename from src/client/tst/MockConsumer.cpp rename to tst/client/MockConsumer.cpp diff --git a/src/client/tst/MockConsumer.h b/tst/client/MockConsumer.h similarity index 100% rename from src/client/tst/MockConsumer.h rename to tst/client/MockConsumer.h diff --git a/src/client/tst/MockProducer.cpp b/tst/client/MockProducer.cpp similarity index 100% rename from src/client/tst/MockProducer.cpp rename to tst/client/MockProducer.cpp diff --git a/src/client/tst/MockProducer.h b/tst/client/MockProducer.h similarity index 100% rename from src/client/tst/MockProducer.h rename to tst/client/MockProducer.h diff --git a/src/client/tst/StateTransitionFunctionalityTest.cpp b/tst/client/StateTransitionFunctionalityTest.cpp similarity index 99% rename from src/client/tst/StateTransitionFunctionalityTest.cpp rename to tst/client/StateTransitionFunctionalityTest.cpp index b396c02d9..f717dd603 100644 --- a/src/client/tst/StateTransitionFunctionalityTest.cpp +++ b/tst/client/StateTransitionFunctionalityTest.cpp @@ -247,7 +247,7 @@ TEST_P(StateTransitionFunctionalityTest, ControlPlaneServiceCallExhaustRetry) TEST_AUTH_EXPIRATION)); freeKinesisVideoStream(&mStreamHandle); } - +#ifdef ALIGNED_MEMORY_MODEL // check that kinesisVideoStreamTerminated with certain service call results should move to getEndpoint state TEST_P(StateTransitionFunctionalityTest, StreamTerminatedAndGoToGetEndpointState) { @@ -573,6 +573,7 @@ TEST_P(StateTransitionFunctionalityTest, basicResetConnectionTest) { VerifyStopStreamSyncAndFree(); } +#endif TEST_P(StateTransitionFunctionalityTest, TestExecutionOfStreamStateMachineErrorHandlerOnErrors) { diff --git a/src/client/tst/StreamApiFunctionalityScenarioTest.cpp b/tst/client/StreamApiFunctionalityScenarioTest.cpp similarity index 99% rename from src/client/tst/StreamApiFunctionalityScenarioTest.cpp rename to tst/client/StreamApiFunctionalityScenarioTest.cpp index 329f62295..db63b94e8 100644 --- a/src/client/tst/StreamApiFunctionalityScenarioTest.cpp +++ b/tst/client/StreamApiFunctionalityScenarioTest.cpp @@ -22,6 +22,8 @@ class StreamApiFunctionalityScenarioTest : public ClientTestBase, } }; +#ifdef ALIGNED_MEMORY_MODEL + /* * Testing basic token rotation. The test was given enough time for 1 token rotations plus 2 seconds extra. * When the given time ran out, we should have observed 3 token rotations taken place. if timedGetStreamData returns @@ -515,3 +517,5 @@ TEST_P(StreamApiFunctionalityScenarioTest, TokenRotationBasicMultiTrackPassThrou INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, StreamApiFunctionalityScenarioTest, Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); + +#endif \ No newline at end of file diff --git a/src/client/tst/StreamApiFunctionalityTest.cpp b/tst/client/StreamApiFunctionalityTest.cpp similarity index 99% rename from src/client/tst/StreamApiFunctionalityTest.cpp rename to tst/client/StreamApiFunctionalityTest.cpp index f510cff22..43e3161b8 100644 --- a/src/client/tst/StreamApiFunctionalityTest.cpp +++ b/tst/client/StreamApiFunctionalityTest.cpp @@ -134,6 +134,7 @@ TEST_F(StreamApiFunctionalityTest, streamFormatChange_stateCheck) // Ensure we can successfully set the CPD EXPECT_EQ(STATUS_SUCCESS, kinesisVideoStreamFormatChanged(mStreamHandle, SIZEOF(cpd), cpd, TEST_TRACKID)); +#ifdef ALIGNED_MEMORY_MODEL for (i = 0, timestamp = 0; i < 20; timestamp += TEST_FRAME_DURATION, i++) { frame.index = i; frame.decodingTs = timestamp; @@ -155,6 +156,7 @@ TEST_F(StreamApiFunctionalityTest, streamFormatChange_stateCheck) // Setting CPD should fail EXPECT_NE(STATUS_SUCCESS, kinesisVideoStreamFormatChanged(mStreamHandle, SIZEOF(cpd), cpd, TEST_TRACKID)); } +#endif } TEST_F(StreamApiFunctionalityTest, setNalAdaptionFlags_stateCheck) @@ -211,6 +213,7 @@ TEST_F(StreamApiFunctionalityTest, setNalAdaptionFlags_stateCheck) EXPECT_EQ(nalFlags, pKinesisVideoStream->streamInfo.streamCaps.nalAdaptationFlags); EXPECT_EQ(MKV_NALS_ADAPT_NONE, ((PStreamMkvGenerator) pKinesisVideoStream->pMkvGenerator)->nalsAdaptation); +#ifdef ALIGNED_MEMORY_MODEL for (i = 0, timestamp = 0; i < 20; timestamp += TEST_FRAME_DURATION, i++) { frame.index = i; frame.decodingTs = timestamp; @@ -232,8 +235,10 @@ TEST_F(StreamApiFunctionalityTest, setNalAdaptionFlags_stateCheck) // Setting NAL flags should fail EXPECT_NE(STATUS_SUCCESS, kinesisVideoStreamSetNalAdaptationFlags(mStreamHandle, nalFlags)); } +#endif } +#ifdef ALIGNED_MEMORY_MODEL TEST_F(StreamApiFunctionalityTest, putFrame_BasicPutTestItemLimit) { UINT32 i, maxIteration; @@ -1747,29 +1752,6 @@ TEST_F(StreamApiFunctionalityTest, submitAck_shouldBeInWindowAfterErrorAck) MEMFREE(getDataBuffer); } -TEST_F(StreamApiFunctionalityTest, putFrame_AdaptAnnexB) -{ - BYTE frameData[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x1e, - 0xa9, 0x50, 0x14, 0x07, 0xb4, 0x20, 0x00, 0x00, - 0x7d, 0x00, 0x00, 0x1d, 0x4c, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x01, 0x68, 0xce, 0x3c, 0x80}; - UINT32 frameDataSize = SIZEOF(frameData); - Frame frame; - - // Create and ready a stream - ReadyStream(); - - frame.index = 0; - frame.decodingTs = 0; - frame.presentationTs = 0; - frame.duration = TEST_FRAME_DURATION; - frame.size = frameDataSize; - frame.trackId = TEST_TRACKID; - frame.frameData = frameData; - frame.flags = FRAME_FLAG_KEY_FRAME; - EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFrame(mStreamHandle, &frame)); -} - TEST_F(StreamApiFunctionalityTest, PutGet_ConnectionStaleNotification) { UINT32 i, filledSize; @@ -1827,6 +1809,8 @@ TEST_F(StreamApiFunctionalityTest, PutGet_ConnectionStaleNotification) } } +#endif + extern UINT64 gPresetCurrentTime; TEST_F(StreamApiFunctionalityTest, streamingTokenJitter_none) { @@ -1985,3 +1969,26 @@ TEST_F(StreamApiFunctionalityTest, streamingTokenJitter_preset_max) EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoClient(&clientHandle)); } + +TEST_F(StreamApiFunctionalityTest, putFrame_AdaptAnnexB) +{ + BYTE frameData[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x1e, + 0xa9, 0x50, 0x14, 0x07, 0xb4, 0x20, 0x00, 0x00, + 0x7d, 0x00, 0x00, 0x1d, 0x4c, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x01, 0x68, 0xce, 0x3c, 0x80}; + UINT32 frameDataSize = SIZEOF(frameData); + Frame frame; + + // Create and ready a stream + ReadyStream(); + + frame.index = 0; + frame.decodingTs = 0; + frame.presentationTs = 0; + frame.duration = TEST_FRAME_DURATION; + frame.size = frameDataSize; + frame.trackId = TEST_TRACKID; + frame.frameData = frameData; + frame.flags = FRAME_FLAG_KEY_FRAME; + EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFrame(mStreamHandle, &frame)); +} \ No newline at end of file diff --git a/src/client/tst/StreamApiServiceCallsTest.cpp b/tst/client/StreamApiServiceCallsTest.cpp similarity index 100% rename from src/client/tst/StreamApiServiceCallsTest.cpp rename to tst/client/StreamApiServiceCallsTest.cpp diff --git a/src/client/tst/StreamApiTest.cpp b/tst/client/StreamApiTest.cpp similarity index 99% rename from src/client/tst/StreamApiTest.cpp rename to tst/client/StreamApiTest.cpp index d5e68c386..9c8ff78b6 100644 --- a/src/client/tst/StreamApiTest.cpp +++ b/tst/client/StreamApiTest.cpp @@ -384,6 +384,7 @@ TEST_F(StreamApiTest, insertKinesisVideoEvent_NULL_Invalid) EXPECT_EQ(STATUS_INVALID_ARG, putKinesisVideoEventMetadata(mStreamHandle, STREAM_EVENT_TYPE_LAST + rand() % STREAM_EVENT_TYPE_LAST, &Meta)); } +#ifdef ALIGNED_MEMORY_MODEL TEST_F(StreamApiTest, insertKinesisVideoEvent_Invalid_Length) { StreamEventMetadata Meta{STREAM_EVENT_METADATA_CURRENT_VERSION, NULL, 1, {}, {}}; @@ -447,26 +448,6 @@ TEST_F(StreamApiTest, insertKinesisVideoEvent_Invalid_Length) } -TEST_F(StreamApiTest, insertKinesisVideoTag_Invalid_Name) -{ - // Create and ready stream - ReadyStream(); - - EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWS", (PCHAR) "Tag Value", FALSE)); - EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWS", (PCHAR) "Tag Value", TRUE)); - EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWS ", (PCHAR) "Tag Value", FALSE)); - EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWS ", (PCHAR) "Tag Value", TRUE)); - EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWSTag", (PCHAR) "Tag Value", FALSE)); - EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWSTag", (PCHAR) "Tag Value", TRUE)); - EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWS:", (PCHAR) "Tag Value", FALSE)); - EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWS:", (PCHAR) "Tag Value", TRUE)); - - EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "aWS", (PCHAR) "Tag Value", FALSE)); - EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "aWS", (PCHAR) "Tag Value", TRUE)); - EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "aws", (PCHAR) "Tag Value", FALSE)); - EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "aws", (PCHAR) "Tag Value", TRUE)); -} - TEST_F(StreamApiTest, insertKinesisVideoEvent_Invalid_Name) { StreamEventMetadata Meta{STREAM_EVENT_METADATA_CURRENT_VERSION, NULL, 1, {}, {}}; @@ -512,6 +493,27 @@ TEST_F(StreamApiTest, insertKinesisVideoEvent_Invalid_Name) MEMCPY(tagName, (PCHAR) "aws", STRLEN("aws")); EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoEventMetadata(mStreamHandle, STREAM_EVENT_TYPE_IMAGE_GENERATION, &Meta)); } +#endif + +TEST_F(StreamApiTest, insertKinesisVideoTag_Invalid_Name) +{ + // Create and ready stream + ReadyStream(); + + EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWS", (PCHAR) "Tag Value", FALSE)); + EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWS", (PCHAR) "Tag Value", TRUE)); + EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWS ", (PCHAR) "Tag Value", FALSE)); + EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWS ", (PCHAR) "Tag Value", TRUE)); + EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWSTag", (PCHAR) "Tag Value", FALSE)); + EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWSTag", (PCHAR) "Tag Value", TRUE)); + EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWS:", (PCHAR) "Tag Value", FALSE)); + EXPECT_EQ(STATUS_INVALID_METADATA_NAME, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "AWS:", (PCHAR) "Tag Value", TRUE)); + + EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "aWS", (PCHAR) "Tag Value", FALSE)); + EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "aWS", (PCHAR) "Tag Value", TRUE)); + EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "aws", (PCHAR) "Tag Value", FALSE)); + EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFragmentMetadata(mStreamHandle, (PCHAR) "aws", (PCHAR) "Tag Value", TRUE)); +} TEST_F(StreamApiTest, insertKinesisVideoTag_Stream_State_Error) { @@ -748,6 +750,7 @@ PVOID streamStopNotifier(PVOID arg) return NULL; } +#ifdef ALIGNED_MEMORY_MODEL TEST_F(StreamApiTest, kinesisVideoStreamCreateSync_Valid) { freeKinesisVideoStream(&mStreamHandle); @@ -777,26 +780,6 @@ TEST_F(StreamApiTest, kinesisVideoStreamCreateSync_Valid) EXPECT_EQ(STATUS_SUCCESS, stopKinesisVideoStreamSync(mStreamHandle)); } -TEST_F(StreamApiTest, kinesisVideoStreamCreateSync_Valid_Timeout) -{ - CLIENT_HANDLE clientHandle; - - // Create a client with appropriate timeout so we don't block on test. - mClientSyncMode = TRUE; - mDeviceInfo.clientInfo.createStreamTimeout = 20 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; - EXPECT_EQ(STATUS_SUCCESS, createKinesisVideoClientSync(&mDeviceInfo, &mClientCallbacks, &clientHandle)); - - // Create synchronously - EXPECT_EQ(STATUS_OPERATION_TIMED_OUT, createKinesisVideoStreamSync(clientHandle, &mStreamInfo, &mStreamHandle)); - - EXPECT_FALSE(IS_VALID_STREAM_HANDLE(mStreamHandle)); - - // Stop synchronously - will fail as we should have invalid handle - EXPECT_NE(STATUS_SUCCESS, stopKinesisVideoStreamSync(mStreamHandle)); - - EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoClient(&clientHandle)); -} - TEST_F(StreamApiTest, kinesisVideoStreamCreateSyncStopSync_Valid_Timeout) { CLIENT_HANDLE clientHandle; @@ -827,3 +810,25 @@ TEST_F(StreamApiTest, kinesisVideoStreamCreateSyncStopSync_Valid_Timeout) EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoClient(&clientHandle)); } + +#endif + +TEST_F(StreamApiTest, kinesisVideoStreamCreateSync_Valid_Timeout) +{ + CLIENT_HANDLE clientHandle; + + // Create a client with appropriate timeout so we don't block on test. + mClientSyncMode = TRUE; + mDeviceInfo.clientInfo.createStreamTimeout = 20 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; + EXPECT_EQ(STATUS_SUCCESS, createKinesisVideoClientSync(&mDeviceInfo, &mClientCallbacks, &clientHandle)); + + // Create synchronously + EXPECT_EQ(STATUS_OPERATION_TIMED_OUT, createKinesisVideoStreamSync(clientHandle, &mStreamInfo, &mStreamHandle)); + + EXPECT_FALSE(IS_VALID_STREAM_HANDLE(mStreamHandle)); + + // Stop synchronously - will fail as we should have invalid handle + EXPECT_NE(STATUS_SUCCESS, stopKinesisVideoStreamSync(mStreamHandle)); + + EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoClient(&clientHandle)); +} \ No newline at end of file diff --git a/src/client/tst/StreamDeviceTagsTest.cpp b/tst/client/StreamDeviceTagsTest.cpp similarity index 100% rename from src/client/tst/StreamDeviceTagsTest.cpp rename to tst/client/StreamDeviceTagsTest.cpp diff --git a/src/client/tst/StreamFunctionalityTest.cpp b/tst/client/StreamFunctionalityTest.cpp similarity index 99% rename from src/client/tst/StreamFunctionalityTest.cpp rename to tst/client/StreamFunctionalityTest.cpp index d25f656f2..d894c481f 100644 --- a/src/client/tst/StreamFunctionalityTest.cpp +++ b/tst/client/StreamFunctionalityTest.cpp @@ -58,7 +58,7 @@ TEST_P(StreamFunctionalityTest, CreateSyncStopSyncFreePutFrameFail) { MockProducer mockProducer(mMockProducerConfig, mStreamHandle); EXPECT_NE(STATUS_SUCCESS, mockProducer.putFrame()); } - +#ifdef ALIGNED_MEMORY_MODEL TEST_P(StreamFunctionalityTest, CreateAwaitReadyPutFrameFree) { PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); @@ -298,6 +298,7 @@ TEST_P(StreamFunctionalityTest, CreateSyncPutFrameEoFRFirstForceNotSkipping) EXPECT_EQ(0, streamMetrics.skippedFrames); // There should be no mem leaks } +#endif // Validate StreamDescription_V0 structure handling TEST_P(StreamFunctionalityTest, StreamDescription_V0_Test) diff --git a/src/client/tst/StreamParallelTest.cpp b/tst/client/StreamParallelTest.cpp similarity index 99% rename from src/client/tst/StreamParallelTest.cpp rename to tst/client/StreamParallelTest.cpp index 3fa31a9bc..5b99c37c8 100644 --- a/src/client/tst/StreamParallelTest.cpp +++ b/tst/client/StreamParallelTest.cpp @@ -98,7 +98,7 @@ PVOID ClientTestBase::basicConsumerRoutine(UINT64 streamId) return NULL; } - +#ifdef ALIGNED_MEMORY_MODEL TEST_F(StreamParallelTest, putFrame_BasicParallelPutGet) { UINT32 index; @@ -188,3 +188,4 @@ TEST_F(StreamParallelTest, putFrame_BasicParallelPutGet) EXPECT_EQ(STATUS_SUCCESS, THREAD_JOIN(mConsumerThreads[index], NULL)); } } +#endif diff --git a/src/client/tst/StreamPutGetTest.cpp b/tst/client/StreamPutGetTest.cpp similarity index 99% rename from src/client/tst/StreamPutGetTest.cpp rename to tst/client/StreamPutGetTest.cpp index 6d6122dd3..ff84b9581 100644 --- a/src/client/tst/StreamPutGetTest.cpp +++ b/tst/client/StreamPutGetTest.cpp @@ -2,7 +2,7 @@ class StreamPutGetTest : public ClientTestBase { }; - +#ifdef ALIGNED_MEMORY_MODEL TEST_F(StreamPutGetTest, putFrame_PutGetFrameBoundary) { UINT32 i, j, filledSize, offset, bufferSize; @@ -1735,3 +1735,4 @@ TEST_F(StreamPutGetTest, putFrame_PutGetPersistentTagsStoreData) MEMFREE(getDataBuffer); } +#endif \ No newline at end of file diff --git a/src/client/tst/StreamRecoveryFunctionalityTest.cpp b/tst/client/StreamRecoveryFunctionalityTest.cpp similarity index 99% rename from src/client/tst/StreamRecoveryFunctionalityTest.cpp rename to tst/client/StreamRecoveryFunctionalityTest.cpp index 0057eabdd..426a27de1 100644 --- a/src/client/tst/StreamRecoveryFunctionalityTest.cpp +++ b/tst/client/StreamRecoveryFunctionalityTest.cpp @@ -22,7 +22,7 @@ class StreamRecoveryFunctionalityTest : public ClientTestBase, mStreamInfo.streamCaps.replayDuration = (UINT64) replayDuration; } }; - +#ifdef ALIGNED_MEMORY_MODEL TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamResetConnectionEnsureRecovery) { std::vector currentUploadHandles; @@ -1349,3 +1349,5 @@ TEST_P(StreamRecoveryFunctionalityTest, EventMetadataStartStreamFailRecovery) { INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, StreamRecoveryFunctionalityTest, Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); + +#endif \ No newline at end of file diff --git a/src/client/tst/StreamStateTransitionsTest.cpp b/tst/client/StreamStateTransitionsTest.cpp similarity index 99% rename from src/client/tst/StreamStateTransitionsTest.cpp rename to tst/client/StreamStateTransitionsTest.cpp index 937210170..ba3ba8167 100644 --- a/src/client/tst/StreamStateTransitionsTest.cpp +++ b/tst/client/StreamStateTransitionsTest.cpp @@ -71,7 +71,7 @@ TEST_F(StreamStateTransitionsTest, stopStateFromGetToken) EXPECT_EQ(STATUS_SUCCESS, kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_RESULT_OK)); } - +#ifdef ALIGNED_MEMORY_MODEL TEST_F(StreamStateTransitionsTest, stopStateFromStreamingSuccessRecovery) { UINT32 i, remaining; @@ -1047,3 +1047,4 @@ TEST_F(StreamStateTransitionsTest, stopStateFromStreamingOtherNoRecovery) EXPECT_EQ(STATUS_SERVICE_CALL_DEVICE_NOT_FOND_ERROR, kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_DEVICE_NOT_FOUND)); } +#endif \ No newline at end of file diff --git a/src/client/tst/StreamStoppingFunctionalityTest.cpp b/tst/client/StreamStoppingFunctionalityTest.cpp similarity index 98% rename from src/client/tst/StreamStoppingFunctionalityTest.cpp rename to tst/client/StreamStoppingFunctionalityTest.cpp index 38e111570..b21f801db 100644 --- a/src/client/tst/StreamStoppingFunctionalityTest.cpp +++ b/tst/client/StreamStoppingFunctionalityTest.cpp @@ -23,6 +23,27 @@ class StreamStoppingFunctionalityTest : public ClientTestBase, } }; +TEST_P(StreamStoppingFunctionalityTest, CreateSyncResetConnectionSuccess) +{ + PStateMachineState pState; + CreateScenarioTestClient(); + + PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); + + CreateStreamSync(); + + // stream state should be STREAM_STATE_READY at this point. + PKinesisVideoStream pKinesisVideoStream = fromStreamHandle(mStreamHandle); + + // kinesisVideoStreamTerminated should succeed but have no effect on stream state because stream state is STREAM_STATE_READY + kinesisVideoStreamTerminated(mStreamHandle, INVALID_UPLOAD_HANDLE_VALUE, SERVICE_CALL_RESULT_OK); + + EXPECT_EQ(STATUS_SUCCESS, getStateMachineCurrentState(pKinesisVideoStream->base.pStateMachine, &pState)); + EXPECT_TRUE(pState->state == STREAM_STATE_READY); +} + +#ifdef ALIGNED_MEMORY_MODEL + TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamWithTwoUploadHandlesStopSyncFreeSuccess) { UINT64 currentTime, testTerminationTime; @@ -38,7 +59,7 @@ TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamWithTwoUploadHandlesStop CreateStreamSync(); testTerminationTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) - + 2 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 15 * HUNDREDS_OF_NANOS_IN_A_SECOND; + + 2 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 15 * HUNDREDS_OF_NANOS_IN_A_SECOND; MockProducer mockProducer(mMockProducerConfig, mStreamHandle); @@ -67,24 +88,6 @@ TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamWithTwoUploadHandlesStop VerifyStopStreamSyncAndFree(); } -TEST_P(StreamStoppingFunctionalityTest, CreateSyncResetConnectionSuccess) -{ - PStateMachineState pState; - CreateScenarioTestClient(); - - PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); - - CreateStreamSync(); - - // stream state should be STREAM_STATE_READY at this point. - PKinesisVideoStream pKinesisVideoStream = fromStreamHandle(mStreamHandle); - - // kinesisVideoStreamTerminated should succeed but have no effect on stream state because stream state is STREAM_STATE_READY - kinesisVideoStreamTerminated(mStreamHandle, INVALID_UPLOAD_HANDLE_VALUE, SERVICE_CALL_RESULT_OK); - - EXPECT_EQ(STATUS_SUCCESS, getStateMachineCurrentState(pKinesisVideoStream->base.pStateMachine, &pState)); - EXPECT_TRUE(pState->state == STREAM_STATE_READY); -} TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamHighDensityStopSyncTimeoutFreeSuccess) { std::vector currentUploadHandles; @@ -242,5 +245,7 @@ TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamStopSyncErrorAckWhileStr EXPECT_EQ(0, ATOMIC_LOAD(&mDroppedFrameReportFuncCount)); } +#endif + INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, StreamStoppingFunctionalityTest, Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); diff --git a/src/client/tst/StreamTokenRotationTest.cpp b/tst/client/StreamTokenRotationTest.cpp similarity index 99% rename from src/client/tst/StreamTokenRotationTest.cpp rename to tst/client/StreamTokenRotationTest.cpp index 4be03d609..5cd1a773e 100644 --- a/src/client/tst/StreamTokenRotationTest.cpp +++ b/tst/client/StreamTokenRotationTest.cpp @@ -48,6 +48,8 @@ STATUS testPutStream(UINT64 customData, return STATUS_SUCCESS; } +#ifdef ALIGNED_MEMORY_MODEL + TEST_F(StreamTokenRotationTest, basicTokenRotationNonPersistAwait) { UINT32 i, filledSize, rotation, lastRotation; @@ -351,3 +353,4 @@ TEST_F(StreamTokenRotationTest, rotationWithAwaitingCheck) } MEMFREE(emptyTagValue); } +#endif \ No newline at end of file diff --git a/src/client/tst/StreamingSession.cpp b/tst/client/StreamingSession.cpp similarity index 100% rename from src/client/tst/StreamingSession.cpp rename to tst/client/StreamingSession.cpp diff --git a/src/client/tst/StreamingSession.h b/tst/client/StreamingSession.h similarity index 100% rename from src/client/tst/StreamingSession.h rename to tst/client/StreamingSession.h diff --git a/src/client/tst/TokenRotationFunctionalityTest.cpp b/tst/client/TokenRotationFunctionalityTest.cpp similarity index 99% rename from src/client/tst/TokenRotationFunctionalityTest.cpp rename to tst/client/TokenRotationFunctionalityTest.cpp index 3445bd6dc..f801e2307 100644 --- a/src/client/tst/TokenRotationFunctionalityTest.cpp +++ b/tst/client/TokenRotationFunctionalityTest.cpp @@ -23,6 +23,7 @@ class TokenRotationFunctionalityTest : public ClientTestBase, } }; +#ifdef ALIGNED_MEMORY_MODEL TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamWithResultEventAfterGracePeriodStopFreeSuccess) { UINT64 currentTime, testTerminationTime, startTestTime, stopPutFrameTime, @@ -319,3 +320,4 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamAtTokenRotationLongDelayF INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, TokenRotationFunctionalityTest, Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); +#endif \ No newline at end of file diff --git a/src/duration/tst/DurationTest.cpp b/tst/duration/DurationTest.cpp similarity index 100% rename from src/duration/tst/DurationTest.cpp rename to tst/duration/DurationTest.cpp diff --git a/src/heap/tst/HeapApiFunctionalityTest.cpp b/tst/heap/HeapApiFunctionalityTest.cpp similarity index 99% rename from src/heap/tst/HeapApiFunctionalityTest.cpp rename to tst/heap/HeapApiFunctionalityTest.cpp index c74950e0e..7c44afd8b 100644 --- a/src/heap/tst/HeapApiFunctionalityTest.cpp +++ b/tst/heap/HeapApiFunctionalityTest.cpp @@ -358,7 +358,7 @@ TEST_F(HeapApiFunctionalityTest, SingleLargeAlloc) EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_SYSTEM_HEAP, NULL, &pHeap))); singleLargeAlloc(pHeap); } - +#ifdef ALIGNED_MEMORY_MODEL TEST_F(HeapApiFunctionalityTest, MultipleLargeAlloc) { PHeap pHeap; @@ -370,14 +370,6 @@ TEST_F(HeapApiFunctionalityTest, MultipleLargeAlloc) multipleLargeAlloc(pHeap); } -TEST_F(HeapApiFunctionalityTest, DefragmentationAlloc) -{ - PHeap pHeap; - - EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_AIV_HEAP, NULL, &pHeap))); - defragmentationAlloc(pHeap); -} - TEST_F(HeapApiFunctionalityTest, SingleByteAlloc) { PHeap pHeap; @@ -415,11 +407,7 @@ TEST_F(HeapApiFunctionalityTest, AivHeapUnalignedHeapLimit) PHeap pHeap; EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(MIN_HEAP_SIZE + 1, 20, FLAGS_USE_AIV_HEAP, NULL, &pHeap))); -#ifdef ALIGNED_MEMORY_MODEL EXPECT_EQ(MIN_HEAP_SIZE + 8, pHeap->heapLimit); -#else - EXPECT_EQ(MIN_HEAP_SIZE + 1, pHeap->heapLimit); -#endif EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } @@ -677,6 +665,15 @@ TEST_F(HeapApiFunctionalityTest, AivHeapResizeUpDownTopDown) EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } +#endif + +TEST_F(HeapApiFunctionalityTest, DefragmentationAlloc) +{ + PHeap pHeap; + + EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_AIV_HEAP, NULL, &pHeap))); + defragmentationAlloc(pHeap); +} TEST_F(HeapApiFunctionalityTest, MultipleMapUnmapByteAlloc) { diff --git a/src/heap/tst/HeapApiTest.cpp b/tst/heap/HeapApiTest.cpp similarity index 100% rename from src/heap/tst/HeapApiTest.cpp rename to tst/heap/HeapApiTest.cpp diff --git a/src/heap/tst/HeapPerfTest.cpp b/tst/heap/HeapPerfTest.cpp similarity index 100% rename from src/heap/tst/HeapPerfTest.cpp rename to tst/heap/HeapPerfTest.cpp diff --git a/src/heap/tst/HeapTestFixture.cpp b/tst/heap/HeapTestFixture.cpp similarity index 100% rename from src/heap/tst/HeapTestFixture.cpp rename to tst/heap/HeapTestFixture.cpp diff --git a/src/heap/tst/HeapTestFixture.h b/tst/heap/HeapTestFixture.h similarity index 100% rename from src/heap/tst/HeapTestFixture.h rename to tst/heap/HeapTestFixture.h diff --git a/src/heap/tst/HybridFileHeapTest.cpp b/tst/heap/HybridFileHeapTest.cpp similarity index 97% rename from src/heap/tst/HybridFileHeapTest.cpp rename to tst/heap/HybridFileHeapTest.cpp index 3bc3bb7fe..d28265723 100644 --- a/src/heap/tst/HybridFileHeapTest.cpp +++ b/tst/heap/HybridFileHeapTest.cpp @@ -14,6 +14,11 @@ class HybridFileHeapTest : public HeapTestBase, HEAP_BEHAVIOR_FLAGS primaryHeapType; std::tie(primaryHeapType) = GetParam(); +#ifndef ALIGNED_MEMORY_MODEL + if (primaryHeapType == FLAGS_USE_AIV_HEAP) { + primaryHeapType = FLAGS_USE_SYSTEM_HEAP; + } +#endif mHeapType = primaryHeapType | FLAGS_USE_HYBRID_FILE_HEAP; } diff --git a/src/heap/tst/HybridHeapTest.cpp b/tst/heap/HybridHeapTest.cpp similarity index 100% rename from src/heap/tst/HybridHeapTest.cpp rename to tst/heap/HybridHeapTest.cpp diff --git a/src/mkvgen/tst/AnnexBCpdNalAdapterTest.cpp b/tst/mkvgen/AnnexBCpdNalAdapterTest.cpp similarity index 96% rename from src/mkvgen/tst/AnnexBCpdNalAdapterTest.cpp rename to tst/mkvgen/AnnexBCpdNalAdapterTest.cpp index d7f78f22e..5acc32c69 100644 --- a/src/mkvgen/tst/AnnexBCpdNalAdapterTest.cpp +++ b/tst/mkvgen/AnnexBCpdNalAdapterTest.cpp @@ -3,6 +3,7 @@ class AnnexBCpdNalAdapterTest : public MkvgenTestBase { }; +#ifdef FIXUP_ANNEX_B_TRAILING_NALU_ZERO TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_InvalidInput) { PBYTE pCpd = (PBYTE) 100; @@ -18,6 +19,7 @@ TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_InvalidInput) EXPECT_NE(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(pCpd, MIN_H264_ANNEXB_CPD_SIZE - 1, pAdaptedCpd, &adaptedCpdSize)); } +#endif TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_InvalidNoStartCode) { @@ -104,8 +106,12 @@ TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_FixedUpValidSpsPps) BYTE adaptedCpd[1000]; UINT32 adaptedCpdSize = SIZEOF(adaptedCpd); - EXPECT_EQ(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, NULL, &adaptedCpdSize)); - EXPECT_EQ(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, adaptedCpd, &adaptedCpdSize)); + ASSERT_EQ(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, NULL, &adaptedCpdSize)); +#ifdef FIXUP_ANNEX_B_TRAILING_NALU_ZERO + ASSERT_EQ(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, adaptedCpd, &adaptedCpdSize)); +#else + ASSERT_EQ(STATUS_MKV_INVALID_ANNEXB_NALU_IN_FRAME_DATA, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, adaptedCpd, &adaptedCpdSize)); +#endif } TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_ValidH265) { diff --git a/src/mkvgen/tst/AnnexBNalAdapterTest.cpp b/tst/mkvgen/AnnexBNalAdapterTest.cpp similarity index 99% rename from src/mkvgen/tst/AnnexBNalAdapterTest.cpp rename to tst/mkvgen/AnnexBNalAdapterTest.cpp index 3073a705e..18b9b35b1 100644 --- a/src/mkvgen/tst/AnnexBNalAdapterTest.cpp +++ b/tst/mkvgen/AnnexBNalAdapterTest.cpp @@ -3,6 +3,7 @@ class AnnexBNalAdapterTest : public MkvgenTestBase { }; +#ifdef FIXUP_ANNEX_B_TRAILING_NALU_ZERO TEST_F(AnnexBNalAdapterTest, nalAdapter_InvalidInput) { PBYTE pFrameData = (PBYTE) 100; @@ -20,6 +21,7 @@ TEST_F(AnnexBNalAdapterTest, nalAdapter_InvalidInput) EXPECT_NE(STATUS_SUCCESS, adaptFrameNalsFromAnnexBToAvcc(pFrameData, frameDataSize, FALSE, pAdaptedFrameData, NULL)); EXPECT_NE(STATUS_SUCCESS, adaptFrameNalsFromAnnexBToAvcc(pFrameData, frameDataSize, TRUE, pAdaptedFrameData, NULL)); } +#endif TEST_F(AnnexBNalAdapterTest, nalAdapter_ValidOneByteNonZero) { @@ -176,6 +178,7 @@ TEST_F(AnnexBNalAdapterTest, nalAdapter_ValidTrailingZeros) EXPECT_EQ(frameData4Size, adaptedFrameDataSize); EXPECT_EQ(0, MEMCMP(adaptedFrameData, frameData, frameData4Size)); +#ifdef FIXUP_ANNEX_B_TRAILING_NALU_ZERO BYTE frameData5[] = {0, 0, 0, 0, 1}; UINT32 frameData5Size = SIZEOF(frameData5); EXPECT_EQ(STATUS_SUCCESS, adaptFrameNalsFromAnnexBToAvcc(frameData5, frameData5Size, TRUE, NULL, &adaptedFrameDataSize)); @@ -184,7 +187,7 @@ TEST_F(AnnexBNalAdapterTest, nalAdapter_ValidTrailingZeros) // Should set the size larger due to extra 0 removal and checking for at least the same size for EPB adaptedFrameDataSize += 1; EXPECT_EQ(STATUS_SUCCESS, adaptFrameNalsFromAnnexBToAvcc(frameData5, frameData5Size, TRUE, adaptedFrameData, &adaptedFrameDataSize)); - +#endif BYTE frameData6[] = {0, 0, 0, 1, 0}; UINT32 frameData6Size = SIZEOF(frameData6); @@ -372,6 +375,7 @@ TEST_F(AnnexBNalAdapterTest, nalAdapter_ValidEPB) } } +#ifdef FIXUP_ANNEX_B_TRAILING_NALU_ZERO TEST_F(AnnexBNalAdapterTest, nalAdapter_badRealLifeEncoderSampleWithFix) { // I-frame from a real-life encoder output which is actually invalid Annex-B format (shortened after a few bytes of the actual frame) @@ -423,3 +427,4 @@ TEST_F(AnnexBNalAdapterTest, nalAdapter_badRealLifeEncoderSampleWithFix) EXPECT_TRUE(pPps != NULL); EXPECT_EQ(4, ppsSize); } +#endif \ No newline at end of file diff --git a/src/mkvgen/tst/AudioCpdParserTest.cpp b/tst/mkvgen/AudioCpdParserTest.cpp similarity index 100% rename from src/mkvgen/tst/AudioCpdParserTest.cpp rename to tst/mkvgen/AudioCpdParserTest.cpp diff --git a/src/mkvgen/tst/AvccNalAdapterTest.cpp b/tst/mkvgen/AvccNalAdapterTest.cpp similarity index 100% rename from src/mkvgen/tst/AvccNalAdapterTest.cpp rename to tst/mkvgen/AvccNalAdapterTest.cpp diff --git a/src/mkvgen/tst/MkvgenApiFunctionalityTest.cpp b/tst/mkvgen/MkvgenApiFunctionalityTest.cpp similarity index 99% rename from src/mkvgen/tst/MkvgenApiFunctionalityTest.cpp rename to tst/mkvgen/MkvgenApiFunctionalityTest.cpp index 8f6178bd5..66c735c0c 100644 --- a/src/mkvgen/tst/MkvgenApiFunctionalityTest.cpp +++ b/tst/mkvgen/MkvgenApiFunctionalityTest.cpp @@ -192,7 +192,7 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvFromJpegAsFo mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator)); for (i = 0, index = 0; i < 100; i++) { - SPRINTF(fileName, (PCHAR) "samples" FPATHSEPARATOR_STR "gif%03d.jpg", i); + SNPRINTF(fileName, 24, (PCHAR) "samples" FPATHSEPARATOR_STR "gif%03d.jpg", i); fileSize = MKV_TEST_BUFFER_SIZE; if (STATUS_FAILED(readFile(fileName, TRUE, NULL, &fileSize))) { break; @@ -215,8 +215,8 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvFromJpegAsFo // Add tags for (i = 0; i < MKV_TEST_TAG_COUNT; i++) { packagedSize = size; - SPRINTF(tagName, (PCHAR) "testTag_%d", i); - SPRINTF(tagVal, (PCHAR) "testTag_%d_Value", i); + SNPRINTF(tagName, 16, (PCHAR) "testTag_%d", i); + SNPRINTF(tagVal, 16, (PCHAR) "testTag_%d_Value", i); EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mkvGenerator, mkvBuffer + index, tagName, @@ -259,8 +259,8 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvTagsOnly) // Add tags for (i = 0; i < MKV_TEST_TAG_COUNT; i++) { packagedSize = size; - SPRINTF(tagName, (PCHAR) "testTag_%d", i); - SPRINTF(tagVal, (PCHAR) "testTag_%d_Value", i); + SNPRINTF(tagName, 16, (PCHAR) "testTag_%d", i); + SNPRINTF(tagVal, 24, (PCHAR) "testTag_%d_Value", i); EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mkvGenerator, mkvBuffer + index, tagName, @@ -316,8 +316,8 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvMixedTags) { if ((frame.flags & FRAME_FLAG_KEY_FRAME) == FRAME_FLAG_KEY_FRAME) { for (i = 0; i < MKV_TEST_TAG_COUNT; i++) { packagedSize = size; - SPRINTF(tagName, (PCHAR) "testTag_%d", i); - SPRINTF(tagVal, "(PCHAR) testTag_%d_Value", i); + SNPRINTF(tagName, 16, (PCHAR) "testTag_%d", i); + SNPRINTF(tagVal, 24, "(PCHAR) testTag_%d_Value", i); EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mkvGenerator, mkvBuffer + index, tagName, @@ -343,8 +343,8 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvMixedTags) { // Insert tags after the last cluster for (i = 0; i < MKV_TEST_TAG_COUNT; i++) { packagedSize = size; - SPRINTF(tagName, (PCHAR) "testTag_%d", i); - SPRINTF(tagVal, (PCHAR) "testTag_%d_Value", i); + SNPRINTF(tagName, 16, (PCHAR) "testTag_%d", i); + SNPRINTF(tagVal, 24, (PCHAR) "testTag_%d_Value", i); EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mkvGenerator, mkvBuffer + index, tagName, @@ -1660,6 +1660,7 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) MEMCPY(frame.frameData, cpdH264AudSeiExtra0, frame.size); size = SIZEOF(frameBuf); +#ifdef FIXUP_ANNEX_B_TRAILING_NALU_ZERO EXPECT_EQ(STATUS_SUCCESS, mkvgenPackageFrame(pMkvGenerator, &frame, pTrackInfo, mBuffer, &size, &encodedFrameInfo)); // Ensure we have no width/height or CPD @@ -1667,7 +1668,7 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) EXPECT_NE((PBYTE) NULL, pStreamMkvGenerator->trackInfoList[0].codecPrivateData); EXPECT_EQ(704, pStreamMkvGenerator->trackInfoList[0].trackCustomData.trackVideoConfig.videoWidth); EXPECT_EQ(480, pStreamMkvGenerator->trackInfoList[0].trackCustomData.trackVideoConfig.videoHeight); - +#endif // Free the generator EXPECT_EQ(STATUS_SUCCESS, freeMkvGenerator(pMkvGenerator)); @@ -1700,14 +1701,14 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) MEMCPY(frame.frameData, cpdH264AudSeiExtra0, frame.size); size = SIZEOF(frameBuf); +#ifdef FIXUP_ANNEX_B_TRAILING_NALU_ZERO EXPECT_EQ(STATUS_SUCCESS, mkvgenPackageFrame(pMkvGenerator, &frame, pTrackInfo, mBuffer, &size, &encodedFrameInfo)); - // Ensure we have no width/height or CPD EXPECT_NE(0, pStreamMkvGenerator->trackInfoList[0].codecPrivateDataSize); EXPECT_NE((PBYTE) NULL, pStreamMkvGenerator->trackInfoList[0].codecPrivateData); EXPECT_EQ(704, pStreamMkvGenerator->trackInfoList[0].trackCustomData.trackVideoConfig.videoWidth); EXPECT_EQ(480, pStreamMkvGenerator->trackInfoList[0].trackCustomData.trackVideoConfig.videoHeight); - +#endif // Free the generator EXPECT_EQ(STATUS_SUCCESS, freeMkvGenerator(pMkvGenerator)); diff --git a/src/mkvgen/tst/MkvgenApiTest.cpp b/tst/mkvgen/MkvgenApiTest.cpp similarity index 99% rename from src/mkvgen/tst/MkvgenApiTest.cpp rename to tst/mkvgen/MkvgenApiTest.cpp index 652a52f6b..86c6b9e45 100644 --- a/src/mkvgen/tst/MkvgenApiTest.cpp +++ b/tst/mkvgen/MkvgenApiTest.cpp @@ -535,7 +535,7 @@ TEST_F(MkvgenApiTest, mkvgenIncreaseTagsTagSize_FunctionalityTest) /*** RANDOMIZATION TESTING ***/ randomSize = rand()%(0x000fffffffffffff); //UINT64, first byte is occupied, - EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTagsChain(tagsMkvHolder, "TEST_NAME", "TEST_VALUE", &size, MKV_TREE_TAGS)); + EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTagsChain(tagsMkvHolder, (PCHAR) "TEST_NAME", (PCHAR) "TEST_VALUE", &size, MKV_TREE_TAGS)); EXPECT_EQ(STATUS_SUCCESS, mkvgenIncreaseTagsTagSize(tagsMkvHolder, randomSize)); //grab size, and verify it increase by the expected amount. diff --git a/src/mkvgen/tst/MkvgenTestFixture.cpp b/tst/mkvgen/MkvgenTestFixture.cpp similarity index 100% rename from src/mkvgen/tst/MkvgenTestFixture.cpp rename to tst/mkvgen/MkvgenTestFixture.cpp diff --git a/src/mkvgen/tst/MkvgenTestFixture.h b/tst/mkvgen/MkvgenTestFixture.h similarity index 100% rename from src/mkvgen/tst/MkvgenTestFixture.h rename to tst/mkvgen/MkvgenTestFixture.h diff --git a/src/mkvgen/tst/SpsParserTest.cpp b/tst/mkvgen/SpsParserTest.cpp similarity index 100% rename from src/mkvgen/tst/SpsParserTest.cpp rename to tst/mkvgen/SpsParserTest.cpp diff --git a/src/mkvgen/tst/samples/gif000.jpg b/tst/mkvgen/samples/gif000.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif000.jpg rename to tst/mkvgen/samples/gif000.jpg diff --git a/src/mkvgen/tst/samples/gif001.jpg b/tst/mkvgen/samples/gif001.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif001.jpg rename to tst/mkvgen/samples/gif001.jpg diff --git a/src/mkvgen/tst/samples/gif002.jpg b/tst/mkvgen/samples/gif002.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif002.jpg rename to tst/mkvgen/samples/gif002.jpg diff --git a/src/mkvgen/tst/samples/gif003.jpg b/tst/mkvgen/samples/gif003.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif003.jpg rename to tst/mkvgen/samples/gif003.jpg diff --git a/src/mkvgen/tst/samples/gif004.jpg b/tst/mkvgen/samples/gif004.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif004.jpg rename to tst/mkvgen/samples/gif004.jpg diff --git a/src/mkvgen/tst/samples/gif005.jpg b/tst/mkvgen/samples/gif005.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif005.jpg rename to tst/mkvgen/samples/gif005.jpg diff --git a/src/mkvgen/tst/samples/gif006.jpg b/tst/mkvgen/samples/gif006.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif006.jpg rename to tst/mkvgen/samples/gif006.jpg diff --git a/src/mkvgen/tst/samples/gif007.jpg b/tst/mkvgen/samples/gif007.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif007.jpg rename to tst/mkvgen/samples/gif007.jpg diff --git a/src/mkvgen/tst/samples/gif008.jpg b/tst/mkvgen/samples/gif008.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif008.jpg rename to tst/mkvgen/samples/gif008.jpg diff --git a/src/mkvgen/tst/samples/gif009.jpg b/tst/mkvgen/samples/gif009.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif009.jpg rename to tst/mkvgen/samples/gif009.jpg diff --git a/src/mkvgen/tst/samples/gif010.jpg b/tst/mkvgen/samples/gif010.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif010.jpg rename to tst/mkvgen/samples/gif010.jpg diff --git a/src/mkvgen/tst/samples/gif011.jpg b/tst/mkvgen/samples/gif011.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif011.jpg rename to tst/mkvgen/samples/gif011.jpg diff --git a/src/mkvgen/tst/samples/gif012.jpg b/tst/mkvgen/samples/gif012.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif012.jpg rename to tst/mkvgen/samples/gif012.jpg diff --git a/src/mkvgen/tst/samples/gif013.jpg b/tst/mkvgen/samples/gif013.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif013.jpg rename to tst/mkvgen/samples/gif013.jpg diff --git a/src/mkvgen/tst/samples/gif014.jpg b/tst/mkvgen/samples/gif014.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif014.jpg rename to tst/mkvgen/samples/gif014.jpg diff --git a/src/mkvgen/tst/samples/gif015.jpg b/tst/mkvgen/samples/gif015.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif015.jpg rename to tst/mkvgen/samples/gif015.jpg diff --git a/src/mkvgen/tst/samples/gif016.jpg b/tst/mkvgen/samples/gif016.jpg similarity index 100% rename from src/mkvgen/tst/samples/gif016.jpg rename to tst/mkvgen/samples/gif016.jpg diff --git a/src/state/tst/StateApiFunctionalityTest.cpp b/tst/state/StateApiFunctionalityTest.cpp similarity index 100% rename from src/state/tst/StateApiFunctionalityTest.cpp rename to tst/state/StateApiFunctionalityTest.cpp diff --git a/src/state/tst/StateApiTest.cpp b/tst/state/StateApiTest.cpp similarity index 100% rename from src/state/tst/StateApiTest.cpp rename to tst/state/StateApiTest.cpp diff --git a/src/state/tst/StateTestFixture.cpp b/tst/state/StateTestFixture.cpp similarity index 100% rename from src/state/tst/StateTestFixture.cpp rename to tst/state/StateTestFixture.cpp diff --git a/src/state/tst/StateTestFixture.h b/tst/state/StateTestFixture.h similarity index 100% rename from src/state/tst/StateTestFixture.h rename to tst/state/StateTestFixture.h diff --git a/src/utils/tst/suppressions/TSAN.supp b/tst/suppressions/TSAN.supp similarity index 100% rename from src/utils/tst/suppressions/TSAN.supp rename to tst/suppressions/TSAN.supp diff --git a/src/utils/tst/suppressions/UBSAN.supp b/tst/suppressions/UBSAN.supp similarity index 100% rename from src/utils/tst/suppressions/UBSAN.supp rename to tst/suppressions/UBSAN.supp diff --git a/src/trace/tst/TraceApiFunctionalityTest.cpp b/tst/trace/TraceApiFunctionalityTest.cpp similarity index 100% rename from src/trace/tst/TraceApiFunctionalityTest.cpp rename to tst/trace/TraceApiFunctionalityTest.cpp diff --git a/src/trace/tst/TraceApiTest.cpp b/tst/trace/TraceApiTest.cpp similarity index 100% rename from src/trace/tst/TraceApiTest.cpp rename to tst/trace/TraceApiTest.cpp diff --git a/src/trace/tst/TraceTestFixture.cpp b/tst/trace/TraceTestFixture.cpp similarity index 100% rename from src/trace/tst/TraceTestFixture.cpp rename to tst/trace/TraceTestFixture.cpp diff --git a/src/trace/tst/TraceTestFixture.h b/tst/trace/TraceTestFixture.h similarity index 100% rename from src/trace/tst/TraceTestFixture.h rename to tst/trace/TraceTestFixture.h diff --git a/src/utils/tst/BitField.cpp b/tst/utils/BitField.cpp similarity index 100% rename from src/utils/tst/BitField.cpp rename to tst/utils/BitField.cpp diff --git a/src/utils/tst/BitReader.cpp b/tst/utils/BitReader.cpp similarity index 100% rename from src/utils/tst/BitReader.cpp rename to tst/utils/BitReader.cpp diff --git a/src/utils/tst/Crc32Test.cpp b/tst/utils/Crc32Test.cpp similarity index 100% rename from src/utils/tst/Crc32Test.cpp rename to tst/utils/Crc32Test.cpp diff --git a/src/utils/tst/Directory.cpp b/tst/utils/Directory.cpp similarity index 97% rename from src/utils/tst/Directory.cpp rename to tst/utils/Directory.cpp index de55a664c..8ffa70974 100644 --- a/src/utils/tst/Directory.cpp +++ b/tst/utils/Directory.cpp @@ -67,7 +67,7 @@ STATUS createSubDirStruct(PCHAR dirPath, UINT32 depth, UINT32 numberOfFiles, UIN // Create the files first for (UINT32 i = 0; i < numberOfFiles; i++) { // Create the file path - SPRINTF(temp, FPATHSEPARATOR_STR "file_%03d.tmp", i); + SNPRINTF(temp, 32, FPATHSEPARATOR_STR "file_%03d.tmp", i); STRCAT(dirPath, temp); // Create/write the file @@ -83,7 +83,7 @@ STATUS createSubDirStruct(PCHAR dirPath, UINT32 depth, UINT32 numberOfFiles, UIN // Create the directories and iterate for (UINT32 i = 0; i < numberOfDirectories; i++) { // Create the file path - SPRINTF(temp, FPATHSEPARATOR_STR "tmp_dir_%03d", i); + SNPRINTF(temp, 32, FPATHSEPARATOR_STR "tmp_dir_%03d", i); STRCAT(dirPath, temp); // Create the dir diff --git a/src/utils/tst/DoubleLinkedList.cpp b/tst/utils/DoubleLinkedList.cpp similarity index 100% rename from src/utils/tst/DoubleLinkedList.cpp rename to tst/utils/DoubleLinkedList.cpp diff --git a/src/utils/tst/Endianness.cpp b/tst/utils/Endianness.cpp similarity index 100% rename from src/utils/tst/Endianness.cpp rename to tst/utils/Endianness.cpp diff --git a/src/utils/tst/ExponentialBackoffUtilsTest.cpp b/tst/utils/ExponentialBackoffUtilsTest.cpp similarity index 100% rename from src/utils/tst/ExponentialBackoffUtilsTest.cpp rename to tst/utils/ExponentialBackoffUtilsTest.cpp diff --git a/src/utils/tst/FileLogger.cpp b/tst/utils/FileLogger.cpp similarity index 99% rename from src/utils/tst/FileLogger.cpp rename to tst/utils/FileLogger.cpp index b877a6009..2f0d62434 100644 --- a/src/utils/tst/FileLogger.cpp +++ b/tst/utils/FileLogger.cpp @@ -98,7 +98,7 @@ TEST_F(FileLoggerTest, checkFileRotation) // make sure the files dont exist FREMOVE(TEST_TEMP_DIR_PATH "kvsFileLogIndex"); for(; i < logIterationCount; ++i) { - SPRINTF(filePath, TEST_TEMP_DIR_PATH "kvsFileLog.%u", i); + SNPRINTF(filePath, 1024, TEST_TEMP_DIR_PATH "kvsFileLog.%u", i); FREMOVE(filePath); } @@ -115,7 +115,7 @@ TEST_F(FileLoggerTest, checkFileRotation) RELEASE_FILE_LOGGER(); for(i = 0; i < logIterationCount; ++i) { - SPRINTF(filePath, TEST_TEMP_DIR_PATH "kvsFileLog.%u", i); + SNPRINTF(filePath, 1024, TEST_TEMP_DIR_PATH "kvsFileLog.%u", i); EXPECT_EQ(STATUS_SUCCESS, fileExists(filePath, &fileFound)); // only log file with index from 6 to 11 should remain. The rest are rotated out. if (i < logIterationCount && i >= (logIterationCount - maxLogFileCount)) { diff --git a/src/utils/tst/FindStringTest.cpp b/tst/utils/FindStringTest.cpp similarity index 100% rename from src/utils/tst/FindStringTest.cpp rename to tst/utils/FindStringTest.cpp diff --git a/src/utils/tst/HashTable.cpp b/tst/utils/HashTable.cpp similarity index 100% rename from src/utils/tst/HashTable.cpp rename to tst/utils/HashTable.cpp diff --git a/src/utils/tst/InstrumentedAllocators.cpp b/tst/utils/InstrumentedAllocators.cpp similarity index 100% rename from src/utils/tst/InstrumentedAllocators.cpp rename to tst/utils/InstrumentedAllocators.cpp diff --git a/src/utils/tst/IntegerToString.cpp b/tst/utils/IntegerToString.cpp similarity index 100% rename from src/utils/tst/IntegerToString.cpp rename to tst/utils/IntegerToString.cpp diff --git a/src/utils/tst/MathTest.cpp b/tst/utils/MathTest.cpp similarity index 100% rename from src/utils/tst/MathTest.cpp rename to tst/utils/MathTest.cpp diff --git a/src/utils/tst/Semaphore.cpp b/tst/utils/Semaphore.cpp similarity index 100% rename from src/utils/tst/Semaphore.cpp rename to tst/utils/Semaphore.cpp diff --git a/src/utils/tst/SingleLinkedList.cpp b/tst/utils/SingleLinkedList.cpp similarity index 100% rename from src/utils/tst/SingleLinkedList.cpp rename to tst/utils/SingleLinkedList.cpp diff --git a/src/utils/tst/StackQueue.cpp b/tst/utils/StackQueue.cpp similarity index 100% rename from src/utils/tst/StackQueue.cpp rename to tst/utils/StackQueue.cpp diff --git a/src/utils/tst/StringSearch.cpp b/tst/utils/StringSearch.cpp similarity index 100% rename from src/utils/tst/StringSearch.cpp rename to tst/utils/StringSearch.cpp diff --git a/src/utils/tst/StringToInteger.cpp b/tst/utils/StringToInteger.cpp similarity index 100% rename from src/utils/tst/StringToInteger.cpp rename to tst/utils/StringToInteger.cpp diff --git a/src/utils/tst/Tags.cpp b/tst/utils/Tags.cpp similarity index 100% rename from src/utils/tst/Tags.cpp rename to tst/utils/Tags.cpp diff --git a/src/utils/tst/Thread.cpp b/tst/utils/Thread.cpp similarity index 100% rename from src/utils/tst/Thread.cpp rename to tst/utils/Thread.cpp diff --git a/src/utils/tst/Threadpool.cpp b/tst/utils/Threadpool.cpp similarity index 99% rename from src/utils/tst/Threadpool.cpp rename to tst/utils/Threadpool.cpp index 7d28688dc..caf8b5179 100644 --- a/src/utils/tst/Threadpool.cpp +++ b/tst/utils/Threadpool.cpp @@ -144,10 +144,12 @@ TEST_F(ThreadpoolFunctionalityTest, ThreadsExitGracefullyAfterThreadpoolFreeTest THREAD_SLEEP(500 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } -typedef struct ThreadpoolUser { + + +typedef struct __ThreadpoolUser { PThreadpool pThreadpool; volatile ATOMIC_BOOL usable; -}; +} ThreadpoolUser; PVOID createTasks(PVOID customData) { diff --git a/src/utils/tst/ThreadsafeBlockingQueue.cpp b/tst/utils/ThreadsafeBlockingQueue.cpp similarity index 99% rename from src/utils/tst/ThreadsafeBlockingQueue.cpp rename to tst/utils/ThreadsafeBlockingQueue.cpp index a6e0a2dfc..89ec99272 100644 --- a/src/utils/tst/ThreadsafeBlockingQueue.cpp +++ b/tst/utils/ThreadsafeBlockingQueue.cpp @@ -89,10 +89,10 @@ TEST_F(ThreadsafeBlockingQueueFunctionalityTest, queueCountCorrectTest) } #define STATIC_NUMBER_OF_ITEMS 50 -typedef struct SafeQueueUser { +typedef struct __SafeQueueUser { PSafeBlockingQueue pSafeQueue; volatile ATOMIC_BOOL usable; -}; +} SafeQueueUser; void* writingThread(void* ptr) { SafeQueueUser * user = (SafeQueueUser*)ptr; diff --git a/src/utils/tst/TimerQueue.cpp b/tst/utils/TimerQueue.cpp similarity index 100% rename from src/utils/tst/TimerQueue.cpp rename to tst/utils/TimerQueue.cpp diff --git a/src/utils/tst/TrimStringTest.cpp b/tst/utils/TrimStringTest.cpp similarity index 100% rename from src/utils/tst/TrimStringTest.cpp rename to tst/utils/TrimStringTest.cpp diff --git a/src/utils/tst/UtilTestFixture.cpp b/tst/utils/UtilTestFixture.cpp similarity index 100% rename from src/utils/tst/UtilTestFixture.cpp rename to tst/utils/UtilTestFixture.cpp diff --git a/src/utils/tst/UtilTestFixture.h b/tst/utils/UtilTestFixture.h similarity index 100% rename from src/utils/tst/UtilTestFixture.h rename to tst/utils/UtilTestFixture.h diff --git a/src/utils/tst/VersionsTest.cpp b/tst/utils/VersionsTest.cpp similarity index 100% rename from src/utils/tst/VersionsTest.cpp rename to tst/utils/VersionsTest.cpp diff --git a/tst/utils/suppressions/TSAN.supp b/tst/utils/suppressions/TSAN.supp new file mode 100644 index 000000000..f6c441f0f --- /dev/null +++ b/tst/utils/suppressions/TSAN.supp @@ -0,0 +1,25 @@ +# Every exception in this file should be heavily justified + +# Suppressing lock order reports from TSAN. Our tests and the PIC codebase is based on differnet layer of locks which are re-entrant. +deadlock:StreamApiTest_kinesisVideoStreamCreateSync_Valid_Test::TestBody +deadlock:StreamApiTest_kinesisVideoStreamCreateSyncStopSync_Valid_Timeout_Test +deadlock:clientReadyFunc +deadlock:describeStreamResult + +# For some reason TSAN has a false positive flagging the global logging function race condition where as we use create stream SYNC API which should have set the logger +race:globalCustomLogPrintFn + +# False-positive hit on createsync and the handle. This one is really bizarre so disabling TSAN on this particular test which simulates a network stack async stop notification +race:StreamApiTest_kinesisVideoStreamCreateSync_Valid_Test + + +# Weird failure with data race in Semaphore tests with the gtest nternal contructor and the spun threads which simulate multi-thread access. SHould not have contention due to the atomics. This is a false positive, +race:acquireThreadRoutine +race:drainThreadRoutine + +# Time-sensitive tests for the semaphore teardown without awaiting which is synchronized by thread sleeps in the test. This is OK, +race:freeWithoutReleaseAllThreadsTest + +# Another false positive on a single-threaded execution of a test. This seems to be an issue with TSAN as the test in question has no threads +deadlock:ClientTestBase::lockMutexFunc + diff --git a/tst/utils/suppressions/UBSAN.supp b/tst/utils/suppressions/UBSAN.supp new file mode 100644 index 000000000..510734b67 --- /dev/null +++ b/tst/utils/suppressions/UBSAN.supp @@ -0,0 +1,2 @@ +# Some of these suppressions are heavy handed, but can't trace them down to a single cause +signed-integer-overflow:String.c \ No newline at end of file diff --git a/src/view/tst/ViewApiFunctionalityTest.cpp b/tst/view/ViewApiFunctionalityTest.cpp similarity index 100% rename from src/view/tst/ViewApiFunctionalityTest.cpp rename to tst/view/ViewApiFunctionalityTest.cpp diff --git a/src/view/tst/ViewApiTest.cpp b/tst/view/ViewApiTest.cpp similarity index 100% rename from src/view/tst/ViewApiTest.cpp rename to tst/view/ViewApiTest.cpp diff --git a/src/view/tst/ViewDropPolicyFunctionalityTest.cpp b/tst/view/ViewDropPolicyFunctionalityTest.cpp similarity index 100% rename from src/view/tst/ViewDropPolicyFunctionalityTest.cpp rename to tst/view/ViewDropPolicyFunctionalityTest.cpp diff --git a/src/view/tst/ViewTestFixture.cpp b/tst/view/ViewTestFixture.cpp similarity index 100% rename from src/view/tst/ViewTestFixture.cpp rename to tst/view/ViewTestFixture.cpp diff --git a/src/view/tst/ViewTestFixture.h b/tst/view/ViewTestFixture.h similarity index 100% rename from src/view/tst/ViewTestFixture.h rename to tst/view/ViewTestFixture.h