-
Notifications
You must be signed in to change notification settings - Fork 21
RDK-60805: Adding L1 unit test cases for reportprofiles #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #include <stdbool.h> | ||
shibu-kv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #include <cjson/cJSON.h> | ||
| #include "test/bulkdata/reportprofileMock.h" | ||
|
|
||
|
|
||
|
|
||
| // Mock Method | ||
|
|
||
| extern "C" bool __wrap_isRbusEnabled() | ||
| { | ||
| if (!g_reportprofileMock) | ||
| { | ||
| return false; | ||
| } | ||
| return g_reportprofileMock->isRbusEnabled(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #pragma once | ||
|
|
||
| #include <gtest/gtest.h> | ||
| #include <gmock/gmock.h> | ||
|
|
||
|
|
||
| #include "telemetry2_0.h" | ||
|
|
||
| class reportprofileMock | ||
| { | ||
| public: | ||
|
|
||
| MOCK_METHOD(bool, isRbusEnabled, (), ()); | ||
| }; | ||
|
|
||
| extern reportprofileMock *g_reportprofileMock; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,126 @@ | ||||||||||||||||||||||||||||||||||
| #include <gtest/gtest.h> | ||||||||||||||||||||||||||||||||||
shibu-kv marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||
| #include <gmock/gmock.h> | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| extern "C" { | ||||||||||||||||||||||||||||||||||
| #include "reportprofiles.h" | ||||||||||||||||||||||||||||||||||
| #include "profile.h" | ||||||||||||||||||||||||||||||||||
| #include "t2eventreceiver.h" | ||||||||||||||||||||||||||||||||||
| #include "t2collection.h" | ||||||||||||||||||||||||||||||||||
| #include "t2log_wrapper.h" | ||||||||||||||||||||||||||||||||||
| #include "msgpack.h" | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #include "test/mocks/SystemMock.h" | ||||||||||||||||||||||||||||||||||
| #include "test/mocks/FileioMock.h" | ||||||||||||||||||||||||||||||||||
| #include "test/mocks/rdklogMock.h" | ||||||||||||||||||||||||||||||||||
| #include "test/mocks/rbusMock.h" | ||||||||||||||||||||||||||||||||||
| #include "test/mocks/rdkconfigMock.h" | ||||||||||||||||||||||||||||||||||
| #include "test/mocks/VectorMock.h" | ||||||||||||||||||||||||||||||||||
| #include "test/bulkdata/SchedulerMock.h" | ||||||||||||||||||||||||||||||||||
| #include "reportprofileMock.h" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| using namespace std; | ||||||||||||||||||||||||||||||||||
| using ::testing::_; | ||||||||||||||||||||||||||||||||||
| using ::testing::Return; | ||||||||||||||||||||||||||||||||||
| using ::testing::StrEq; | ||||||||||||||||||||||||||||||||||
| using ::testing::Invoke; | ||||||||||||||||||||||||||||||||||
| // Create global mocks if you need them just like t2markersTest.cpp | ||||||||||||||||||||||||||||||||||
| FileMock *g_fileIOMock = NULL; | ||||||||||||||||||||||||||||||||||
| SystemMock * g_systemMock = NULL; | ||||||||||||||||||||||||||||||||||
| rdklogMock *m_rdklogMock = NULL; | ||||||||||||||||||||||||||||||||||
| rbusMock *g_rbusMock = NULL; | ||||||||||||||||||||||||||||||||||
| rdkconfigMock *g_rdkconfigMock = nullptr; | ||||||||||||||||||||||||||||||||||
| extern VectorMock *g_vectorMock; | ||||||||||||||||||||||||||||||||||
| extern SchedulerMock *g_schedulerMock; | ||||||||||||||||||||||||||||||||||
| reportprofileMock* g_reportprofileMock = nullptr; | ||||||||||||||||||||||||||||||||||
| // Test fixture for reportprofiles | ||||||||||||||||||||||||||||||||||
| class reportprofilesTestFixture : public ::testing::Test { | ||||||||||||||||||||||||||||||||||
| protected: | ||||||||||||||||||||||||||||||||||
| 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(); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+60
to
+67
|
||||||||||||||||||||||||||||||||||
| void TearDown() override { | ||||||||||||||||||||||||||||||||||
| delete g_reportprofileMock; | ||||||||||||||||||||||||||||||||||
| delete g_systemMock; | ||||||||||||||||||||||||||||||||||
| delete g_fileIOMock; | ||||||||||||||||||||||||||||||||||
| delete m_rdklogMock; | ||||||||||||||||||||||||||||||||||
| delete g_rbusMock; | ||||||||||||||||||||||||||||||||||
| delete g_vectorMock; | ||||||||||||||||||||||||||||||||||
| g_reportprofileMock = nullptr; | ||||||||||||||||||||||||||||||||||
| g_systemMock = nullptr; | ||||||||||||||||||||||||||||||||||
| g_fileIOMock = nullptr; | ||||||||||||||||||||||||||||||||||
| m_rdklogMock = nullptr; | ||||||||||||||||||||||||||||||||||
| g_rbusMock = nullptr; | ||||||||||||||||||||||||||||||||||
| g_vectorMock = nullptr; | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+74
to
+80
|
||||||||||||||||||||||||||||||||||
| delete g_vectorMock; | |
| g_reportprofileMock = nullptr; | |
| g_systemMock = nullptr; | |
| g_fileIOMock = nullptr; | |
| m_rdklogMock = nullptr; | |
| g_rbusMock = nullptr; | |
| g_vectorMock = nullptr; | |
| delete g_vectorMock; | |
| delete g_schedulerMock; | |
| g_reportprofileMock = nullptr; | |
| g_systemMock = nullptr; | |
| g_fileIOMock = nullptr; | |
| m_rdklogMock = nullptr; | |
| g_rbusMock = nullptr; | |
| g_vectorMock = nullptr; | |
| g_schedulerMock = nullptr; |
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case doesn't verify any behavior or outcome after calling ReportProfiles_ProcessReportProfilesBlob with an empty profiles array and T2_TEMP_RP flag. Consider adding assertions to verify the expected behavior, such as checking that the function returns without error or that no profiles are created. Without assertions, this test only verifies that the function doesn't crash.
| cJSON_AddItemToObject(root, "profiles", profiles); | |
| cJSON_AddItemToObject(root, "profiles", profiles); | |
| // For temporary report profiles with an empty array, we expect that | |
| // no vector-based delete or cleanup operations are triggered. | |
| EXPECT_CALL(*g_vectorMock, Vector_Size(_)).Times(0); | |
| EXPECT_CALL(*g_vectorMock, Vector_Destroy(_, _)).Times(0); |
Uh oh!
There was an error while loading. Please reload this page.