common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / systemservice / system_manager / server / src / ss_sm_config.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_SystemManager
19 /// \brief    This file provides support for System Manager configuration.
20 ///
21 ///////////////////////////////////////////////////////////////////////////////
22
23 #include <boost/algorithm/string.hpp>
24
25
26 #include <other_service/PosixBasedOS001ClockCycleApi.h>
27 #include <other_service/ultoa.h>
28 #include <native_service/frameworkunified_framework_if.h>
29 #include <system_service/ss_string_maps.h>
30 #include <system_service/ss_templates.h>
31 #include <native_service/ns_config_parser_if.h>
32 #include <errno.h>
33 #include <sys/time.h>
34 #include <sys/resource.h>
35 #include <cctype>
36 #include <string>
37 #include <iomanip>
38 #include <fstream>
39 #include <iostream>
40 #include <sstream>
41 #include <algorithm>
42 #include <functional>
43 #include <list>
44 #include <vector>
45 #include <utility>
46
47 #include "ss_sm_config.h"
48 #include "ss_sm_systemmanagerlog.h"
49 #include "ss_sm_launch_configuration.h"
50 #include "system_launcher_cfg_format.h"
51 #include "ss_sm_default_paths.h"
52
53 using namespace std;  // NOLINT
54
55 // Constants for Heart Beat configuration data
56 const UI_32 HBApplicationHeartBeatIntervalInitial = 40u;  // Units of seconds. 0 = HB Disabled.
57 const UI_32 HBApplicationHeartBeatIntervalRepeat = 5u;  // Units of seconds. 0 = HB Disabled.
58 const UI_32 HBMaxHeartBeatRetryCount = 3u;
59
60 // Constants for Crash Detector configuration data
61 const BOOL CDEnabled = TRUE;
62
63 // Constants for system low memory configuration data
64
65 const UI_32 SLMTimerValue = 5000;        // msec
66 const UI_32 SLMThresholdValue = (1024 * 512);  // bytes
67 const UI_32 SLMRetryCount = 6;
68 const UI_32 SLMSystemmanagerLogIntervalMs = 30000;
69
70 // Constants for Module connect time and Stat Resp Time
71
72 const UI_32 ModuleConnectionNumTimesToCheck = 5;
73 const UI_32 ModuleConnectionTimeOutSec = 5;  // sec
74 const UI_32 ModuleStartRespTimeOutSec = 120;  // sec
75
76 // Constants for Critical Apps Max wait timeout
77
78 const UI_32 CriticalAppsMaxShutdownTimeFastSleepSec = 2;  // sec
79 const UI_32 CriticalAppsMaxShutdownTimeNormalResetSec = 15;  // sec
80
81 // Constants for User Mode data structure type
82 const BOOL isBoolean = TRUE;
83
84 const CHAR SMConfigDataHeader[] = "SystemManager";
85 const CHAR HBConfigDataHeader[] = "HeartBeat";
86 const CHAR CDConfigDataHeader[] = "CrashDetector";
87 const CHAR SLMConfigDataHeader[] = "SysLowMemory";
88 const CHAR UserModeConfigDataHeader[] = "UserMode";
89
90 struct CfgLaunchParams {
91   CfgLaunchParams() :
92         group_id(0),
93         group_launch_wait(0),
94         group_wait_for_trigger(0),
95         priority(0),
96         critical(0),
97         retry_cnt(0),
98         is_start_required(0),
99         shutdown_critical(0),
100         shutdown_wait_time(0),
101         fast_shutdown_wait_time(0),
102         cpu_assign(0x0),
103         is_agl_unit(TRUE),
104         disable_agl_resethistory(FALSE),
105         disable_nonagl_resethistory(FALSE) {
106     std::memset(&group_name[0], 0, sizeof(group_name));
107     std::memset(&name[0], 0, sizeof(name));
108     std::memset(&binary_name[0], 0, sizeof(binary_name));
109     std::memset(&arguments[0], 0, sizeof(arguments));
110     std::memset(&logging_msk_str[0], 0, sizeof(logging_msk_str));
111     std::memset(&restart[0], 0, sizeof(restart));
112     std::memset(&unix_user_name[0], 0, sizeof(unix_user_name));
113     std::memset(&env_value_condition[0], 0, sizeof(env_value_condition));
114   }
115
116   CHAR group_name[100];
117   UI_32 group_id;
118   UI_32 group_launch_wait;
119   BOOL group_wait_for_trigger;
120   CHAR name[100];
121   CHAR binary_name[MAX_PATH_LENGTH];
122   UI_32 priority;
123   BOOL critical;
124   UI_32 retry_cnt;
125   CHAR arguments[512];
126   CHAR logging_msk_str[50];
127   CHAR restart[32];
128   BOOL is_start_required;
129   BOOL shutdown_critical;
130   UI_32 shutdown_wait_time;
131   UI_32 fast_shutdown_wait_time;
132   TUserNameBuffer unix_user_name;  // TODO(username): Stuff.: Does Posix define a useful
133                                    // constant representing max length of user id?
134   CHAR env_value_condition[256];
135   int cpu_assign;
136
137  public:
138   BOOL IsAGLUnit(void) const { return is_agl_unit; }
139   BOOL IsAGLResetHistoryDisable(void) const { return disable_agl_resethistory; }
140   BOOL IsNonAGLResetHistoryDisable(void) const { return disable_nonagl_resethistory; }
141   void SetAGLUnit(BOOL f_is_agl_unit) { is_agl_unit = f_is_agl_unit; }
142   void SetAGLResetHistoryDisable(BOOL f_disable_agl_resethistory) {
143     disable_agl_resethistory = f_disable_agl_resethistory;
144   }
145   void SetNonAGLResetHisoryDisable(BOOL f_disable_nonagl_resethistory) {
146     disable_nonagl_resethistory = f_disable_nonagl_resethistory;
147   }
148
149  private:
150   BOOL is_agl_unit;
151   BOOL disable_agl_resethistory;
152   BOOL disable_nonagl_resethistory;
153 };
154
155 namespace ss_sm_cfg {
156 class cfg_args {
157  public:
158   enum {  // typedef enum _tokens
159     group_name,
160     group_id,
161     group_launch_wait,
162     group_wait_for_trigger,
163     name,
164     binary_name,
165     priority,
166     critical,
167     retry_cnt,
168     arguments,
169     logging_msk,
170     restart,
171     is_start_required,
172     shutdown_critical,
173     shutdown_wait_time,
174     fast_shutdown_wait_time,
175     unix_user_name,
176     is_agl_unit,
177     disable_agl_resethistory,
178     disable_nonagl_resethistory,
179     env_value_condition,
180     cpu_assign,
181     END
182   };
183 };
184 };  // namespace ss_sm_cfg
185
186 static void set_grp_member_info(const LaunchInfo& launch_info, ModuleLaunchList& module_lst);  // NOLINT
187 static void load_parameters_order_cfg(
188     GroupLaunchMap& groups_map, LaunchOrderedVector& f_OrderList, SS_String& f_launchOrderName, SS_String& f_launchCfgFn);  // NOLINT
189
190 /*******************************************************************************
191  * CTimeSpan class                                                             *
192  *                                                                             *
193  * Set Initial time, reset Final and Delta to zero, return time                *
194  *                                                                             */
195 UI_64 CTimeSpan::Begin() {
196   initial = GetTimeMilliseconds();
197   final = 0;
198   delta = 0;
199   return initial;
200 }  // End of UI_64 CTimeSpan::Begin()
201
202 /*
203  * Set Final time, calculate Delta time, return time
204  */
205 UI_64 CTimeSpan::End() {
206   final = GetTimeMilliseconds();
207   delta = (final > initial) ? (final - initial) : 0;  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
208   return final;
209 }  // End of UI_64 CTimeSpan::End()
210
211 UI_64 CTimeSpan::GetInitial(void) {
212   return initial;
213 }
214
215 UI_64 CTimeSpan::GetFinal() {
216   return final;
217 }
218
219 UI_64 CTimeSpan::GetDelta() {
220   return delta;
221 }
222
223 UI_64 CTimeSpan::GetTimeMilliseconds() {
224   UI_64 l_totalmsec = 0;
225   struct timespec timeSpec;
226
227   if (0 != clock_gettime(CLOCK_MONOTONIC, &timeSpec)) {
228     SS_ASERT_ERRNO(0);  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
229   } else {
230     l_totalmsec = (timeSpec.tv_sec * 1000ULL)
231             + (timeSpec.tv_nsec / 1000000);
232   }
233
234   return l_totalmsec;
235 }
236
237 /*                                                                             *
238  * End of CTimeSpan class                                                      *
239  ******************************************************************************/
240
241 ModuleLaunchParams::ModuleLaunchParams():
242   name("")
243   , path("")
244   , arguments("")
245   , restart("")
246   , configuration_priority(0)
247   , cpu_assign(0x0)
248   , previous_priority(0)
249   , current_priority(0)
250   , critical(FALSE)
251   , retry_cnt(0)
252   , logging_msk_str("")
253   , is_start_required(FALSE)
254   , shutdown_critical(FALSE)
255   , shutdown_wait_time(0)
256   , fast_shutdown_wait_time(0)
257   , pid(0)
258   , hsession(NULL)
259   , relaunch_count(0)
260   , relaunch_status(NotRelaunched)
261   , group_id(0xFFFF)
262   , m_serviceAvailability(FALSE)
263   , m_startReason()
264   , m_stopReason()
265   , m_ModuleDebugDumpState(MODULE_DEBUG_DUMP_STATE_NOT_REQUESTED)
266   , is_agl_unit(TRUE)
267   , disable_agl_resethistory(FALSE)
268   , disable_nonagl_resethistory(FALSE) {  // LCOV_EXCL_BR_START 11:Gcov constraints (because exception-handling routes are automatically generated)
269   SetModuleState(MODULE_STATE_INVALID, FALSE);
270   //
271   //    Module State strings
272   m_ModuleStateStrMap[MODULE_STATE_INVALID] = "INVALID";
273   m_ModuleStateStrMap[MODULE_STATE_SKIPPED] = "SKIPPED";
274   m_ModuleStateStrMap[MODULE_STATE_LAUNCHING] = "LAUNCHING";
275   m_ModuleStateStrMap[MODULE_STATE_LAUNCHED] = "LAUNCHED";
276   m_ModuleStateStrMap[MODULE_STATE_LAUNCH_FAILED] = "LAUNCH_FAIL";
277   m_ModuleStateStrMap[MODULE_STATE_CONNECTED] = "CONNECTED";
278   m_ModuleStateStrMap[MODULE_STATE_START_SENT] = "START_SENT";
279   m_ModuleStateStrMap[MODULE_STATE_START_FAILED] = "START_FAIL";
280   m_ModuleStateStrMap[MODULE_STATE_STARTED] = "STARTED";
281   m_ModuleStateStrMap[MODULE_STATE_STOP_FAILED] = "STOP_FAIL";
282   m_ModuleStateStrMap[MODULE_STATE_STOP_SENT] = "STOP_SENT";
283   m_ModuleStateStrMap[MODULE_STATE_STOPPED] = "STOPPED";
284   m_ModuleStateStrMap[MODULE_STATE_START_PRE_SENT] = "PRE_START_SENT";
285   m_ModuleStateStrMap[MODULE_STATE_START_PRE_FAILED] = "PRE_START_FAIL";
286   m_ModuleStateStrMap[MODULE_STATE_STARTED_PRE] = "PRE_STARTED";
287   m_ModuleStateStrMap[MODULE_STATE_STOP_PRE_SENT] = "PRE_STOP_SENT";
288   m_ModuleStateStrMap[MODULE_STATE_STOP_PRE_FAILED] = "PRE_STOP_FAIL";
289   m_ModuleStateStrMap[MODULE_STATE_STOPPED_PRE] = "PRE_STOPPED";
290   m_ModuleStateStrMap[MODULE_STATE_START_BACKGROUND_SENT] = "BACKGROUND_START_SENT";
291   m_ModuleStateStrMap[MODULE_STATE_START_BACKGROUND_FAILED] = "BACKGROUND_START_FAIL";
292   m_ModuleStateStrMap[MODULE_STATE_STARTED_BACKGROUND] = "BACKGROUND_STARTED";
293   m_ModuleStateStrMap[MODULE_STATE_STOP_BACKGROUND_SENT] = "BACKGROUND_STOP_SENT";
294   m_ModuleStateStrMap[MODULE_STATE_STOP_BACKGROUND_FAILED] = "BACKGROUND_STOP_FAIL";
295   m_ModuleStateStrMap[MODULE_STATE_STOPPED_BACKGROUND] = "BACKGROUND_STOPPED";
296   // LCOV_EXCL_BR_STOP
297
298   m_startReason.SetReason(NotStarted);
299   m_stopReason.SetReason(NotStopped);
300
301   MAP_ENTRY(m_ModuleDebugDumpStateStrMap, MODULE_DEBUG_DUMP_STATE_NOT_REQUESTED);  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
302   MAP_ENTRY(m_ModuleDebugDumpStateStrMap, MODULE_DEBUG_DUMP_STATE_REQUEST_SENT);  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
303   MAP_ENTRY(m_ModuleDebugDumpStateStrMap, MODULE_DEBUG_DUMP_STATE_RESPONSE_RECEIVED);  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
304
305   std::memset(&unix_user_name[0], 0, sizeof(unix_user_name));
306 }  // End of ModuleLaunchParams::ModuleLaunchParams() :
307
308 ModuleLaunchParams::~ModuleLaunchParams() {
309 }  // End of ModuleLaunchParams::~ModuleLaunchParams() :
310
311 SMModuleState ModuleLaunchParams::GetModuleState(void) {
312     return m_moduleState;
313 }  // End of SMModuleState ModuleLaunchParams::GetModuleState(void)
314
315 BOOL ModuleLaunchParams::IsModuleState(SMModuleState f_moduleState) {
316     return m_moduleState == f_moduleState;
317 }  // End of BOOL ModuleLaunchParams::IsModuleState(SMModuleState f_moduleState )
318
319 // IsModuleConnected
320 // Determine if a module is in a state capable of receiving messages from System Manager.
321 BOOL ModuleLaunchParams::IsModuleConnected() const {
322   BOOL l_isModuleConnected = FALSE;
323
324   switch (m_moduleState) {
325     case MODULE_STATE_CONNECTED:
326     case MODULE_STATE_START_SENT:
327     case MODULE_STATE_START_FAILED:
328     case MODULE_STATE_STARTED:
329     case MODULE_STATE_STOP_SENT:
330     case MODULE_STATE_STOP_FAILED:
331     case MODULE_STATE_STOPPED:
332     case MODULE_STATE_START_PRE_SENT:
333     case MODULE_STATE_START_PRE_FAILED:
334     case MODULE_STATE_STARTED_PRE:
335     case MODULE_STATE_STOP_PRE_SENT:
336     case MODULE_STATE_STOP_PRE_FAILED:
337     case MODULE_STATE_STOPPED_PRE:
338     case MODULE_STATE_START_BACKGROUND_SENT:
339     case MODULE_STATE_START_BACKGROUND_FAILED:
340     case MODULE_STATE_STARTED_BACKGROUND:
341     case MODULE_STATE_STOP_BACKGROUND_SENT:
342     case MODULE_STATE_STOP_BACKGROUND_FAILED:
343     case MODULE_STATE_STOPPED_BACKGROUND:
344       l_isModuleConnected = TRUE;
345       break;
346
347     default:
348       l_isModuleConnected = FALSE;
349       break;
350   }
351
352   return (l_isModuleConnected);
353 }  // End of BOOL ModuleLaunchParams::IsModuleConnected(void)
354
355 VOID ModuleLaunchParams::SetModuleState(SMModuleState f_moduleState, BOOL f_bLog) {
356   m_moduleState = f_moduleState;
357
358   switch (m_moduleState) {  // Because the module status cannot be changed from the external API
359     case MODULE_STATE_INVALID:
360     case MODULE_STATE_SKIPPED:
361     case MODULE_STATE_LAUNCH_FAILED:
362     case MODULE_STATE_LAUNCHING:
363     case MODULE_STATE_LAUNCHED:
364     case MODULE_STATE_CONNECTED:
365       break;
366     case MODULE_STATE_START_SENT:
367       m_startReason.Begin();
368       break;
369     case MODULE_STATE_START_FAILED:
370       m_startReason.End();
371       m_startReason.SetReason(StartedByModuleStartFail);
372       break;
373     case MODULE_STATE_STARTED:
374       m_startReason.End();
375       m_startReason.SetReason(StartedByModuleStartComplete);
376       break;
377
378     case MODULE_STATE_STOP_SENT:
379       m_stopReason.Begin();
380       break;
381
382     case MODULE_STATE_STOP_FAILED:
383       m_stopReason.End();
384       m_stopReason.SetReason(StoppedByModuleStopFail);
385       break;
386     case MODULE_STATE_STOPPED:
387       m_stopReason.End();
388       m_stopReason.SetReason(StoppedByModuleStopComplete);
389       break;
390
391     case MODULE_STATE_START_PRE_SENT:
392       m_startReason.Begin();
393       break;
394     case MODULE_STATE_START_PRE_FAILED:
395       m_startReason.End();
396       m_startReason.SetReason(StartedByModulePreStartFail);
397       break;
398     case MODULE_STATE_STARTED_PRE:
399       m_startReason.End();
400       m_startReason.SetReason(StartedByModulePreStartComplete);
401       break;
402     case MODULE_STATE_STOP_PRE_SENT:
403       m_stopReason.Begin();
404       break;
405     case MODULE_STATE_STOP_PRE_FAILED:
406       m_stopReason.End();
407       m_stopReason.SetReason(StoppedByModulePreStopFail);
408       break;
409     case MODULE_STATE_STOPPED_PRE:
410       m_stopReason.End();
411       m_stopReason.SetReason(StoppedByModulePreStopComplete);
412       break;
413
414     case MODULE_STATE_START_BACKGROUND_SENT:
415       m_startReason.Begin();
416       break;
417     case MODULE_STATE_START_BACKGROUND_FAILED:
418       m_startReason.End();
419       m_startReason.SetReason(StartedByModuleBackgroundStartFail);
420       break;
421     case MODULE_STATE_STARTED_BACKGROUND:
422       m_startReason.End();
423       m_startReason.SetReason(StartedByModuleBackgroundStartComplete);
424       break;
425     case MODULE_STATE_STOP_BACKGROUND_SENT:
426       m_stopReason.Begin();
427       break;
428     case MODULE_STATE_STOP_BACKGROUND_FAILED:
429       m_stopReason.End();
430       m_stopReason.SetReason(StoppedByModuleBackgroundStopFail);
431       break;
432     case MODULE_STATE_STOPPED_BACKGROUND:
433       m_stopReason.End();
434       m_stopReason.SetReason(StoppedByModuleBackgroundStopComplete);
435       break;
436
437     // default:  Don't code a 'default' here - let the compiler
438     // issue a warning ( set via -Wall or -Wswitch ) when the set of
439     // enumerations changes - then the maintainer will
440     // automagically know to update this switch statement.
441   }
442
443   if (f_bLog) {
444     char buf[255];
445     char *p = buf;
446     strcpy(p, m_ModuleStateStrMap[m_moduleState].c_str());  // NOLINT
447     p += m_ModuleStateStrMap[m_moduleState].size();
448     strcpy(p, ":");  // NOLINT
449     p += sizeof(":") - 1;
450     strcpy(p, name.c_str());  // NOLINT
451     FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, buf);
452   }
453 }  // End of VOID ModuleLaunchParams::SetModuleState(SMModuleState f_moduleState )
454
455 std::string ModuleLaunchParams::ModuleStateStr(void) {
456   return m_ModuleStateStrMap[m_moduleState];
457 }  // End of std::string ModuleLaunchParams::ModuleStateStr(SMModuleState f_moduleState )
458
459 SMModuleDebugDumpState ModuleLaunchParams::GetModuleDebugDumpState(void) {  // LCOV_EXCL_START 6: Because the condition cannot be set // NOLINT(whitespace/line_length)
460   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
461   return m_ModuleDebugDumpState;
462 }  // End of SMModuleDebugDumpState ModuleLaunchParams::GetModuleDebugDumpState(void)
463 // LCOV_EXCL_STOP
464
465 std::string ModuleLaunchParams::GetModuleDebugDumpStateStr(void) {
466   return m_ModuleDebugDumpStateStrMap[m_ModuleDebugDumpState];
467 }  // End of std::string ModuleLaunchParams::GetModuleDebugDumpStateStr()
468
469 VOID ModuleLaunchParams::SetModuleDebugDumpState(
470         SMModuleDebugDumpState f_moduleDebugDumpState, BOOL f_bLog) {
471   m_ModuleDebugDumpState = f_moduleDebugDumpState;
472
473   if (f_bLog) {  // LCOV_EXCL_BR_LINE 200:f_bLog must be TRUE
474     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s set for %s",
475             GetModuleDebugDumpStateStr().c_str(), name.c_str());
476   }
477 }  // End of VOID ModuleLaunchParams::SetModuleDebugDumpState(SMModuleDebugDumpState f_moduleDebugDumpState )
478
479 EFrameworkunifiedStatus ModuleLaunchParams::SendMsgAndUpdateState(
480     const UI_32 f_iCmd, const T_SS_SM_START_DataStructType* const f_startData) {
481   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
482   char l_cBuf[500] = " Error: char l_cBuf[] not built";
483   T_SS_SM_START_DataStructType l_startData;
484   SMModuleState l_SendSuccess = MODULE_STATE_START_SENT;
485   SMModuleState l_SendFailed = MODULE_STATE_START_FAILED;
486
487   memcpy(&l_startData, f_startData, sizeof(T_SS_SM_START_DataStructType));
488
489   switch (relaunch_status) {  // LCOV_EXCL_BR_LINE 6: Because all conditions cannot be satisfied from the external API
490   case NotRelaunched:
491     // Setting startup information at the first startup
492     break;
493   case RelaunchSafe:  // LCOV_EXCL_START 6: Because all conditions cannot be satisfied from the external API
494     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
495     l_startData.resetStatus = e_SS_SM_RESET_STATUS_NONE;
496     break;
497   case RelaunchErr:
498     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
499     l_startData.resetStatus = e_SS_SM_RESET_STATUS_NG;
500     break;
501   default:
502     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
503     SS_ASERT(0);
504     break;
505     // LCOV_EXCL_STOP
506   }
507
508   switch (f_iCmd) {
509   case SS_SM_PRE_START:
510     l_SendSuccess = MODULE_STATE_START_PRE_SENT;
511     l_SendFailed = MODULE_STATE_START_PRE_FAILED;
512     break;
513   case SS_SM_PRE_STOP:
514     l_SendSuccess = MODULE_STATE_STOP_PRE_SENT;
515     l_SendFailed = MODULE_STATE_STOP_PRE_FAILED;
516     break;
517   case SS_SM_BACKGROUND_START:
518     l_SendSuccess = MODULE_STATE_START_BACKGROUND_SENT;
519     l_SendFailed = MODULE_STATE_START_BACKGROUND_FAILED;
520     break;
521   case SS_SM_BACKGROUND_STOP:
522     l_SendSuccess = MODULE_STATE_STOP_BACKGROUND_SENT;
523     l_SendFailed = MODULE_STATE_STOP_BACKGROUND_FAILED;
524     break;
525   case SS_SM_START:
526   default:
527     l_SendSuccess = MODULE_STATE_START_SENT;
528     l_SendFailed = MODULE_STATE_START_FAILED;
529     break;
530   }
531
532   const EFrameworkunifiedStatus l_eStatus = FrameworkunifiedSendMsg(hsession, f_iCmd,
533                                           sizeof(T_SS_SM_START_DataStructType),
534                                           static_cast<PCVOID>(&l_startData));
535
536   // LCOV_EXCL_START 6: As no TRUE is returned
537   if (IS_ZONE_SET(ZONE_ERR) || IS_ZONE_SET(ZONE_INFO)) {
538
539     snprintf(l_cBuf, sizeof(l_cBuf), "FrameworkunifiedSendMsg(%s, system_manager protocol message, %d/%s)",
540         name.c_str(), l_startData.startupReason,
541         GetStr(l_startData.startupReason).c_str());
542   }
543   // LCOV_EXCL_STOP 6:As no TRUE is returned
544   if (eFrameworkunifiedStatusOK != l_eStatus) {  // LCOV_EXCL_BR_LINE 4:NSFW's error
545     // LCOV_EXCL_START 4:NSFW's error
546     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
547     LOG_ERROR(l_cBuf);  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
548     SetModuleState(l_SendFailed);
549     // LCOV_EXCL_STOP
550   } else {
551     LOG_SUCCESS(l_cBuf);  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
552     SetModuleState(l_SendSuccess);
553   }
554   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
555   return l_eStatus;
556 }
557 // End of EFrameworkunifiedStatus ModuleLaunchParams::SendMsgAndUpdateState(T_SS_SM_START_DataStructType const * f_startData)
558
559 EFrameworkunifiedStatus ModuleLaunchParams::SendMsgAndUpdateState(
560         T_SS_SM_STOP_DataStructType const* f_stopData) {
561   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
562   char l_cBuf[500] = " Error: char l_cBuf[] not built";
563   EFrameworkunifiedStatus l_eStatus = FrameworkunifiedSendMsg(hsession, SS_SM_STOP,
564         sizeof(T_SS_SM_STOP_DataStructType),
565         static_cast<PCVOID>(f_stopData));
566
567   if (IS_ZONE_SET(ZONE_ERR) || IS_ZONE_SET(ZONE_INFO)) {  // LCOV_EXCL_BR_LINE 200:alwasy true
568     snprintf(l_cBuf, sizeof(l_cBuf), "FrameworkunifiedSendMsg(%s, SS_SM_STOP, %d/%s, "
569         "Last User Mode: %s)", name.c_str(),
570         f_stopData->shutdownTrigger,
571         GetStr(f_stopData->shutdownTrigger).c_str(),
572         GetStr(f_stopData->lastUserMode).c_str());
573   }
574   if (eFrameworkunifiedStatusOK != l_eStatus) {  // LCOV_EXCL_BR_LINE 4:NSFW's error
575     // LCOV_EXCL_START 4:NSFW's error
576     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
577     LOG_ERROR(l_cBuf);  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
578     SetModuleState(MODULE_STATE_STOP_FAILED);
579     // LCOV_EXCL_STOP
580   } else {
581     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s successful", l_cBuf);
582     SetModuleState(MODULE_STATE_STOP_SENT);
583   }
584   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
585   return l_eStatus;
586 }
587 // End of EFrameworkunifiedStatus ModuleLaunchParams::SendMsgAndUpdateState(T_SS_SM_STOP_DataStructType const * f_stopData)
588
589 EFrameworkunifiedStatus ModuleLaunchParams::GetPriority(UI_32& f_Priority) {
590   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
591   EFrameworkunifiedStatus l_eStatus;
592
593   struct sched_param cur_sch_params;
594   errno = 0;
595   f_Priority = 0xDEAD;
596
597   if (0 == pid) {  // LCOV_EXCL_BR_LINE 200: pid can not be 0
598     // LCOV_EXCL_START 200: pid can not be 0
599     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
600     l_eStatus = eFrameworkunifiedStatusInvldParam;
601     LOG_ERROR("0 == pid");  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
602     // LCOV_EXCL_STOP
603   } else if (-1 >= sched_getparam(pid, &cur_sch_params)) {  // LCOV_EXCL_BR_LINE 5: system function failed
604     // LCOV_EXCL_START 5: system function failed
605     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
606     l_eStatus = eFrameworkunifiedStatusFault;
607     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
608         " Error: 'sched_getparam( pid %d, &cur_sch_params )' returned -1, "
609                 "strerr() is '%s'", pid, strerror(errno));
610     // LCOV_EXCL_STOP
611   } else {
612     l_eStatus = eFrameworkunifiedStatusOK;
613     f_Priority = cur_sch_params.sched_priority;
614   }
615   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
616   return l_eStatus;
617 }  // End of EFrameworkunifiedStatus ModuleLaunchParams::GetPriority (UI_32 & f_Priority )
618
619 EFrameworkunifiedStatus ModuleLaunchParams::SetPriority(UI_32 f_Priority) {
620   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
621   EFrameworkunifiedStatus l_eStatus;
622
623   errno = 0;
624
625   if (99 < f_Priority) {  // LCOV_EXCL_BR_LINE 200: priority can not greater than 99
626     // LCOV_EXCL_START 200: priority can not greater than 99
627     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
628     l_eStatus = eFrameworkunifiedStatusInvldParam;
629     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: Invalid 'f_Priority' %d/0x%X",
630             f_Priority, f_Priority);
631     // LCOV_EXCL_STOP
632   } else if (0 == pid) {  // LCOV_EXCL_BR_LINE 200: pid can not be 0
633     // LCOV_EXCL_START 200: pid can not be 0
634     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
635     l_eStatus = eFrameworkunifiedStatusInvldParam;
636     LOG_ERROR("0 == pid");  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
637     // LCOV_EXCL_STOP
638   } else {
639     int rc;
640     struct sched_param l_schedParam = { };
641     l_schedParam.sched_priority = f_Priority;
642
643     if (f_Priority == 0) {  // LCOV_EXCL_BR_LINE 200: f_Priority can not be 0
644       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
645       rc = sched_setscheduler(pid, SCHED_OTHER, &l_schedParam);  // LCOV_EXCL_LINE 200: f_Priority can not be 0
646     } else {
647       rc = sched_setscheduler(pid, SCHED_FIFO, &l_schedParam);
648     }
649     SS_ASERT_ERRNO(0 == rc);  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
650     if (rc == 0) {
651       previous_priority = current_priority;
652       current_priority = f_Priority;
653       l_eStatus = eFrameworkunifiedStatusOK;
654       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
655           " setprio( %s, pid %d, 'previous_priority' %d -> %d ) successful",
656           name.c_str(), pid, previous_priority, f_Priority);
657     } else if (rc == -1) {  // LCOV_EXCL_BR_LINE 5: system function failed
658       // LCOV_EXCL_START 5: system function failed
659       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
660       l_eStatus = eFrameworkunifiedStatusFault;
661       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
662           " setprio( %s, pid %d, 'current_priority' %d -> %d ) returned '-1', strerr() is '%s'",
663           name.c_str(), pid, current_priority, f_Priority,
664           strerror(errno));
665       // LCOV_EXCL_STOP
666     } else {  // LCOV_EXCL_BR_LINE 5: can not be other value
667       // LCOV_EXCL_START 5: can not be other value
668       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
669       l_eStatus = eFrameworkunifiedStatusFault;
670       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
671           " setprio( %s, pid %d, 'current_priority' %d -> %d ) returned '%d'; "
672                   "'rc' is neither original priority nor '-1': 'errno' is '%d', strerr() is '%s'",
673           name.c_str(), pid, current_priority, f_Priority, rc,
674           errno, strerror(errno));
675       // LCOV_EXCL_STOP
676     }
677   }
678
679   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
680   return l_eStatus;
681 }  // End of EFrameworkunifiedStatus ModuleLaunchParams::SetPriority( UI_32 f_Priority )
682
683 SysMgrConfiguration::SysMgrConfiguration():
684 l_pReaderCfg(NULL) {
685 }
686
687 SysMgrConfiguration::~SysMgrConfiguration() {
688 }
689
690 static BOOL is_satisfy_env_launch_cond(CHAR *env_cond) {  // LCOV_EXCL_START 6: Because the condition cannot be set
691   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
692   BOOL l_isSatisfy = FALSE;
693   BOOL l_isReverse = FALSE;
694   CHAR *l_pString = NULL;
695
696   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "env_cond [%s]", env_cond);
697
698   if (NULL != (l_pString = strstr(env_cond, "!="))) {
699     l_isReverse = TRUE;
700   } else if (NULL == (l_pString = strstr(env_cond, "=="))) {
701     SS_ASERT(0);
702   }
703
704   if (NULL != l_pString) {
705     CHAR *l_pEnv = env_cond;
706     CHAR *l_pValue = l_pString + 2;
707     *l_pString = '\0';
708
709     CHAR *l_pEnvVariable = NULL;
710
711     if (NULL != (l_pEnvVariable = std::getenv(l_pEnv))) {
712       l_isSatisfy = (0 == strcmp(l_pValue, l_pEnvVariable)) ? TRUE : FALSE;
713       if (l_isReverse) {
714         l_isSatisfy = !l_isSatisfy;
715       }
716     }
717   }
718
719   return l_isSatisfy;
720 }
721
722 static void set_grp_member_info(const LaunchInfo& launch_info, ModuleLaunchList& module_lst) {  // NOLINT
723   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
724   // Note: the
725   ModuleLaunchParams grp_member_info;
726   grp_member_info.name = launch_info.name;
727   grp_member_info.path = launch_info.binary_name;
728   grp_member_info.arguments = launch_info.arguments;
729   grp_member_info.restart = launch_info.restart;
730   grp_member_info.configuration_priority = launch_info.priority;
731   grp_member_info.retry_cnt = launch_info.retry_cnt;
732   grp_member_info.logging_msk_str = launch_info.logging_msk_str;
733   grp_member_info.critical = launch_info.critical;
734   grp_member_info.shutdown_critical = launch_info.shutdown_critical;
735   grp_member_info.shutdown_wait_time = launch_info.shutdown_wait_time;
736   grp_member_info.group_id = launch_info.group_id;
737   grp_member_info.is_start_required = launch_info.is_start_required;
738   grp_member_info.fast_shutdown_wait_time = launch_info.fast_shutdown_wait_time;
739   grp_member_info.SetAGLUnit(launch_info.IsAGLUnit());
740   grp_member_info.SetAGLResetHistoryDisable(launch_info.IsAGLResetHistoryDisable());
741   grp_member_info.SetNonAGLResetHisoryDisable(launch_info.IsNonAGLResetHistoryDisable());
742
743   module_lst.push_back(grp_member_info);
744 }
745 // LCOV_EXCL_STOP
746
747 static ModuleLaunchListIter set_cfg_grp_member_info(
748         const CfgLaunchParams& launch_info, ModuleLaunchList& module_lst) {  // NOLINT
749   ModuleLaunchParams grp_member_info;
750   ModuleLaunchListIter moduleLaunchListIter;
751
752   grp_member_info.name = launch_info.name;
753   grp_member_info.path = launch_info.binary_name;
754   grp_member_info.arguments = (  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
755       std::strcmp(launch_info.arguments, "NULL") == 0 ? "" : launch_info.arguments);
756   grp_member_info.restart = (  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
757       std::strcmp(launch_info.restart, "NULL") == 0 ? "" : launch_info.restart);
758   grp_member_info.configuration_priority = launch_info.priority;
759   grp_member_info.cpu_assign = launch_info.cpu_assign;
760   grp_member_info.retry_cnt = launch_info.retry_cnt;
761   grp_member_info.logging_msk_str = (  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
762       std::strcmp(launch_info.logging_msk_str, "NULL") == 0 ? "" : launch_info.logging_msk_str);
763
764   grp_member_info.critical = launch_info.critical;
765   grp_member_info.shutdown_critical = launch_info.shutdown_critical;
766   grp_member_info.shutdown_wait_time = launch_info.shutdown_wait_time;
767   grp_member_info.group_id = launch_info.group_id;
768   grp_member_info.is_start_required = launch_info.is_start_required;
769   grp_member_info.fast_shutdown_wait_time = launch_info.fast_shutdown_wait_time;
770   grp_member_info.SetAGLUnit(launch_info.IsAGLUnit());
771   grp_member_info.SetAGLResetHistoryDisable(launch_info.IsAGLResetHistoryDisable());
772   grp_member_info.SetNonAGLResetHisoryDisable(launch_info.IsNonAGLResetHistoryDisable());
773
774   strncpy(&grp_member_info.unix_user_name[0], &launch_info.unix_user_name[0],
775       sizeof(TUserNameBuffer));
776
777   moduleLaunchListIter = module_lst.insert(module_lst.end(), grp_member_info);
778   return (moduleLaunchListIter);
779 }
780
781 static void load_parameters_order_cfg(GroupLaunchMap& groups_map,  // NOLINT
782         LaunchOrderedVector& f_OrderList, SS_String& f_launchOrderName,  // NOLINT
783         SS_String& f_launchCfgFn) {  // NOLINT
784   SS_String l_OrderCfgFn = f_launchCfgFn;
785   string::size_type pos = l_OrderCfgFn.find(".cfg");
786
787   if (pos == string::npos) {  // LCOV_EXCL_BR_LINE 5:C error
788     // LCOV_EXCL_START 5:C error
789     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
790     FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "invalid file name:%s",
791             f_launchCfgFn.c_str());
792     return;
793     // LCOV_EXCL_STOP
794   }
795
796   l_OrderCfgFn.replace(pos, strlen(".order.cfg"), ".order.cfg");
797   CNSConfigReader *l_pReaderOrderCfg = new CNSConfigReader(l_OrderCfgFn);
798
799   if (l_pReaderOrderCfg != NULL) {  // LCOV_EXCL_BR_LINE 5:new error
800     CHAR key[128];
801     std::sprintf(key, "%s.order", f_launchOrderName.c_str());  // NOLINT
802     SS_String value = l_pReaderOrderCfg->GetString(key);
803     std::vector<std::string> strList;
804     if (value.empty()) {  // LCOV_EXCL_BR_LINE 200:cannot be empty
805       goto ERROR;
806     }
807 // LCOV_EXCL_START 6: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied
808     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
809     boost::split(strList, value, boost::is_any_of("|"));
810     for (UI_32 i = 0; i < strList.size(); i++) {
811         char* endptr = NULL;
812         f_OrderList.push_back(
813                 static_cast<UI_32>(strtoul(strList[i].c_str(), &endptr, 10)));
814         if (*endptr != '\0') {
815             // Discard boot order if invalid string is detected
816             f_OrderList.clear();
817             goto ERROR;
818         }
819     }
820     std::sprintf(key, "%s.owlist", f_launchOrderName.c_str());  // NOLINT
821     SS_String ow_list_value = l_pReaderOrderCfg->GetString(key);
822     std::vector<std::string> owList;
823
824     if (!ow_list_value.empty()) {
825       boost::split(owList, ow_list_value, boost::is_any_of("|"));
826       for (UI_32 i = 0; i < owList.size(); i++) {
827         std::sprintf(key, "%s.%s", f_launchOrderName.c_str(),  // NOLINT
828                 owList[i].c_str());
829         SS_String grop_ow_time = l_pReaderOrderCfg->GetString(key);
830         if (owList[i].compare(0, 4, "oww_") == 0) {
831           char* endptr = NULL;
832           SS_String group_name = owList[i].substr(strlen("oww_"));
833           UI_32 group_launch_wait = static_cast<UI_32>(strtoul(
834                   grop_ow_time.c_str(), &endptr, 10));
835           if (*endptr != '\0') {
836             continue;
837           }
838           GroupLaunchMapIter grp_iter = groups_map.begin();
839           while (grp_iter != groups_map.end()) {
840             if (group_name == grp_iter->second.name) {
841               grp_iter->second.grp_launch_wait = group_launch_wait;
842               FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__,
843                   "grp_launch_wait %s=%d", group_name.c_str(),
844                   group_launch_wait);
845               break;
846             }
847             grp_iter++;
848           }
849         }
850       }
851     }
852   } else {
853     FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "ConfigReader(%s) is NULL",
854             l_OrderCfgFn.c_str());
855   }
856 // LCOV_EXCL_STOP
857   ERROR: if (l_pReaderOrderCfg != NULL) {  // LCOV_EXCL_BR_LINE 200:cannot be null
858     delete l_pReaderOrderCfg;  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
859   }
860   return;
861 }
862
863 // Given a string, splits it up on the seperator character
864 // SubStringIterator( "a|b|| c |", '|' )
865 //   -> On each subsequent invocation of next() would return "a", "b", "", " c ", ""
866 class SubStringIterator {
867   typedef std::string::const_iterator SCIter;
868
869  public:
870   SubStringIterator(const std::string& s, char c) :
871       m_position(s.begin()), m_end(s.end()), m_seperator(c), m_done(false) {
872   }
873
874   std::string next() {
875     SCIter begin = m_position;
876     while (m_position != m_end &&
877             *m_position != m_seperator) {
878       ++m_position;
879     }
880
881     const std::string ret(begin, m_position);
882     if (m_position == m_end) {
883       m_done = true;
884     } else {
885       ++m_position;
886     }
887
888     return ret;
889   }
890   bool done() const {
891     return m_done;
892   }
893
894  private:
895   SCIter m_position;
896   const SCIter m_end;
897   const char m_seperator;
898   bool m_done;
899 };
900
901 template<class Iter>
902 static
903 Iter skipPrecedingWS(Iter begin, Iter end) {  // LCOV_EXCL_START 6: Because the condition cannot be set
904   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
905   return std::find_if(begin, end,
906       std::not1(std::ptr_fun((int (*)(int))std::isspace)));
907 }
908
909 // remove only preceding and trailing whitespace, but leave intermediate whitespace characters alone
910 std::string strip(const std::string& str) {
911   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
912   std::string::const_iterator skipTo = skipPrecedingWS(str.begin(), str.end());
913   if (skipTo == str.end()) {  // if string consists of ONLY whitespace
914     return std::string("");
915   } else {
916     return std::string(skipTo, skipPrecedingWS(str.rbegin(), str.rend()).base());
917   }
918 }
919 // LCOV_EXCL_STOP
920
921 BOOL SysMgrConfiguration::LoadParametersCfg(GroupLaunchMap& groups_map,
922         ProcessNameMap& f_processNameMap, LaunchOrderedVector& f_OrderList,
923         SS_String& f_launchOrderName, SS_String& f_launchCfgFn) {
924   BOOL rtn_code = TRUE;
925   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
926
927   l_pReaderCfg = new (std::nothrow) CNSConfigReader(f_launchCfgFn);  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
928
929   if (NULL != l_pReaderCfg) {  // LCOV_EXCL_BR_LINE 5:new error
930     UI_32 launch_idx = 1;
931     CHAR key[128];
932     std::sprintf(key, "ModulesLaunchConfig.Launch%d", launch_idx);  // NOLINT
933     SS_String value = l_pReaderCfg->GetString(key);
934
935     if (value.empty()) {  // LCOV_EXCL_BR_LINE 200:cannot be empty
936 // LCOV_EXCL_START 6: For setting the initialization conditions at SystemManager startup
937       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
938       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
939           " Error: l_pReaderCfg->GetString(%s) returned empty-string; "
940                   "is launch configuration file mis-configured ?",
941           key);
942       rtn_code = FALSE;
943 // LCOV_EXCL_STOP
944     } else {
945       const char* nfsenv = getenv("AGL_NFS");
946       bool isNfs = (nfsenv && strcmp(nfsenv, "y") == 0) ? true : false;  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
947
948       std::list<std::string> capFiles;
949       if (isNfs) {
950 // LCOV_EXCL_START 6: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied
951         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
952         const std::string capPath("/usr/debug/share/target/cap.lst");
953         std::ifstream fin(capPath.c_str());
954         std::string line;
955         while (fin && std::getline(fin, line)) {
956           std::list<std::string> strList;
957           boost::split(strList, line, boost::is_any_of("|"));
958           if (!strList.empty()) {
959             if (strList.front()[0] == '/') {  // Only character strings beginning with '/' are considered PATH
960               capFiles.push_back(strList.front().c_str());
961             }
962           }
963         }
964       }
965 // LCOV_EXCL_STOP
966       while (!value.empty()) {
967         CHAR critical[10] = { };
968         CHAR is_start_required[10] = { };
969         CHAR shutdown_critical[10] = { };
970         CHAR group_wait_for_trigger[10] = { };
971         CHAR is_agl_unit[10] = { };
972         CHAR disable_agl_resethistory[10] = { };
973         CHAR disable_nonagl_resethistory[10] = { };
974         CfgLaunchParams cfg_data;
975
976         int at = static_cast<int>(ss_sm_cfg::cfg_args::group_name);
977
978         SubStringIterator iter(value, '|');
979         while (!iter.done() && ss_sm_cfg::cfg_args::END != at) {
980           const std::string data_ = iter.next();
981           if (!data_.empty()) {
982             const char* data = data_.c_str();
983             switch (at) {
984             case ss_sm_cfg::cfg_args::group_name:
985               snprintf(cfg_data.group_name,
986                       sizeof(cfg_data.group_name), "%s", data);
987               break;
988             case ss_sm_cfg::cfg_args::group_id:
989               cfg_data.group_id = static_cast<UI_32>(strtoul(data, NULL, 10));
990               break;
991             case ss_sm_cfg::cfg_args::group_launch_wait:
992               cfg_data.group_launch_wait =
993                   static_cast<UI_32>(strtoul(data, NULL, 10));
994               break;
995             case ss_sm_cfg::cfg_args::group_wait_for_trigger:
996               snprintf(group_wait_for_trigger,
997                   sizeof(group_wait_for_trigger), "%s", data);
998               break;
999             case ss_sm_cfg::cfg_args::name:
1000               snprintf(cfg_data.name, sizeof(cfg_data.name), "%s", data);
1001               break;
1002             case ss_sm_cfg::cfg_args::binary_name:
1003               snprintf(cfg_data.binary_name,
1004                   sizeof(cfg_data.binary_name), "%s", data);
1005               break;
1006             case ss_sm_cfg::cfg_args::priority:
1007               cfg_data.priority = static_cast<UI_32>(strtoul(data, NULL, 10));
1008               break;
1009             case ss_sm_cfg::cfg_args::critical:
1010               snprintf(critical, sizeof(critical), "%s", data);
1011               break;
1012             case ss_sm_cfg::cfg_args::retry_cnt:
1013               cfg_data.retry_cnt = static_cast<UI_32>(strtoul(data, NULL, 10));
1014               break;
1015             case ss_sm_cfg::cfg_args::arguments:
1016               strncpy(cfg_data.arguments, data,
1017                       sizeof(cfg_data.arguments) - 1);
1018               break;
1019             case ss_sm_cfg::cfg_args::logging_msk:
1020               snprintf(cfg_data.logging_msk_str,
1021                       sizeof(cfg_data.logging_msk_str), "%s", data);
1022               break;
1023             case ss_sm_cfg::cfg_args::restart:
1024               snprintf(cfg_data.restart, sizeof(cfg_data.restart), "%s", data);
1025               break;
1026             case ss_sm_cfg::cfg_args::is_start_required:
1027               snprintf(is_start_required,
1028                   sizeof(is_start_required), "%s", data);
1029               break;
1030             case ss_sm_cfg::cfg_args::shutdown_critical:
1031               snprintf(shutdown_critical,
1032                   sizeof(shutdown_critical), "%s", data);
1033               break;
1034             case ss_sm_cfg::cfg_args::shutdown_wait_time:
1035               cfg_data.shutdown_wait_time =
1036                   static_cast<UI_32>(strtoul(data, NULL, 10));
1037               break;
1038             case ss_sm_cfg::cfg_args::fast_shutdown_wait_time:
1039               cfg_data.fast_shutdown_wait_time =
1040                   static_cast<UI_32>(strtoul(data, NULL, 10));
1041               break;
1042             case ss_sm_cfg::cfg_args::unix_user_name:
1043               strncpy(&cfg_data.unix_user_name[0],
1044                   strip(data_).c_str(),
1045                   sizeof(cfg_data.unix_user_name) - 1);
1046               break;
1047             case ss_sm_cfg::cfg_args::is_agl_unit:
1048               strncpy(is_agl_unit, data, sizeof(is_agl_unit));
1049               break;
1050             case ss_sm_cfg::cfg_args::disable_agl_resethistory:
1051               strncpy(disable_agl_resethistory, data, sizeof(disable_agl_resethistory));
1052               break;
1053             case ss_sm_cfg::cfg_args::disable_nonagl_resethistory:
1054               strncpy(disable_nonagl_resethistory, data, sizeof(disable_nonagl_resethistory));
1055               break;
1056             case ss_sm_cfg::cfg_args::env_value_condition:  // LCOV_EXCL_START 6: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied // NOLINT(whitespace/line_length)
1057               AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1058               snprintf(cfg_data.env_value_condition,
1059                   sizeof(cfg_data.env_value_condition), "%s", data);
1060               break;
1061             case ss_sm_cfg::cfg_args::cpu_assign:
1062               cfg_data.cpu_assign =
1063                 static_cast<int>(strtoul(data, NULL, 16));
1064               break;
1065             default:
1066               AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1067               FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1068                   " Error: unknown ss_sm_cfg::cfg_args::xxx/'at' "
1069                           "enum value '%d'", at);
1070               break;
1071             // LCOV_EXCL_STOP
1072             }
1073           }
1074           ++at;
1075         }
1076         ////////////////////////////////////////////////////////////////////////////////
1077 // LCOV_EXCL_BR_START 6: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied
1078         if (0 != std::strlen(cfg_data.env_value_condition)
1079               && FALSE
1080                     == is_satisfy_env_launch_cond(
1081 // LCOV_EXCL_BR_STOP
1082           cfg_data.env_value_condition)) {  // LCOV_EXCL_LINE 6: For setting the initialization conditions at SystemManager startup
1083           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1084           FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
1085               "exclude %s from wakeup service", cfg_data.name);
1086         } else {
1087           if (isNfs) {  // LCOV_EXCL_BR_LINE 6: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied
1088             // Since the NFS environment is used by copying the executable file containing the CAP to /tmp, it is read out.
1089 // LCOV_EXCL_START 6: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied
1090             AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1091             std::string binPath(cfg_data.binary_name);
1092             for (std::list<std::string>::iterator ite =
1093                   capFiles.begin(); ite != capFiles.end(); ite++) {
1094               if (binPath == *ite) {
1095                 std::list<std::string> nodes;
1096                 boost::split(nodes, binPath, boost::is_any_of("/"));
1097                 std::string newPath("/tmp/");
1098                 newPath += nodes.back();
1099                 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "EXCHG %s", newPath.c_str());
1100                 snprintf(cfg_data.binary_name,
1101                     sizeof(cfg_data.binary_name), "%s", newPath.c_str());
1102                 break;
1103               }
1104             }
1105           }
1106 // LCOV_EXCL_STOP
1107           // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "is_start_required: %s", is_start_required);
1108           cfg_data.is_start_required = (std::strcmp("True",
1109                   is_start_required) == 0);
1110
1111           if (std::strcmp("True", group_wait_for_trigger) == 0) {
1112               cfg_data.group_wait_for_trigger = TRUE;
1113           } else {
1114               cfg_data.group_wait_for_trigger = FALSE;
1115           }
1116
1117           // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "critical: %s", critical);
1118           cfg_data.critical = (std::strcmp("True", critical) == 0);
1119
1120           // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "shutdown_critical: %s", shutdown_critical);
1121           cfg_data.shutdown_critical = (std::strcmp("True",
1122                   shutdown_critical) == 0);
1123
1124           cfg_data.SetAGLUnit(ParseBoolParameter(is_agl_unit, TRUE));
1125           cfg_data.SetAGLResetHistoryDisable(ParseBoolParameter(disable_agl_resethistory));
1126           cfg_data.SetNonAGLResetHisoryDisable(ParseBoolParameter(disable_nonagl_resethistory));
1127
1128           GroupLaunchInfo grp_info;
1129           grp_info.start_complete = FALSE;
1130           grp_info.stop_complete = FALSE;
1131           grp_info.launch_complete = FALSE;
1132           grp_info.name = cfg_data.group_name;
1133           grp_info.id = cfg_data.group_id;
1134           grp_info.grp_launch_wait = cfg_data.group_launch_wait;
1135           grp_info.grp_wait_for_trigger =
1136                   cfg_data.group_wait_for_trigger;
1137           ModuleLaunchListIter l_moduleLaunchListIter;
1138
1139           GroupLaunchMapIter grp_iter = groups_map.find(grp_info.id);
1140           if (grp_iter != groups_map.end()) {
1141             l_moduleLaunchListIter = set_cfg_grp_member_info(
1142                     cfg_data, grp_iter->second.modules);
1143           } else {
1144             l_moduleLaunchListIter = set_cfg_grp_member_info(
1145                     cfg_data, grp_info.modules);
1146
1147             // add this grp info object to the list of grps
1148             groups_map.insert(make_pair(grp_info.id, grp_info));
1149           }
1150
1151           std::string l_binaryNameStr = cfg_data.binary_name;
1152           size_t l_binaryNamePos = l_binaryNameStr.find_last_of("/");
1153           if (std::string::npos != l_binaryNamePos) {
1154             l_binaryNameStr = l_binaryNameStr.substr(l_binaryNamePos + 1);
1155             f_processNameMap.insert(
1156                 make_pair(l_binaryNameStr, l_moduleLaunchListIter));
1157           }
1158         }
1159
1160         std::sprintf(key, "ModulesLaunchConfig.Launch%d", ++launch_idx);  // NOLINT
1161         value = l_pReaderCfg->GetString(key);
1162       }  // end while
1163     }
1164   } else {  // LCOV_EXCL_START 6: Because new doesn't pass the failure case
1165     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1166     // defaults use from the header file ... this is much faster then reading from an xml file.
1167     FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
1168         " Warning: \"new CNSConfigReader(%s)\" returned NULL; using "
1169                 "constants.", f_launchCfgFn.c_str());
1170     UI_32 num_of_items = static_cast<UI_32>(_countof(g_arrLaunchTableCfg));
1171     for (UI_32 arr_idx = 0; arr_idx < num_of_items; arr_idx++) {
1172       GroupLaunchInfo grp_info;
1173       grp_info.launch_complete = FALSE;
1174       grp_info.name = g_arrLaunchTableCfg[arr_idx].group_name;
1175       grp_info.id = g_arrLaunchTableCfg[arr_idx].group_id;
1176       grp_info.grp_launch_wait =
1177               g_arrLaunchTableCfg[arr_idx].group_launch_wait;
1178
1179       GroupLaunchMapIter grp_iter = groups_map.find(grp_info.id);
1180
1181       if (grp_iter != groups_map.end()) {
1182         set_grp_member_info(g_arrLaunchTableCfg[arr_idx],
1183                 grp_iter->second.modules);
1184       } else {
1185         set_grp_member_info(g_arrLaunchTableCfg[arr_idx],
1186                 grp_info.modules);
1187         // add this grp info object to the list of grps
1188         groups_map.insert(make_pair(grp_info.id, grp_info));
1189       }
1190     }
1191   }
1192   // LCOV_EXCL_STOP
1193   if (rtn_code == TRUE) {
1194     load_parameters_order_cfg(groups_map, f_OrderList, f_launchOrderName, f_launchCfgFn);
1195   }
1196
1197   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1198   return rtn_code;
1199 }
1200
1201 VOID SysMgrConfiguration::PrintGroupInfo(GroupLaunchInfo& refGrpInfo) {
1202   std::stringstream l_logMsg;
1203
1204   l_logMsg << endl << "Group: " << refGrpInfo.name.data() << endl
1205       << "    id: " << refGrpInfo.id << endl << "    wait-time: "
1206       << refGrpInfo.grp_launch_wait << endl << "    launch complete: "
1207       << (refGrpInfo.launch_complete == TRUE ? "YES" : "NO");  // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT(whitespace/line_length)
1208
1209   std::string l_logStr = l_logMsg.str();
1210   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s", l_logStr.c_str());
1211 }
1212
1213 VOID SysMgrConfiguration::PrintModuleInfo(ModuleLaunchParams& refMbrInfo) {
1214   std::stringstream l_logMsg;
1215
1216   // LCOV_EXCL_BR_START 11:unexpected branch  // NOLINT(whitespace/line_length)
1217   l_logMsg << endl << "Module: " << refMbrInfo.name.data() << endl
1218       << "    path: " << refMbrInfo.path.data() << endl << "    args: "
1219       << refMbrInfo.arguments.data() << endl << "    restart: "
1220       << refMbrInfo.restart.data() << endl
1221       << "    configuration_priority: "
1222       << refMbrInfo.configuration_priority << endl
1223       << "    cpu_assign: "
1224       << refMbrInfo.cpu_assign << endl
1225       << "    current_priority: " << refMbrInfo.current_priority << endl
1226       << "    previous_priority: " << refMbrInfo.previous_priority << endl
1227       << "    critical: " << (refMbrInfo.critical == TRUE ? "YES" : "NO")
1228       << endl
1229       << "    retry count: " << refMbrInfo.retry_cnt << endl
1230       << "    logging mask: " << refMbrInfo.logging_msk_str << endl
1231       << "    is_start_required: "
1232       << (refMbrInfo.is_start_required == TRUE ? "YES" : "NO")
1233       << endl
1234       << "    shutdown_critical: "
1235       << (refMbrInfo.shutdown_critical == TRUE ? "YES" : "NO") << endl
1236       << "    shutdown_wait_time: " << refMbrInfo.shutdown_wait_time
1237       << endl << "    fast_shutdown_wait_time: "
1238       << refMbrInfo.fast_shutdown_wait_time << endl << "    is_agl_unit: "
1239       << refMbrInfo.IsAGLUnit() << endl << "    disable_agl_resethistory: "
1240       << refMbrInfo.IsAGLResetHistoryDisable() << endl << "    disable_nonagl_resethistory: "
1241       << refMbrInfo.IsNonAGLResetHistoryDisable() << endl << "    state: "
1242       << refMbrInfo.ModuleStateStr() << endl << "    group ID: "
1243       << refMbrInfo.group_id << endl << "    debug dump state: "
1244       << refMbrInfo.GetModuleDebugDumpStateStr();
1245   // LCOV_EXCL_BR_STOP
1246   std::string l_logStr = l_logMsg.str();
1247   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s", l_logStr.c_str());
1248 }
1249
1250 VOID SysMgrConfiguration::PrintAllInfo(GroupLaunchMap& refGrpMap) {
1251   // get first client from the map...
1252   GroupLaunchMapIter grp_iter = refGrpMap.begin();
1253
1254   for (; grp_iter != refGrpMap.end(); grp_iter++) {
1255     PrintGroupInfo(grp_iter->second);
1256     ModuleLaunchListIter mbr_iter = grp_iter->second.modules.begin();
1257     for (; mbr_iter != grp_iter->second.modules.end(); mbr_iter++) {
1258       PrintModuleInfo(*mbr_iter);
1259     }
1260   }
1261 }
1262
1263 BOOL SysMgrConfiguration::ParseBoolParameter(PCSTR f_value, BOOL f_default) const {
1264   if (FALSE == f_default) {
1265     const char TRUE_VALUE[] = "True";
1266     if (0 == strcmp(TRUE_VALUE, f_value)) {
1267       return TRUE;
1268     }
1269   } else {
1270     const char FALSE_VALUE[] = "False";
1271     if (0 == strcmp(FALSE_VALUE, f_value)) {
1272       return FALSE;
1273     }
1274   }
1275   return f_default;
1276 }
1277
1278 /*
1279  * SM Configuration data constructor
1280  */
1281 SMConfigParams::SMConfigParams() {
1282 }
1283
1284 /*
1285  * SM Configuration data destructor
1286  */
1287 SMConfigParams::~SMConfigParams() {
1288 }
1289
1290 ////////////////////////////////////////////////////////////////////////////////////////////
1291 ///  PrintConfigInfo
1292 ///  \brief Print the configuration data stored in config structure
1293 ///
1294 /// \param [in] configata
1295 ///         ConfigurationData & - Ref to structure that get populated.
1296 ///
1297 /// \return VOID
1298 ////////////////////////////////////////////////////////////////////////////////////////////
1299 VOID SMConfigParams::PrintConfigInfo(ConfigurationData const & f_ConfigParams) {
1300   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "AppHeartBeatInterval_Initial Info: %d",
1301       f_ConfigParams.HBConfig.ApplicationHeartBeatIntervalInitial);
1302   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "AppHeartBeatInterval_Repeat Info: %d",
1303       f_ConfigParams.HBConfig.ApplicationHeartBeatIntervalRepeat);
1304   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "HBMaxHeartBeatRetryCount Info: %d",
1305       f_ConfigParams.HBConfig.MaxHeartBeatRetryCount);
1306   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "CDEnabled: %d",
1307       f_ConfigParams.CDConfig.CrashDetectorEnabled);
1308   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SLMTimerValue: %d",
1309       f_ConfigParams.SLMConfig.SLMTimerValue);
1310   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SLMMaxRetryCount: %d",
1311       f_ConfigParams.SLMConfig.SLMMaxRetryCount);
1312   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SLMThresholdValue: %d",
1313       f_ConfigParams.SLMConfig.SLMThresholdValue);
1314   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SLMSystemmanagerLogIntervalMs: %d",
1315       f_ConfigParams.SLMConfig.SLMSystemmanagerLogIntervalMs);
1316   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "UserModeStructIsBoolean: %s",
1317       GetStr(f_ConfigParams.UMConfig.IsUserModeNotificationABOOL).c_str());
1318   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "ModuleConnectionNumTimesToCheck: %d",
1319       f_ConfigParams.MCConfig.ModuleConnectionNumTimesToCheck);
1320   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "ModuleConnectionTimeOutSec: %d",
1321       f_ConfigParams.MCConfig.ModuleConnectionTimeOutSec);
1322   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "ModuleStartRespTimeOutSec: %d",
1323       f_ConfigParams.MCConfig.ModuleStartRespTimeOutSec);
1324   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "CriticalAppsMaxShutdownTimeFastSleep: %d",
1325       f_ConfigParams.CAMSTConfig.CriticalAppsMaxShutdownTimeFastSleep);
1326   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
1327       "CriticalAppsMaxShutdownTimeNormalReset: %d",
1328       f_ConfigParams.CAMSTConfig.CriticalAppsMaxShutdownTimeNormalReset);
1329   return;
1330 }
1331
1332 ////////////////////////////////////////////////////////////////////////////////////////////
1333 /// GetSMConfigInformation
1334 /// \brief Read config data from cfg file and populate the configuration data structure
1335 ///
1336 /// \param [in] f_ConfigParams & - Ref to ConfigurationData that get populated.
1337 /// \param [in] f_FileName       - Configuration file name.
1338 ///
1339 /// \return BOOL
1340 ///         BOOL - TRUE or FALSE
1341 ////////////////////////////////////////////////////////////////////////////////////////////
1342 BOOL SMConfigParams::GetSMConfigInformation(ConfigurationData& f_ConfigParams, SS_String f_FileName) {
1343   EFrameworkunifiedStatus l_eStatus;
1344   BOOL l_rtnCode = FALSE;  // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h  // NOLINT(whitespace/line_length)
1345
1346   CNSConfigReader *l_pReaderCfg = new (std::nothrow) CNSConfigReader();  // LCOV_EXCL_BR_LINE 10: As new does not fail
1347 // LCOV_EXCL_BR_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1348   if (NULL == l_pReaderCfg) {
1349     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1350     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1351         " Error. new CNSConfigReader() returned NULL pointer.");
1352   } else {
1353     if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->Parse(f_FileName))) {
1354       // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1355       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1356       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1357               " Error. l_pReaderCfg->Open(%s) returned NULL pointer.",
1358               f_FileName.c_str());
1359       // LCOV_EXCL_STOP
1360     } else if (eFrameworkunifiedStatusOK
1361           != (l_eStatus = l_pReaderCfg->GetInt(
1362               "Heartbeat.MaxHeartBeatRetryCount",
1363               f_ConfigParams.HBConfig.MaxHeartBeatRetryCount))) {
1364       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1365       LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1366           "l_pReaderCfg->GetInt('Heartbeat.MaxHeartBeatRetryCount')");
1367     } else if (eFrameworkunifiedStatusOK
1368           != (l_eStatus = l_pReaderCfg->GetInt(
1369               "Heartbeat.AppHeartBeatIntervalInitial",
1370               f_ConfigParams.HBConfig.ApplicationHeartBeatIntervalInitial))) {
1371       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1372       LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1373           "l_pReaderCfg->GetInt('Heartbeat.AppHeartBeatIntervalInitial')");
1374     } else if (eFrameworkunifiedStatusOK
1375           != (l_eStatus = l_pReaderCfg->GetInt(
1376               "Heartbeat.AppHeartBeatIntervalRepeat",
1377               f_ConfigParams.HBConfig.ApplicationHeartBeatIntervalRepeat))) {
1378       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1379       LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1380           "l_pReaderCfg->GetInt('Heartbeat.AppHeartBeatIntervalRepeat')");
1381     } else if (eFrameworkunifiedStatusOK
1382           != (l_eStatus = l_pReaderCfg->GetBool("CrashDetector.Enabled",
1383               f_ConfigParams.CDConfig.CrashDetectorEnabled))) {
1384       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1385       LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1386           "l_pReaderCfg->GetBool('CrashDetector.Enabled')");
1387     } else if (eFrameworkunifiedStatusOK
1388           != (l_eStatus = l_pReaderCfg->GetInt("SysLowMemory.TimerValue",
1389               f_ConfigParams.SLMConfig.SLMTimerValue))) {
1390       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1391       LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1392           "l_pReaderCfg->GetInt('SysLowMemory.TimerValue')");
1393     } else if (eFrameworkunifiedStatusOK
1394           != (l_eStatus = l_pReaderCfg->GetInt(
1395               "SysLowMemory.MaxRetryCount",
1396               f_ConfigParams.SLMConfig.SLMMaxRetryCount))) {
1397       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1398       LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1399           "l_pReaderCfg->GetInt('SysLowMemory.MaxRetryCount')");
1400     } else if (eFrameworkunifiedStatusOK
1401           != (l_eStatus = l_pReaderCfg->GetInt(
1402               "SysLowMemory.ThresholdValue",
1403               f_ConfigParams.SLMConfig.SLMThresholdValue))) {
1404       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1405       LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1406           "l_pReaderCfg->GetInt('SysLowMemory.ThresholdValue')");
1407     } else if (eFrameworkunifiedStatusOK
1408           != (l_eStatus = l_pReaderCfg->GetInt(
1409               "SysLowMemory.InterfaceunifiedLogIntervalMs",
1410               f_ConfigParams.SLMConfig.SLMSystemmanagerLogIntervalMs))) {
1411       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1412       LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1413           "l_pReaderCfg->GetInt('SysLowMemory.InterfaceunifiedLogIntervalMs')");
1414     } else if (eFrameworkunifiedStatusOK
1415           != (l_eStatus = l_pReaderCfg->GetBool(
1416               "UserModeNotification.IsBoolean",
1417               f_ConfigParams.UMConfig.IsUserModeNotificationABOOL))) {
1418       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1419       LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1420           "l_pReaderCfg->GetBool('UserModeNotification.IsBoolean')");
1421       f_ConfigParams.UMConfig.IsUserModeNotificationABOOL = TRUE;
1422     } else if (eFrameworkunifiedStatusOK
1423           != (l_eStatus = l_pReaderCfg->GetInt(
1424               "Module.ModuleConnectionNumTimesToCheck",
1425               f_ConfigParams.MCConfig.ModuleConnectionNumTimesToCheck))) {
1426       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1427       LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1428           "l_pReaderCfg->GetInt('Module.ModuleConnectionNumTimesToCheck')");
1429     } else if (eFrameworkunifiedStatusOK
1430           != (l_eStatus = l_pReaderCfg->GetInt(
1431               "Module.ModuleConnectionTimeOutSec",
1432               f_ConfigParams.MCConfig.ModuleConnectionTimeOutSec))) {
1433       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1434       LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1435           "l_pReaderCfg->GetInt('Module.ModuleConnectionTimeOutSec')");
1436     } else if (eFrameworkunifiedStatusOK
1437           != (l_eStatus = l_pReaderCfg->GetInt(
1438               "Module.ModuleStartRespTimeOutSec",
1439               f_ConfigParams.MCConfig.ModuleStartRespTimeOutSec))) {
1440       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1441       LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1442           "l_pReaderCfg->GetInt('Module.ModuleStartRespTimeOutSec')");
1443     } else if (eFrameworkunifiedStatusOK
1444           != (l_eStatus = l_pReaderCfg->GetInt(
1445               "CriticalApps.CriticalAppsMaxShutdownTimeFastSleep",
1446               f_ConfigParams.CAMSTConfig.CriticalAppsMaxShutdownTimeFastSleep))) {
1447       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1448       LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1449           "l_pReaderCfg->GetInt('CriticalApps.CriticalAppsMaxShutdownTimeFastSleep')");
1450     } else if (eFrameworkunifiedStatusOK
1451           != (l_eStatus = l_pReaderCfg->GetInt(
1452               "CriticalApps.CriticalAppsMaxShutdownTimeNormalReset",
1453               f_ConfigParams.CAMSTConfig.CriticalAppsMaxShutdownTimeNormalReset))) {
1454       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1455       LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1456           "l_pReaderCfg->GetInt('CriticalApps.CriticalAppsMaxShutdownTimeNormalReset')");
1457     } else {
1458       l_rtnCode = TRUE;
1459     }
1460
1461     delete l_pReaderCfg;  // LCOV_EXCL_BR_LINE 10: As the delete does not fail
1462   }
1463 // LCOV_EXCL_BR_STOP
1464
1465   return (l_rtnCode);
1466 }
1467
1468 ////////////////////////////////////////////////////////////////////////////////////////////
1469 /// LoadSMConfigParameters
1470 /// \brief Read System Manager configuration parameters from cfg file or
1471 ///        use defaults values in case cfg file is not available
1472 ///
1473 /// \param [in] f_ConfigParams & - Ref to ConfigurationData that get populated.
1474 /// \param [in] f_FileName       - Configuration file name.
1475 ///
1476 /// \return BOOL
1477 ///         BOOL - TRUE or FALSE
1478 ////////////////////////////////////////////////////////////////////////////////////////////
1479 BOOL SMConfigParams::LoadSMConfigParameters(ConfigurationData& f_ConfigParams, SS_String f_FileName) {
1480   BOOL rtn_code = TRUE;
1481
1482   rtn_code = GetSMConfigInformation(f_ConfigParams, f_FileName);
1483
1484   // cfg config file not found, use constants
1485   if (FALSE == rtn_code) {
1486     // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1487     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1488     FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
1489         " Warning: cfg config file not open, using constants");
1490
1491     // Heart Beat constants
1492     f_ConfigParams.HBConfig.ApplicationHeartBeatIntervalInitial =
1493         HBApplicationHeartBeatIntervalInitial;
1494     f_ConfigParams.HBConfig.ApplicationHeartBeatIntervalRepeat =
1495         HBApplicationHeartBeatIntervalRepeat;
1496     f_ConfigParams.HBConfig.MaxHeartBeatRetryCount = HBMaxHeartBeatRetryCount;
1497
1498     // Crash Detector constants
1499     f_ConfigParams.CDConfig.CrashDetectorEnabled = CDEnabled;
1500
1501     // System Low Memory
1502     f_ConfigParams.SLMConfig.SLMTimerValue = SLMTimerValue;
1503     f_ConfigParams.SLMConfig.SLMMaxRetryCount = SLMRetryCount;
1504     f_ConfigParams.SLMConfig.SLMThresholdValue = SLMThresholdValue;
1505     f_ConfigParams.SLMConfig.SLMSystemmanagerLogIntervalMs = SLMSystemmanagerLogIntervalMs;
1506
1507     // Module connect and start resp
1508     f_ConfigParams.MCConfig.ModuleConnectionNumTimesToCheck =
1509         ModuleConnectionNumTimesToCheck;
1510     f_ConfigParams.MCConfig.ModuleConnectionTimeOutSec =
1511         ModuleConnectionTimeOutSec;
1512     f_ConfigParams.MCConfig.ModuleStartRespTimeOutSec = ModuleStartRespTimeOutSec;
1513
1514     // Critical Apps shutdown time
1515     f_ConfigParams.CAMSTConfig.CriticalAppsMaxShutdownTimeFastSleep =
1516         CriticalAppsMaxShutdownTimeFastSleepSec;
1517     f_ConfigParams.CAMSTConfig.CriticalAppsMaxShutdownTimeNormalReset =
1518         CriticalAppsMaxShutdownTimeNormalResetSec;
1519
1520     // USer Mode Data Structure Type
1521     f_ConfigParams.UMConfig.IsUserModeNotificationABOOL = TRUE;
1522     // LCOV_EXCL_STOP
1523   }
1524   PrintConfigInfo(f_ConfigParams);
1525
1526   return rtn_code;
1527 }  // LCOV_EXCL_BR_LINE 10: Final line
1528