From 80172116a4a01ff7afa150be3683807b17c499dd Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Thu, 14 Dec 2023 10:12:34 -0500 Subject: [PATCH 01/32] remove unnecessary double compiles, separate out test ci run into a separate section, address compile warning --- .github/workflows/ci.yml | 28 ++++++++++++++++++++++++---- src/utils/src/Threadpool.c | 2 +- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a08c19c8..110ad19f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,8 +34,11 @@ 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 ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" mac-os-build-clang: runs-on: macos-latest @@ -47,8 +50,11 @@ 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 + - name: Run tests + run: | + cd build ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" mac-os-m1-build-clang: runs-on: macos-13-xlarge @@ -61,8 +67,11 @@ 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 + - name: Run tests + run: | + cd build ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" mac-os-m1-build-gcc: runs-on: macos-13-xlarge @@ -77,8 +86,11 @@ jobs: run: | brew unlink openssl 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 ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" linux-gcc-code-coverage: runs-on: ubuntu-latest @@ -131,6 +143,9 @@ 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.*" linux-gcc-4_4: @@ -155,6 +170,9 @@ 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.*" # memory-sanitizer: @@ -207,6 +225,8 @@ jobs: - name: Build and run run: | .github/build_windows.bat + - name: Run tests + run: | 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*" arm64-cross-compilation: runs-on: ubuntu-latest diff --git a/src/utils/src/Threadpool.c b/src/utils/src/Threadpool.c index 72af3dc2..2ab9808a 100644 --- a/src/utils/src/Threadpool.c +++ b/src/utils/src/Threadpool.c @@ -206,7 +206,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: From b5be08f1fc0c21485ff45e2c0405d76094ad5871 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Thu, 14 Dec 2023 10:36:08 -0500 Subject: [PATCH 02/32] address multiple compile warnings --- src/heap/src/HybridFileHeap.c | 14 +++++++------- src/mkvgen/tst/MkvgenApiFunctionalityTest.cpp | 18 +++++++++--------- src/mkvgen/tst/MkvgenApiTest.cpp | 2 +- src/utils/src/Allocators.c | 2 +- src/utils/tst/Directory.cpp | 4 ++-- src/utils/tst/FileLogger.cpp | 4 ++-- src/utils/tst/Threadpool.cpp | 6 ++++-- src/utils/tst/ThreadsafeBlockingQueue.cpp | 4 ++-- 8 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/heap/src/HybridFileHeap.c b/src/heap/src/HybridFileHeap.c index e401ae8d..de9ca8ad 100644 --- a/src/heap/src/HybridFileHeap.c +++ b/src/heap/src/HybridFileHeap.c @@ -213,7 +213,7 @@ 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); + SNPRINTF(filePath, 1024, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, pHybridHeap->handleNum); // Create a file with the overall size CHK_STATUS(createFile(filePath, allocationSize)); @@ -268,7 +268,7 @@ 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); + SNPRINTF(filePath, 1024, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); retCode = FREMOVE(filePath); @@ -320,7 +320,7 @@ 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); + SNPRINTF(filePath, 1024, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); CHK_STATUS(readFileSegment(filePath, TRUE, (PBYTE) &allocationHeader, 0, FILE_ALLOCATION_HEADER_SIZE)); // Set the values and return @@ -369,7 +369,7 @@ 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); + SNPRINTF(filePath, 1024, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); // Set the file size CHK_STATUS(setFileLength(filePath, overallSize)); @@ -422,7 +422,7 @@ 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); + SNPRINTF(filePath, 1024, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); // Get the file size, allocate and read the entire file into memory CHK_STATUS(getFileLength(filePath, &fileLength)); @@ -473,7 +473,7 @@ DEFINE_HEAP_UNMAP(hybridFileHeapUnmap) } DLOGS("Indirect allocation"); - SPRINTF(filePath, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, pHeader->fileHandle); + SNPRINTF(filePath, 1024, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, pHeader->fileHandle); // 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)); @@ -521,7 +521,7 @@ 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); + SNPRINTF(filePath, 1024, "%s%c%u" FILE_HEAP_FILE_EXTENSION, pHybridHeap->rootDirectory, FPATHSEPARATOR, fileHandle); // 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/mkvgen/tst/MkvgenApiFunctionalityTest.cpp b/src/mkvgen/tst/MkvgenApiFunctionalityTest.cpp index 8f6178bd..2faef78b 100644 --- a/src/mkvgen/tst/MkvgenApiFunctionalityTest.cpp +++ b/src/mkvgen/tst/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, diff --git a/src/mkvgen/tst/MkvgenApiTest.cpp b/src/mkvgen/tst/MkvgenApiTest.cpp index 652a52f6..86c6b9e4 100644 --- a/src/mkvgen/tst/MkvgenApiTest.cpp +++ b/src/mkvgen/tst/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/utils/src/Allocators.c b/src/utils/src/Allocators.c index f402a9b9..6016eadb 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/tst/Directory.cpp b/src/utils/tst/Directory.cpp index de55a664..8ffa7097 100644 --- a/src/utils/tst/Directory.cpp +++ b/src/utils/tst/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/FileLogger.cpp b/src/utils/tst/FileLogger.cpp index b877a600..2f0d6243 100644 --- a/src/utils/tst/FileLogger.cpp +++ b/src/utils/tst/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/Threadpool.cpp b/src/utils/tst/Threadpool.cpp index 7d28688d..caf8b517 100644 --- a/src/utils/tst/Threadpool.cpp +++ b/src/utils/tst/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/src/utils/tst/ThreadsafeBlockingQueue.cpp index a6e0a2df..89ec9927 100644 --- a/src/utils/tst/ThreadsafeBlockingQueue.cpp +++ b/src/utils/tst/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; From 16c9643256410141cc29ba706ba2c66c85a28744 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Thu, 14 Dec 2023 10:52:46 -0500 Subject: [PATCH 03/32] address more compiler warnings for linux, separate out few more tests from build in ci --- .github/workflows/ci.yml | 6 ++++++ .../include/com/amazonaws/kinesis/video/common/CommonDefs.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 110ad19f..54792d6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,6 +104,9 @@ 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 ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" - name: Code coverage @@ -122,6 +125,9 @@ 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.*" undefined-behavior-sanitizer: 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 fe982494..d7ed8a55 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 From b2b5647cd6df1b43d8e8134c0bad416d668db4c5 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Thu, 14 Dec 2023 13:01:54 -0500 Subject: [PATCH 04/32] move stuff around --- .github/workflows/ci.yml | 18 +++++----- CMakeLists.txt | 33 ++---------------- README.md | 2 +- src/client/CMakeLists.txt | 2 +- src/client/tst/CMakeLists.txt | 19 ---------- src/common/CMakeLists.txt | 2 +- src/duration/CMakeLists.txt | 2 +- src/duration/tst/CMakeLists.txt | 12 ------- src/heap/CMakeLists.txt | 2 +- src/heap/src/HybridFileHeap.c | 31 +++++++++++----- src/heap/tst/CMakeLists.txt | 12 ------- src/mkvgen/CMakeLists.txt | 2 +- src/mkvgen/tst/CMakeLists.txt | 10 ------ src/state/CMakeLists.txt | 2 +- src/state/tst/CMakeLists.txt | 10 ------ src/trace/CMakeLists.txt | 2 +- src/trace/tst/CMakeLists.txt | 9 ----- src/utils/CMakeLists.txt | 2 +- src/utils/src/Thread.c | 2 +- src/utils/tst/CMakeLists.txt | 11 ------ src/view/CMakeLists.txt | 2 +- src/view/tst/CMakeLists.txt | 9 ----- tst/CMakeLists.txt | 28 +++++++++++++++ .../client}/AcksFunctionalityTest.cpp | 0 ...CallbacksAndPressuresFunctionalityTest.cpp | 0 .../client}/ClientApiFunctionalityTest.cpp | 0 .../tst => tst/client}/ClientApiTest.cpp | 0 .../client}/ClientFunctionalityTest.cpp | 0 .../tst => tst/client}/ClientTestFixture.cpp | 0 .../tst => tst/client}/ClientTestFixture.h | 0 .../client}/FrameOrderCoordinatorTest.cpp | 0 ...rmittentProducerAutomaticStreamingTest.cpp | 0 .../IntermittentProducerFunctionalityTest.cpp | 0 .../tst => tst/client}/MockConsumer.cpp | 0 {src/client/tst => tst/client}/MockConsumer.h | 0 .../tst => tst/client}/MockProducer.cpp | 0 {src/client/tst => tst/client}/MockProducer.h | 0 .../StateTransitionFunctionalityTest.cpp | 0 .../StreamApiFunctionalityScenarioTest.cpp | 0 .../client}/StreamApiFunctionalityTest.cpp | 0 .../client}/StreamApiServiceCallsTest.cpp | 0 .../tst => tst/client}/StreamApiTest.cpp | 0 .../client}/StreamDeviceTagsTest.cpp | 0 .../client}/StreamFunctionalityTest.cpp | 0 .../tst => tst/client}/StreamParallelTest.cpp | 0 .../tst => tst/client}/StreamPutGetTest.cpp | 0 .../StreamRecoveryFunctionalityTest.cpp | 0 .../client}/StreamStateTransitionsTest.cpp | 0 .../StreamStoppingFunctionalityTest.cpp | 0 .../client}/StreamTokenRotationTest.cpp | 0 .../tst => tst/client}/StreamingSession.cpp | 0 .../tst => tst/client}/StreamingSession.h | 0 .../TokenRotationFunctionalityTest.cpp | 0 .../tst => tst/duration}/DurationTest.cpp | 0 .../heap}/HeapApiFunctionalityTest.cpp | 0 {src/heap/tst => tst/heap}/HeapApiTest.cpp | 0 {src/heap/tst => tst/heap}/HeapPerfTest.cpp | 0 .../heap/tst => tst/heap}/HeapTestFixture.cpp | 0 {src/heap/tst => tst/heap}/HeapTestFixture.h | 0 .../tst => tst/heap}/HybridFileHeapTest.cpp | 0 {src/heap/tst => tst/heap}/HybridHeapTest.cpp | 0 .../mkvgen}/AnnexBCpdNalAdapterTest.cpp | 0 .../mkvgen}/AnnexBNalAdapterTest.cpp | 0 .../tst => tst/mkvgen}/AudioCpdParserTest.cpp | 0 .../tst => tst/mkvgen}/AvccNalAdapterTest.cpp | 0 .../mkvgen}/MkvgenApiFunctionalityTest.cpp | 0 .../tst => tst/mkvgen}/MkvgenApiTest.cpp | 0 .../tst => tst/mkvgen}/MkvgenTestFixture.cpp | 0 .../tst => tst/mkvgen}/MkvgenTestFixture.h | 0 .../tst => tst/mkvgen}/SpsParserTest.cpp | 0 .../tst => tst/mkvgen}/samples/gif000.jpg | Bin .../tst => tst/mkvgen}/samples/gif001.jpg | Bin .../tst => tst/mkvgen}/samples/gif002.jpg | Bin .../tst => tst/mkvgen}/samples/gif003.jpg | Bin .../tst => tst/mkvgen}/samples/gif004.jpg | Bin .../tst => tst/mkvgen}/samples/gif005.jpg | Bin .../tst => tst/mkvgen}/samples/gif006.jpg | Bin .../tst => tst/mkvgen}/samples/gif007.jpg | Bin .../tst => tst/mkvgen}/samples/gif008.jpg | Bin .../tst => tst/mkvgen}/samples/gif009.jpg | Bin .../tst => tst/mkvgen}/samples/gif010.jpg | Bin .../tst => tst/mkvgen}/samples/gif011.jpg | Bin .../tst => tst/mkvgen}/samples/gif012.jpg | Bin .../tst => tst/mkvgen}/samples/gif013.jpg | Bin .../tst => tst/mkvgen}/samples/gif014.jpg | Bin .../tst => tst/mkvgen}/samples/gif015.jpg | Bin .../tst => tst/mkvgen}/samples/gif016.jpg | Bin .../state}/StateApiFunctionalityTest.cpp | 0 {src/state/tst => tst/state}/StateApiTest.cpp | 0 .../tst => tst/state}/StateTestFixture.cpp | 0 .../tst => tst/state}/StateTestFixture.h | 0 .../trace}/TraceApiFunctionalityTest.cpp | 0 {src/trace/tst => tst/trace}/TraceApiTest.cpp | 0 .../tst => tst/trace}/TraceTestFixture.cpp | 0 .../tst => tst/trace}/TraceTestFixture.h | 0 {src/utils/tst => tst/utils}/BitField.cpp | 0 {src/utils/tst => tst/utils}/BitReader.cpp | 0 {src/utils/tst => tst/utils}/Crc32Test.cpp | 0 {src/utils/tst => tst/utils}/Directory.cpp | 0 .../tst => tst/utils}/DoubleLinkedList.cpp | 0 {src/utils/tst => tst/utils}/Endianness.cpp | 0 .../utils}/ExponentialBackoffUtilsTest.cpp | 0 {src/utils/tst => tst/utils}/FileLogger.cpp | 0 .../tst => tst/utils}/FindStringTest.cpp | 0 {src/utils/tst => tst/utils}/HashTable.cpp | 0 .../utils}/InstrumentedAllocators.cpp | 0 .../tst => tst/utils}/IntegerToString.cpp | 0 {src/utils/tst => tst/utils}/MathTest.cpp | 0 {src/utils/tst => tst/utils}/Semaphore.cpp | 0 .../tst => tst/utils}/SingleLinkedList.cpp | 0 {src/utils/tst => tst/utils}/StackQueue.cpp | 0 {src/utils/tst => tst/utils}/StringSearch.cpp | 0 .../tst => tst/utils}/StringToInteger.cpp | 0 {src/utils/tst => tst/utils}/Tags.cpp | 0 {src/utils/tst => tst/utils}/Thread.cpp | 0 {src/utils/tst => tst/utils}/Threadpool.cpp | 0 .../utils}/ThreadsafeBlockingQueue.cpp | 0 {src/utils/tst => tst/utils}/TimerQueue.cpp | 0 .../tst => tst/utils}/TrimStringTest.cpp | 0 .../tst => tst/utils}/UtilTestFixture.cpp | 0 .../utils/tst => tst/utils}/UtilTestFixture.h | 0 {src/utils/tst => tst/utils}/VersionsTest.cpp | 0 .../tst => tst/utils}/suppressions/TSAN.supp | 0 .../tst => tst/utils}/suppressions/UBSAN.supp | 0 .../view}/ViewApiFunctionalityTest.cpp | 0 {src/view/tst => tst/view}/ViewApiTest.cpp | 0 .../view}/ViewDropPolicyFunctionalityTest.cpp | 0 .../view/tst => tst/view}/ViewTestFixture.cpp | 0 {src/view/tst => tst/view}/ViewTestFixture.h | 0 129 files changed, 73 insertions(+), 151 deletions(-) delete mode 100644 src/client/tst/CMakeLists.txt delete mode 100644 src/duration/tst/CMakeLists.txt delete mode 100644 src/heap/tst/CMakeLists.txt delete mode 100644 src/mkvgen/tst/CMakeLists.txt delete mode 100644 src/state/tst/CMakeLists.txt delete mode 100644 src/trace/tst/CMakeLists.txt delete mode 100644 src/utils/tst/CMakeLists.txt delete mode 100644 src/view/tst/CMakeLists.txt create mode 100644 tst/CMakeLists.txt rename {src/client/tst => tst/client}/AcksFunctionalityTest.cpp (100%) rename {src/client/tst => tst/client}/CallbacksAndPressuresFunctionalityTest.cpp (100%) rename {src/client/tst => tst/client}/ClientApiFunctionalityTest.cpp (100%) rename {src/client/tst => tst/client}/ClientApiTest.cpp (100%) rename {src/client/tst => tst/client}/ClientFunctionalityTest.cpp (100%) rename {src/client/tst => tst/client}/ClientTestFixture.cpp (100%) rename {src/client/tst => tst/client}/ClientTestFixture.h (100%) rename {src/client/tst => tst/client}/FrameOrderCoordinatorTest.cpp (100%) rename {src/client/tst => tst/client}/IntermittentProducerAutomaticStreamingTest.cpp (100%) rename {src/client/tst => tst/client}/IntermittentProducerFunctionalityTest.cpp (100%) rename {src/client/tst => tst/client}/MockConsumer.cpp (100%) rename {src/client/tst => tst/client}/MockConsumer.h (100%) rename {src/client/tst => tst/client}/MockProducer.cpp (100%) rename {src/client/tst => tst/client}/MockProducer.h (100%) rename {src/client/tst => tst/client}/StateTransitionFunctionalityTest.cpp (100%) rename {src/client/tst => tst/client}/StreamApiFunctionalityScenarioTest.cpp (100%) rename {src/client/tst => tst/client}/StreamApiFunctionalityTest.cpp (100%) rename {src/client/tst => tst/client}/StreamApiServiceCallsTest.cpp (100%) rename {src/client/tst => tst/client}/StreamApiTest.cpp (100%) rename {src/client/tst => tst/client}/StreamDeviceTagsTest.cpp (100%) rename {src/client/tst => tst/client}/StreamFunctionalityTest.cpp (100%) rename {src/client/tst => tst/client}/StreamParallelTest.cpp (100%) rename {src/client/tst => tst/client}/StreamPutGetTest.cpp (100%) rename {src/client/tst => tst/client}/StreamRecoveryFunctionalityTest.cpp (100%) rename {src/client/tst => tst/client}/StreamStateTransitionsTest.cpp (100%) rename {src/client/tst => tst/client}/StreamStoppingFunctionalityTest.cpp (100%) rename {src/client/tst => tst/client}/StreamTokenRotationTest.cpp (100%) rename {src/client/tst => tst/client}/StreamingSession.cpp (100%) rename {src/client/tst => tst/client}/StreamingSession.h (100%) rename {src/client/tst => tst/client}/TokenRotationFunctionalityTest.cpp (100%) rename {src/duration/tst => tst/duration}/DurationTest.cpp (100%) rename {src/heap/tst => tst/heap}/HeapApiFunctionalityTest.cpp (100%) rename {src/heap/tst => tst/heap}/HeapApiTest.cpp (100%) rename {src/heap/tst => tst/heap}/HeapPerfTest.cpp (100%) rename {src/heap/tst => tst/heap}/HeapTestFixture.cpp (100%) rename {src/heap/tst => tst/heap}/HeapTestFixture.h (100%) rename {src/heap/tst => tst/heap}/HybridFileHeapTest.cpp (100%) rename {src/heap/tst => tst/heap}/HybridHeapTest.cpp (100%) rename {src/mkvgen/tst => tst/mkvgen}/AnnexBCpdNalAdapterTest.cpp (100%) rename {src/mkvgen/tst => tst/mkvgen}/AnnexBNalAdapterTest.cpp (100%) rename {src/mkvgen/tst => tst/mkvgen}/AudioCpdParserTest.cpp (100%) rename {src/mkvgen/tst => tst/mkvgen}/AvccNalAdapterTest.cpp (100%) rename {src/mkvgen/tst => tst/mkvgen}/MkvgenApiFunctionalityTest.cpp (100%) rename {src/mkvgen/tst => tst/mkvgen}/MkvgenApiTest.cpp (100%) rename {src/mkvgen/tst => tst/mkvgen}/MkvgenTestFixture.cpp (100%) rename {src/mkvgen/tst => tst/mkvgen}/MkvgenTestFixture.h (100%) rename {src/mkvgen/tst => tst/mkvgen}/SpsParserTest.cpp (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif000.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif001.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif002.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif003.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif004.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif005.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif006.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif007.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif008.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif009.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif010.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif011.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif012.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif013.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif014.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif015.jpg (100%) rename {src/mkvgen/tst => tst/mkvgen}/samples/gif016.jpg (100%) rename {src/state/tst => tst/state}/StateApiFunctionalityTest.cpp (100%) rename {src/state/tst => tst/state}/StateApiTest.cpp (100%) rename {src/state/tst => tst/state}/StateTestFixture.cpp (100%) rename {src/state/tst => tst/state}/StateTestFixture.h (100%) rename {src/trace/tst => tst/trace}/TraceApiFunctionalityTest.cpp (100%) rename {src/trace/tst => tst/trace}/TraceApiTest.cpp (100%) rename {src/trace/tst => tst/trace}/TraceTestFixture.cpp (100%) rename {src/trace/tst => tst/trace}/TraceTestFixture.h (100%) rename {src/utils/tst => tst/utils}/BitField.cpp (100%) rename {src/utils/tst => tst/utils}/BitReader.cpp (100%) rename {src/utils/tst => tst/utils}/Crc32Test.cpp (100%) rename {src/utils/tst => tst/utils}/Directory.cpp (100%) rename {src/utils/tst => tst/utils}/DoubleLinkedList.cpp (100%) rename {src/utils/tst => tst/utils}/Endianness.cpp (100%) rename {src/utils/tst => tst/utils}/ExponentialBackoffUtilsTest.cpp (100%) rename {src/utils/tst => tst/utils}/FileLogger.cpp (100%) rename {src/utils/tst => tst/utils}/FindStringTest.cpp (100%) rename {src/utils/tst => tst/utils}/HashTable.cpp (100%) rename {src/utils/tst => tst/utils}/InstrumentedAllocators.cpp (100%) rename {src/utils/tst => tst/utils}/IntegerToString.cpp (100%) rename {src/utils/tst => tst/utils}/MathTest.cpp (100%) rename {src/utils/tst => tst/utils}/Semaphore.cpp (100%) rename {src/utils/tst => tst/utils}/SingleLinkedList.cpp (100%) rename {src/utils/tst => tst/utils}/StackQueue.cpp (100%) rename {src/utils/tst => tst/utils}/StringSearch.cpp (100%) rename {src/utils/tst => tst/utils}/StringToInteger.cpp (100%) rename {src/utils/tst => tst/utils}/Tags.cpp (100%) rename {src/utils/tst => tst/utils}/Thread.cpp (100%) rename {src/utils/tst => tst/utils}/Threadpool.cpp (100%) rename {src/utils/tst => tst/utils}/ThreadsafeBlockingQueue.cpp (100%) rename {src/utils/tst => tst/utils}/TimerQueue.cpp (100%) rename {src/utils/tst => tst/utils}/TrimStringTest.cpp (100%) rename {src/utils/tst => tst/utils}/UtilTestFixture.cpp (100%) rename {src/utils/tst => tst/utils}/UtilTestFixture.h (100%) rename {src/utils/tst => tst/utils}/VersionsTest.cpp (100%) rename {src/utils/tst => tst/utils}/suppressions/TSAN.supp (100%) rename {src/utils/tst => tst/utils}/suppressions/UBSAN.supp (100%) rename {src/view/tst => tst/view}/ViewApiFunctionalityTest.cpp (100%) rename {src/view/tst => tst/view}/ViewApiTest.cpp (100%) rename {src/view/tst => tst/view}/ViewDropPolicyFunctionalityTest.cpp (100%) rename {src/view/tst => tst/view}/ViewTestFixture.cpp (100%) rename {src/view/tst => tst/view}/ViewTestFixture.h (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54792d6b..13de85a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: - name: Run tests run: | cd build - ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" mac-os-build-clang: runs-on: macos-latest env: @@ -55,7 +55,7 @@ jobs: - name: Run tests run: | cd build - ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" mac-os-m1-build-clang: runs-on: macos-13-xlarge env: @@ -72,7 +72,7 @@ jobs: - name: Run tests run: | cd build - ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + ./tstkvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" mac-os-m1-build-gcc: runs-on: macos-13-xlarge env: @@ -91,7 +91,7 @@ jobs: - name: Run tests run: | cd build - ./kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" linux-gcc-code-coverage: runs-on: ubuntu-latest env: @@ -108,7 +108,7 @@ jobs: 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 @@ -129,7 +129,7 @@ jobs: 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.*" undefined-behavior-sanitizer: runs-on: ubuntu-latest env: @@ -153,7 +153,7 @@ jobs: 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.*" linux-gcc-4_4: runs-on: ubuntu-20.04 env: @@ -180,7 +180,7 @@ jobs: 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.*" # memory-sanitizer: # runs-on: ubuntu-18.04 # env: @@ -233,7 +233,7 @@ jobs: .github/build_windows.bat - name: Run tests run: | - 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*" + 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 d0e97c88..0514f272 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 f82953bd..d95c8b05 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 fd1be330..f4a1dd1c 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 704d331d..00000000 --- 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 7265fdbb..e5f4608d 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/duration/CMakeLists.txt b/src/duration/CMakeLists.txt index 6605f781..073c2eca 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 a2ad2243..00000000 --- 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 c1d54419..e218940a 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 de9ca8ad..e1291145 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,8 @@ DEFINE_HEAP_ALLOC(hybridFileHeapAlloc) DLOGS("Allocating from File heap"); // Try to allocate from file storage - SNPRINTF(filePath, 1024, "%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 +270,8 @@ DEFINE_HEAP_FREE(hybridFileHeapFree) DLOGS("Indirect allocation"); // Convert the handle and create the file path fileHandle = TO_FILE_HANDLE(handle); - SNPRINTF(filePath, 1024, "%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 +306,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 +324,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); - SNPRINTF(filePath, 1024, "%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 +350,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 +376,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); - SNPRINTF(filePath, 1024, "%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 +412,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 +430,8 @@ DEFINE_HEAP_MAP(hybridFileHeapMap) fileHandle = TO_FILE_HANDLE(handle); DLOGS("File heap allocation. Handle 0x%016" PRIx64 " File handle 0x%08x", handle, fileHandle); - SNPRINTF(filePath, 1024, "%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 +466,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 +483,8 @@ DEFINE_HEAP_UNMAP(hybridFileHeapUnmap) } DLOGS("Indirect allocation"); - SNPRINTF(filePath, 1024, "%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 +518,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 +533,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); - SNPRINTF(filePath, 1024, "%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 470cb6e9..00000000 --- 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 df3a42f0..a1164533 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 afac9341..00000000 --- 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 9e38df1f..4aa7edea 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 31c9a761..00000000 --- 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 8d2a7bcb..6506e570 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 46c56028..00000000 --- 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 13697d1e..14800f8d 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/src/Thread.c b/src/utils/src/Thread.c index 0cfe6894..b4fa7f2e 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/tst/CMakeLists.txt b/src/utils/tst/CMakeLists.txt deleted file mode 100644 index 76821701..00000000 --- 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 7e21be9a..05f62f54 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 729b6560..00000000 --- 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 00000000..ce1280e2 --- /dev/null +++ b/tst/CMakeLists.txt @@ -0,0 +1,28 @@ +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) + +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") + + +add_executable(kvspic_test ${PIC_TEST_SOURCE_FILES}) +target_compile_definitions(kvspic_test PRIVATE ALIGNED_MEMORY_MODEL=TRUE FIXUP_ANNEX_B_TRAILING_NALU_ZERO=TRUE) +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() \ No newline at end of file diff --git a/src/client/tst/AcksFunctionalityTest.cpp b/tst/client/AcksFunctionalityTest.cpp similarity index 100% rename from src/client/tst/AcksFunctionalityTest.cpp rename to tst/client/AcksFunctionalityTest.cpp diff --git a/src/client/tst/CallbacksAndPressuresFunctionalityTest.cpp b/tst/client/CallbacksAndPressuresFunctionalityTest.cpp similarity index 100% rename from src/client/tst/CallbacksAndPressuresFunctionalityTest.cpp rename to tst/client/CallbacksAndPressuresFunctionalityTest.cpp 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 100% rename from src/client/tst/ClientApiTest.cpp rename to tst/client/ClientApiTest.cpp diff --git a/src/client/tst/ClientFunctionalityTest.cpp b/tst/client/ClientFunctionalityTest.cpp similarity index 100% rename from src/client/tst/ClientFunctionalityTest.cpp rename to tst/client/ClientFunctionalityTest.cpp 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 100% rename from src/client/tst/ClientTestFixture.h rename to tst/client/ClientTestFixture.h 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 100% rename from src/client/tst/IntermittentProducerAutomaticStreamingTest.cpp rename to tst/client/IntermittentProducerAutomaticStreamingTest.cpp diff --git a/src/client/tst/IntermittentProducerFunctionalityTest.cpp b/tst/client/IntermittentProducerFunctionalityTest.cpp similarity index 100% rename from src/client/tst/IntermittentProducerFunctionalityTest.cpp rename to tst/client/IntermittentProducerFunctionalityTest.cpp 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 100% rename from src/client/tst/StateTransitionFunctionalityTest.cpp rename to tst/client/StateTransitionFunctionalityTest.cpp diff --git a/src/client/tst/StreamApiFunctionalityScenarioTest.cpp b/tst/client/StreamApiFunctionalityScenarioTest.cpp similarity index 100% rename from src/client/tst/StreamApiFunctionalityScenarioTest.cpp rename to tst/client/StreamApiFunctionalityScenarioTest.cpp diff --git a/src/client/tst/StreamApiFunctionalityTest.cpp b/tst/client/StreamApiFunctionalityTest.cpp similarity index 100% rename from src/client/tst/StreamApiFunctionalityTest.cpp rename to tst/client/StreamApiFunctionalityTest.cpp 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 100% rename from src/client/tst/StreamApiTest.cpp rename to tst/client/StreamApiTest.cpp 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 100% rename from src/client/tst/StreamFunctionalityTest.cpp rename to tst/client/StreamFunctionalityTest.cpp diff --git a/src/client/tst/StreamParallelTest.cpp b/tst/client/StreamParallelTest.cpp similarity index 100% rename from src/client/tst/StreamParallelTest.cpp rename to tst/client/StreamParallelTest.cpp diff --git a/src/client/tst/StreamPutGetTest.cpp b/tst/client/StreamPutGetTest.cpp similarity index 100% rename from src/client/tst/StreamPutGetTest.cpp rename to tst/client/StreamPutGetTest.cpp diff --git a/src/client/tst/StreamRecoveryFunctionalityTest.cpp b/tst/client/StreamRecoveryFunctionalityTest.cpp similarity index 100% rename from src/client/tst/StreamRecoveryFunctionalityTest.cpp rename to tst/client/StreamRecoveryFunctionalityTest.cpp diff --git a/src/client/tst/StreamStateTransitionsTest.cpp b/tst/client/StreamStateTransitionsTest.cpp similarity index 100% rename from src/client/tst/StreamStateTransitionsTest.cpp rename to tst/client/StreamStateTransitionsTest.cpp diff --git a/src/client/tst/StreamStoppingFunctionalityTest.cpp b/tst/client/StreamStoppingFunctionalityTest.cpp similarity index 100% rename from src/client/tst/StreamStoppingFunctionalityTest.cpp rename to tst/client/StreamStoppingFunctionalityTest.cpp diff --git a/src/client/tst/StreamTokenRotationTest.cpp b/tst/client/StreamTokenRotationTest.cpp similarity index 100% rename from src/client/tst/StreamTokenRotationTest.cpp rename to tst/client/StreamTokenRotationTest.cpp 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 100% rename from src/client/tst/TokenRotationFunctionalityTest.cpp rename to tst/client/TokenRotationFunctionalityTest.cpp 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 100% rename from src/heap/tst/HeapApiFunctionalityTest.cpp rename to tst/heap/HeapApiFunctionalityTest.cpp 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 100% rename from src/heap/tst/HybridFileHeapTest.cpp rename to tst/heap/HybridFileHeapTest.cpp 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 100% rename from src/mkvgen/tst/AnnexBCpdNalAdapterTest.cpp rename to tst/mkvgen/AnnexBCpdNalAdapterTest.cpp diff --git a/src/mkvgen/tst/AnnexBNalAdapterTest.cpp b/tst/mkvgen/AnnexBNalAdapterTest.cpp similarity index 100% rename from src/mkvgen/tst/AnnexBNalAdapterTest.cpp rename to tst/mkvgen/AnnexBNalAdapterTest.cpp 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 100% rename from src/mkvgen/tst/MkvgenApiFunctionalityTest.cpp rename to tst/mkvgen/MkvgenApiFunctionalityTest.cpp diff --git a/src/mkvgen/tst/MkvgenApiTest.cpp b/tst/mkvgen/MkvgenApiTest.cpp similarity index 100% rename from src/mkvgen/tst/MkvgenApiTest.cpp rename to tst/mkvgen/MkvgenApiTest.cpp 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/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 100% rename from src/utils/tst/Directory.cpp rename to tst/utils/Directory.cpp 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 100% rename from src/utils/tst/FileLogger.cpp rename to tst/utils/FileLogger.cpp 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 100% rename from src/utils/tst/Threadpool.cpp rename to tst/utils/Threadpool.cpp diff --git a/src/utils/tst/ThreadsafeBlockingQueue.cpp b/tst/utils/ThreadsafeBlockingQueue.cpp similarity index 100% rename from src/utils/tst/ThreadsafeBlockingQueue.cpp rename to tst/utils/ThreadsafeBlockingQueue.cpp 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/src/utils/tst/suppressions/TSAN.supp b/tst/utils/suppressions/TSAN.supp similarity index 100% rename from src/utils/tst/suppressions/TSAN.supp rename to tst/utils/suppressions/TSAN.supp diff --git a/src/utils/tst/suppressions/UBSAN.supp b/tst/utils/suppressions/UBSAN.supp similarity index 100% rename from src/utils/tst/suppressions/UBSAN.supp rename to tst/utils/suppressions/UBSAN.supp 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 From 49e8e66b989741fad0a00884365d1dc9af6d532d Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Thu, 14 Dec 2023 13:55:20 -0500 Subject: [PATCH 05/32] use consistent flags in pic library and test --- tst/CMakeLists.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tst/CMakeLists.txt b/tst/CMakeLists.txt index ce1280e2..403c1062 100644 --- a/tst/CMakeLists.txt +++ b/tst/CMakeLists.txt @@ -4,6 +4,9 @@ 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}) @@ -18,11 +21,16 @@ 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_compile_definitions(kvspic_test PRIVATE ALIGNED_MEMORY_MODEL=TRUE FIXUP_ANNEX_B_TRAILING_NALU_ZERO=TRUE) 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() \ No newline at end of file +endif() + +add_test(${PROJECT_NAME} ${PROJECT_NAME}) \ No newline at end of file From 26c8c910c077a7d579b76fe41353a912d3d1502f Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Thu, 14 Dec 2023 13:56:09 -0500 Subject: [PATCH 06/32] clang format --- src/heap/src/HybridFileHeap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/heap/src/HybridFileHeap.c b/src/heap/src/HybridFileHeap.c index e1291145..70cb89b5 100644 --- a/src/heap/src/HybridFileHeap.c +++ b/src/heap/src/HybridFileHeap.c @@ -214,7 +214,8 @@ DEFINE_HEAP_ALLOC(hybridFileHeapAlloc) DLOGS("Allocating from File heap"); // Try to allocate from file storage - retCode = SNPRINTF(filePath, MAX_PATH_LEN + 1, "%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 @@ -483,7 +484,8 @@ DEFINE_HEAP_UNMAP(hybridFileHeapUnmap) } DLOGS("Indirect allocation"); - retCode = SNPRINTF(filePath, MAX_PATH_LEN + 1, "%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 From 460d592b4285791aa4158f956fb3aed7c99c7fd4 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Thu, 14 Dec 2023 14:45:46 -0500 Subject: [PATCH 07/32] only run test if flag FIXUP_ANNEX_B_TRAILING_NALU_ZERO is set, previously we re-built pic with this flag for the tests but the test itself segfaults if it's not set --- tst/mkvgen/AnnexBCpdNalAdapterTest.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tst/mkvgen/AnnexBCpdNalAdapterTest.cpp b/tst/mkvgen/AnnexBCpdNalAdapterTest.cpp index d7f78f22..aff1a090 100644 --- a/tst/mkvgen/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) { @@ -105,7 +107,11 @@ TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_FixedUpValidSpsPps) UINT32 adaptedCpdSize = SIZEOF(adaptedCpd); EXPECT_EQ(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, NULL, &adaptedCpdSize)); +#ifdef FIXUP_ANNEX_B_TRAILING_NALU_ZERO EXPECT_EQ(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, adaptedCpd, &adaptedCpdSize)); +#else + EXPECT_EQ(STATUS_MKV_INVALID_ANNEXB_NALU_IN_FRAME_DATA, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, adaptedCpd, &adaptedCpdSize)); +#endif } TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_ValidH265) { From c95656c2f89d933e44ca260b3bb6139fa817bb43 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Thu, 14 Dec 2023 16:30:03 -0500 Subject: [PATCH 08/32] put tests behind ifdefs which require flags set --- tst/mkvgen/AnnexBCpdNalAdapterTest.cpp | 6 +++--- tst/mkvgen/AnnexBNalAdapterTest.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tst/mkvgen/AnnexBCpdNalAdapterTest.cpp b/tst/mkvgen/AnnexBCpdNalAdapterTest.cpp index aff1a090..5acc32c6 100644 --- a/tst/mkvgen/AnnexBCpdNalAdapterTest.cpp +++ b/tst/mkvgen/AnnexBCpdNalAdapterTest.cpp @@ -106,11 +106,11 @@ TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_FixedUpValidSpsPps) BYTE adaptedCpd[1000]; UINT32 adaptedCpdSize = SIZEOF(adaptedCpd); - EXPECT_EQ(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, NULL, &adaptedCpdSize)); + ASSERT_EQ(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, NULL, &adaptedCpdSize)); #ifdef FIXUP_ANNEX_B_TRAILING_NALU_ZERO - EXPECT_EQ(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, adaptedCpd, &adaptedCpdSize)); + ASSERT_EQ(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, adaptedCpd, &adaptedCpdSize)); #else - EXPECT_EQ(STATUS_MKV_INVALID_ANNEXB_NALU_IN_FRAME_DATA, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, adaptedCpd, &adaptedCpdSize)); + ASSERT_EQ(STATUS_MKV_INVALID_ANNEXB_NALU_IN_FRAME_DATA, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, adaptedCpd, &adaptedCpdSize)); #endif } diff --git a/tst/mkvgen/AnnexBNalAdapterTest.cpp b/tst/mkvgen/AnnexBNalAdapterTest.cpp index 3073a705..18b9b35b 100644 --- a/tst/mkvgen/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 From b7b78bc8c48ee1ea04c13080793b7fab8f697752 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Thu, 14 Dec 2023 16:34:08 -0500 Subject: [PATCH 09/32] tweak ci yml --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13de85a0..4ab732f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,7 @@ jobs: - name: Run tests run: | cd build - ./tstkvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" + ./tst/kvspic_test --gtest_filter="-TimerQueueFunctionalityTest.*:HeapPerfTest.*" mac-os-m1-build-gcc: runs-on: macos-13-xlarge env: @@ -200,7 +200,7 @@ 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: @@ -220,7 +220,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: From cd93da4f124ca673b388ed65801a2354bb0025fa Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Thu, 14 Dec 2023 17:03:57 -0500 Subject: [PATCH 10/32] more ifdefing tests --- tst/client/ClientApiTest.cpp | 6 ++++++ tst/client/ClientFunctionalityTest.cpp | 5 +++++ tst/client/ClientTestFixture.h | 1 + 3 files changed, 12 insertions(+) diff --git a/tst/client/ClientApiTest.cpp b/tst/client/ClientApiTest.cpp index 74d697f6..8ed78b38 100644 --- a/tst/client/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/tst/client/ClientFunctionalityTest.cpp b/tst/client/ClientFunctionalityTest.cpp index af902c05..d5103ef8 100644 --- a/tst/client/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; } }; diff --git a/tst/client/ClientTestFixture.h b/tst/client/ClientTestFixture.h index 95b23dab..334a245e 100644 --- a/tst/client/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)); \ From 721a45ab4fee451479a05f434179e962c6387f9e Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Thu, 14 Dec 2023 18:26:29 -0500 Subject: [PATCH 11/32] more ifdefs for tests --- .github/workflows/ci.yml | 2 +- tst/heap/HybridFileHeapTest.cpp | 5 +++++ tst/mkvgen/MkvgenApiFunctionalityTest.cpp | 7 ++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ab732f5..553f62df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -135,7 +135,7 @@ jobs: 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 diff --git a/tst/heap/HybridFileHeapTest.cpp b/tst/heap/HybridFileHeapTest.cpp index 3bc3bb7f..d2826572 100644 --- a/tst/heap/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/tst/mkvgen/MkvgenApiFunctionalityTest.cpp b/tst/mkvgen/MkvgenApiFunctionalityTest.cpp index 2faef78b..66c735c0 100644 --- a/tst/mkvgen/MkvgenApiFunctionalityTest.cpp +++ b/tst/mkvgen/MkvgenApiFunctionalityTest.cpp @@ -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)); From 3bd2458bd747ff08752b0eb67dfe154697b6ac39 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Thu, 14 Dec 2023 22:42:54 -0500 Subject: [PATCH 12/32] more changes --- .github/workflows/ci.yml | 4 +-- ...rmittentProducerAutomaticStreamingTest.cpp | 2 +- tst/suppressions/TSAN.supp | 25 +++++++++++++++++++ tst/suppressions/UBSAN.supp | 2 ++ 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 tst/suppressions/TSAN.supp create mode 100644 tst/suppressions/UBSAN.supp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 553f62df..94b2ab63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -135,7 +135,7 @@ jobs: env: CC: clang CXX: clang++ - UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1:suppressions=../tst/suppressions/UBSAN.supp + UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1:suppressions=suppressions/UBSAN.supp AWS_KVS_LOG_LEVEL: 2 steps: - name: Clone repository @@ -207,7 +207,7 @@ jobs: # 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=suppressions/TSAN.supp # steps: # - name: Clone repository # uses: actions/checkout@v2 diff --git a/tst/client/IntermittentProducerAutomaticStreamingTest.cpp b/tst/client/IntermittentProducerAutomaticStreamingTest.cpp index d2f6824d..b66d9527 100644 --- a/tst/client/IntermittentProducerAutomaticStreamingTest.cpp +++ b/tst/client/IntermittentProducerAutomaticStreamingTest.cpp @@ -138,7 +138,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)); } diff --git a/tst/suppressions/TSAN.supp b/tst/suppressions/TSAN.supp new file mode 100644 index 00000000..f6c441f0 --- /dev/null +++ b/tst/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/suppressions/UBSAN.supp b/tst/suppressions/UBSAN.supp new file mode 100644 index 00000000..510734b6 --- /dev/null +++ b/tst/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 From 391ea5714d17fab0c8583b8dd9590a9b68b3c227 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Thu, 14 Dec 2023 22:49:50 -0500 Subject: [PATCH 13/32] correct path for tsan/ubsan suppressions files --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94b2ab63..3bcd5eab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -135,7 +135,7 @@ jobs: env: CC: clang CXX: clang++ - UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1:suppressions=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 @@ -207,7 +207,7 @@ jobs: # CC: clang-7 # CXX: clang++-7 # AWS_KVS_LOG_LEVEL: 2 - # TSAN_OPTIONS: halt_on_error=1:suppressions=suppressions/TSAN.supp + # TSAN_OPTIONS: halt_on_error=1:suppressions=../../tst/suppressions/TSAN.supp # steps: # - name: Clone repository # uses: actions/checkout@v2 From ca550444061b9527fa70700773dcfc28c250e174 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 00:44:59 -0500 Subject: [PATCH 14/32] address warning for linux implicit decl of pthread_getname_np --- .../include/com/amazonaws/kinesis/video/common/CommonDefs.h | 3 +++ 1 file changed, 3 insertions(+) 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 d7ed8a55..e93e89f1 100644 --- a/src/common/include/com/amazonaws/kinesis/video/common/CommonDefs.h +++ b/src/common/include/com/amazonaws/kinesis/video/common/CommonDefs.h @@ -234,6 +234,9 @@ typedef UINT64 MUTEX; #if defined __WINDOWS_BUILD__ typedef PCONDITION_VARIABLE CVAR; #else +#ifdef __linux__ +#define _GNU_SOURCE +#endif #include #include typedef pthread_cond_t* CVAR; From 2b9bb8ebc4ddeea95b68fdb40fb8b090a85541a6 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 00:48:49 -0500 Subject: [PATCH 15/32] define only once --- .../include/com/amazonaws/kinesis/video/common/CommonDefs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e93e89f1..75595c79 100644 --- a/src/common/include/com/amazonaws/kinesis/video/common/CommonDefs.h +++ b/src/common/include/com/amazonaws/kinesis/video/common/CommonDefs.h @@ -234,7 +234,7 @@ typedef UINT64 MUTEX; #if defined __WINDOWS_BUILD__ typedef PCONDITION_VARIABLE CVAR; #else -#ifdef __linux__ +#if defined(__linux__) && !defined(_GNU_SOURCE) #define _GNU_SOURCE #endif #include From 4e430709e66401681342faa298c1b4e03631e07b Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 02:24:55 -0500 Subject: [PATCH 16/32] more ifdefs --- .../amazonaws/kinesis/video/utils/Include.h | 2 + src/utils/src/Threadpool.c | 1 + tst/client/StreamApiFunctionalityTest.cpp | 53 +++++++++++-------- 3 files changed, 33 insertions(+), 23 deletions(-) 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 7a6aeebe..4ff81138 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,8 @@ 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/Threadpool.c b/src/utils/src/Threadpool.c index 2ab9808a..42de3c60 100644 --- a/src/utils/src/Threadpool.c +++ b/src/utils/src/Threadpool.c @@ -418,6 +418,7 @@ STATUS threadpoolInternalInactiveThreadCount(PThreadpool pThreadpool, PSIZE_T pC CHK_STATUS(safeBlockingQueueGetCount(pThreadpool->taskQueue, &pendingTasks)); unblockedThreads = (SIZE_T) ATOMIC_LOAD(&pThreadpool->availableThreads); + CHK_ERR(unblockedThreads >= (SIZE_T) pendingTasks, STATUS_THREADPOOL_INTERNAL_ERROR, "Pending tasks is greater than unblocked threads"); *pCount = unblockedThreads - (SIZE_T) pendingTasks; CleanUp: diff --git a/tst/client/StreamApiFunctionalityTest.cpp b/tst/client/StreamApiFunctionalityTest.cpp index f510cff2..43e3161b 100644 --- a/tst/client/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 From 122391dfa3f176aa3a9f64352d58c21b44ac3dda Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 02:41:14 -0500 Subject: [PATCH 17/32] more ifdefs for tests --- tst/client/StreamApiTest.cpp | 43 +++++++++++++++++-------------- tst/client/StreamParallelTest.cpp | 3 ++- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/tst/client/StreamApiTest.cpp b/tst/client/StreamApiTest.cpp index d5e68c38..dda6cf4f 100644 --- a/tst/client/StreamApiTest.cpp +++ b/tst/client/StreamApiTest.cpp @@ -748,6 +748,7 @@ PVOID streamStopNotifier(PVOID arg) return NULL; } +#ifdef ALIGNED_MEMORY_MODEL TEST_F(StreamApiTest, kinesisVideoStreamCreateSync_Valid) { freeKinesisVideoStream(&mStreamHandle); @@ -777,26 +778,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 +808,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/tst/client/StreamParallelTest.cpp b/tst/client/StreamParallelTest.cpp index 3fa31a9b..5b99c37c 100644 --- a/tst/client/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 From 62374427152e009a9ba7469ba703da9cff1349f1 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 02:49:27 -0500 Subject: [PATCH 18/32] ifdef more tests --- tst/client/StreamPutGetTest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tst/client/StreamPutGetTest.cpp b/tst/client/StreamPutGetTest.cpp index 6d6122dd..ff84b958 100644 --- a/tst/client/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 From 728b25d14d6d4270aba567fd8aab1349da938923 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 03:02:19 -0500 Subject: [PATCH 19/32] more ifdefs --- tst/client/StreamStateTransitionsTest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tst/client/StreamStateTransitionsTest.cpp b/tst/client/StreamStateTransitionsTest.cpp index 93721017..ba3ba816 100644 --- a/tst/client/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 From 83ebe0acac7581ecaa55da4907d290404a025e5f Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 03:08:35 -0500 Subject: [PATCH 20/32] more ifdefs --- .../amazonaws/kinesis/video/utils/Include.h | 1 - src/utils/src/Threadpool.c | 3 ++- tst/client/AcksFunctionalityTest.cpp | 3 ++- ...CallbacksAndPressuresFunctionalityTest.cpp | 3 ++- tst/client/StreamTokenRotationTest.cpp | 3 +++ tst/heap/HeapApiFunctionalityTest.cpp | 23 ++++++++----------- 6 files changed, 19 insertions(+), 17 deletions(-) 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 4ff81138..a96d6f5b 100644 --- a/src/utils/include/com/amazonaws/kinesis/video/utils/Include.h +++ b/src/utils/include/com/amazonaws/kinesis/video/utils/Include.h @@ -70,7 +70,6 @@ extern "C" { #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/Threadpool.c b/src/utils/src/Threadpool.c index 42de3c60..451f0435 100644 --- a/src/utils/src/Threadpool.c +++ b/src/utils/src/Threadpool.c @@ -418,7 +418,8 @@ STATUS threadpoolInternalInactiveThreadCount(PThreadpool pThreadpool, PSIZE_T pC CHK_STATUS(safeBlockingQueueGetCount(pThreadpool->taskQueue, &pendingTasks)); unblockedThreads = (SIZE_T) ATOMIC_LOAD(&pThreadpool->availableThreads); - CHK_ERR(unblockedThreads >= (SIZE_T) pendingTasks, STATUS_THREADPOOL_INTERNAL_ERROR, "Pending tasks is greater than unblocked threads"); + CHK_ERR(unblockedThreads >= (SIZE_T) pendingTasks, STATUS_THREADPOOL_INTERNAL_ERROR, + "Pending tasks: %llu is greater than unblocked threads: %llu", (UINT64) pendingTasks, (UINT64) unblockedThreads); *pCount = unblockedThreads - (SIZE_T) pendingTasks; CleanUp: diff --git a/tst/client/AcksFunctionalityTest.cpp b/tst/client/AcksFunctionalityTest.cpp index d1e44181..3e048812 100644 --- a/tst/client/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/tst/client/CallbacksAndPressuresFunctionalityTest.cpp b/tst/client/CallbacksAndPressuresFunctionalityTest.cpp index 3df3558f..fd39e5f6 100644 --- a/tst/client/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/tst/client/StreamTokenRotationTest.cpp b/tst/client/StreamTokenRotationTest.cpp index 4be03d60..5cd1a773 100644 --- a/tst/client/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/tst/heap/HeapApiFunctionalityTest.cpp b/tst/heap/HeapApiFunctionalityTest.cpp index c74950e0..7c44afd8 100644 --- a/tst/heap/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) { From f89df4456e8d853778e8cef16235bc264a346c05 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 03:58:23 -0500 Subject: [PATCH 21/32] more ifdefs --- tst/client/ClientFunctionalityTest.cpp | 4 +- ...rmittentProducerAutomaticStreamingTest.cpp | 4 ++ tst/client/StreamApiTest.cpp | 42 ++++++++++--------- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/tst/client/ClientFunctionalityTest.cpp b/tst/client/ClientFunctionalityTest.cpp index d5103ef8..98367d8a 100644 --- a/tst/client/ClientFunctionalityTest.cpp +++ b/tst/client/ClientFunctionalityTest.cpp @@ -128,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) { @@ -262,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/tst/client/IntermittentProducerAutomaticStreamingTest.cpp b/tst/client/IntermittentProducerAutomaticStreamingTest.cpp index b66d9527..b32b56f3 100644 --- a/tst/client/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()); @@ -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/tst/client/StreamApiTest.cpp b/tst/client/StreamApiTest.cpp index dda6cf4f..9c8ff78b 100644 --- a/tst/client/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) { From 1f31ee430c9ec439dfd4273efe1565fe0a5a869a Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 04:01:31 -0500 Subject: [PATCH 22/32] more ifdefs --- tst/client/IntermittentProducerFunctionalityTest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tst/client/IntermittentProducerFunctionalityTest.cpp b/tst/client/IntermittentProducerFunctionalityTest.cpp index 82371111..8a5f172d 100644 --- a/tst/client/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 From cc17b9d6c458305f63349f2b69c25a8a8f15754c Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 04:06:50 -0500 Subject: [PATCH 23/32] more ifdefs --- tst/client/StateTransitionFunctionalityTest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tst/client/StateTransitionFunctionalityTest.cpp b/tst/client/StateTransitionFunctionalityTest.cpp index b396c02d..f717dd60 100644 --- a/tst/client/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) { From 7e5b4a8c9b7f7242a81daf72495f2b5044b28215 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 10:11:37 -0500 Subject: [PATCH 24/32] if thread count is going to overflow, return 0 --- src/utils/src/Threadpool.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils/src/Threadpool.c b/src/utils/src/Threadpool.c index 451f0435..e251c637 100644 --- a/src/utils/src/Threadpool.c +++ b/src/utils/src/Threadpool.c @@ -418,9 +418,7 @@ STATUS threadpoolInternalInactiveThreadCount(PThreadpool pThreadpool, PSIZE_T pC CHK_STATUS(safeBlockingQueueGetCount(pThreadpool->taskQueue, &pendingTasks)); unblockedThreads = (SIZE_T) ATOMIC_LOAD(&pThreadpool->availableThreads); - CHK_ERR(unblockedThreads >= (SIZE_T) pendingTasks, STATUS_THREADPOOL_INTERNAL_ERROR, - "Pending tasks: %llu is greater than unblocked threads: %llu", (UINT64) pendingTasks, (UINT64) unblockedThreads); - *pCount = unblockedThreads - (SIZE_T) pendingTasks; + *pCount = unblockedThreads > (SIZE_T) pendingTasks ? (unblockedThreads - (SIZE_T) pendingTasks) : 0; CleanUp: return retStatus; From 63492dd4a371595a60ab8d5958064b54314b7d26 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 10:33:44 -0500 Subject: [PATCH 25/32] another if/def --- tst/client/StreamApiFunctionalityScenarioTest.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tst/client/StreamApiFunctionalityScenarioTest.cpp b/tst/client/StreamApiFunctionalityScenarioTest.cpp index 329f6229..db63b94e 100644 --- a/tst/client/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 From a36bfb2ad8920aff3ac9df4586647d78bdb297a0 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 10:48:18 -0500 Subject: [PATCH 26/32] add build and testing with ALIGNED_MEMORY_MODEL and FIXUP_ANNEX_B_TRAILING_NALU_ZERO to test both paths in CI --- .github/workflows/ci.yml | 81 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3bcd5eab..a584bde2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,16 @@ jobs: 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-build-clang: runs-on: macos-latest env: @@ -56,6 +66,16 @@ jobs: 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: @@ -73,6 +93,16 @@ jobs: 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: @@ -92,6 +122,16 @@ jobs: 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: @@ -109,6 +149,17 @@ jobs: 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 ./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 @@ -130,6 +181,16 @@ jobs: 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 .. -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: @@ -154,6 +215,16 @@ jobs: 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 .. -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: @@ -181,6 +252,16 @@ jobs: 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 .. -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: From 7757669338c31a58161906614fe8e4825320f17a Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 13:10:59 -0500 Subject: [PATCH 27/32] more ifdefs for unalign access --- tst/client/StreamFunctionalityTest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tst/client/StreamFunctionalityTest.cpp b/tst/client/StreamFunctionalityTest.cpp index d25f656f..d894c481 100644 --- a/tst/client/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) From 4843b1bb32a35c3e9004ff470d474de2345d2637 Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 13:55:56 -0500 Subject: [PATCH 28/32] more ifdefs for ubsan --- tst/client/StreamRecoveryFunctionalityTest.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tst/client/StreamRecoveryFunctionalityTest.cpp b/tst/client/StreamRecoveryFunctionalityTest.cpp index 0057eabd..426a27de 100644 --- a/tst/client/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 From d86d19655b753e597ca16bae5a6b582ef437afea Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 14:06:16 -0500 Subject: [PATCH 29/32] ifdef more tests for aligned memory model --- src/utils/src/Threadpool.c | 5 --- .../StreamStoppingFunctionalityTest.cpp | 43 +++++++++++-------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/utils/src/Threadpool.c b/src/utils/src/Threadpool.c index e251c637..edb38c47 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; diff --git a/tst/client/StreamStoppingFunctionalityTest.cpp b/tst/client/StreamStoppingFunctionalityTest.cpp index 38e11157..b21f801d 100644 --- a/tst/client/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))); From 64646c56681464fce2f4d7aafa7dc3719052051a Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 14:17:34 -0500 Subject: [PATCH 30/32] more memory aligned ifdefs for tests --- tst/client/TokenRotationFunctionalityTest.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tst/client/TokenRotationFunctionalityTest.cpp b/tst/client/TokenRotationFunctionalityTest.cpp index 3445bd6d..f801e230 100644 --- a/tst/client/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 From c67aef788088177faba2da648142fbebc538e55e Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Fri, 15 Dec 2023 14:43:03 -0500 Subject: [PATCH 31/32] more if defs in tests --- tst/heap/HybridHeapTest.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tst/heap/HybridHeapTest.cpp b/tst/heap/HybridHeapTest.cpp index 345af348..841e97b4 100644 --- a/tst/heap/HybridHeapTest.cpp +++ b/tst/heap/HybridHeapTest.cpp @@ -16,6 +16,12 @@ class HybridHeapTest : 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_VRAM_HEAP; // Set the invalid allocation handles From bb7f0877c0c093c4a488482251d6af2c0bab1ebe Mon Sep 17 00:00:00 2001 From: Hassan Sahibzada Date: Mon, 18 Dec 2023 18:15:52 -0500 Subject: [PATCH 32/32] make sure correct number of bytes for snprintf --- src/utils/src/Allocators.c | 2 +- tst/heap/HybridHeapTest.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utils/src/Allocators.c b/src/utils/src/Allocators.c index 6016eadb..7530fc7e 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++) { - SNPRINTF(pCur, 2, "%02x ", *pByte++); + SNPRINTF(pCur, 4, "%02x ", *pByte++); pCur += 3; if ((i + 1) % 16 == 0) { DLOGS("%s", buf); diff --git a/tst/heap/HybridHeapTest.cpp b/tst/heap/HybridHeapTest.cpp index 841e97b4..41e01d2e 100644 --- a/tst/heap/HybridHeapTest.cpp +++ b/tst/heap/HybridHeapTest.cpp @@ -21,7 +21,6 @@ class HybridHeapTest : public HeapTestBase, primaryHeapType = FLAGS_USE_SYSTEM_HEAP; } #endif - mHeapType = primaryHeapType | FLAGS_USE_HYBRID_VRAM_HEAP; // Set the invalid allocation handles