Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Code Coverage

on:
pull_request:
branches: [ main ]
branches: [ develop ]

Comment on lines 4 to 6
jobs:
execute-unit-code-coverage-report-on-release:
Expand Down
87 changes: 87 additions & 0 deletions rfcMgr/gtest/gtest_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,27 @@ TEST(rfcMgrTest, executeCommandAndGetOutput_eRdkSsaCli) {
EXPECT_EQ(ret , -1);
}

// --- Additional tests for rfc_common.cpp ---

TEST(rfcMgrTest, getSyseventValue_returnsEmptyOnInvalidKey) {
// This test expects sysevent is not available in test env, so returns empty
std::string value = getSyseventValue("__nonexistent_key_for_test__");
EXPECT_EQ(value, "");
}

TEST(rfcMgrTest, waitForRfcCompletion_doesNotCrash) {
// This test just ensures the function runs without crashing or hanging
// It is a smoke test, as actual sysevent and file presence are not guaranteed in test env
ASSERT_NO_FATAL_FAILURE(waitForRfcCompletion());
Comment on lines +918 to +920
}
Comment on lines +917 to +921
Comment on lines +917 to +921
Comment on lines +917 to +921

TEST(rfcMgrTest, getCronFromDCMSettings_returnsStringOrEmpty) {
// This test expects no real DCMSettings.conf, so should return empty string
std::string cron = getCronFromDCMSettings();
// Accept either empty or any string (smoke test)
SUCCEED();
Comment on lines +926 to +927
Comment on lines +924 to +927
}
Comment on lines +923 to +928
Comment on lines +923 to +928

TEST(rfcMgrTest, getRebootRequirement) {
RuntimeFeatureControlProcessor *rfcObj = new RuntimeFeatureControlProcessor();
bool result = rfcObj->getRebootRequirement();
Expand Down Expand Up @@ -1570,6 +1591,72 @@ TEST(rfcMgrTest, ProcessXconfResponse_WithValidAccountID)
EXPECT_GE(result, 0);
}



// --- Additional coverage for rfc_manager.cpp ---

TEST(rfcMgrTest, IsIarmBusConnected_smoke) {
rfc::RFCManager mgr;
// Should not crash, always returns true if !USE_IARMBUS
EXPECT_TRUE(mgr.IsIarmBusConnected());
}
Comment on lines +1598 to +1602

TEST(rfcMgrTest, InitializeIARM_smoke) {
rfc::RFCManager mgr;
// Should not crash
ASSERT_NO_FATAL_FAILURE(mgr.InitializeIARM());
}
/*
TEST(rfcMgrTest, term_event_handler_smoke) {
// Should not crash, always returns 0
EXPECT_EQ(term_event_handler(), 0);
}
*/
TEST(rfcMgrTest, getErouterIPAddress_empty) {
rfc::RFCManager mgr;
// Should return empty string in test env
std::string ip = mgr.getErouterIPAddress();
SUCCEED();
}
Comment on lines +1615 to +1620
Comment on lines +1615 to +1620

TEST(rfcMgrTest, CheckIPConnectivity_noIP) {
rfc::RFCManager mgr;
// Should return false in test env
EXPECT_FALSE(mgr.CheckIPConnectivity());
}

TEST(rfcMgrTest, CheckIProuteConnectivity_nullFile) {
rfc::RFCManager mgr;
// Should return false for null file
EXPECT_FALSE(mgr.CheckIProuteConnectivity(nullptr));
}
/*
TEST(rfcMgrTest, rfcMgrEventHandler_smoke) {
#if defined(USE_IARMBUS)
rfcMgrEventHandler(nullptr, 0, nullptr, 0);
#endif
SUCCEED();
}
*/
// --- Additional edge/error-path tests for rfc_common.cpp ---

TEST(rfcMgrTest, read_RFCProperty_nullArgs) {
char buf[16];
// Null key
EXPECT_EQ(read_RFCProperty("type", nullptr, buf, sizeof(buf)), -1);
// Null out_value
EXPECT_EQ(read_RFCProperty("type", "key", nullptr, sizeof(buf)), -1);
// Zero datasize
EXPECT_EQ(read_RFCProperty("type", "key", buf, 0), -1);
}

TEST(rfcMgrTest, executeCommandAndGetOutput_invalidCmd) {
std::string result;
// Invalid enum value (simulate by casting)
int ret = executeCommandAndGetOutput((SYSCMD)999, nullptr, result);
EXPECT_EQ(ret, -1);
}

GTEST_API_ int main(int argc, char *argv[]){
::testing::InitGoogleTest(&argc, argv);

Expand Down
5 changes: 5 additions & 0 deletions rfcMgr/gtest/gtest_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ TEST(utilsTest, cleanAllFiles) {
std::remove("/opt/secure/RFC/.RFC_LIST_SNMP2WL.ini");
}

TEST(utilsTest, legacyRfcEnabled_returnsFalseIfFileMissing) {
// This test expects the .RFC_LegacyRFCEnabled.ini file does not exist
// Should return false
Comment on lines +199 to +200
EXPECT_FALSE(legacyRfcEnabled());
}
Comment on lines +198 to +202
Comment on lines +198 to +202

GTEST_API_ int main(int argc, char *argv[]){
::testing::InitGoogleTest(&argc, argv);
Expand Down
1 change: 1 addition & 0 deletions rfcMgr/mtlsUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* limitations under the License.
*/


#include "mtlsUtils.h"
Comment on lines +23 to 24
#include "rfc_common.h"
Comment on lines +23 to 25
#ifdef LIBRDKCONFIG_BUILD
Expand Down
2 changes: 1 addition & 1 deletion run_ut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# limitations under the License.
####################################################################################

ENABLE_COV=false
ENABLE_COV=true

if [ "x$1" = "x--enable-cov" ]; then
echo "Enabling coverage options"
Expand Down
Loading