diff --git a/cov_build.sh b/cov_build.sh index 2c2e17d2..e442b8ba 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -48,7 +48,7 @@ cd rfc autoreconf -i ./configure --enable-rfctool=yes --enable-tr181set=yes cd rfcapi -make librfcapi_la_CPPFLAGS="-I/usr/include/cjson -I/usr/rfc/rfcMgr/gtest/mocks" +make librfcapi_la_CPPFLAGS="-I/usr/include/cjson -I/usr/rfc/rfcMgr/gtest/mocks -DUSE_IARMBUS" make install cd /usr/rfc/tr181api g++ -fPIC -shared -o libtr181api.so tr181api.cpp -I/usr/local/include/wdmp-c @@ -64,7 +64,6 @@ cp /usr/iarmmgrs/rdmmgr/include/rdmMgr.h /usr/local/include cp /usr/iarmbus/core/include/libIBusDaemon.h /usr/local/include cp /usr/iarmbus/core/include/libIBus.h /usr/local/include cp /usr/iarmbus/core/libIARMCore.h /usr/local/include -cp /usr/iarmmgrs/hal/include/pwrMgr.h /usr/local/include/ # Build and install stubs from tr69hostif @@ -79,5 +78,5 @@ cd $WORKDIR autoreconf -i autoupdate ./configure --prefix=${INSTALL_DIR} --enable-iarmbusSupport=yes -make remotedebugger_CFLAGS="-I/usr/include/cjson -I/usr/local/include/wdmp-c -I/usr/local/include/rbus -I/usr/local/include -I/usr/local/include/trower-base64 -DIARMBUS_SUPPORT -DUSECOV" remotedebugger_LDFLAGS="-L/usr/local/lib -lrdkloggers -lcjson -lrfcapi -lrbus -lmsgpackc -lsecure_wrapper -lwebconfig_framework -lIARMBus -ltr181api -L/usr/local/lib/x86_64-linux-gnu -ltrower-base64 -L/usr/lib/x86_64-linux-gnu" +make remotedebugger_CFLAGS="-I/usr/include/cjson -I/usr/local/include/wdmp-c -I/usr/local/include/rbus -I/usr/local/include -I./unittest/mocks -I/usr/local/include/trower-base64 -DIARMBUS_SUPPORT -DUSECOV" remotedebugger_LDFLAGS="-L/usr/local/lib -lrdkloggers -lcjson -lrfcapi -lrbus -lmsgpackc -lsecure_wrapper -lwebconfig_framework -lIARMBus -ltr181api -L/usr/local/lib/x86_64-linux-gnu -ltrower-base64 -L/usr/lib/x86_64-linux-gnu" make install diff --git a/remote_debugger.json b/remote_debugger.json index 9c7f1e83..1f36b579 100644 --- a/remote_debugger.json +++ b/remote_debugger.json @@ -39,5 +39,30 @@ "Commands": "systemctl list-units --type=service --all", "Timeout" : 10 } - } + }, + "DeepSleep": { + "Audio" : { + "AudioStatus" : { + "Commands": "cat /sys/class/avsync_session0/session_stat;cat /sys/class/vdec/vdec_status;hal_dump", + "Timeout" : 10 + } + }, + "Video" : { + "VideoStatus" : { + "Commands": "cat /sys/class/avsync_session0/session_stat;cat /sys/class/vdec/vdec_status;hal_dump", + "Timeout" : 10 + } + }, + "Process" : { + "ProcessStatus" : { + "Commands": "cat /opt/logs/top_log.txt*", + "Timeout" : 10 + }, + "ServiceStatus" : { + "Commands": "systemctl list-units --type=service --all", + "Timeout" : 10 + } + + } + } } diff --git a/run_l2.sh b/run_l2.sh index 2da98029..95783ffc 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -60,7 +60,10 @@ rm -rf /opt/logs/remotedebugger.log* # Run L2 Test cases pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_dynamic_profile_missing_report.json test/functional-tests/tests/test_rrd_dynamic_profile_missing_report.py +pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/test_category.json test/functional-tests/tests/test_rrd_dynamic_subcategory_report.py +pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_append.json test/functional-tests/tests/test_rrd_append_report.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_dynamic_profile_harmful_report.json test/functional-tests/tests/test_rrd_dynamic_profile_harmful_report.py +cp remote_debugger.json /etc/rrd/ pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_dynamic_profile_report.json test/functional-tests/tests/test_rrd_dynamic_profile_report.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_append_dynamic_profile_static_notfound.json test/functional-tests/tests/test_rrd_append_dynamic_profile_static_notfound.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_single_instance.json test/functional-tests/tests/test_rrd_single_instance.py @@ -75,3 +78,4 @@ pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_em pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_static_profile_missing_command_report.json test/functional-tests/tests/test_rrd_static_profile_missing_command_report.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_background_cmd_static_profile_report.json test/functional-tests/tests/test_rrd_background_cmd_static_profile_report.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_debug_report_upload.json test/functional-tests/tests/test_rrd_debug_report_upload.py +pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_deepsleep_static.json test/functional-tests/tests/test_rrd_deepsleep_static_report.py diff --git a/src/unittest/mocks/pwrMgr.h b/src/unittest/mocks/pwrMgr.h new file mode 100644 index 00000000..ddc93da9 --- /dev/null +++ b/src/unittest/mocks/pwrMgr.h @@ -0,0 +1,356 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2016 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +/** + * @file pwrMgr.h + * + * @brief IARM-Bus Power Manager Public API. + * + * This API defines the structures and functions for the IARM-Bus Power Manager interface. + */ + +/** +* @defgroup iarmmgrs +* @{ +* @defgroup hal +* @{ +**/ + +#ifndef _IARM_BUS_PWRMGR_H +#define _IARM_BUS_PWRMGR_H + +#include "libIARM.h" +#include "libIBusDaemon.h" + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @addtogroup IARM_PLAT_POWER_API + * @{ + */ + +#define IARM_BUS_PWRMGR_NAME "PWRMgr" /*!< Power manager IARM bus name */ + +/** + * @brief Represents the published Events from PWR Manager + */ +typedef enum _PWRMgr_EventId_t { + IARM_BUS_PWRMGR_EVENT_MODECHANGED = 0, /*!< Event to notify power mode change */ + IARM_BUS_PWRMGR_EVENT_DEEPSLEEP_TIMEOUT, /*!< Event to notify deepsleep timeout */ + IARM_BUS_PWRMGR_EVENT_RESET_SEQUENCE, /*!< Event to notify progress of reset key sequence*/ + IARM_BUS_PWRMGR_EVENT_REBOOTING, /*!< Event to notify that the device is about to reboot.*/ + IARM_BUS_PWRMGR_EVENT_THERMAL_MODECHANGED, /*!< Event to notify temperature level change */ + IARM_BUS_PWRMGR_EVENT_WAREHOUSEOPS_STATUSCHANGED, /*!< Event to notify ware house operation status changed */ + IARM_BUS_PWRMGR_EVENT_NETWORK_STANDBYMODECHANGED, /*!< Event to notify that the network standby mode changed.*/ + IARM_BUS_PWRMGR_EVENT_MAX, /*!< Max event id from this module */ +} IARM_Bus_PWRMgr_EventId_t; + + +/** + * @brief Enumerator which represents the possible temeperature states + */ +typedef enum _IARM_Bus_PWRMgr_ThermalState_t{ + IARM_BUS_PWRMGR_TEMPERATURE_NORMAL = 0, /* Temp is within normal operating range */ + IARM_BUS_PWRMGR_TEMPERATURE_HIGH, /* Temp is high, but just a warning as device can still operate */ + IARM_BUS_PWRMGR_TEMPERATURE_CRITICAL /* Temp is critical, should trigger a thermal reset */ +} IARM_Bus_PWRMgr_ThermalState_t; + +/** + * @brief Enumerator which represents the possible warehouse ops + */ +typedef enum _IARM_Bus_PWRMgr_WareHouseOps_t{ + IARM_BUS_PWRMGR_WAREHOUSE_RESET = 0, /* warehouse reset */ + IARM_BUS_PWRMGR_WAREHOUSE_CLEAR, /* warehouse clear*/ +} IARM_Bus_PWRMgr_WareHouseOps_t; + +/** + * @brief Enumerator which represents the possible warehouse ops + */ +typedef enum _IARM_Bus_PWRMgr_WareHouseOpsStatus_t{ + IARM_BUS_PWRMGR_WAREHOUSE_COMPLETED = 0, /* warehouse operation completed sucessfully */ + IARM_BUS_PWRMGR_WAREHOUSE_INPROGRESS, /* warehouse operation in progress*/ + IARM_BUS_PWRMGR_WAREHOUSE_FAILED, /* warehouse operation failed.*/ +} IARM_Bus_PWRMgr_WareHouseOpsStatus_t; + +/** + * @brief Enumerator which represents the possible wakeup sources + */ +typedef enum _WakeupSrcType_t { + WAKEUPSRC_VOICE = 0, + WAKEUPSRC_PRESENCE_DETECTION, + WAKEUPSRC_BLUETOOTH, + WAKEUPSRC_WIFI, + WAKEUPSRC_IR, + WAKEUPSRC_POWER_KEY, + WAKEUPSRC_TIMER, + WAKEUPSRC_CEC, + WAKEUPSRC_LAN, + WAKEUPSRC_MAX +} WakeupSrcType_t; + +/** + * @brief Structure which holds the event data. + */ +typedef struct _PWRMgr_EventData_t { + union { + struct _MODE_DATA{ + /* Declare Event Data structure for PWRMGR_EVENT_DUMMY0 */ + IARM_Bus_PowerState_t curState; /*!< Power manager current power state */ + IARM_Bus_PowerState_t newState; /*!< Power manager new power state */ + #ifdef ENABLE_DEEP_SLEEP + uint32_t deep_sleep_timeout; + #endif + bool nwStandbyMode; + } state; + #ifdef ENABLE_THERMAL_PROTECTION + struct _THERM_DATA{ + IARM_Bus_PWRMgr_ThermalState_t curLevel; + IARM_Bus_PWRMgr_ThermalState_t newLevel; + float curTemperature; + } therm; + #endif + bool bNetworkStandbyMode; + int32_t reset_sequence_progress; + } data; +}IARM_Bus_PWRMgr_EventData_t; + +/** + * @brief Structure which holds the Deep sleep timeout value. + */ +typedef struct _IARM_BUS_PWRMgr_DeepSleepTimeout_EventData_t { + unsigned int timeout; /*!< Timeout for deep sleep in seconds*/ +} IARM_BUS_PWRMgr_DeepSleepTimeout_EventData_t; + +/** + * @brief Structure which holds warehouse opn status value. + */ +typedef struct _IARM_BUS_PWRMgr_WareHouseOpn_EventData_t { + IARM_Bus_PWRMgr_WareHouseOps_t wareHouseOpn; /*!< WareHouse operation*/ + IARM_Bus_PWRMgr_WareHouseOpsStatus_t status; /*!< WareHouse operation status*/ +} IARM_BUS_PWRMgr_WareHouseOpn_EventData_t; + +/** + * Declare RPC API names and their arguments + */ +#define IARM_BUS_PWRMGR_API_SetPowerState "SetPowerState" /*!< Sets the powerstate of the device*/ + +/** + * @brief Structure which holds the new powerstate to be set to the device. + */ +typedef struct _IARM_Bus_PWRMgr_SetPowerState_Param_t { + IARM_Bus_PowerState_t newState; /*!< [in] New powerstate to be set */ + int keyCode; /*!< [in] Key code for the last key Pressed */ +} IARM_Bus_PWRMgr_SetPowerState_Param_t; + +#define IARM_BUS_PWRMGR_API_GetPowerState "GetPowerState" /*!< Retrives current power state of the box*/ + +/** + * @brief Structure which holds the current power state of the CPE. + */ +typedef struct _IARM_Bus_PWRMgr_GetPowerState_Param_t { + IARM_Bus_PowerState_t curState; /*!< Current powerstate of the box*/ + IARM_Bus_PowerState_t prevState; /*!< Current powerstate of the box*/ +} IARM_Bus_PWRMgr_GetPowerState_Param_t; + +#define IARM_BUS_PWRMGR_API_WareHouseReset "WareHouseReset" /*!< Reset the box to warehouse state*/ + +/** + * @brief Structure which holds the ware house reset time. + */ +typedef struct _IARM_Bus_PWRMgr_WareHouseReset_Param_t { + bool suppressReboot; /*!< STB should not be rebooted */ +} IARM_Bus_PWRMgr_WareHouseReset_Param_t; + +#define IARM_BUS_PWRMGR_API_WareHouseClear "WarehouseClear" /*!< */ + +#define IARM_BUS_PWRMGR_API_ColdFactoryReset "ColdFactoryReset" /*!< Reset the box to cold factory state*/ +#define IARM_BUS_PWRMGR_API_FactoryReset "FactoryReset" /*!< Reset the box to factory state*/ +#define IARM_BUS_PWRMGR_API_UserFactoryReset "UserFactoryReset" /*!< Reset the box to user factory state*/ + +#define IARM_BUS_PWRMGR_API_SetDeepSleepTimeOut "SetDeepSleepTimeOut" /*!< Sets the timeout for deep sleep*/ + +/** + * @brief Structure which holds the timeout value to set for Deep sleep. + */ +typedef struct _IARM_Bus_PWRMgr_SetDeepSleepTimeOut_Param_t { + unsigned int timeout; /*!< Timeout for deep sleep in seconds*/ +} IARM_Bus_PWRMgr_SetDeepSleepTimeOut_Param_t; + +#define IARM_BUS_PWRMGR_API_SetSleepTimer "SetSleepTimer" /*!< Sets sleep timer state and timeout*/ +#define IARM_BUS_PWRMGR_API_GetSleepTimer "GetSleepTimer" /*!< Gets sleep timer state and remaining */ + +/** + * @brief Structure which holds the sleep timer information. + */ +typedef struct _IARM_Bus_PWRMgr_SleepTimer_Param_t { + double time; /*!< timer duration*/ + int start; /*!< timer state, started=1 or stopped=0*/ +} IARM_Bus_PWRMgr_SleepTimer_Param_t; + +#ifdef ENABLE_THERMAL_PROTECTION + +/** + * @brief Structure which holds the data associated with thermal level. + */ +typedef struct _IARM_Bus_PWRMgr_GetThermalState_Param_t{ + IARM_Bus_PWRMgr_ThermalState_t curLevel; /*!< Current Thermal level */ + float curTemperature; /* !< Current temperature value */ +} IARM_Bus_PWRMgr_GetThermalState_Param_t; + +#define IARM_BUS_PWRMGR_API_GetThermalState "GetThermalState" /*!< Retrieves current thermal level of the box*/ + +/** + * @brief Structure which holds the thermal threshold value to be set to the device. + */ +typedef struct _IARM_Bus_PWRMgr_SetTempThresholds_Param_t{ + float tempHigh; /*!< New threshold at which TEMPERATURE_HIGH will be reported */ + float tempCritical; /*!< New threshold at which TEMPERATURE_CRITICAL will be reported */ +} IARM_Bus_PWRMgr_SetTempThresholds_Param_t; + +#define IARM_BUS_PWRMGR_API_SetTemperatureThresholds "SetTemperatureThresholds" /*!< Sets the thermal threshold for the device*/ + + +/** + * @brief Structure which holds the data associated with current temperature threshold. + */ +typedef struct _IARM_Bus_PWRMgr_GetTempThresholds_Param_t{ + float tempHigh; /*!< New threshold at which TEMPERATURE_HIGH will be reported */ + float tempCritical; /*!< New threshold at which TEMPERATURE_CRITICAL will be reported */ +} IARM_Bus_PWRMgr_GetTempThresholds_Param_t; + +#define IARM_BUS_PWRMGR_API_GetTemperatureThresholds "GetTemperatureThresholds" /*!< Gets the thermal threshold for the device*/ + +/** + * @brief Structure which holds the grace interval value to be set to the device. + */ +typedef struct _IARM_Bus_PWRMgr_SetOvertempGraceInterval_Param_t{ + int graceInterval; /*!< New over teamparature grace interval */ +} IARM_Bus_PWRMgr_SetOvertempGraceInterval_Param_t; + +#define IARM_BUS_PWRMGR_API_SetOvertempGraceInterval "SetOvertempGraceInterval" /*!< Sets the over temparature grace interval for the device*/ + +/** + * @brief Structure which holds the data associated with current over temparature grace interval. + */ +typedef struct _IARM_Bus_PWRMgr_GetOvertempGraceInterval_Param_t{ + int graceInterval; /*!< New over temparature grace interval */ +} IARM_Bus_PWRMgr_GetOvertempGraceInterval_Param_t; + +#define IARM_BUS_PWRMGR_API_GetOvertempGraceInterval "GetOvertempGraceInterval" /*!< Gets the over temparature grace interval for the device*/ + +/** @brief This function will be used to initialize thermal protection thread */ +extern void initializeThermalProtection(); +#endif //ENABLE_THERMAL_PROTECTION + +/** + * @brief Structure which holds the setting for whether video port is enabled in standby. + */ + +#define PWRMGR_MAX_VIDEO_PORT_NAME_LENGTH 16 +typedef struct _IARM_Bus_PWRMgr_StandbyVideoState_Param_t{ + char port[PWRMGR_MAX_VIDEO_PORT_NAME_LENGTH]; + int isEnabled; + int result; +} IARM_Bus_PWRMgr_StandbyVideoState_Param_t; +#define IARM_BUS_PWRMGR_API_SetStandbyVideoState "SetStandbyVideoState" +#define IARM_BUS_PWRMGR_API_GetStandbyVideoState "GetStandbyVideoState" + +#define IARM_BUS_PWRMGR_API_SetNetworkStandbyMode "SetNetworkStandbyMode" +#define IARM_BUS_PWRMGR_API_GetNetworkStandbyMode "GetNetworkStandbyMode" +typedef struct _IARM_Bus_PWRMgr_NetworkStandbyMode_Param_t { + bool bStandbyMode; /*!< Standby mode to set and get*/ +} IARM_Bus_PWRMgr_NetworkStandbyMode_Param_t; + +#define MAX_PWR_STATE_BEF_REBOOR_STR_LEN (32) +#define IARM_BUS_PWRMGR_API_GetPowerStateBeforeReboot "GetPowerStateBeforeReboot" /*!< Retrives power state before reboot*/ +/** + * @brief Structure which holds the power state before reboot of the CPE. + */ +typedef struct _IARM_Bus_PWRMgr_GetPowerStateBeforeReboot_Param_t { + char powerStateBeforeReboot [MAX_PWR_STATE_BEF_REBOOR_STR_LEN]; /*!< Powerstate before reboot of the box*/ +} IARM_Bus_PWRMgr_GetPowerStateBeforeReboot_Param_t; + + +#define PWRMGR_MAX_REBOOT_REASON_LENGTH 100 +#define PWRMGR_REBOOT_REASON_MAINTENANCE "MAINTENANCE_REBOOT" +/** + * @brief Structure to pass reboot reason argument with the reboot call. + */ +typedef struct _IARM_Bus_PWRMgr_RebootParam_t{ + char reboot_reason_custom[PWRMGR_MAX_REBOOT_REASON_LENGTH]; + char reboot_reason_other[PWRMGR_MAX_REBOOT_REASON_LENGTH]; + char requestor[PWRMGR_MAX_REBOOT_REASON_LENGTH]; +} IARM_Bus_PWRMgr_RebootParam_t; +#define IARM_BUS_PWRMGR_API_Reboot "performReboot" /*!< Reboots device.*/ +#ifdef ENABLE_SET_WAKEUP_SRC_CONFIG //ToDo Remove aftre rdkservices merge. +/** + * @brief Structure which holds the wakeup source type and the value to be set. + */ +typedef struct _IARM_Bus_PWRMgr_SetWakeupSrcConfig_Param_t{ + WakeupSrcType_t srcType; + bool config; +} IARM_Bus_PWRMgr_SetWakeupSrcConfig_Param_t; +#endif +/** + * @brief Structure which holds the wakeup source type and the value to be set and the power state. + */ +typedef struct _IARM_Bus_PWRMgr_WakeupSrcConfig_Param_t{ + uint32_t pwrMode; + uint32_t srcType; + uint32_t config; +} IARM_Bus_PWRMgr_WakeupSrcConfig_Param_t; +#define IARM_BUS_PWRMGR_API_SetWakeupSrcConfig "setWakeupSrcConfig" /*!< sets wakup configuration*/ +#define IARM_BUS_PWRMGR_API_GetWakeupSrcConfig "getWakeupSrcConfig" /*!< gets wakup configuration*/ + +/** + * Declare RPC API names and their arguments + */ +#define IARM_BUS_PWRMGR_API_handleDeepsleepTimeoutWakeup "handleDeepsleepTimeoutWakeup" /*!< Invoke when deepsleep timeout occurs*/ + + +#define IARM_BUS_DEEPSLEEPMGR_NAME "DEEPSLEEPMgr" /*!< Power manager IARM bus name */ + +typedef enum _DeepSleepStatus_t { + DeepSleepStatus_Failed = -1, /*!< Deepsleep operation failed*/ + DeepSleepStatus_NotStarted = 0, /*!< Deepsleep operation not started*/ + DeepSleepStatus_InProgress, /*!< Deepsleep operation in progress */ + DeepSleepStatus_Completed, /*!< Deepsleep operation completed */ +} DeepSleepStatus_t; + +/** Sets the timer for deep sleep ,timer is set explicitly by client of deep sleep manager, + * then the STB will accept the timer value, and go to sleep when sleep timer is expired. + */ +#define IARM_BUS_PWRMGR_API_GetLastWakeupReason "GetLastWakeupReason" +#define IARM_BUS_PWRMGR_API_GetLastWakeupKeyCode "GetLastWakeupKeycode" + +#ifdef __cplusplus +} +#endif +#endif + +/** @} */ // End of Doxygen Tag + +/** @} */ +/** @} */ diff --git a/test/functional-tests/features/rrd_append_report.feature b/test/functional-tests/features/rrd_append_report.feature new file mode 100644 index 00000000..5088c93a --- /dev/null +++ b/test/functional-tests/features/rrd_append_report.feature @@ -0,0 +1,45 @@ +########################################################################## +# If not stated otherwise in this file or this component's LICENSE +# file the following copyright and licenses apply: +# +# Copyright 2018 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################## + +Feature: Remote Debugger Append Request success case + + Scenario: Verify remote debugger process is running + Given the remote debugger process is not running + When I start the remote debugger process + Then the remote debugger process should be running + + Scenario: Send WebPA event for Issuetype Test.TestRun4_apnd and verify logs + Given the remote debugger is running + When I trigger the event "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType" + Then the logs should contain "SUCCESS: Message sending Done" + Then the logs should be seen with "SUCCESS: Message Reception Done" + And the issuetype request should match between Send and Receive + + Scenario: Verify the Issuetype is found in dynamic profile + Given the remote debugger received the message from RBUS command + When the remotedebugger read the json file form the dynamic path + Then remotedebugger json read and parse should be success in dynamic path + + Scenario: Verify the Issuetype is found in static profile and execute command + Given the remote debugger received the message from RBUS command + When the remotedebugger static json profile is present + Then remotedebugger should read the Json file + And remotedebugger logs should contain the Json File Parse Success + And remotedebugger should log as the Issue requested found in the profile + And Update the command after appending data from both the dynamic and static profiles, then execute the commands diff --git a/test/functional-tests/features/rrd_deepsleep_static_report.feature b/test/functional-tests/features/rrd_deepsleep_static_report.feature new file mode 100644 index 00000000..1f106161 --- /dev/null +++ b/test/functional-tests/features/rrd_deepsleep_static_report.feature @@ -0,0 +1,44 @@ +########################################################################## +# If not stated otherwise in this file or this component's LICENSE +# file the following copyright and licenses apply: +# +# Copyright 2018 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################## + +Feature: Remote Debugger Deepsleep Static Report + + Scenario: Verify remote debugger process is running + Given the remote debugger process is not running + When I start the remote debugger process + Then the remote debugger process should be running + + Scenario: Send WebPA event for Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType with deepsleep issuetype + Given the remote debugger is running + When I trigger the event "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType" + Then the event for RRD_SET_ISSUE_EVENT should be received + And the logs should contain "SUCCESS: Message sending Done" + And the logs should be seen with "SUCCESS: Message Reception Done" + When the remotedebugger received the message from webPA event + Then remotedebugger should read the Json file + And remotedebugger logs should contain the Json File Parse success + And the issue data node and sub-node should be found in the JSON file + And the directory should be created to store the executed output + And Sanity check to validate the commands should be executed + And Command output shopuld be added to the output file + And the issuetype systemd service should start successfully + And the journalctl service should start successfully + And the process should sleep with timeout + And the issuetype systemd service should stop successfully + And the remotedebugger should call script to upload the debug report diff --git a/test/functional-tests/features/rrd_dynamic_profile_subcategory_report.feature b/test/functional-tests/features/rrd_dynamic_profile_subcategory_report.feature new file mode 100644 index 00000000..29073463 --- /dev/null +++ b/test/functional-tests/features/rrd_dynamic_profile_subcategory_report.feature @@ -0,0 +1,60 @@ +########################################################################## +# If not stated otherwise in this file or this component's LICENSE +# file the following copyright and licenses apply: +# +# Copyright 2018 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################## + +Feature: Remote Debugger Dynamic Issuetype Report + + Scenario: Verify remote debugger process is running + Given the remote debugger process is not running + When I start the remote debugger process + Then the remote debugger process should be running + + Scenario: Send WebPA event for Issuetype Test and verify logs + Given the remote debugger is running + When I trigger the event "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType" + Then the logs should contain "SUCCESS: Message sending Done" + Then the logs should be seen with "SUCCESS: Message Reception Done" + And the issuetype request should match between Send and Receive + + Scenario: Verify the Issuetype is not found in static profile + Given the remote debugger received the message from RBUS command + When the remotedebugger static json profile is present + Then remotedebugger should read the Json file + And remotedebugger logs should contain the Json File Parse Success + And remotedebugger should log as the Issue requested is not found in the profile + + Scenario: Verify the Issuetype in dynamic path + Given the remote debugger issuetype is missing in static profile + When the remotedebugger read the json file form the dynamic path + Then remotedebugger json read and parse should be success + And remotedebugger should read the Issuetype from dynamic profile + And the issue data node and sub-node should be found in the JSON file + And the directory should be created to store the executed output + And Sanity check to validate the commands should be executed + And Command output shopuld be added to the output file + And the issuetype systemd service should start successfully + And the journalctl service should start successfully + And the process should sleep with timeout + And the issuetype systemd service should stop successfully + And the remotedebugger should call script to upload the debug report + + Scenario: Upload remote debugger debug report + Given the remote debugger upload script is present + When I check the upload status in the logs + Then the upload should be successful if upload is success + Or the upload should fail if upload fails diff --git a/test/functional-tests/tests/create_json.sh b/test/functional-tests/tests/create_json.sh index 3c71b688..436996d8 100644 --- a/test/functional-tests/tests/create_json.sh +++ b/test/functional-tests/tests/create_json.sh @@ -23,17 +23,27 @@ json_file="/media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" echo '{ "Test": { + "TestRun1": { + "Commands": "cat /version.txt;uptime;cat /proc/buddyinfo;cat /proc/meminfo;cat /tmp/.deviceDetails.cache", + "Timeout": 10 + }, + "TestRun5": { + "Commands": "cat /version.txt;uptime;cat /tmp/.deviceDetails.cache", + "Timeout": 10 + }, + "TestRun4": { + "Commands": "cat /version.txt;uptime;cat /tmp/.deviceDetails.cache", + "Timeout": 10 + }, "TestRun3": { "Commands": "cat /version.txt;uptime;rm -rf;cat /tmp/.deviceDetails.cache", "Timeout": 10 - }, + }, "TestRun2": { "Commands": "cat /version.txt;uptime;/proc/version;cat /proc/buddyinfo;cat /proc/meminfo;cat /tmp/.deviceDetails.cache", "Timeout": 10 - }, - "TestRun1": { - "Commands": "cat /version.txt;uptime;cat /proc/buddyinfo;cat /proc/meminfo;cat /tmp/.deviceDetails.cache", - "Timeout": 10 } } }' > $json_file +mkdir -p /tmp/RDK-RRD-Test/etc/rrd/ +cp $json_file /tmp/RDK-RRD-Test/etc/rrd/ diff --git a/test/functional-tests/tests/power_controller.h b/test/functional-tests/tests/power_controller.h new file mode 100644 index 00000000..803e10b5 --- /dev/null +++ b/test/functional-tests/tests/power_controller.h @@ -0,0 +1,415 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2025 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef POWERMANAGER_CLIENT_H +#define POWERMANAGER_CLIENT_H + +#include +#include + +#undef EXTERNAL +#if defined(WIN32) || defined(_WINDOWS) || defined (__CYGWIN__) || defined(_WIN64) +#ifdef DEVICEINFO_EXPORTS +#define EXTERNAL __declspec(dllexport) +#else +#define EXTERNAL __declspec(dllimport) +#pragma comment(lib, "deviceinfo.lib") +#endif +#else +#define EXTERNAL __attribute__((visibility("default"))) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum PowerController_PowerState { + POWER_STATE_UNKNOWN = 0 /* UNKNOWN */, + POWER_STATE_OFF = 1 /* OFF */, + POWER_STATE_STANDBY = 2 /* STANDBY */, + POWER_STATE_ON = 3 /* ON */, + POWER_STATE_STANDBY_LIGHT_SLEEP = 4 /* LIGHT_SLEEP */, + POWER_STATE_STANDBY_DEEP_SLEEP = 5 /* DEEP_SLEEP */ +} PowerController_PowerState_t; + +typedef enum PowerController_ThermalTemperature { + THERMAL_TEMPERATURE_UNKNOWN = 0 /* UNKNOWN Thermal Temperature */, + THERMAL_TEMPERATURE_NORMAL = 1 /* Normal Thermal Temperature */, + THERMAL_TEMPERATURE_HIGH = 2 /* High Thermal Temperature */, + THERMAL_TEMPERATURE_CRITICAL = 4 /* Critial Thermal Temperature */ +} PowerController_ThermalTemperature_t; + +typedef enum PowerController_WakeupSrcType { + WAKEUP_SRC_UNKNOWN = 0 /* UNKNOWN */, + WAKEUP_SRC_VOICE = 1 /* VOICE */, + WAKEUP_SRC_PRESENCEDETECTED = 2 /* PRESENCEDETECTED */, + WAKEUP_SRC_BLUETOOTH = 3 /* BLUETOOTH */, + WAKEUP_SRC_WIFI = 4 /* WIFI */, + WAKEUP_SRC_IR = 5 /* IR */, + WAKEUP_SRC_POWERKEY = 6 /* POWERKEY */, + WAKEUP_SRC_TIMER = 7 /* TIMER */, + WAKEUP_SRC_CEC = 8 /* CEC */, + WAKEUP_SRC_LAN = 9 /* LAN */, + WAKEUP_SRC_RF4CE = 10 /* RF4CE */ +} PowerController_WakeupSrcType_t; + +typedef enum PowerController_WakeupReason { + WAKEUP_REASON_UNKNOWN = 0 /* UNKNOWN */, + WAKEUP_REASON_IR = 1 /* IR */, + WAKEUP_REASON_BLUETOOTH = 2 /* BLUETOOTH */, + WAKEUP_REASON_RF4CE = 3 /* RF4CE */, + WAKEUP_REASON_GPIO = 4 /* GPIO */, + WAKEUP_REASON_LAN = 5 /* LAN */, + WAKEUP_REASON_WIFI = 6 /* WIFI */, + WAKEUP_REASON_TIMER = 7 /* TIMER */, + WAKEUP_REASON_FRONTPANEL = 8 /* FRONTPANEL */, + WAKEUP_REASON_WATCHDOG = 9 /* WATCHDOG */, + WAKEUP_REASON_SOFTWARERESET = 10 /* SOFTWARERESET */, + WAKEUP_REASON_THERMALRESET = 11 /* THERMALRESET */, + WAKEUP_REASON_WARMRESET = 12 /* WARMRESET */, + WAKEUP_REASON_COLDBOOT = 13 /* COLDBOOT */, + WAKEUP_REASON_STRAUTHFAIL = 14 /* STR_AUTH_FAIL */, + WAKEUP_REASON_CEC = 15 /* CEC */, + WAKEUP_REASON_PRESENCE = 16 /* PRESENCE */, + WAKEUP_REASON_VOICE = 17 /* VOICE */ +} PowerController_WakeupReason_t; + +typedef enum PowerController_SystemMode { + SYSTEM_MODE_UNKNOWN = 0 /* UNKNOWN */, + SYSTEM_MODE_NORMAL = 1 /* NORMAL */, + SYSTEM_MODE_EAS = 2 /* EAS */, + SYSTEM_MODE_WAREHOUSE = 3 /* WAREHOUSE */ +} PowerController_SystemMode_t; + +#define POWER_CONTROLLER_ERROR_NONE 0 +#define POWER_CONTROLLER_ERROR_GENERAL 1 +#define POWER_CONTROLLER_ERROR_UNAVAILABLE 2 +#define POWER_CONTROLLER_ERROR_NOT_EXIST 43 + +/** + * @brief Initializes the Power Controller. + * + * This function creates an instance of the PowerManager plugin client interface and increments the client instance count. + * + * @details + * - If the Power Controller instance does not already exist, it will be created. + * - The instance count is incremented each time this function is called. + * - After Init, & before making any PowerController request client needs to ensure + * - Power Manager plugin is activated and operational via `PowerController_IsOperational`. + * - If not operational, clients can use this Connect API to establish COM-RPC connection with the Power Manager plugin. + * - If there us any failure in Connect all PowerController requests will fail with `POWER_CONTROLLER_ERROR_UNAVAILABLE` (Except for callback register / unregister APIs). + * + * @see PowerController_Term + */ +EXTERNAL void PowerController_Init(); + +/** + * @brief PowerController attempts to connect to the Power Manager plugin. + * + * This function connects to the Power Manager plugin. + * + * @details + * - This function is used to connect to the Power Manager plugin. + * - Before making any PowerController request client needs to ensure + * - Power Manager plugin is activated and operational via `PowerController_IsOperational`. + * - If not operational, clients can use this Connect API to establish COM-RPC connection with the Power Manager plugin. + * - If there us any failure in Connect all PowerController requests will fail with `POWER_CONTROLLER_ERROR_UNAVAILABLE` (Except for callback register / unregister APIs). + * - In case of failure this API should be called again with brief delay. + * + * @return `POWER_CONTROLLER_ERROR_NONE` on success. + * @return `POWER_CONTROLLER_ERROR_UNAVAILABLE` if Thunder RPC server is not running / error establishing RPC communication channel. + * @return `POWER_CONTROLLER_ERROR_NOT_EXIST` if the PowerManager plugin is not activated yet. + */ +EXTERNAL uint32_t PowerController_Connect(); + +/** + * @brief Terminates the Power Controller. + * + * This function decrements client instance count attempts to delete Power Controller instance + * + * @details + * - If the controller reference count is greater than one, this function only decrements the count. + * - When the reference count reaches zero, the controller instance is destroyed, and all associated resources are released (PowerManager plugin client instance). + * - Ensure that this function is called once for every call to `PowerController_Init`. + * + * @see PowerController_Init + */ +EXTERNAL void PowerController_Term(); + +/** + * @brief Checks if the Power Manager plugin is active & operational + * + * This function determines whether the Power Manager interface is operational and ready to handle requests. + * It can be used to verify the availability of the Power Manager client before initiating operations that depend on it. + * + * IMPORTANT - This is the first function that should be called after `PowerController_Init`. + * + * @return `true` if the Power Manager interface is active and operational, otherwise `false`. + * + * @details + * - Use this function to confirm the operational status of the Power Manager plugin. + * - Calling this function is NOT MANDATORY but optional + * - Clients can register for notifications about state changes using `PowerController_RegisterOperationalStateChangeCallback`. + * - If the Power Manager interface is not active, subsequent Power Manager operations will fail with the error `POWER_CONTROLLER_ERROR_UNAVAILABLE`. + * - Therefore in failure cases, clients can use `PowerController_Connect` to establish COM-RPC connection with the Power Manager plugin. + * + * @see PowerController_RegisterOperationalStateChangeCallback + */ +EXTERNAL bool PowerController_IsOperational(); + +/** Gets the Power State.*/ +// @text getPowerState +// @brief Get Power State +// @param powerState: Get current power state +EXTERNAL uint32_t PowerController_GetPowerState(PowerController_PowerState_t* currentState /* @out */, PowerController_PowerState_t* previousState /* @out */); + +/** Sets Power State . */ +// @text setPowerState +// @brief Set Power State +// @param keyCode: NA for most platfroms, to be depricated +// @param powerState: Set power to this state +// @param reason: null terminated string stating reason for for state change +EXTERNAL uint32_t PowerController_SetPowerState(const int keyCode /* @in */, const PowerController_PowerState_t powerstate /* @in */, const char* reason /* @in */); + +/** Gets the current Thermal state.*/ +// @text getThermalState +// @brief Get Current Thermal State (temperature) +// @param currentTemperature: current temperature +EXTERNAL uint32_t PowerController_GetThermalState(float* currentTemperature /* @out */); + +/** Sets the Temperature Thresholds.*/ +// @text setTemperatureThresholds +// @brief Set Temperature Thresholds +// @param high: high threshold +// @param critical : critical threshold +EXTERNAL uint32_t PowerController_SetTemperatureThresholds(float high /* @in */, float critical /* @in */); + +/** Gets the current Temperature Thresholds.*/ +// @text getTemperatureThresholds +// @brief Get Temperature Thresholds +// @param high: high threshold +// @param critical : critical threshold +EXTERNAL uint32_t PowerController_GetTemperatureThresholds(float* high /* @out */, float* critical /* @out */); + +/** Sets the current Temperature Grace interval.*/ +// @property +// @text PowerController_SetOvertempGraceInterval +// @brief Set Temperature Thresholds +// @param graceInterval: interval in secs? +EXTERNAL uint32_t PowerController_SetOvertempGraceInterval(const int graceInterval /* @in */); + +/** Gets the grace interval for over-temperature.*/ +// @property +// @text PowerController_GetOvertempGraceInterval +// @brief Get Temperature Grace interval +// @param graceInterval: interval in secs? +EXTERNAL uint32_t PowerController_GetOvertempGraceInterval(int* graceInterval /* @out */); + +/** Set Deep Sleep Timer for later wakeup */ +// @property +// @text setDeepSleepTimer +// @brief Set Deep sleep timer for timeOut period +// @param timeOut: deep sleep timeout +EXTERNAL uint32_t PowerController_SetDeepSleepTimer(const int timeOut /* @in */); + +/** Get Last Wakeup reason */ +// @property +// @text getLastWakeupReason +// @brief Get Last Wake up reason +// @param wakeupReason: wake up reason +EXTERNAL uint32_t PowerController_GetLastWakeupReason(PowerController_WakeupReason_t* wakeupReason /* @out */); + +/** Get Last Wakeup key code */ +// @property +// @text getLastWakeupKeyCode +// @brief Get the key code that can be used for wakeup +// @param keycode: Key code for wakeup +EXTERNAL uint32_t PowerController_GetLastWakeupKeyCode(int* keycode /* @out */); + +/** Request Reboot with PowerManager */ +// @text reboot +// @brief Reboot device +// @param rebootRequestor: null terminated string identifier for the entity requesting the reboot. +// @param rebootReasonCustom: custom-defined reason for the reboot, provided as a null terminated string. +// @param rebootReasonOther: null terminated string describing any other reasons for the reboot. +EXTERNAL uint32_t PowerController_Reboot(const char* rebootRequestor /* @in */, const char* rebootReasonCustom /* @in */, const char* rebootReasonOther /* @in */); + +/** Set Network Standby Mode */ +// @property +// @text setNetworkStandbyMode +// @brief Set the standby mode for Network +// @param standbyMode: Network standby mode +EXTERNAL uint32_t PowerController_SetNetworkStandbyMode(const bool standbyMode /* @in */); + +/** Get Network Standby Mode */ +// @text getNetworkStandbyMode +// @brief Get the standby mode for Network +// @param standbyMode: Network standby mode +EXTERNAL uint32_t PowerController_GetNetworkStandbyMode(bool* standbyMode /* @out */); + +/** Set Wakeup source configuration */ +// @text setWakeupSrcConfig +// @brief Set the source configuration for device wakeup +// @param powerMode: power mode +// @param wakeSrcType: source type +// @param config: config +EXTERNAL uint32_t PowerController_SetWakeupSrcConfig(const int powerMode /* @in */, const int wakeSrcType /* @in */, int config /* @in */); + +/** Get Wakeup source configuration */ +// @text getWakeupSrcConfig +// @brief Get the source configuration for device wakeup +// @param powerMode: power mode +// @param srcType: source type +// @param config: config +EXTERNAL uint32_t PowerController_GetWakeupSrcConfig(int* powerMode /* @out */, int* srcType /* @out */, int* config /* @out */); + +/** Initiate System mode change */ +// @text PowerController_SetSystemMode +// @brief System mode change +// @param oldMode: current mode +// @param newMode: new mode +EXTERNAL uint32_t PowerController_SetSystemMode(const PowerController_SystemMode_t currentMode /* @in */, const PowerController_SystemMode_t newMode /* @in */); + +/** Get Power State before last reboot */ +// @text PowerController_GetPowerStateBeforeReboot +// @brief Get Power state before last reboot +// @param powerStateBeforeReboot: power state +EXTERNAL uint32_t PowerController_GetPowerStateBeforeReboot(PowerController_PowerState_t* powerStateBeforeReboot /* @out */); + +/** Engage a client in power mode change operation. */ +// @text PowerController_AddPowerModePreChangeClient +// @brief - Register a client to engage in power mode state changes. +// - When `PowerModePreChange` event is received, then added client should call either +// - `PowerModePreChangeComplete` API to inform power manager that this client has completed its pre-change operation. +// - Or `DelayPowerModeChangeBy` API to delay the power mode change. +// - If the client does not call `PowerModePreChangeComplete` API, the power mode change will complete +// after the maximum delay `stateChangeAfter` seconds (as received in `OnPowerModePreChange` event). +// - Clients are required to re-register if the PowerManager plugin restarts. Therefore, it is essential for clients to register +// for operational state changes using `PowerController_RegisterOperationalStateChangeCallback`. +// +// IMPORTANT: ** IT'S A BUG IF CLIENT `Unregister` FROM `IModePreChangeNotification` BEFORE DISENGAGING ITSELF ** +// always make sure to call `RemovePowerModePreChangeClient` before calling `Unregister` from `IModePreChangeNotification`. +// +// @param clientName: Name of the client as null terminated string +// @param clientId: Unique identifier for the client to be used while acknowledging the pre-change operation (`PowerModePreChangeComplete`) +// or to delay the power mode change (`DelayPowerModeChangeBy`) +EXTERNAL uint32_t PowerController_AddPowerModePreChangeClient(const char *clientName /* @in */, uint32_t* clientId /* @out */); + +/** Disengage a client from the power mode change operation. */ +// @text PowerController_RemovePowerModePreChangeClient +// @brief Removes a registered client from participating in power mode pre-change operations. +// NOTE client will still continue to receive pre-change notifications. +// @param clientId: Unique identifier for the client. See `AddPowerModePreChangeClient` +EXTERNAL uint32_t PowerController_RemovePowerModePreChangeClient(const uint32_t clientId /* @in */); + +/** Power prechange activity completed */ +// @text PowerController_PowerModePreChangeComplete +// @brief Pre power mode handling complete for given client and transation id +// @param clientId: Unique identifier for the client, as received in AddPowerModePreChangeClient +// @param transactionId: transaction id as received in OnPowerModePreChange +EXTERNAL uint32_t PowerController_PowerModePreChangeComplete(const uint32_t clientId /* @in */, const int transactionId /* @in */); + +/** Delay Powermode change by given time */ +// @text PowerController_DelayPowerModeChangeBy +// @brief Delay Powermode change by given time. If different clients provide different values of delay, then the maximum of these values is used. +// @param clientId: Unique identifier for the client, as received in AddPowerModePreChangeClient +// @param transactionId: transaction id as received in OnPowerModePreChange +// @param delayPeriod: delay in seconds +EXTERNAL uint32_t PowerController_DelayPowerModeChangeBy(const uint32_t clientId /* @in */, const int transactionId /* @in */, const int delayPeriod /* @in */); + +/* Callback data types for event notifications from power manager plugin */ +// @brief Operational state changed event +// @param isOperational: true if PowerManager plugin is activated, false otherwise +// @param userdata: opaque data, client can use it to have context to callbacks +typedef void (*PowerController_OperationalStateChangeCb)(bool isOperational, void* userdata); + +// @brief Power mode changed +// @param currentState: Current Power State +// @param newState: New Power State +// @param userdata: opaque data, client can use it to have context to callbacks +typedef void (*PowerController_PowerModeChangedCb)(const PowerController_PowerState_t currentState, const PowerController_PowerState_t newState, void* userdata); + +// @brief Power mode Pre-change event +// @param currentState: Current Power State +// @param newState: Changing power state to this New Power State +// @param transactionId: transactionId to be used when invoking prePowerChangeComplete() / delayPowerModeChangeBy API +// @param stateChangeAfter: seconds after which the actual power mode will be applied. +// @param userdata: opaque data, client can use it to have context to callbacks +typedef void (*PowerController_PowerModePreChangeCb)(const PowerController_PowerState_t currentState, const PowerController_PowerState_t newState, const int transactionId, const int stateChangeAfter, void* userdata); + +// @brief Deep sleep timeout event +// @param wakeupTimeout: Deep sleep wakeup timeout in seconds +// @param userdata: opaque data, client can use it to have context to callbacks +typedef void (*PowerController_DeepSleepTimeoutCb)(const int wakeupTimeout, void* userdata); + +// @brief Network Standby Mode changed event - only on XIone +// @param enabled: network standby enabled or disabled +// @param userdata: opaque data, client can use it to have context to callbacks +typedef void (*PowerController_NetworkStandbyModeChangedCb)(const bool enabled, void* userdata); + +// @brief Thermal Mode changed event +// @param currentThermalLevel: current thermal level +// @param newThermalLevel: new thermal level +// @param currentTemperature: current temperature +// @param userdata: opaque data, client can use it to have context to callbacks +typedef void (*PowerController_ThermalModeChangedCb)(const PowerController_ThermalTemperature_t currentThermalLevel, const PowerController_ThermalTemperature_t newThermalLevel, const float currentTemperature, void* userdata); + +// @brief Reboot begin event +// @param rebootReasonCustom: Reboot reason custom +// @param rebootReasonOther: Reboot reason other +// @param rebootRequestor: Reboot requested by +// @param userdata: opaque data, client can use it to have context to callbacks +typedef void (*PowerController_RebootBeginCb)(const char* rebootReasonCustom, const char* rebootReasonOther, const char* rebootRequestor, void* userdata); + +/* Type defines for callbacks / notifications */ +/* userdata in all callbacks are opaque, clients can use it to have context to callbacks */ + +/** Register for PowerManager plugin operational state change event callback, for initial state use `PowerController_IsOperational` call */ +EXTERNAL uint32_t PowerController_RegisterOperationalStateChangeCallback(PowerController_OperationalStateChangeCb callback, void* userdata); +/** UnRegister (previously registered) PowerManager plugin operational state change event callback */ +EXTERNAL uint32_t PowerController_UnRegisterOperationalStateChangeCallback(PowerController_OperationalStateChangeCb callback); +/** Register for PowerMode changed callback */ +EXTERNAL uint32_t PowerController_RegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback, void* userdata); +/** UnRegister (previously registered) PowerMode changed callback */ +EXTERNAL uint32_t PowerController_UnRegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback); +/** Register for PowerMode pre-change callback */ +EXTERNAL uint32_t PowerController_RegisterPowerModePreChangeCallback(PowerController_PowerModePreChangeCb callback, void* userdata); +/** UnRegister (previously registered) PowerMode pre-change callback */ +EXTERNAL uint32_t PowerController_UnRegisterPowerModePreChangeCallback(PowerController_PowerModePreChangeCb callback); +/** Register for PowerMode pre-change callback */ +EXTERNAL uint32_t PowerController_RegisterDeepSleepTimeoutCallback(PowerController_DeepSleepTimeoutCb callback, void* userdata); +/** UnRegister (previously registered) DeepSleep Timeout callback */ +EXTERNAL uint32_t PowerController_UnRegisterDeepSleepTimeoutCallback(PowerController_DeepSleepTimeoutCb callback); +/** Register for Network Standby Mode changed event - only on XIone */ +EXTERNAL uint32_t PowerController_RegisterNetworkStandbyModeChangedCallback(PowerController_NetworkStandbyModeChangedCb callback, void* userdata); +/** UnRegister (previously registered) Network Standby Mode changed callback */ +EXTERNAL uint32_t PowerController_UnRegisterNetworkStandbyModeChangedCallback(PowerController_NetworkStandbyModeChangedCb callback); +/** Register for Thermal Mode changed event callback */ +EXTERNAL uint32_t PowerController_RegisterThermalModeChangedCallback(PowerController_ThermalModeChangedCb callback, void* userdata); +/** UnRegister (previously registered) Thermal Mode changed event callback */ +EXTERNAL uint32_t PowerController_UnRegisterThermalModeChangedCallback(PowerController_ThermalModeChangedCb callback); +/** Register for reboot start event callback */ +EXTERNAL uint32_t PowerController_RegisterRebootBeginCallback(PowerController_RebootBeginCb callback, void* userdata); +/** UnRegister (previously registered) reboot start event callback */ +EXTERNAL uint32_t PowerController_UnRegisterRebootBeginCallback(PowerController_RebootBeginCb callback); + +#ifdef __cplusplus +}; // extern "C" +#endif + +#endif // POWERMANAGER_CLIENT_H diff --git a/test/functional-tests/tests/test_rrd_append_report.py b/test/functional-tests/tests/test_rrd_append_report.py new file mode 100644 index 00000000..72e28e0f --- /dev/null +++ b/test/functional-tests/tests/test_rrd_append_report.py @@ -0,0 +1,134 @@ +import json +from helper_functions import * + +# Path to the existing JSON file +file_path = "/etc/rrd/remote_debugger.json" + +# Read the existing JSON data +with open(file_path, "r") as json_file: + data = json.load(json_file) + +# New entry to add +new_entry = { + "Test": { + "TestRun4": { + "Commands": "cat /version.txt;cat /tmp/.deviceDetails.cache", + "Timeout": 10 + } + } +} + +# Update the JSON data with the new entry +data.update(new_entry) + +# Write the updated data back to the JSON file +with open(file_path, "w") as json_file: + json.dump(data, json_file, indent=4) + +def test_check_remote_debugger_config_file(): + config_file_path = JSON_FILE + assert check_file_exists(config_file_path), f"Configuration file '{config_file_path}' does not exist." + +def test_check_rrd_directory_exists(): + dir_path = OUTPUT_DIR + assert check_directory_exists(dir_path), f"Directory '{dir_path}' does not exist." + +def test_check_dynamic_config_file(): + config_file_path = APPEND_JSON_FILE + assert check_file_exists(config_file_path), f"Configuration file '{config_file_path}' does not exist." + +def test_check_dynamic_directory_exists(): + dir_path = DYNAMIC_DIR + assert check_directory_exists(dir_path), f"Directory '{dir_path}' does not exist." + +def test_check_and_start_remotedebugger(): + kill_rrd() + remove_logfile() + test_check_dynamic_directory_exists() + test_check_dynamic_config_file() + print("Starting remotedebugger process") + command_to_start = "nohup /usr/local/bin/remotedebugger > /dev/null 2>&1 &" + run_shell_silent(command_to_start) + command_to_get_pid = "pidof remotedebugger" + pid = run_shell_command(command_to_get_pid) + assert pid != "", "remotedebugger process did not start" + +def reset_issuetype_rfc(): + command = 'rbuscli set Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType string ""' + result = subprocess.run(command, shell=True, capture_output=True, text=True) + assert result.returncode == 0 + +def test_remote_debugger_trigger_event(): + APPEND_STRING1 = "Test.TestRun4_apnd" + reset_issuetype_rfc() + sleep(10) + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', + 'string', APPEND_STRING1 + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + + sleep(15) + + QUERY_MSG = "Received event for RRD_SET_ISSUE_EVENT" + assert QUERY_MSG in grep_rrdlogs(QUERY_MSG) + + MSG_SEND = "SUCCESS: Message sending Done" + sleep(2) + assert MSG_SEND in grep_rrdlogs(MSG_SEND) + + MSG_RECEIVE = "SUCCESS: Message Reception Done" + sleep(2) + assert MSG_RECEIVE in grep_rrdlogs(MSG_RECEIVE) + +def test_check_issue_in_dynamic_profile(): + APPEND_MSG = "Received append request to process static and dynamic profiles" + assert APPEND_MSG in grep_rrdlogs(APPEND_MSG) + + DYNAMIC_JSONFILE = "Reading json config file /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert DYNAMIC_JSONFILE in grep_rrdlogs(DYNAMIC_JSONFILE) + + JSON_READ_SUCCESS = "Reading json file Success" + assert JSON_READ_SUCCESS in grep_rrdlogs(JSON_READ_SUCCESS) + + JSON_PARSE_SUCCESS = "Json File parse Success" + assert JSON_PARSE_SUCCESS in grep_rrdlogs(JSON_PARSE_SUCCESS) + + JSON_SUCCESS = "Dynamic Profile Parse And Read Success... /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert JSON_SUCCESS in grep_rrdlogs(JSON_SUCCESS) + + CHECKING_DYNAMIC_JSON = "Check if Issue in Parsed Dynamic JSON... /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert CHECKING_DYNAMIC_JSON in grep_rrdlogs(CHECKING_DYNAMIC_JSON) + + STATIC_READ = "Reading static profile command info..." + assert STATIC_READ in grep_rrdlogs(STATIC_READ) + + READING_JSON = "Start Reading JSON File... /etc/rrd/remote_debugger.json" + assert READING_JSON in grep_rrdlogs(READING_JSON) + + JSON_STATIC_SUCCESS = "Reading json file Success, Parsing the Content..." + assert JSON_STATIC_SUCCESS in grep_rrdlogs(JSON_STATIC_SUCCESS) + + JSON_PARSE_STATIC_SUCCESS = "Json File parse Success... /etc/rrd/remote_debugger.json" + assert JSON_PARSE_STATIC_SUCCESS in grep_rrdlogs(JSON_PARSE_STATIC_SUCCESS) + + SUCCESS_STATIC = "Static Profile Parse And Read Success... /etc/rrd/remote_debugger.json" + assert SUCCESS_STATIC in grep_rrdlogs(SUCCESS_STATIC) + + CHECKING_STATIC_JSON = "Check if Issue in Parsed Static JSON... /etc/rrd/remote_debugger.json" + assert CHECKING_STATIC_JSON in grep_rrdlogs(CHECKING_STATIC_JSON) + + READ_COMPLETE_STATIC = "Read complete for Static Profile: RFCValue: Test.TestRun4, Command: " + assert READ_COMPLETE_STATIC in grep_rrdlogs(READ_COMPLETE_STATIC) + + APPEND_UPDATE = "Updated command after append from dynamic and static profile: " + assert APPEND_UPDATE in grep_rrdlogs(APPEND_UPDATE) + + EXECUTE_SERVICE = "Executing Commands in Runtime Service..." + assert EXECUTE_SERVICE in grep_rrdlogs(EXECUTE_SERVICE) + + remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd() diff --git a/test/functional-tests/tests/test_rrd_deepsleep_static_report.py b/test/functional-tests/tests/test_rrd_deepsleep_static_report.py new file mode 100644 index 00000000..119e2d5c --- /dev/null +++ b/test/functional-tests/tests/test_rrd_deepsleep_static_report.py @@ -0,0 +1,160 @@ +########################################################################## +# If not stated otherwise in this file or this component's LICENSE +# file the following copyright and licenses apply: +# +# Copyright 2018 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################## + +from helper_functions import * + +def test_check_remote_debugger_config_file(): + config_file_path = JSON_FILE + assert check_file_exists(config_file_path), f"Configuration file '{config_file_path}' does not exist." + +def test_check_rrd_directory_exists(): + dir_path = OUTPUT_DIR + assert check_directory_exists(dir_path), f"Directory '{dir_path}' does not exist." + +def reset_issuetype_rfc(): + command = 'rbuscli set Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType string ""' + result = subprocess.run(command, shell=True, capture_output=True, text=True) + assert result.returncode == 0 + +def test_check_and_start_remotedebugger(): + kill_rrd() + remove_logfile() + print("Starting remotedebugger process") + command_to_start = "nohup /usr/local/bin/remotedebugger > /dev/null 2>&1 &" + run_shell_silent(command_to_start) + command_to_get_pid = "pidof remotedebugger" + pid = run_shell_command(command_to_get_pid) + assert pid != "", "remotedebugger process did not start" + +def test_remote_debugger_trigger_event(): + CATEGORY_STRING1 = "DEEPSLEEP" + reset_issuetype_rfc() + sleep(20) + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', + 'string', CATEGORY_STRING1 + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + sleep(15) + + QUERY_MSG = "Received event for RRD_SET_ISSUE_EVENT" + assert QUERY_MSG in grep_rrdlogs(QUERY_MSG) + + MSG_SEND = "SUCCESS: Message sending Done" + sleep(2) + assert MSG_SEND in grep_rrdlogs(MSG_SEND) + + MSG_RECEIVE = "SUCCESS: Message Reception Done" + sleep(2) + assert MSG_RECEIVE in grep_rrdlogs(MSG_RECEIVE) + + ISSUE_MSG = "MSG=DEEPSLEEP" + assert ISSUE_MSG in grep_rrdlogs(ISSUE_MSG) + + SUBNODE_MSG = "SubNode not found in RFC parameter" + assert SUBNODE_MSG in grep_rrdlogs(SUBNODE_MSG) + + READ_JSON = "Start Reading JSON File... /etc/rrd/remote_debugger.json" + assert READ_JSON in grep_rrdlogs(READ_JSON) + + PARSE_JSON = "Json File parse Success... /etc/rrd/remote_debugger.json" + assert PARSE_JSON in grep_rrdlogs(PARSE_JSON) + + SUBTYPE_MSG = "Reading all Sub Issue types" + assert SUBTYPE_MSG in grep_rrdlogs(SUBTYPE_MSG) + + ISSUE_FOUND = "Issue Data Node: DEEPSLEEP" + assert ISSUE_FOUND in grep_rrdlogs(ISSUE_FOUND) + + DIR_CREATION = "Creating Directory" + assert DIR_CREATION in grep_rrdlogs(DIR_CREATION) + + ALL_ISSUE_MSG = "Run Debug Commands for all issue types" + assert ALL_ISSUE_MSG in grep_rrdlogs(ALL_ISSUE_MSG) + + SANITY_CHECK = "Found valid Commands" + assert SANITY_CHECK in grep_rrdlogs(SANITY_CHECK) + + DEBUG_FILE = "Adding Details of Debug commands to Output File" + assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) + + issue_string = "DEEPSLEEP" + SERVICE_START = f"Starting remote_debugger_Audio.Audio service success..." + assert SERVICE_START in grep_rrdlogs(SERVICE_START) + + JOURNAL_START = "journalctl remote_debugger_Audio.Audio service success..." + assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) + + SLEEP_TIME = "Sleeping with timeout" + assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) + sleep(20) + + SERVICE_STOP = f"Stopping remote_debugger_Audio.Audio service..." + assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) + + SANITY_CHECK = "Found valid Commands" + assert SANITY_CHECK in grep_rrdlogs(SANITY_CHECK) + + DEBUG_FILE = "Adding Details of Debug commands to Output File" + assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) + + SERVICE_START = f"Starting remote_debugger_Video.Video service success" + assert SERVICE_START in grep_rrdlogs(SERVICE_START) + + JOURNAL_START = f"journalctl remote_debugger_Video.Video service success" + assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) + + SLEEP_TIME = "Sleeping with timeout" + assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) + sleep(20) + + SERVICE_STOP = f"Stopping remote_debugger_Video.Video service" + assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) + + result = check_output_dir() + print(result) + + UPLOAD_LOGS = "Starting Upload Debug output Script: /lib/rdk/uploadRRDLogs.sh" + assert UPLOAD_LOGS in grep_rrdlogs(UPLOAD_LOGS) + +def test_remotedebugger_upload_report(): + UPLOAD_SUCCESS = "RRD Upload Script Execution Success" + UPLOAD_FAILURE = "RRD Upload Script Execution Failure" + if UPLOAD_SUCCESS in grep_rrdlogs(UPLOAD_SUCCESS): + print("Upload success") + elif UPLOAD_FAILURE in grep_rrdlogs(UPLOAD_FAILURE): + print("Upload failed") + else: + print("Upload status not found in logs") + + SCRIPT_SUCCESS = "Debug Information Report upload Failed" + SCRIPT_FAILURE = "Debug Information Report upload Success" + if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS): + print("Script execution success") + elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE): + print("Script execution failed") + else: + print("Script execution not found in logs") + + remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd() diff --git a/test/functional-tests/tests/test_rrd_dynamic_subcategory_report.py b/test/functional-tests/tests/test_rrd_dynamic_subcategory_report.py new file mode 100644 index 00000000..55aad454 --- /dev/null +++ b/test/functional-tests/tests/test_rrd_dynamic_subcategory_report.py @@ -0,0 +1,168 @@ +########################################################################## +# If not stated otherwise in this file or this component's LICENSE +# file the following copyright and licenses apply: +# +# Copyright 2018 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################## + +import json +import subprocess +from helper_functions import * + +def test_check_remote_debugger_config_file(): + config_file_path = JSON_FILE + assert check_file_exists(config_file_path), f"Configuration file '{config_file_path}' does not exist." + +def test_check_rrd_directory_exists(): + dir_path = OUTPUT_DIR + assert check_directory_exists(dir_path), f"Directory '{dir_path}' does not exist." + +def test_check_and_start_remotedebugger(): + kill_rrd() + remove_logfile() + print("Starting remotedebugger process") + command_to_start = "nohup /usr/local/bin/remotedebugger > /dev/null 2>&1 &" + run_shell_silent(command_to_start) + command_to_get_pid = "pidof remotedebugger" + pid = run_shell_command(command_to_get_pid) + assert pid != "", "remotedebugger process did not start" + +def reset_issuetype_rfc(): + command = 'rbuscli set Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType string ""' + result = subprocess.run(command, shell=True, capture_output=True, text=True) + assert result.returncode == 0 + +def test_remote_debugger_trigger_event(): + STRING_TEST = "Test.TestRun1" + reset_issuetype_rfc() + sleep(10) + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', + 'string', STRING_TEST + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + + sleep(15) + + QUERY_MSG = "Received event for RRD_SET_ISSUE_EVENT" + assert QUERY_MSG in grep_rrdlogs(QUERY_MSG) + + MSG_SEND = "SUCCESS: Message sending Done" + sleep(2) + assert MSG_SEND in grep_rrdlogs(MSG_SEND) + + MSG_RECEIVE = "SUCCESS: Message Reception Done" + sleep(2) + assert MSG_RECEIVE in grep_rrdlogs(MSG_RECEIVE) + +def test_check_issue_in_static_profile(): + READ_JSON = "Start Reading JSON File... /etc/rrd/remote_debugger.json" + assert READ_JSON in grep_rrdlogs(READ_JSON) + + PARSE_JSON = "Static Profile Parse And Read Success" + assert PARSE_JSON in grep_rrdlogs(PARSE_JSON) + + MISSING_MSG = "Issue Data Not found in Static JSON File" + assert MISSING_MSG in grep_rrdlogs(MISSING_MSG) + + script_path="./test/functional-tests/tests/create_json.sh" + # Run the shell script + try: + result = subprocess.run(['bash', script_path], check=True, text=True, capture_output=True) + print("Script output:") + print(result.stdout) + except subprocess.CalledProcessError as e: + print("Error while executing the script:") + print(e.stderr) + +def test_check_issue_in_dynamic_profile(): + DYNAMIC_READ = "Checking Dynamic Profile..." + assert DYNAMIC_READ in grep_rrdlogs(DYNAMIC_READ) + + DYNAMIC_JSONFILE = "Reading json config file /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert DYNAMIC_JSONFILE in grep_rrdlogs(DYNAMIC_JSONFILE) + + DYNAMIC_READ = "Reading json file Success, Parsing the Content..." + assert DYNAMIC_READ in grep_rrdlogs(DYNAMIC_READ) + + DYNAMIC_PROFILE = "Dynamic Profile Parse And Read Success... /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert DYNAMIC_PROFILE in grep_rrdlogs(DYNAMIC_PROFILE) + + CHECK_PARSED_JSON = "Check if Issue in Parsed Dynamic JSON... /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert CHECK_PARSED_JSON in grep_rrdlogs(CHECK_PARSED_JSON) + + READING_CATEGORY = "Reading Issue Category:Test..." + assert READING_CATEGORY in grep_rrdlogs(READING_CATEGORY) + + ISSUE_DATA_NODE = "Issue Data Node:Test and Sub-Node:TestRun1 found in Dynamic JSON File /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json..." + assert ISSUE_DATA_NODE in grep_rrdlogs(ISSUE_DATA_NODE) + + CREATE_DIR = "Creating Directory /tmp/rrd/Test-DebugReport" + assert CREATE_DIR in grep_rrdlogs(CREATE_DIR) + + RUN_DEBUG = "Run Debug Commands for Test:TestRun1" + assert RUN_DEBUG in grep_rrdlogs(RUN_DEBUG) + + READ_SANITY = "Reading Sanity Check Commands List" + assert READ_SANITY in grep_rrdlogs(READ_SANITY) + + FOUND_COMMANDS = "Found valid Commands, Execute..." + assert FOUND_COMMANDS in grep_rrdlogs(FOUND_COMMANDS) + + EXEC_RUNTIME = "Executing Commands in Runtime Service..." + assert EXEC_RUNTIME in grep_rrdlogs(EXEC_RUNTIME) + + EXEC_COMMANDS = 'Executing Debug Commands: ""cat /version.txt;uptime;cat /proc/buddyinfo;cat /proc/meminfo;cat /tmp/.deviceDetails.cache""' + assert EXEC_COMMANDS in grep_rrdlogs(EXEC_COMMANDS) + + START_SERVICE = "Starting remote_debugger_Test.TestRun1 service success..." + assert START_SERVICE in grep_rrdlogs(START_SERVICE) + + USE_JOURNALCTL = "Using journalctl to log command output..." + assert USE_JOURNALCTL in grep_rrdlogs(USE_JOURNALCTL) + + JOURNALCTL_SUCCESS = "journalctl remote_debugger_Test.TestRun1 service success..." + assert JOURNALCTL_SUCCESS in grep_rrdlogs(JOURNALCTL_SUCCESS) + + STOP_SERVICE = "Stopping remote_debugger_Test.TestRun1 service..." + assert STOP_SERVICE in grep_rrdlogs(STOP_SERVICE) + + UPLOAD_SCRIPT_START = "Starting Upload Debug output Script: /lib/rdk/uploadRRDLogs.sh..." + assert UPLOAD_SCRIPT_START in grep_rrdlogs(UPLOAD_SCRIPT_START) + +def test_remotedebugger_upload_report(): + UPLOAD_SUCCESS = "RRD Upload Script Execution Success" + UPLOAD_FAILURE = "RRD Upload Script Execution Failure" + if UPLOAD_SUCCESS in grep_rrdlogs(UPLOAD_SUCCESS): + print("Upload success") + elif UPLOAD_FAILURE in grep_rrdlogs(UPLOAD_FAILURE): + print("Upload failed") + else: + print("Upload status not found in logs") + + SCRIPT_SUCCESS = "Debug Information Report upload Failed" + SCRIPT_FAILURE = "Debug Information Report upload Success" + if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS): + print("Script execution success") + elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE): + print("Script execution failed") + else: + print("Script execution not found in logs") + + remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd() diff --git a/test/functional-tests/tests/test_rrd_single_instance.py b/test/functional-tests/tests/test_rrd_single_instance.py index 26332331..177f182f 100644 --- a/test/functional-tests/tests/test_rrd_single_instance.py +++ b/test/functional-tests/tests/test_rrd_single_instance.py @@ -31,19 +31,26 @@ def test_check_remotedebugger_is_starting(): assert pid != "", "remotedebugger process did not start" def test_second_remotedebugger_instance_is_not_started(): + kill_rrd() + sleep(2) command_to_get_pid = "pidof remotedebugger" - pid1 = run_shell_command(command_to_get_pid) + pid1 = run_shell_command(command_to_get_pid).strip().split() if is_remotedebugger_running(): - print("remotedebugger process is already running") + print(f"remotedebugger process is already running with PID(s): {pid1}") else: command_to_start = "nohup /usr/local/bin/remotedebugger > /dev/null 2>&1 &" run_shell_silent(command_to_start) sleep(2) + pid1 = run_shell_command(command_to_get_pid).strip().split() - pid2 = run_shell_command(command_to_get_pid) - assert pid1 == pid2, "A second instance of remotedebugger was started." + pid2 = run_shell_command(command_to_get_pid).strip().split() + # Assert only one PID exists (no second instance) + assert len(pid2) == 1, f"A second instance of remotedebugger was started: {pid2}" + # ensure it's the same PID as before + assert pid1[0] == pid2[0], f"PID changed unexpectedly: before={pid1}, after={pid2}" + def test_tear_down(): command_to_stop = "kill -9 `pidof remotedebugger`" run_shell_command(command_to_stop)