From c0ac43120da2deadc1c1fab5a80ca397f4373211 Mon Sep 17 00:00:00 2001 From: rdkdevpilot Date: Mon, 14 Sep 2026 22:01:54 +0530 Subject: [PATCH 1/6] Fix MISSING_LOCK in profilexconf.c Defect ID: a9153b55-435d-4580-9dfa-558bdc89f783 --- source/bulkdata/profilexconf.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/source/bulkdata/profilexconf.c b/source/bulkdata/profilexconf.c index cda933f9..4b529c68 100644 --- a/source/bulkdata/profilexconf.c +++ b/source/bulkdata/profilexconf.c @@ -535,11 +535,20 @@ static void* CollectAndReportXconf(void* data) } // Notify status of upload in case of on demand report upload. - if(isOnDemandReport) + pthread_mutex_lock(&xconfProfileLock); + bool localIsOnDemandReport = isOnDemandReport; + bool localIsAbortTriggered = isAbortTriggered; + if(isAbortTriggered == true) + { + isAbortTriggered = false; + } + pthread_mutex_unlock(&xconfProfileLock); + + if(localIsOnDemandReport) { if(ret == T2ERROR_FAILURE) { - if(isAbortTriggered) + if(localIsAbortTriggered) { publishReportUploadStatus("ABORTED"); } @@ -554,12 +563,6 @@ static void* CollectAndReportXconf(void* data) } } - // Reset the abort trigger flags - if(isAbortTriggered == true) - { - isAbortTriggered = false ; - } - /* CRITICAL SECTION START: Re-acquire xconfProfileLock before updating profile state. * pthread_cond_wait requires us to hold xconfProfileLock, so we acquire it here * and hold it through the state update and into the cond_wait. From cdfcc8ea100ad62295e543889fabfd5e998737b5 Mon Sep 17 00:00:00 2001 From: tabbas651 Date: Wed, 30 Sep 2026 11:07:40 -0400 Subject: [PATCH 2/6] Added ProfileXConf_OnDemandStatusSnapshot test cases --- .github/workflows/L2-tests.yml | 4 ++ source/bulkdata/profilexconf.c | 60 +++++++++++++---------- source/test/bulkdata/profilexconfTest.cpp | 16 ++++++ 3 files changed, 53 insertions(+), 27 deletions(-) diff --git a/.github/workflows/L2-tests.yml b/.github/workflows/L2-tests.yml index 0f2bce37..a6eff822 100644 --- a/.github/workflows/L2-tests.yml +++ b/.github/workflows/L2-tests.yml @@ -57,6 +57,10 @@ jobs: run: | docker run -d --name native-platform --link mockxconf -e ENABLE_MTLS=true -v ${{ github.workspace }}:/mnt/L2_CONTAINER_SHARED_VOLUME ghcr.io/rdkcentral/docker-device-mgt-service-test/native-platform:latest + - name: Provision RDK logger configuration + run: | + docker exec native-platform /bin/bash -c "printf 'LOG.RDK.DEFAULT=INFO\\nLOG.RDK.T2=DEBUG\\n' > /etc/debug.ini && chmod 644 /etc/debug.ini" + - name: Enter Inside Platform native container and run L2 Test run: | docker exec -i native-platform /bin/bash -c "cd /mnt/L2_CONTAINER_SHARED_VOLUME/ && sh build_inside_container.sh && export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/lib/aarch64-linux-gnu:/usr/local/lib: && sh test/run_l2.sh" diff --git a/source/bulkdata/profilexconf.c b/source/bulkdata/profilexconf.c index a12a7ff2..0dc2b340 100644 --- a/source/bulkdata/profilexconf.c +++ b/source/bulkdata/profilexconf.c @@ -113,6 +113,29 @@ static void freeConfig(void *data) } } +static void publishReportUploadStatusForResult(T2ERROR ret) +{ + pthread_mutex_lock(&xconfProfileLock); + bool localIsOnDemandReport = isOnDemandReport; + bool localIsAbortTriggered = isAbortTriggered; + isAbortTriggered = false; + pthread_mutex_unlock(&xconfProfileLock); + + if(!localIsOnDemandReport) + { + return; + } + + if(ret == T2ERROR_FAILURE) + { + publishReportUploadStatus(localIsAbortTriggered ? "ABORTED" : "FAILURE"); + } + else + { + publishReportUploadStatus("SUCCESS"); + } +} + static void freeProfileXConf() { if(singleProfile != NULL) @@ -548,33 +571,7 @@ static void* CollectAndReportXconf(void* data) } // Notify status of upload in case of on demand report upload. - pthread_mutex_lock(&xconfProfileLock); - bool localIsOnDemandReport = isOnDemandReport; - bool localIsAbortTriggered = isAbortTriggered; - if(isAbortTriggered == true) - { - isAbortTriggered = false; - } - pthread_mutex_unlock(&xconfProfileLock); - - if(localIsOnDemandReport) - { - if(ret == T2ERROR_FAILURE) - { - if(localIsAbortTriggered) - { - publishReportUploadStatus("ABORTED"); - } - else - { - publishReportUploadStatus("FAILURE"); - } - } - else - { - publishReportUploadStatus("SUCCESS"); - } - } + publishReportUploadStatusForResult(ret); /* CRITICAL SECTION START: Re-acquire xconfProfileLock before updating profile state. * pthread_cond_wait requires us to hold xconfProfileLock, so we acquire it here @@ -1189,6 +1186,15 @@ T2ERROR ProfileXConf_storeMarkerEvent(T2Event *eventInfo) return T2ERROR_SUCCESS; } #ifdef GTEST_ENABLE +void test_publishReportUploadStatusForResult(T2ERROR ret, bool isOnDemand, bool isAbort) +{ + pthread_mutex_lock(&xconfProfileLock); + isOnDemandReport = isOnDemand; + isAbortTriggered = isAbort; + pthread_mutex_unlock(&xconfProfileLock); + publishReportUploadStatusForResult(ret); +} + void test_set_reportThreadExits(bool value) { reportThreadExits = value; diff --git a/source/test/bulkdata/profilexconfTest.cpp b/source/test/bulkdata/profilexconfTest.cpp index 7ab28d2d..bf4b064c 100644 --- a/source/test/bulkdata/profilexconfTest.cpp +++ b/source/test/bulkdata/profilexconfTest.cpp @@ -55,6 +55,8 @@ using ::testing::Invoke; using ::testing::SetArgPointee; using ::testing::DoAll; +extern "C" void test_publishReportUploadStatusForResult(T2ERROR ret, bool isOnDemand, bool isAbort); + rbusMock* g_rbusMock = nullptr; SystemMock* g_systemMock = nullptr; FileMock* g_fileIOMock = nullptr; @@ -548,6 +550,20 @@ TEST_F(profileXconfTestFixture, ReportProfiles_storeMarkerEvent_success_2) free(eventInfo); } +TEST_F(profileXconfTestFixture, ProfileXConf_OnDemandStatusSnapshot) +{ + EXPECT_CALL(*g_profileXConfMock, publishReportUploadStatus(StrEq("FAILURE"))) + .Times(1); + EXPECT_CALL(*g_profileXConfMock, publishReportUploadStatus(StrEq("ABORTED"))) + .Times(1); + EXPECT_CALL(*g_profileXConfMock, publishReportUploadStatus(StrEq("SUCCESS"))) + .Times(1); + + test_publishReportUploadStatusForResult(T2ERROR_FAILURE, true, false); + test_publishReportUploadStatusForResult(T2ERROR_FAILURE, true, true); + test_publishReportUploadStatusForResult(T2ERROR_SUCCESS, true, false); +} + //ProfileXConf_notifyTimeout Test the timeout of the profile /* TEST_F(profileXconfTestFixture, ProfileXConf_notifyTimeout) From ca88c1a0be4e6574927d33efaebaa67ea815b375 Mon Sep 17 00:00:00 2001 From: tabbas651 Date: Wed, 30 Sep 2026 11:33:57 -0400 Subject: [PATCH 3/6] updated test cases Sets abort state once. Verifies the first failure publishes ABORTED. Calls the helper again without resetting globals. Verifies the next failure publishes FAILURE, proving isAbortTriggered was reset. Adds a separate non-on-demand test verifying no status is published. --- source/bulkdata/profilexconf.c | 6 +++++- source/test/bulkdata/profilexconfTest.cpp | 23 ++++++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/source/bulkdata/profilexconf.c b/source/bulkdata/profilexconf.c index 0dc2b340..41abe597 100644 --- a/source/bulkdata/profilexconf.c +++ b/source/bulkdata/profilexconf.c @@ -1186,12 +1186,16 @@ T2ERROR ProfileXConf_storeMarkerEvent(T2Event *eventInfo) return T2ERROR_SUCCESS; } #ifdef GTEST_ENABLE -void test_publishReportUploadStatusForResult(T2ERROR ret, bool isOnDemand, bool isAbort) +void test_setReportUploadStatusState(bool isOnDemand, bool isAbort) { pthread_mutex_lock(&xconfProfileLock); isOnDemandReport = isOnDemand; isAbortTriggered = isAbort; pthread_mutex_unlock(&xconfProfileLock); +} + +void test_publishReportUploadStatusForResult(T2ERROR ret) +{ publishReportUploadStatusForResult(ret); } diff --git a/source/test/bulkdata/profilexconfTest.cpp b/source/test/bulkdata/profilexconfTest.cpp index bf4b064c..075fffa6 100644 --- a/source/test/bulkdata/profilexconfTest.cpp +++ b/source/test/bulkdata/profilexconfTest.cpp @@ -55,7 +55,8 @@ using ::testing::Invoke; using ::testing::SetArgPointee; using ::testing::DoAll; -extern "C" void test_publishReportUploadStatusForResult(T2ERROR ret, bool isOnDemand, bool isAbort); +extern "C" void test_setReportUploadStatusState(bool isOnDemand, bool isAbort); +extern "C" void test_publishReportUploadStatusForResult(T2ERROR ret); rbusMock* g_rbusMock = nullptr; SystemMock* g_systemMock = nullptr; @@ -552,16 +553,24 @@ TEST_F(profileXconfTestFixture, ReportProfiles_storeMarkerEvent_success_2) TEST_F(profileXconfTestFixture, ProfileXConf_OnDemandStatusSnapshot) { - EXPECT_CALL(*g_profileXConfMock, publishReportUploadStatus(StrEq("FAILURE"))) - .Times(1); + testing::InSequence sequence; EXPECT_CALL(*g_profileXConfMock, publishReportUploadStatus(StrEq("ABORTED"))) .Times(1); - EXPECT_CALL(*g_profileXConfMock, publishReportUploadStatus(StrEq("SUCCESS"))) + EXPECT_CALL(*g_profileXConfMock, publishReportUploadStatus(StrEq("FAILURE"))) .Times(1); - test_publishReportUploadStatusForResult(T2ERROR_FAILURE, true, false); - test_publishReportUploadStatusForResult(T2ERROR_FAILURE, true, true); - test_publishReportUploadStatusForResult(T2ERROR_SUCCESS, true, false); + test_setReportUploadStatusState(true, true); + test_publishReportUploadStatusForResult(T2ERROR_FAILURE); + test_publishReportUploadStatusForResult(T2ERROR_FAILURE); +} + +TEST_F(profileXconfTestFixture, ProfileXConf_NonOnDemandStatusIsIgnored) +{ + EXPECT_CALL(*g_profileXConfMock, publishReportUploadStatus(_)) + .Times(0); + + test_setReportUploadStatusState(false, true); + test_publishReportUploadStatusForResult(T2ERROR_FAILURE); } //ProfileXConf_notifyTimeout Test the timeout of the profile From 7e812ab302a8c9e1a5b4e5a6025c01e130465a32 Mon Sep 17 00:00:00 2001 From: tabbas651 <74683978+tabbas651@users.noreply.github.com> Date: Wed, 30 Sep 2026 12:41:37 -0400 Subject: [PATCH 4/6] Potential fix for pull request finding 'Reset isOnDemandReport after test execution' Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- source/test/bulkdata/profilexconfTest.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/test/bulkdata/profilexconfTest.cpp b/source/test/bulkdata/profilexconfTest.cpp index 075fffa6..21e7746b 100644 --- a/source/test/bulkdata/profilexconfTest.cpp +++ b/source/test/bulkdata/profilexconfTest.cpp @@ -562,6 +562,7 @@ TEST_F(profileXconfTestFixture, ProfileXConf_OnDemandStatusSnapshot) test_setReportUploadStatusState(true, true); test_publishReportUploadStatusForResult(T2ERROR_FAILURE); test_publishReportUploadStatusForResult(T2ERROR_FAILURE); + test_setReportUploadStatusState(false, false); } TEST_F(profileXconfTestFixture, ProfileXConf_NonOnDemandStatusIsIgnored) From 51dea245f6bee44182f6d2d7c650a4a2e61bd007 Mon Sep 17 00:00:00 2001 From: tabbas651 <74683978+tabbas651@users.noreply.github.com> Date: Wed, 30 Sep 2026 12:43:42 -0400 Subject: [PATCH 5/6] Update profilexconfTest.cpp --- source/test/bulkdata/profilexconfTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/test/bulkdata/profilexconfTest.cpp b/source/test/bulkdata/profilexconfTest.cpp index 21e7746b..e2ad1068 100644 --- a/source/test/bulkdata/profilexconfTest.cpp +++ b/source/test/bulkdata/profilexconfTest.cpp @@ -562,7 +562,7 @@ TEST_F(profileXconfTestFixture, ProfileXConf_OnDemandStatusSnapshot) test_setReportUploadStatusState(true, true); test_publishReportUploadStatusForResult(T2ERROR_FAILURE); test_publishReportUploadStatusForResult(T2ERROR_FAILURE); - test_setReportUploadStatusState(false, false); + test_setReportUploadStatusState(false, false); } TEST_F(profileXconfTestFixture, ProfileXConf_NonOnDemandStatusIsIgnored) From 05dd4f46ff663ba72425ecc0ae671867810c0658 Mon Sep 17 00:00:00 2001 From: tabbas651 <74683978+tabbas651@users.noreply.github.com> Date: Wed, 30 Sep 2026 14:37:04 -0400 Subject: [PATCH 6/6] Update L2-tests.yml --- .github/workflows/L2-tests.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/L2-tests.yml b/.github/workflows/L2-tests.yml index a6eff822..0f2bce37 100644 --- a/.github/workflows/L2-tests.yml +++ b/.github/workflows/L2-tests.yml @@ -57,10 +57,6 @@ jobs: run: | docker run -d --name native-platform --link mockxconf -e ENABLE_MTLS=true -v ${{ github.workspace }}:/mnt/L2_CONTAINER_SHARED_VOLUME ghcr.io/rdkcentral/docker-device-mgt-service-test/native-platform:latest - - name: Provision RDK logger configuration - run: | - docker exec native-platform /bin/bash -c "printf 'LOG.RDK.DEFAULT=INFO\\nLOG.RDK.T2=DEBUG\\n' > /etc/debug.ini && chmod 644 /etc/debug.ini" - - name: Enter Inside Platform native container and run L2 Test run: | docker exec -i native-platform /bin/bash -c "cd /mnt/L2_CONTAINER_SHARED_VOLUME/ && sh build_inside_container.sh && export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/lib/aarch64-linux-gnu:/usr/local/lib: && sh test/run_l2.sh"