Skip to content

PR to get the latest code coverage#272

Closed
shibu-kv wants to merge 2 commits intomainfrom
develop
Closed

PR to get the latest code coverage#272
shibu-kv wants to merge 2 commits intomainfrom
develop

Conversation

@shibu-kv
Copy link
Contributor

No description provided.

shibu-kv and others added 2 commits February 6, 2026 09:33
* RDK-60805: Adding L1 unit test cases for reportprofiles

Reason for change: Adding L1 unit test cases for reportprofiles
Test Procedure:  Tested and verified
Risks: Medium
Priority: P1
Signed-off-by: Rose Mary Benny <RoseMary_Benny@comcast.com>

* Adding Apache banners to new files

* added GTEST_ENABLE flag for bulkdata

---------

Signed-off-by: Rose Mary Benny <RoseMary_Benny@comcast.com>
Co-authored-by: shibu-kv <shibu.kakkoth@gmail.com>
Copilot AI review requested due to automatic review settings February 18, 2026 21:12
@shibu-kv shibu-kv requested a review from a team as a code owner February 18, 2026 21:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds comprehensive test coverage for the report profiles functionality in the telemetry system. The changes introduce new unit tests for reportprofiles.c and expand existing tests in profileTest.cpp, along with the necessary mock infrastructure and build system configuration.

Changes:

  • Added new test file reportprofilesTest.cpp with tests for report profile processing (msgpack and JSON blob handling)
  • Created mock infrastructure (reportprofileMock and profileMock) to support testing of HTTP reporting and RBUS functionality
  • Enhanced existing profileTest.cpp with additional test cases for profile management, callbacks, and edge cases
  • Updated build configuration to enable test compilation with proper linker wrapping for mock functions

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
test/run_ut.sh Added reportprofiles_gtest.bin to the test execution list
source/test/bulkdata/reportprofilesTest.cpp New test file with 6 test cases covering report profile blob processing
source/test/bulkdata/reportprofileMock.h Mock header for isRbusEnabled and HTTP reporting functions
source/test/bulkdata/reportprofileMock.cpp Mock implementation with _wrap functions for linker wrapping
source/test/bulkdata/profileMock.h Mock header for HTTP reporting functions used in profile tests
source/test/bulkdata/profileMock.cpp Mock implementation for HTTP functions
source/test/bulkdata/profileTest.cpp Added 11 new test cases and helper function calls for enhanced coverage
source/test/bulkdata/Makefile.am Fixed syntax error, added GTEST_ENABLE flags, configured new test binary with linker wrapping
source/ccspinterface/rbusInterface.c Added DCMAGENT guard for GTEST_ENABLE callback function
source/bulkdata/reportprofiles.c Added GTEST_ENABLE callback functions, removed unnecessary blank lines
source/bulkdata/profilexconf.c Added test helper function to set reportThreadExits for testing
source/bulkdata/profile.c Added macro definitions to redirect HTTP functions to _wrap versions for testing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +60 to +67
void SetUp() override {
g_reportprofileMock = new reportprofileMock();
g_systemMock = new SystemMock();
g_fileIOMock = new FileMock();
m_rdklogMock = new rdklogMock();
g_rbusMock = new rbusMock();
g_vectorMock = new VectorMock();
}
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

The test fixture does not initialize g_schedulerMock in SetUp, but declares it as extern. If tests using this fixture call functions that depend on g_schedulerMock (which is defined elsewhere), there may be issues if it's null. Consider whether this mock needs to be initialized here or if the extern declaration is sufficient for your use case.

Copilot uses AI. Check for mistakes.
.Times(::testing::AtMost(5))
.WillRepeatedly(Return(T2ERROR_SUCCESS));

EXPECT_EQ(ReportProfiles_uninit(), T2ERROR_FAILURE);
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

This test expects ReportProfiles_uninit to return T2ERROR_FAILURE, which seems counterintuitive for a unit test. Tests typically verify successful operation unless specifically testing error handling. Consider whether the expected return value is correct or if the test setup needs adjustment to allow successful uninitialization.

Suggested change
EXPECT_EQ(ReportProfiles_uninit(), T2ERROR_FAILURE);
EXPECT_EQ(ReportProfiles_uninit(), T2ERROR_SUCCESS);

Copilot uses AI. Check for mistakes.
#include "t2log_wrapper.h"
#include "msgpack.h"
#include <glib.h>
#include <glib/gi18n.h>
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

Trailing whitespace found on this line after the include statement. This should be removed to maintain code cleanliness.

Suggested change
#include <glib/gi18n.h>
#include <glib/gi18n.h>

Copilot uses AI. Check for mistakes.
ProfileXConf profile;
EXPECT_CALL(*g_vectorMock, Vector_Size(_))
.Times(::testing::AtMost(1))
.WillRepeatedly(Return(0)); // Return 1 to indicate only one profile (no duplicates)
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

The comment on this line is incorrect. The mock is set to return 0 (indicating an empty list), not 1 (one profile). The comment should be updated to match the actual behavior or removed if it's a copy-paste error.

Copilot uses AI. Check for mistakes.
Comment on lines +61 to +75
g_reportprofileMock = new reportprofileMock();
g_systemMock = new SystemMock();
g_fileIOMock = new FileMock();
m_rdklogMock = new rdklogMock();
g_rbusMock = new rbusMock();
g_vectorMock = new VectorMock();
}
void TearDown() override {
delete g_reportprofileMock;
delete g_systemMock;
delete g_fileIOMock;
delete m_rdklogMock;
delete g_rbusMock;
delete g_vectorMock;
g_reportprofileMock = nullptr;
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

Inconsistent indentation: Lines 61, 69, and 75 use tabs while the surrounding lines use spaces. This should be corrected to match the indentation style of the rest of the file.

Copilot uses AI. Check for mistakes.
EXPECT_CALL(*g_vectorMock, Vector_Destroy(_, _)).Times(::testing::AtMost(1))
.WillRepeatedly(Return(T2ERROR_SUCCESS));

ReportProfiles_ProcessReportProfilesMsgPackBlob(msg->msgpack_blob, msg->msgpack_blob_size);
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

Memory leak: The allocated memory for 'msg' and 'webConfigString' is not freed before the test ends. This should be cleaned up to prevent memory leaks in the test suite.

Suggested change
ReportProfiles_ProcessReportProfilesMsgPackBlob(msg->msgpack_blob, msg->msgpack_blob_size);
ReportProfiles_ProcessReportProfilesMsgPackBlob(msg->msgpack_blob, msg->msgpack_blob_size);
g_free(msg->msgpack_blob);
free(msg);

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +20
//#ifndef SOURCE_TEST_MOCKS_SYSTEMMOCK_H_
//#define SOURCE_TEST_MOCKS_SYSTEMMOCK_H_

Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

Commented-out code should be removed. If this code is not needed, it should be deleted rather than left as a comment. Version control systems can track historical code if needed.

Suggested change
//#ifndef SOURCE_TEST_MOCKS_SYSTEMMOCK_H_
//#define SOURCE_TEST_MOCKS_SYSTEMMOCK_H_

Copilot uses AI. Check for mistakes.
gsProfile->execCounter = 0;
}
profile->grepSeekProfile = gsProfile;
//profile->grepSeekProfile = nullptr;
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

Commented-out code should be removed. This line sets a property that is subsequently commented out, indicating uncertainty about the test setup. Either use it or remove it.

Suggested change
//profile->grepSeekProfile = nullptr;

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

Code Coverage Summary

                                   Total:|62.1%   8993|89.2%   332|    -      0

@rdkcmf-jenkins
Copy link
Contributor

Coverity Issue - Data race condition

Accessing "profile->grepSeekProfile->execCounter" without holding lock "plMutex". Elsewhere, "_GrepSeekProfile.execCounter" is written to with "plMutex" held 2 out of 2 times.

Medium Impact, CWE-366
MISSING_LOCK

Issue location

This issue was discovered outside the diff for this Pull Request. You can find it at:
source/bulkdata/profile.c:344

@shibu-kv shibu-kv closed this Feb 20, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Feb 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants