diff --git a/configure.ac b/configure.ac index 6a87226c..9fee3ad3 100644 --- a/configure.ac +++ b/configure.ac @@ -62,6 +62,19 @@ AC_TYPE_SIZE_T AC_CONFIG_FILES([Makefile src/Makefile]) +AC_ARG_ENABLE([L2support], + AS_HELP_STRING([--enable-L2support],[enable L2support (default is no)]), + [ + case "${enableval}" in + yes) L2_SUPPORT_ENABLE=true + L2_SUPPORT_FLAG="-DUSE_L2_SUPPORT" + m4_if(m4_sysval,[0],[SUBDIRS_L2_SUPPORT="src"]) ;; + no) L2_SUPPORT_ENABLE=false AC_MSG_ERROR([L2_SUPPORT is disabled]) ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-L2support]) ;; + esac + ], + [echo "L2support is disabled"]) + # IARMBus Support AC_ARG_ENABLE([iarmbusSupport], [ --enable-iarmbusSupport Turn on iarmbus support], @@ -74,3 +87,4 @@ AM_CONDITIONAL([IARMBUS_ENABLE], [test x$iarmbusSupport = xtrue]) AC_SUBST(GTEST_ENABLE_FLAG) AC_OUTPUT + diff --git a/cov_build.sh b/cov_build.sh index 2c2e17d2..db158f7f 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -48,7 +48,9 @@ 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" +#cp /usr/include/cjson/cJSON.h ./ +#cp /usr/local/include/wdmp-c/wdmp-c.h ./ +make librfcapi_la_CPPFLAGS="-I/usr/include/cjson -I/usr/rfc/rfcMgr/gtest/mocks -DUSE_IARMBUS -DTEMP_LOGGING" make install cd /usr/rfc/tr181api g++ -fPIC -shared -o libtr181api.so tr181api.cpp -I/usr/local/include/wdmp-c @@ -64,7 +66,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 @@ -78,6 +79,7 @@ cp libIARM.h /usr/local/include 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" +./configure --prefix=${INSTALL_DIR} --enable-iarmbusSupport=yes --enable-L2support=yes +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 -DUSE_L2_SUPPORT" 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..d82cc27c 100644 --- a/remote_debugger.json +++ b/remote_debugger.json @@ -39,5 +39,31 @@ "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..93c8b9e1 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -28,8 +28,10 @@ mkdir -p "$OUTPUT_DIR" mkdir -p "$STATIC_PROFILE_DIR" mkdir -p "$LIB_DIR" mkdir -p /media/apps/RDK-RRD-Test/etc/rrd +mkdir -p /media/apps/RDK-RRD-DEEPSLEEP/etc/rrd touch /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json +touch /media/apps/RDK-RRD-DEEPSLEEP/etc/rrd/remote_debugger.json apt-get remove systemd apt-get update && apt-get install -y tcpdump @@ -58,9 +60,26 @@ ln -s /usr/local/bin/journalctl /usr/bin/journalctl rm -rf /tmp/rrd/* rm -rf /opt/logs/remotedebugger.log* +cd ./test/functional-tests/tests +make +cd - +echo "tr69 process :" +ps -ef | grep tr69hostif # Run L2 Test cases +pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_neg.json test/functional-tests/tests/test_rrd_negative.py + 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 +cat /opt/logs/remotedebugger.log.0 +cat /opt/logs/rfcscript.txt.0 +rm -rf /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json +rm -rf /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json +pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_dynamic_profile_harmful_with_download.json test/functional-tests/tests/test_rrd_dynamic_with_download_harmful.py +rm -rf /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json +rm -rf /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json +pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/test_category.json test/functional-tests/tests/test_category.py +pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_append.json test/functional-tests/tests/test_append.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 +94,9 @@ 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_deepsleep_static.py +cp remote_debugger.json /media/apps/RDK-RRD-DEEPSLEEP/etc/rrd/remote_debugger.json +pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_deepsleep_dynamic.json test/functional-tests/tests/test_deepsleep_dynamic.py + + + diff --git a/src/rrdIarmEvents.c b/src/rrdIarmEvents.c index ecc3f744..cf7f7826 100644 --- a/src/rrdIarmEvents.c +++ b/src/rrdIarmEvents.c @@ -157,12 +157,14 @@ void _pwrManagerEventHandler(const PowerController_PowerState_t currentState, rbusValue_Init(&value); rbusValue_SetString(value,"root"); rc = rbus_set(rrdRbusHandle, RRD_WEBCFG_FORCE_SYNC, value, NULL); - if (rc != RBUS_ERROR_SUCCESS) +#ifndef USE_L2_SUPPORT + if (rc != RBUS_ERROR_SUCCESS) { RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: rbus_set failed for [%s] with error [%d]\n\n", __FUNCTION__, __LINE__,RRD_WEBCFG_FORCE_SYNC ,rc); return; } - RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Invoking WebCfg Force Sync: %s... \n", __FUNCTION__, __LINE__, RRD_WEBCFG_FORCE_SYNC); +#endif + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Invoking WebCfg Force Sync: %s... \n", __FUNCTION__, __LINE__, RRD_WEBCFG_FORCE_SYNC); RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Copying Message Received to the queue.. \n", __FUNCTION__, __LINE__); sbuf = (data_buf *)malloc(sizeof(data_buf)); if (!sbuf) @@ -437,3 +439,4 @@ int RRD_IARM_unsubscribe() #endif return ret; } + diff --git a/src/rrdInterface.c b/src/rrdInterface.c index a6d963ff..440126be 100644 --- a/src/rrdInterface.c +++ b/src/rrdInterface.c @@ -74,16 +74,24 @@ int RRD_subscribe() subscriptions[1].handler = _remoteDebuggerWebCfgDataEventHandler; subscriptions[1].userData = NULL; -#ifndef IARMBUS_SUPPORT - subscriptions[2].eventName = RDM_DOWNLOAD_EVENT; - subscriptions[2].filter = NULL; - subscriptions[2].duration = 0; - subscriptions[2].handler = _rdmDownloadEventHandler; - subscriptions[2].userData = NULL; - - ret = rbusEvent_SubscribeEx(rrdRbusHandle, subscriptions, 3, 60); +#ifdef IARMBUS_SUPPORT +#ifdef USE_L2_SUPPORT + subscriptions[2].eventName = RDM_DOWNLOAD_EVENT; + subscriptions[2].filter = NULL; + subscriptions[2].duration = 0; + subscriptions[2].handler = _rdmDownloadEventHandler; + subscriptions[2].userData = NULL; + ret = rbusEvent_SubscribeEx(rrdRbusHandle, subscriptions, 3, 60); +#else + ret = rbusEvent_SubscribeEx(rrdRbusHandle, subscriptions, 2, 60); +#endif #else - ret = rbusEvent_SubscribeEx(rrdRbusHandle, subscriptions, 2, 60); + subscriptions[2].eventName = RDM_DOWNLOAD_EVENT; + subscriptions[2].filter = NULL; + subscriptions[2].duration = 0; + subscriptions[2].handler = _rdmDownloadEventHandler; + subscriptions[2].userData = NULL; + ret = rbusEvent_SubscribeEx(rrdRbusHandle, subscriptions, 3, 60); #endif #endif if(ret != 0) diff --git a/src/unittest/mocks/pwrMgr.h b/src/unittest/mocks/pwrMgr.h new file mode 100644 index 00000000..5c84b060 --- /dev/null +++ b/src/unittest/mocks/pwrMgr.h @@ -0,0 +1,357 @@ +/* + * 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..486303d5 --- /dev/null +++ b/test/functional-tests/features/rrd_append_report.feature @@ -0,0 +1,46 @@ +########################################################################## +# 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_dynamic.feature b/test/functional-tests/features/rrd_deepsleep_dynamic.feature new file mode 100644 index 00000000..adb2ee0a --- /dev/null +++ b/test/functional-tests/features/rrd_deepsleep_dynamic.feature @@ -0,0 +1,50 @@ +########################################################################## +# 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 dynamic scenario + + 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 event for Deepsleep + Given the Deepsleep event is triggered + When I trigger the event Deepsleep event + Then the event changes from DEEPSLEEP to ON state + And the logs should contain "Received state from Power Manager Current :[5] New[3]" + And the logs should be seen with "Copying Message Received to the queue" + When the remotedebugger received the message from deepsleep trigger + 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 + + Scenario: Upload remote debugger debug report + 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/features/rrd_deepsleep_static.feature b/test/functional-tests/features/rrd_deepsleep_static.feature new file mode 100644 index 00000000..232cc130 --- /dev/null +++ b/test/functional-tests/features/rrd_deepsleep_static.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 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_missing_report.feature b/test/functional-tests/features/rrd_dynamic_profile_missing_report.feature index 0b8f2667..76e11faf 100644 --- a/test/functional-tests/features/rrd_dynamic_profile_missing_report.feature +++ b/test/functional-tests/features/rrd_dynamic_profile_missing_report.feature @@ -43,3 +43,13 @@ Feature: Remote Debugger Missing Issuetype When the remotedebugger read the json file form the dynamic path Then remotedebugger json read and parse should be failed And remotedebugger should request RDM to download the package + + Scenario: Verify the Issuetype is not found in downloaded package + Given the test package downloaded successfully + When the remotedebugger read the json file from dynamic download path + Then remotedebugger json read and parse should be success + And remotedebugger should Execute the commands successfully + + + + diff --git a/test/functional-tests/features/rrd_dynamic_with_download_harmful_report.feature b/test/functional-tests/features/rrd_dynamic_with_download_harmful_report.feature new file mode 100644 index 00000000..e7688973 --- /dev/null +++ b/test/functional-tests/features/rrd_dynamic_with_download_harmful_report.feature @@ -0,0 +1,56 @@ +########################################################################## +# 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 Harmful Commands 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 is not found 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 failed + And remotedebugger should request RDM to download the package + + Scenario: Check for harmfull commands and abort + Given Test package has been downloaded successfully + When the issue node and subnode are present in the profile + Then the remote debugger should read the Sanity Check list from profile + And the remotedebugger should perform sanity check on issue commands + Given the remote debugger profile has the harmfull commands + When the issue command and the sanity commands are matched + Then the remote debugger should exit the processing of commands + And Abort the commmand execution and skip report upload + diff --git a/test/functional-tests/tests/Makefile b/test/functional-tests/tests/Makefile new file mode 100644 index 00000000..788ff0b8 --- /dev/null +++ b/test/functional-tests/tests/Makefile @@ -0,0 +1,26 @@ +CC = gcc +CFLAGS = -DIARMBUS_SUPPORT -DUSE_L2_SUPPORT -DPWRMGR_PLUGIN -Iremote_debugger/src -I/usr/local/include -I/usr/local/include/rbus -I/usr/local/include/cjson -I/usr/local/include/trower-base64 -I../../../src -I./ +LDFLAGS = -lcjson -lmsgpackc -lIARMBus -lwebconfig_framework -lrfcapi -ltr181api -lsecure_wrapper -lpthread -ltrower-base64 -lrbus -lrdkloggers + +# List all object files needed for linking. +# Add additional .c files below if you get linker errors for missing symbols. +OBJS = ../../../src/rrdIarmEvents.c \ + deepsleep_main.c \ + ../../../src/rrdRunCmdThread.c \ + ../../../src/rrdCommandSanity.c \ + ../../../src/rrdEventProcess.c \ + ../../../src/rrdInterface.c \ + ../../../src/rrdJsonParser.c \ + ../../../src/rrdDynamic.c \ + ../../../src/rrdExecuteScript.c \ + ../../../src/rrdMsgPackDecoder.c +TARGET = test_pwr_event_handler + +all: $(TARGET) + +$(TARGET): $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) + +clean: + rm -f $(TARGET) *.o + 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/deepsleep_main.c b/test/functional-tests/tests/deepsleep_main.c new file mode 100644 index 00000000..6b728310 --- /dev/null +++ b/test/functional-tests/tests/deepsleep_main.c @@ -0,0 +1,171 @@ +/* + * 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. +*/ + +#include "rrdMain.h" +#include "rrdRunCmdThread.h" +#include "rrdJsonParser.h" +#include "rrdDynamic.h" +#include "rrdEventProcess.h" +#include "rrdInterface.h" + +#include "power_controller.h" +#include "rrdInterface.h" +#include "rbus.h" + + +devicePropertiesData devPropData; + +void *RRDEventThreadFunc(void *arg) +{ + data_buf *rbuf; + msgRRDHdr msgHdr; + + while (1) + { + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]:Waiting for for TR69/RBUS Events... \n", __FUNCTION__, __LINE__); + + if (msgrcv(msqid, (void *)&msgHdr, sizeof(void *), 0, 0) < 0) + { + RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]:Message Reception failed for Message Queue Id:[%d]!!! \n", __FUNCTION__, __LINE__, msqid); + break; + } + rbuf = (data_buf *)msgHdr.mbody; + RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]:SUCCESS: Message Reception Done for ID=%d MSG=%s TYPE=%u... \n", __FUNCTION__, __LINE__, msqid, rbuf->mdata, rbuf->mtype); + + switch (rbuf->mtype) + { + case EVENT_MSG: + processIssueTypeEvent(rbuf); + break; + case EVENT_WEBCFG_MSG: + processWebCfgTypeEvent(rbuf); + break; + case DEEPSLEEP_EVENT_MSG: + /*Process Deep Sleep Events*/ + RRDProcessDeepSleepAwakeEvents(rbuf); + break; + default: + RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: Invalid Message Type %d!!!\n", __FUNCTION__, __LINE__, rbuf->mtype); + free(rbuf->mdata); + free(rbuf); + break; + } + } + + return arg; +} + +bool isRRDEnabled(void) +{ + bool ret = true; + RFC_ParamData_t param; + WDMP_STATUS status = getRFCParameter("RDKRemoteDebugger", RRD_RFC, ¶m); + if(status == WDMP_SUCCESS || status == WDMP_ERR_DEFAULT_VALUE) { + RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]:getRFCParameter() name=%s,type=%d,value=%s\n", __FUNCTION__, __LINE__, param.name, param.type, param.value); + if (strcasecmp("false", param.value) == 0) { + ret = false; + } + } + else { + RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]:ERROR in getRFCParameter()\n", __FUNCTION__, __LINE__); + } + + return ret; +} + +int main(int argc, char *argv[]) + +{ + pthread_t RRDTR69ThreadID; + + rdk_logger_init(DEBUG_INI_FILE); + + /* Store Device Info.*/ + RRDStoreDeviceInfo(&devPropData); + + /* Initialize Cache */ + initCache(); + + /* Check RRD Enable RFC */ + bool isEnabled = isRRDEnabled(); + if(!isEnabled) { + RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]:RFC is disabled, stopping remote-debugger\n", __FUNCTION__, __LINE__); + exit(0); + } + + RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]:Starting RDK Remote Debugger Daemon \n",__FUNCTION__,__LINE__); + if ((msqid = msgget(key, IPC_CREAT | 0666 )) < 0) + { + RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]:Message Queue ID Creation failed, msqid=%d!!!\n",__FUNCTION__,__LINE__,msqid); + exit(1); + } + RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]:SUCCESS: Message Queue ID Creation Done, msqid=%d...\n",__FUNCTION__,__LINE__,msqid); + + RRD_subscribe(); + RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]:Started RDK Remote Debugger Daemon \n",__FUNCTION__,__LINE__); + + IARM_Bus_RDMMgr_EventData_t eventData; + strcpy(eventData.rdm_pkg_info.pkg_name, "RDK-RRD-DEEPSLEEP"); + strcpy(eventData.rdm_pkg_info.pkg_inst_path, "/media/apps/RDK-RRD-DEEPSLEEP"); + eventData.rdm_pkg_info.pkg_inst_status = RDM_PKG_INSTALL_COMPLETE; + + const char *owner = IARM_BUS_RDMMGR_NAME; + IARM_EventId_t eventId = IARM_BUS_RDMMGR_EVENT_APP_INSTALLATION_STATUS; + size_t len = sizeof(IARM_Bus_RDMMgr_EventData_t); + pthread_create(&RRDTR69ThreadID, NULL, RRDEventThreadFunc, NULL); + // Give the thread a moment to start (optional but helpful) + sleep(1); + PowerController_PowerState_t state1 = POWER_STATE_STANDBY_DEEP_SLEEP; + PowerController_PowerState_t state2 = POWER_STATE_STANDBY_DEEP_SLEEP; + void* userdata = NULL; + _pwrManagerEventHandler(state1, state2, userdata); + state2 = POWER_STATE_ON; + _pwrManagerEventHandler(state1, state2, userdata); + sleep(2); + _rdmManagerEventHandler(owner, eventId, &eventData, len); + // Now wait for the thread to finish (if it ever does) + pthread_join(RRDTR69ThreadID, NULL); + RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]:Stopping RDK Remote Debugger Daemon \n",__FUNCTION__,__LINE__); + RRD_unsubscribe(); + RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]:Stopped RDK Remote Debugger Daemon \n",__FUNCTION__,__LINE__); + + return 0; +} + +uint32_t PowerController_RegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback, void* userdata) +{ + return POWER_CONTROLLER_ERROR_NONE; +} +uint32_t PowerController_Connect() +{ + return POWER_CONTROLLER_ERROR_NONE; +} +uint32_t PowerController_UnRegisterPowerModeChangedCallback(PowerController_PowerModeChangedCb callback) +{ + return POWER_CONTROLLER_ERROR_NONE; +} +void PowerController_Term() +{ + +} +void PowerController_Init() +{ + +} + diff --git a/test/functional-tests/tests/power_controller.h b/test/functional-tests/tests/power_controller.h new file mode 100644 index 00000000..c1e78279 --- /dev/null +++ b/test/functional-tests/tests/power_controller.h @@ -0,0 +1,416 @@ +/* + * 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_append.py b/test/functional-tests/tests/test_append.py new file mode 100644 index 00000000..190fa53d --- /dev/null +++ b/test/functional-tests/tests/test_append.py @@ -0,0 +1,135 @@ +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_category.py b/test/functional-tests/tests/test_category.py new file mode 100644 index 00000000..d1f7a138 --- /dev/null +++ b/test/functional-tests/tests/test_category.py @@ -0,0 +1,190 @@ +########################################################################## +# 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" + 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) + +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) + + PARSE_FAILED = "Dynamic Profile Parse/Read failed" + assert PARSE_FAILED in grep_rrdlogs(PARSE_FAILED) + + RDM_MSG = "Request RDM Manager Download for a new Issue Type" + assert RDM_MSG in grep_rrdlogs(RDM_MSG) + + RDM_PACKAGE = "Request RDM Manager Download for... RDK-RRD-Test:1.0" + assert RDM_PACKAGE in grep_rrdlogs(RDM_PACKAGE) + + 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_rdm_trigger_event(): + INSTALL_PACKAGE ="RDK-RRD-Test:1.0" + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.InstallPackage', + 'string', INSTALL_PACKAGE + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + + RBUS_SETTING_SUCCESS = "Setting Parameters using rbus success..." + assert RBUS_SETTING_SUCCESS in grep_rrdlogs(RBUS_SETTING_SUCCESS) + + CACHE_UPDATE_SUCCESS = "Setting Parameters Success and Cache Updated ...RDK-RRD-Test" + assert CACHE_UPDATE_SUCCESS in grep_rrdlogs(CACHE_UPDATE_SUCCESS) + +def test_rdm_rrd_trigger_event(): + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.DownloadStatus', + 'bool', 'true' + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + +def test_rdm_rrd_dwnld_status(): + PACKAGE_FOUND = "Package found in Cache...Test" + assert PACKAGE_FOUND in grep_rrdlogs(PACKAGE_FOUND) + + PACKAGE_DETAIL = "Package Details jsonPath: /tmp/RDK-RRD-Test" + assert PACKAGE_DETAIL in grep_rrdlogs(PACKAGE_DETAIL) + + COPY_MSG = "Copying Message Received to the queue.." + assert COPY_MSG in grep_rrdlogs(COPY_MSG) + + SUCCESS_MSG_SEND = "Message sending Done, ID=0 MSG=Test Size=4 Type=1 AppendMode=0!" + assert SUCCESS_MSG_SEND in grep_rrdlogs(SUCCESS_MSG_SEND) + + SUCCESS_MSG_RECEIVE = "Message Reception Done for ID=0 MSG=Test TYPE=1..." + assert SUCCESS_MSG_RECEIVE in grep_rrdlogs(SUCCESS_MSG_RECEIVE) + + ISSUE_CMD_INFO = "Getting Issue command Information for : Test" + assert ISSUE_CMD_INFO in grep_rrdlogs(ISSUE_CMD_INFO) + + CHECK_IN_DYNAMIC = "Checking if Issue marked inDynamic..." + assert CHECK_IN_DYNAMIC in grep_rrdlogs(CHECK_IN_DYNAMIC) + + ISSUE_MARKED_DYNAMIC = "Issue Marked as inDynamic..." + assert ISSUE_MARKED_DYNAMIC in grep_rrdlogs(ISSUE_MARKED_DYNAMIC) + + START_JSON_READ = "Start Reading JSON File... /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert START_JSON_READ in grep_rrdlogs(START_JSON_READ) + + JSON_READ_SUCCESS = "Reading json file Success, Parsing the Content..." + assert JSON_READ_SUCCESS in grep_rrdlogs(JSON_READ_SUCCESS) + + JSON_PARSE_SUCCESS = "Json File parse Success... /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert JSON_PARSE_SUCCESS in grep_rrdlogs(JSON_PARSE_SUCCESS) + + READ_ISSUE_CATEGORY = "Reading Issue Category:Test..." + assert READ_ISSUE_CATEGORY in grep_rrdlogs(READ_ISSUE_CATEGORY) + + RUN_DEBUG_CMD = "Run Debug Commands for all issue types in Test" + assert RUN_DEBUG_CMD in grep_rrdlogs(RUN_DEBUG_CMD) + + EXEC_RUNTIME_SERVICE = "Executing Commands in Runtime Service..." + assert EXEC_RUNTIME_SERVICE in grep_rrdlogs(EXEC_RUNTIME_SERVICE) + + START_REMOTE_DEBUGGER = "Starting remote_debugger_Test.TestRun1 service success..." + assert START_REMOTE_DEBUGGER in grep_rrdlogs(START_REMOTE_DEBUGGER) + + sleep(15); + + READING = "Reading Issue Type 2:Test.TestRun5" + assert READING in grep_rrdlogs(READING) + + START_REMOTE_DEBUGGER = "Starting remote_debugger_Test.TestRun5 service success..." + assert START_REMOTE_DEBUGGER in grep_rrdlogs(START_REMOTE_DEBUGGER) + + remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd() + diff --git a/test/functional-tests/tests/test_deepsleep_dynamic.py b/test/functional-tests/tests/test_deepsleep_dynamic.py new file mode 100644 index 00000000..36e866f9 --- /dev/null +++ b/test/functional-tests/tests/test_deepsleep_dynamic.py @@ -0,0 +1,148 @@ +########################################################################## +# 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 ./test/functional-tests/tests/test_pwr_event_handler > /dev/null 2>&1 &" + run_shell_silent(command_to_start) + command_to_get_pid = "pidof test_pwr_event_handler" + pid = run_shell_command(command_to_get_pid) + assert pid != "", "remotedebugger process did not start" + +def test_deepsleep_trigger(): + sleep(10) + CURR_STATE_1 = "Entering.. currentState =5, newState = 5" + assert CURR_STATE_1 in grep_rrdlogs(CURR_STATE_1) + + DEEP_SLEEP_EVENT = "Event Triggred for DeepSleep" + assert DEEP_SLEEP_EVENT in grep_rrdlogs(DEEP_SLEEP_EVENT) + + CURR_STATE_2 = "...Entering.. currentState =5, newState = 3" + assert CURR_STATE_2 in grep_rrdlogs(CURR_STATE_2) + + RECEIVED_STATE = "Received state from Power Manager Current :[5] New[3]" + assert RECEIVED_STATE in grep_rrdlogs(RECEIVED_STATE) + + COPY_QUEUE = "Copying Message Received to the queue" + assert COPY_QUEUE in grep_rrdlogs(COPY_QUEUE) + + +def test_message_reception(): + MSG_RECEIVE_DEEPSLEEP = "Message Reception Done for ID=0 MSG=DEEPSLEEP TYPE=3" + assert MSG_RECEIVE_DEEPSLEEP in grep_rrdlogs(MSG_RECEIVE_DEEPSLEEP) + + GET_ISSUE_INFO = "Getting Issue command Information for : DEEPSLEEP" + assert GET_ISSUE_INFO in grep_rrdlogs(GET_ISSUE_INFO) + + SEND_RDM_REQ = "Sending RDM Download Request for DeepSleep dynamic package..." + assert SEND_RDM_REQ in grep_rrdlogs(SEND_RDM_REQ) + + REQ_RDM_MANAGER = "Request RDM Manager Download for a new Issue Type" + assert REQ_RDM_MANAGER in grep_rrdlogs(REQ_RDM_MANAGER) + + APPEND_ITEM = "Append Item with PkgData: RDK-RRD-DEEPSLEEP and issue Type: DEEPSLEEP to Cache" + assert APPEND_ITEM in grep_rrdlogs(APPEND_ITEM) + + SET_PARAMS_SUCCESS = "Setting Parameters Success and Cache Updated ...RDK-RRD-DEEPSLEEP IssueStr:DEEPSLEEP Length:9" + assert SET_PARAMS_SUCCESS in grep_rrdlogs(SET_PARAMS_SUCCESS) + + +def trigger_rdm_for_deepsleep(): + + EVENT_RECEIVED = "Received event for IARM_BUS_RDMMGR_NAME RDMMgr" + assert EVENT_RECEIVED in grep_rrdlogs(EVENT_RECEIVED) + + FIND_PKG_CACHE = "finding RDK-RRD-DEEPSLEEP PkgData in Cache" + assert FIND_PKG_CACHE in grep_rrdlogs(FIND_PKG_CACHE) + + PKG_FOUND = "Package found in Cache...DEEPSLEEP" + assert PKG_FOUND in grep_rrdlogs(PKG_FOUND) + + INSTALL_COMPLETE = "Package Installation Status Complete" + assert INSTALL_COMPLETE in grep_rrdlogs(INSTALL_COMPLETE) + + MSG_SEND_DEEPSLEEP = "Message sending Done, ID=0 MSG=DEEPSLEEP Size=9 Type=3 AppendMode=0!" + assert MSG_SEND_DEEPSLEEP in grep_rrdlogs(MSG_SEND_DEEPSLEEP) + +def test_command_execute(): + MAIN_NODE = "Received Main Node= DEEPSLEEP" + assert MAIN_NODE in grep_rrdlogs(MAIN_NODE) + + READ_JSON_SUCCESS = "Reading json file Success, Parsing the Content..." + assert READ_JSON_SUCCESS in grep_rrdlogs(READ_JSON_SUCCESS) + + RUN_DEBUG_CMDS = "Run Debug Commands for all issue types in DEEPSLEEP" + assert RUN_DEBUG_CMDS in grep_rrdlogs(RUN_DEBUG_CMDS) + + READ_ISSUE_TYPE = "Reading Issue Type 1:Audio.Audio" + assert READ_ISSUE_TYPE in grep_rrdlogs(READ_ISSUE_TYPE) + + FOUND_VALID_CMDS = "Found valid Commands, Execute..." + assert FOUND_VALID_CMDS in grep_rrdlogs(FOUND_VALID_CMDS) + + EXECUTE_CMDS = "Executing Commands in Runtime Service.." + assert EXECUTE_CMDS in grep_rrdlogs(EXECUTE_CMDS) + + START_SERVICE_SUCCESS = "Starting remote_debugger_Audio.Audio service success..." + assert START_SERVICE_SUCCESS in grep_rrdlogs(START_SERVICE_SUCCESS) + + JOURNALCTL_SUCCESS = "journalctl remote_debugger_Audio.Audio service success..." + assert JOURNALCTL_SUCCESS in grep_rrdlogs(JOURNALCTL_SUCCESS) + + SLEEP_BEFORE_STOP = "Sleeping with timeout 10 sec before stopping service..." + assert SLEEP_BEFORE_STOP in grep_rrdlogs(SLEEP_BEFORE_STOP) + + +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_deepsleep_static.py b/test/functional-tests/tests/test_deepsleep_static.py new file mode 100644 index 00000000..27b8ac9e --- /dev/null +++ b/test/functional-tests/tests/test_deepsleep_static.py @@ -0,0 +1,161 @@ +########################################################################## +# 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_profile_missing_report.py b/test/functional-tests/tests/test_rrd_dynamic_profile_missing_report.py index 5d837920..5bcafd44 100644 --- a/test/functional-tests/tests/test_rrd_dynamic_profile_missing_report.py +++ b/test/functional-tests/tests/test_rrd_dynamic_profile_missing_report.py @@ -45,12 +45,13 @@ def reset_issuetype_rfc(): assert result.returncode == 0 def test_remote_debugger_trigger_event(): + TEST_STRING = "Test.TestRun5" reset_issuetype_rfc() sleep(10) command = [ 'rbuscli', 'set', 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', - 'string', MISSING_STRING + 'string', TEST_STRING ] result = subprocess.run(command, capture_output=True, text=True) assert result.returncode == 0 @@ -95,7 +96,7 @@ def test_check_issue_in_dynamic_profile(): assert RDM_PACKAGE in grep_rrdlogs(RDM_PACKAGE) script_path="./test/functional-tests/tests/create_json.sh" -# Run the shell script + # Run the shell script try: result = subprocess.run(['bash', script_path], check=True, text=True, capture_output=True) print("Script output:") @@ -103,10 +104,7 @@ def test_check_issue_in_dynamic_profile(): except subprocess.CalledProcessError as e: print("Error while executing the script:") print(e.stderr) - remove_logfile() - remove_outdir_contents(OUTPUT_DIR) - kill_rrd() - + def test_rdm_trigger_event(): INSTALL_PACKAGE ="RDK-RRD-Test:1.0" command = [ @@ -116,3 +114,69 @@ def test_rdm_trigger_event(): ] result = subprocess.run(command, capture_output=True, text=True) assert result.returncode == 0 + + RBUS_SETTING_SUCCESS = "Setting Parameters using rbus success..." + assert RBUS_SETTING_SUCCESS in grep_rrdlogs(RBUS_SETTING_SUCCESS) + + CACHE_UPDATE_SUCCESS = "Setting Parameters Success and Cache Updated ...RDK-RRD-Test" + assert CACHE_UPDATE_SUCCESS in grep_rrdlogs(CACHE_UPDATE_SUCCESS) + +def test_rdm_rrd_trigger_event(): + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.DownloadStatus', + 'bool', 'true' + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + +def test_rdm_rrd_dwnld_status(): + PACKAGE_FOUND = "Package found in Cache...Test.TestRun5" + assert PACKAGE_FOUND in grep_rrdlogs(PACKAGE_FOUND) + + PACKAGE_DETAIL = "Package Details jsonPath: /tmp/RDK-RRD-Test" + assert PACKAGE_DETAIL in grep_rrdlogs(PACKAGE_DETAIL) + + COPY_MSG = "Copying Message Received to the queue.." + assert COPY_MSG in grep_rrdlogs(COPY_MSG) + + SUCCESS_MSG_SEND = "Message sending Done, ID=0 MSG=Test.TestRun5 Size=13 Type=1 AppendMode=0!" + assert SUCCESS_MSG_SEND in grep_rrdlogs(SUCCESS_MSG_SEND) + + SUCCESS_MSG_RECEIVE = "Message Reception Done for ID=0 MSG=Test.TestRun5 TYPE=1..." + assert SUCCESS_MSG_RECEIVE in grep_rrdlogs(SUCCESS_MSG_RECEIVE) + + ISSUE_CMD_INFO = "Getting Issue command Information for : Test.TestRun5" + assert ISSUE_CMD_INFO in grep_rrdlogs(ISSUE_CMD_INFO) + + CHECK_IN_DYNAMIC = "Checking if Issue marked inDynamic..." + assert CHECK_IN_DYNAMIC in grep_rrdlogs(CHECK_IN_DYNAMIC) + + ISSUE_MARKED_DYNAMIC = "Issue Marked as inDynamic..." + assert ISSUE_MARKED_DYNAMIC in grep_rrdlogs(ISSUE_MARKED_DYNAMIC) + + START_JSON_READ = "Start Reading JSON File... /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert START_JSON_READ in grep_rrdlogs(START_JSON_READ) + + JSON_READ_SUCCESS = "Reading json file Success, Parsing the Content..." + assert JSON_READ_SUCCESS in grep_rrdlogs(JSON_READ_SUCCESS) + + JSON_PARSE_SUCCESS = "Json File parse Success... /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert JSON_PARSE_SUCCESS in grep_rrdlogs(JSON_PARSE_SUCCESS) + + READ_ISSUE_CATEGORY = "Reading Issue Category:Test..." + assert READ_ISSUE_CATEGORY in grep_rrdlogs(READ_ISSUE_CATEGORY) + + RUN_DEBUG_CMD = "Run Debug Commands for Test:TestRun5" + assert RUN_DEBUG_CMD in grep_rrdlogs(RUN_DEBUG_CMD) + + EXEC_RUNTIME_SERVICE = "Executing Commands in Runtime Service..." + assert EXEC_RUNTIME_SERVICE in grep_rrdlogs(EXEC_RUNTIME_SERVICE) + + START_REMOTE_DEBUGGER = "Starting remote_debugger_Test.TestRun5 service success..." + assert START_REMOTE_DEBUGGER in grep_rrdlogs(START_REMOTE_DEBUGGER) + + remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd() + diff --git a/test/functional-tests/tests/test_rrd_dynamic_with_download_harmful.py b/test/functional-tests/tests/test_rrd_dynamic_with_download_harmful.py new file mode 100644 index 00000000..3bd7c329 --- /dev/null +++ b/test/functional-tests/tests/test_rrd_dynamic_with_download_harmful.py @@ -0,0 +1,190 @@ +########################################################################## +# 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(): + reset_issuetype_rfc() + sleep(10) + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', + 'string', DYNAMIC_HARMFUL_STRING + ] + 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) + +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) + + PARSE_FAILED = "Dynamic Profile Parse/Read failed" + assert PARSE_FAILED in grep_rrdlogs(PARSE_FAILED) + + RDM_MSG = "Request RDM Manager Download for a new Issue Type" + assert RDM_MSG in grep_rrdlogs(RDM_MSG) + + RDM_PACKAGE = "Request RDM Manager Download for... RDK-RRD-Test:1.0" + assert RDM_PACKAGE in grep_rrdlogs(RDM_PACKAGE) + + 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_rdm_trigger_event(): + INSTALL_PACKAGE ="RDK-RRD-Test:1.0" + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.InstallPackage', + 'string', INSTALL_PACKAGE + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + + RBUS_SETTING_SUCCESS = "Setting Parameters using rbus success..." + assert RBUS_SETTING_SUCCESS in grep_rrdlogs(RBUS_SETTING_SUCCESS) + + CACHE_UPDATE_SUCCESS = "Setting Parameters Success and Cache Updated ...RDK-RRD-Test" + assert CACHE_UPDATE_SUCCESS in grep_rrdlogs(CACHE_UPDATE_SUCCESS) + +def test_rdm_rrd_trigger_event(): + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.DownloadStatus', + 'bool', 'true' + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + +def test_rdm_rrd_dwnld_status(): + PACKAGE_FOUND = "Package found in Cache...Test.TestRun3" + assert PACKAGE_FOUND in grep_rrdlogs(PACKAGE_FOUND) + + PACKAGE_DETAIL = "Package Details jsonPath: /tmp/RDK-RRD-Test" + assert PACKAGE_DETAIL in grep_rrdlogs(PACKAGE_DETAIL) + + COPY_MSG = "Copying Message Received to the queue.." + assert COPY_MSG in grep_rrdlogs(COPY_MSG) + + SUCCESS_MSG_SEND = "Message sending Done, ID=0 MSG=Test.TestRun3 Size=13 Type=1 AppendMode=0!" + assert SUCCESS_MSG_SEND in grep_rrdlogs(SUCCESS_MSG_SEND) + + SUCCESS_MSG_RECEIVE = "Message Reception Done for ID=0 MSG=Test.TestRun3 TYPE=1..." + assert SUCCESS_MSG_RECEIVE in grep_rrdlogs(SUCCESS_MSG_RECEIVE) + + ISSUE_CMD_INFO = "Getting Issue command Information for : Test.TestRun3" + assert ISSUE_CMD_INFO in grep_rrdlogs(ISSUE_CMD_INFO) + + CHECK_IN_DYNAMIC = "Checking if Issue marked inDynamic..." + assert CHECK_IN_DYNAMIC in grep_rrdlogs(CHECK_IN_DYNAMIC) + + ISSUE_MARKED_DYNAMIC = "Issue Marked as inDynamic..." + assert ISSUE_MARKED_DYNAMIC in grep_rrdlogs(ISSUE_MARKED_DYNAMIC) + + START_JSON_READ = "Start Reading JSON File... /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert START_JSON_READ in grep_rrdlogs(START_JSON_READ) + + JSON_READ_SUCCESS = "Reading json file Success, Parsing the Content..." + assert JSON_READ_SUCCESS in grep_rrdlogs(JSON_READ_SUCCESS) + + JSON_PARSE_SUCCESS = "Json File parse Success... /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert JSON_PARSE_SUCCESS in grep_rrdlogs(JSON_PARSE_SUCCESS) + + READ_ISSUE_CATEGORY = "Reading Issue Category:Test..." + assert READ_ISSUE_CATEGORY in grep_rrdlogs(READ_ISSUE_CATEGORY) + + RUN_DEBUG_CMD = "Run Debug Commands for Test:TestRun3" + assert RUN_DEBUG_CMD in grep_rrdlogs(RUN_DEBUG_CMD) + +def test_remote_debugger_command_sanity(): + VALID_COMMAND = "rm -rf" + assert VALID_COMMAND in grep_rrdlogs(VALID_COMMAND) + + SANITY_CHECK = "Found harmful commands" + assert SANITY_CHECK in grep_rrdlogs(SANITY_CHECK) + + sleep(5) + ABORT_MSG = "Aborting Command execution due to Harmful commands" + assert ABORT_MSG in grep_rrdlogs(ABORT_MSG) + + UPLOAD_MSG = "Skip uploading Debug Report" + assert UPLOAD_MSG in grep_rrdlogs(UPLOAD_MSG) + + + remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd() + diff --git a/test/functional-tests/tests/test_rrd_negative.py b/test/functional-tests/tests/test_rrd_negative.py new file mode 100644 index 00000000..47134e8d --- /dev/null +++ b/test/functional-tests/tests/test_rrd_negative.py @@ -0,0 +1,151 @@ +########################################################################## +# 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(): + MISSING_STRING_NEG = "Test.TestRun7" + reset_issuetype_rfc() + sleep(10) + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', + 'string', MISSING_STRING_NEG + ] + 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) + +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) + + PARSE_FAILED = "Dynamic Profile Parse/Read failed" + assert PARSE_FAILED in grep_rrdlogs(PARSE_FAILED) + + RDM_MSG = "Request RDM Manager Download for a new Issue Type" + assert RDM_MSG in grep_rrdlogs(RDM_MSG) + + RDM_PACKAGE = "Request RDM Manager Download for... RDK-RRD-Test:1.0" + assert RDM_PACKAGE in grep_rrdlogs(RDM_PACKAGE) + +def test_rdm_trigger_event(): + INSTALL_PACKAGE ="RDK-RRD-Test:1.0" + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.InstallPackage', + 'string', INSTALL_PACKAGE + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + + RBUS_SETTING_SUCCESS = "Setting Parameters using rbus success..." + assert RBUS_SETTING_SUCCESS in grep_rrdlogs(RBUS_SETTING_SUCCESS) + + CACHE_UPDATE_SUCCESS = "Setting Parameters Success and Cache Updated ...RDK-RRD-Test" + assert CACHE_UPDATE_SUCCESS in grep_rrdlogs(CACHE_UPDATE_SUCCESS) + +def test_rdm_download_event(): + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.DownloadStatus', + 'bool', 'true' + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + sleep(2) + + RDM_DOWNLOAD_EVENT = "Received event for RDM_DOWNLOAD_EVENT Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.DownloadStatus" + assert RDM_DOWNLOAD_EVENT in grep_rrdlogs(RDM_DOWNLOAD_EVENT) + + PACKAGE_FOUND = "Package found in Cache...Test.TestRun7" + assert PACKAGE_FOUND in grep_rrdlogs(PACKAGE_FOUND) + + MESSAGE_SUCCESS = "SUCCESS: Message sending Done, ID=0 MSG=Test.TestRun7 Size=13 Type=1 AppendMode=0!" + assert MESSAGE_SUCCESS in grep_rrdlogs(MESSAGE_SUCCESS) + + ISSUE_TYPE_LIST = "IssueType List [Test.TestRun7]..." + assert ISSUE_TYPE_LIST in grep_rrdlogs(ISSUE_TYPE_LIST) + + CHECKING_DYNAMIC = "Checking if Issue marked inDynamic..." + assert CHECKING_DYNAMIC in grep_rrdlogs(CHECKING_DYNAMIC) + + READING_JSON_CONFIG = "Reading json config file /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert READING_JSON_CONFIG in grep_rrdlogs(READING_JSON_CONFIG) + + JSON_PARSE_SUCCESS = "Reading json file Success, Parsing the Content..." + assert JSON_PARSE_SUCCESS in grep_rrdlogs(JSON_PARSE_SUCCESS) + + DYNAMIC_JSON_PARSE_FAILED = "Dynamic JSON Parse/Read failed... /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert DYNAMIC_JSON_PARSE_FAILED in grep_rrdlogs(DYNAMIC_JSON_PARSE_FAILED) + + #remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd() +