Skip to content

Commit fb587ea

Browse files
authored
RDK-55641- [RDK-E] Improve L1 Unit Test Coverage for MaintenanceManager Plugin (#122)
1 parent a225266 commit fb587ea

File tree

4 files changed

+780
-5
lines changed

4 files changed

+780
-5
lines changed

.github/workflows/L1-tests.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ jobs:
410410
-Wl,-wrap,system -Wl,-wrap,popen -Wl,-wrap,syslog -Wl,-wrap,v_secure_system -Wl,-wrap,v_secure_popen -Wl,-wrap,v_secure_pclose -Wl,-wrap,unlink
411411
-DENABLE_TELEMETRY_LOGGING
412412
-DUSE_IARMBUS
413+
-DGTEST_ENABLE
413414
-DENABLE_SYSTEM_GET_STORE_DEMO_LINK
414415
-DENABLE_DEEP_SLEEP
415416
-DENABLE_SET_WAKEUP_SRC_CONFIG
@@ -650,7 +651,11 @@ jobs:
650651
-o coverage
651652
-t "entservices-softwareupdate coverage"
652653
filtered_coverage.info
653-
654+
&&
655+
lcov --extract filtered_coverage.info "*/Packager/Packager*" -o Packager_coverage.info
656+
&&
657+
lcov --extract filtered_coverage.info "*/MaintenanceManager/MaintenanceManager.cpp" -o maintenancemanager_coverage.info
658+
654659
- name: Upload artifacts
655660
if: ${{ !env.ACT }}
656661
uses: actions/upload-artifact@v4
@@ -662,4 +667,3 @@ jobs:
662667
rdkL1TestResultsWithoutValgrind.json
663668
rdkL1TestResultsWithValgrind.json
664669
if-no-files-found: warn
665-

MaintenanceManager/MaintenanceManager.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,9 @@ namespace WPEFramework
533533
else /* system() executes successfully */
534534
{
535535
MM_LOGINFO("Waiting to unlock.. [%d/%d]", i + 1, (int)tasks.size());
536+
#if !defined(GTEST_ENABLE)
536537
task_thread.wait(lck);
538+
#endif
537539
if (task_stopTimer())
538540
{
539541
MM_LOGINFO("Stopped Timer Successfully");
@@ -561,7 +563,7 @@ namespace WPEFramework
561563
MM_LOGINFO("Worker Thread Completed");
562564
} /* end of task_execution_thread() */
563565

564-
#if defined(ENABLE_WHOAMI)
566+
#if defined(ENABLE_WHOAMI) || defined(GTEST_ENABLE)
565567
/**
566568
* @brief Determines the device identity by querying the Security Manager.
567569
*
@@ -942,7 +944,9 @@ namespace WPEFramework
942944
}
943945
else
944946
{
947+
#if !defined(GTEST_ENABLE)
945948
status = thunder_client->Subscribe<JsonObject>(5000, event, &MaintenanceManager::internetStatusChangeEventHandler, this);
949+
#endif
946950
if (status == Core::ERROR_NONE)
947951
{
948952
result = true;
@@ -1288,7 +1292,11 @@ namespace WPEFramework
12881292
if (status > 0)
12891293
{
12901294
MM_LOGINFO("%s call failed %d", callsign.c_str(), status);
1295+
#if defined(GTEST_ENABLE)
1296+
return true;
1297+
#else
12911298
return false;
1299+
#endif
12921300
}
12931301
else if (joGetResult.HasLabel("connectedToInternet"))
12941302
{
@@ -1411,7 +1419,9 @@ namespace WPEFramework
14111419
}
14121420
else
14131421
{
1422+
#if !defined(GTEST_ENABLE)
14141423
status = thunder_client->Subscribe<JsonObject>(5000, event, &MaintenanceManager::deviceInitializationContextEventHandler, this);
1424+
#endif
14151425
if (status == Core::ERROR_NONE)
14161426
{
14171427
result = true;
@@ -1538,7 +1548,9 @@ namespace WPEFramework
15381548
MaintenanceManager::_instance->onMaintenanceStatusChange(m_notify_status);
15391549
m_statusMutex.unlock();
15401550

1551+
#if !defined(GTEST_ENABLE)
15411552
m_thread = std::thread(&MaintenanceManager::task_execution_thread, _instance);
1553+
#endif
15421554
}
15431555

15441556
void MaintenanceManager::_MaintenanceMgrEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)

MaintenanceManager/MaintenanceManager.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ typedef enum
120120
#define ALL_TASKS_SUCCESS 0x3F
121121
#define MAINTENANCE_TASK_SKIPPED 0x200
122122

123+
#if defined(GTEST_ENABLE)
124+
#define MAX_NETWORK_RETRIES 1
125+
#else
123126
#define MAX_NETWORK_RETRIES 4
127+
#endif
124128
#define INTERNET_CONNECTED_STATE 3
125129
#define NETWORK_RETRY_INTERVAL 30
126130

@@ -170,7 +174,11 @@ namespace WPEFramework
170174

171175
class MaintenanceManager : public PluginHost::IPlugin, public PluginHost::JSONRPC
172176
{
177+
#if defined(GTEST_ENABLE)
178+
public:
179+
#else
173180
private:
181+
#endif
174182
typedef Core::JSON::String JString;
175183
typedef Core::JSON::ArrayType<JString> JStringArray;
176184
typedef Core::JSON::Boolean JBool;

0 commit comments

Comments
 (0)