From 821b155a9bac598c2a49e4c707694fa704e6f589 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 1 Jul 2025 13:12:20 +0530 Subject: [PATCH 01/25] Update configure.ac --- configure.ac | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/configure.ac b/configure.ac index 6a87226c1..aacc9e311 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], From d3ce9482e09ec473341d6516672dccbf19e61968 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 1 Jul 2025 13:13:27 +0530 Subject: [PATCH 02/25] Update cov_build.sh --- cov_build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cov_build.sh b/cov_build.sh index 2c2e17d22..ec7c0f575 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -78,6 +78,6 @@ 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/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 From 52d193e15852916f61655950aab0258531c2e266 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 1 Jul 2025 13:15:44 +0530 Subject: [PATCH 03/25] Update rrdInterface.c --- src/rrdInterface.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/rrdInterface.c b/src/rrdInterface.c index 0aea9b612..be07e2d75 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) @@ -318,15 +326,14 @@ void _remoteDebuggerEventHandler(rbusHandle_t handle, rbusEvent_t const* event, return; } - int len = strlen(rbusValue_GetString(value, NULL))+1; + int len = strlen(rbusValue_GetString(value, NULL)); dataMsg = (char *) calloc(1, len); if(!dataMsg) { RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: Memory Allocation Failed for %s \n", __FUNCTION__, __LINE__, rbusValue_ToString(value, NULL, 0)); return; } - strncpy(dataMsg, rbusValue_GetString(value, NULL), len-1); - dataMsg[len-1]='\0'; + strncpy(dataMsg, rbusValue_GetString(value, NULL), len); if (dataMsg[0] == '\0' || len <= 0 ) { RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: Message Received is empty, Exit Processing!!! \n", __FUNCTION__, __LINE__); @@ -431,4 +438,3 @@ int RRD_unsubscribe() #endif return ret; } - From 7a5c935b50b8d295e3c1d7fa8c2e7e3cae51bf68 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 1 Jul 2025 13:18:08 +0530 Subject: [PATCH 04/25] Update rrdInterface.c --- src/rrdInterface.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rrdInterface.c b/src/rrdInterface.c index be07e2d75..664530e98 100644 --- a/src/rrdInterface.c +++ b/src/rrdInterface.c @@ -326,14 +326,15 @@ void _remoteDebuggerEventHandler(rbusHandle_t handle, rbusEvent_t const* event, return; } - int len = strlen(rbusValue_GetString(value, NULL)); + int len = strlen(rbusValue_GetString(value, NULL))+1; dataMsg = (char *) calloc(1, len); if(!dataMsg) { RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: Memory Allocation Failed for %s \n", __FUNCTION__, __LINE__, rbusValue_ToString(value, NULL, 0)); return; } - strncpy(dataMsg, rbusValue_GetString(value, NULL), len); + strncpy(dataMsg, rbusValue_GetString(value, NULL), len-1); + dataMsg[len-1]='\0'; if (dataMsg[0] == '\0' || len <= 0 ) { RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: Message Received is empty, Exit Processing!!! \n", __FUNCTION__, __LINE__); From a20eacb387356d8eaeaf4affc92727497be45321 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 1 Jul 2025 13:53:37 +0530 Subject: [PATCH 05/25] Update create_json.sh --- test/functional-tests/tests/create_json.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/functional-tests/tests/create_json.sh b/test/functional-tests/tests/create_json.sh index 3c71b688c..436996d8d 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/ From cfe25fa214284dcfe730f5783df9fc0321844233 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 1 Jul 2025 13:55:06 +0530 Subject: [PATCH 06/25] Create test_append.py --- test/functional-tests/tests/test_append.py | 134 +++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 test/functional-tests/tests/test_append.py diff --git a/test/functional-tests/tests/test_append.py b/test/functional-tests/tests/test_append.py new file mode 100644 index 000000000..72e28e0f1 --- /dev/null +++ b/test/functional-tests/tests/test_append.py @@ -0,0 +1,134 @@ +import json +from helper_functions import * + +# Path to the existing JSON file +file_path = "/etc/rrd/remote_debugger.json" + +# Read the existing JSON data +with open(file_path, "r") as json_file: + data = json.load(json_file) + +# New entry to add +new_entry = { + "Test": { + "TestRun4": { + "Commands": "cat /version.txt;cat /tmp/.deviceDetails.cache", + "Timeout": 10 + } + } +} + +# Update the JSON data with the new entry +data.update(new_entry) + +# Write the updated data back to the JSON file +with open(file_path, "w") as json_file: + json.dump(data, json_file, indent=4) + +def test_check_remote_debugger_config_file(): + config_file_path = JSON_FILE + assert check_file_exists(config_file_path), f"Configuration file '{config_file_path}' does not exist." + +def test_check_rrd_directory_exists(): + dir_path = OUTPUT_DIR + assert check_directory_exists(dir_path), f"Directory '{dir_path}' does not exist." + +def test_check_dynamic_config_file(): + config_file_path = APPEND_JSON_FILE + assert check_file_exists(config_file_path), f"Configuration file '{config_file_path}' does not exist." + +def test_check_dynamic_directory_exists(): + dir_path = DYNAMIC_DIR + assert check_directory_exists(dir_path), f"Directory '{dir_path}' does not exist." + +def test_check_and_start_remotedebugger(): + kill_rrd() + remove_logfile() + test_check_dynamic_directory_exists() + test_check_dynamic_config_file() + print("Starting remotedebugger process") + command_to_start = "nohup /usr/local/bin/remotedebugger > /dev/null 2>&1 &" + run_shell_silent(command_to_start) + command_to_get_pid = "pidof remotedebugger" + pid = run_shell_command(command_to_get_pid) + assert pid != "", "remotedebugger process did not start" + +def reset_issuetype_rfc(): + command = 'rbuscli set Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType string ""' + result = subprocess.run(command, shell=True, capture_output=True, text=True) + assert result.returncode == 0 + +def test_remote_debugger_trigger_event(): + APPEND_STRING1 = "Test.TestRun4_apnd" + reset_issuetype_rfc() + sleep(10) + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', + 'string', APPEND_STRING1 + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + + sleep(15) + + QUERY_MSG = "Received event for RRD_SET_ISSUE_EVENT" + assert QUERY_MSG in grep_rrdlogs(QUERY_MSG) + + MSG_SEND = "SUCCESS: Message sending Done" + sleep(2) + assert MSG_SEND in grep_rrdlogs(MSG_SEND) + + MSG_RECEIVE = "SUCCESS: Message Reception Done" + sleep(2) + assert MSG_RECEIVE in grep_rrdlogs(MSG_RECEIVE) + +def test_check_issue_in_dynamic_profile(): + APPEND_MSG = "Received append request to process static and dynamic profiles" + assert APPEND_MSG in grep_rrdlogs(APPEND_MSG) + + DYNAMIC_JSONFILE = "Reading json config file /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert DYNAMIC_JSONFILE in grep_rrdlogs(DYNAMIC_JSONFILE) + + JSON_READ_SUCCESS = "Reading json file Success" + assert JSON_READ_SUCCESS in grep_rrdlogs(JSON_READ_SUCCESS) + + JSON_PARSE_SUCCESS = "Json File parse Success" + assert JSON_PARSE_SUCCESS in grep_rrdlogs(JSON_PARSE_SUCCESS) + + JSON_SUCCESS = "Dynamic Profile Parse And Read Success... /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert JSON_SUCCESS in grep_rrdlogs(JSON_SUCCESS) + + CHECKING_DYNAMIC_JSON = "Check if Issue in Parsed Dynamic JSON... /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert CHECKING_DYNAMIC_JSON in grep_rrdlogs(CHECKING_DYNAMIC_JSON) + + STATIC_READ = "Reading static profile command info..." + assert STATIC_READ in grep_rrdlogs(STATIC_READ) + + READING_JSON = "Start Reading JSON File... /etc/rrd/remote_debugger.json" + assert READING_JSON in grep_rrdlogs(READING_JSON) + + JSON_STATIC_SUCCESS = "Reading json file Success, Parsing the Content..." + assert JSON_STATIC_SUCCESS in grep_rrdlogs(JSON_STATIC_SUCCESS) + + JSON_PARSE_STATIC_SUCCESS = "Json File parse Success... /etc/rrd/remote_debugger.json" + assert JSON_PARSE_STATIC_SUCCESS in grep_rrdlogs(JSON_PARSE_STATIC_SUCCESS) + + SUCCESS_STATIC = "Static Profile Parse And Read Success... /etc/rrd/remote_debugger.json" + assert SUCCESS_STATIC in grep_rrdlogs(SUCCESS_STATIC) + + CHECKING_STATIC_JSON = "Check if Issue in Parsed Static JSON... /etc/rrd/remote_debugger.json" + assert CHECKING_STATIC_JSON in grep_rrdlogs(CHECKING_STATIC_JSON) + + READ_COMPLETE_STATIC = "Read complete for Static Profile: RFCValue: Test.TestRun4, Command: " + assert READ_COMPLETE_STATIC in grep_rrdlogs(READ_COMPLETE_STATIC) + + APPEND_UPDATE = "Updated command after append from dynamic and static profile: " + assert APPEND_UPDATE in grep_rrdlogs(APPEND_UPDATE) + + EXECUTE_SERVICE = "Executing Commands in Runtime Service..." + assert EXECUTE_SERVICE in grep_rrdlogs(EXECUTE_SERVICE) + + remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd() From acae0a3e3f0f4fb35f731d9ebff2af7a590583e2 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 1 Jul 2025 13:56:06 +0530 Subject: [PATCH 07/25] Update test_rrd_dynamic_profile_missing_report.py --- ...test_rrd_dynamic_profile_missing_report.py | 75 +++++++++++++++++-- 1 file changed, 69 insertions(+), 6 deletions(-) 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 5d8379204..151b2b891 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(): + MISSING_STRING1 = "Test.TestRun5" reset_issuetype_rfc() sleep(10) command = [ 'rbuscli', 'set', 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', - 'string', MISSING_STRING + 'string', MISSING_STRING1 ] 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,68 @@ 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_RFC.Feature.RDKRemoteDebugger.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() From a2f991fdbbc2a7a767b5bc0c0aeb87ee758af84b Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 1 Jul 2025 13:57:30 +0530 Subject: [PATCH 08/25] Create test_rrd_negative.py --- .../tests/test_rrd_negative.py | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 test/functional-tests/tests/test_rrd_negative.py 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 000000000..0fa927ed5 --- /dev/null +++ b/test/functional-tests/tests/test_rrd_negative.py @@ -0,0 +1,149 @@ +########################################################################## +# 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_RFC.Feature.RDKRemoteDebugger.DownloadStatus', + 'bool', 'true' + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + + RDM_DOWNLOAD_EVENT = "Received event for RDM_DOWNLOAD_EVENT Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.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() From 9a5be23ae2d6f5da727612fdf01fd2aec74e41de Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 1 Jul 2025 13:59:33 +0530 Subject: [PATCH 09/25] Update run_l2.sh --- run_l2.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run_l2.sh b/run_l2.sh index 2da980290..871129ce2 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -59,8 +59,11 @@ rm -rf /tmp/rrd/* rm -rf /opt/logs/remotedebugger.log* # 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 +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 From 03953d726763f6b8434443b0b722cba805f14026 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 1 Jul 2025 22:27:18 +0530 Subject: [PATCH 10/25] Update test_rrd_negative.py --- test/functional-tests/tests/test_rrd_negative.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/functional-tests/tests/test_rrd_negative.py b/test/functional-tests/tests/test_rrd_negative.py index 0fa927ed5..db79616ba 100644 --- a/test/functional-tests/tests/test_rrd_negative.py +++ b/test/functional-tests/tests/test_rrd_negative.py @@ -114,19 +114,19 @@ def test_rdm_trigger_event(): def test_rdm_download_event(): command = [ 'rbuscli', 'set', - 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.DownloadStatus', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.DownloadStatus', 'bool', 'true' ] result = subprocess.run(command, capture_output=True, text=True) assert result.returncode == 0 - RDM_DOWNLOAD_EVENT = "Received event for RDM_DOWNLOAD_EVENT Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.DownloadStatus" + 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!" + MESSAGE_SUCCESS = "SUCCESS: Message sending Done, ID=36 MSG=Test.TestRun7 Size=13 Type=1 AppendMode=0!" assert MESSAGE_SUCCESS in grep_rrdlogs(MESSAGE_SUCCESS) ISSUE_TYPE_LIST = "IssueType List [Test.TestRun7]..." From 487a01e2ea6fe3a132e8105bfa8832badb7642b9 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 1 Jul 2025 23:10:14 +0530 Subject: [PATCH 11/25] Update run_l2.sh --- run_l2.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_l2.sh b/run_l2.sh index 871129ce2..81c3812e5 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -30,7 +30,7 @@ mkdir -p "$LIB_DIR" mkdir -p /media/apps/RDK-RRD-Test/etc/rrd touch /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json - +/usr/local/bin/tr69hostif -c /etc/mgrlist.conf -d /etc/debug.ini -p 10999 -s 11999 apt-get remove systemd apt-get update && apt-get install -y tcpdump From 3dbf1ec5b64995448e791b77a475546670033bd2 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 1 Jul 2025 23:15:34 +0530 Subject: [PATCH 12/25] Update run_l2.sh --- run_l2.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_l2.sh b/run_l2.sh index 81c3812e5..48cd08b29 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -30,7 +30,7 @@ mkdir -p "$LIB_DIR" mkdir -p /media/apps/RDK-RRD-Test/etc/rrd touch /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json -/usr/local/bin/tr69hostif -c /etc/mgrlist.conf -d /etc/debug.ini -p 10999 -s 11999 +/usr/local/bin/tr69hostif -c /etc/mgrlist.conf -d /etc/debug.ini -p 10999 -s 11999 & apt-get remove systemd apt-get update && apt-get install -y tcpdump From 634ddb18721f0efdc6388b7a22d6c81e98666207 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 1 Jul 2025 23:32:24 +0530 Subject: [PATCH 13/25] Update run_l2.sh --- run_l2.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/run_l2.sh b/run_l2.sh index 48cd08b29..92f3dc564 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -30,7 +30,9 @@ mkdir -p "$LIB_DIR" mkdir -p /media/apps/RDK-RRD-Test/etc/rrd touch /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json -/usr/local/bin/tr69hostif -c /etc/mgrlist.conf -d /etc/debug.ini -p 10999 -s 11999 & +cd /usr/tr69hostif +sh run_l2.sh +cd - apt-get remove systemd apt-get update && apt-get install -y tcpdump From 79dfb61316ca0327830e1383cbdea9afa002f369 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Mon, 28 Jul 2025 13:30:49 +0530 Subject: [PATCH 14/25] Update test_rrd_negative.py --- test/functional-tests/tests/test_rrd_negative.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/functional-tests/tests/test_rrd_negative.py b/test/functional-tests/tests/test_rrd_negative.py index db79616ba..4c4c1a099 100644 --- a/test/functional-tests/tests/test_rrd_negative.py +++ b/test/functional-tests/tests/test_rrd_negative.py @@ -119,6 +119,7 @@ def test_rdm_download_event(): ] 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) From 735f7c6c3926cf946fe0db9cd761179b2207915f Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Mon, 28 Jul 2025 13:35:51 +0530 Subject: [PATCH 15/25] Update test_rrd_negative.py --- test/functional-tests/tests/test_rrd_negative.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional-tests/tests/test_rrd_negative.py b/test/functional-tests/tests/test_rrd_negative.py index 4c4c1a099..c72850fbf 100644 --- a/test/functional-tests/tests/test_rrd_negative.py +++ b/test/functional-tests/tests/test_rrd_negative.py @@ -127,7 +127,7 @@ def test_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=36 MSG=Test.TestRun7 Size=13 Type=1 AppendMode=0!" + 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]..." From 9cfc5688222e1bd69d754cc75285844cd08f4c2c Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Mon, 28 Jul 2025 13:43:19 +0530 Subject: [PATCH 16/25] Update test_rrd_dynamic_profile_missing_report.py --- .../tests/test_rrd_dynamic_profile_missing_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 151b2b891..2b4bf528f 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 @@ -124,7 +124,7 @@ def test_rdm_trigger_event(): def test_rdm_rrd_trigger_event(): command = [ 'rbuscli', 'set', - 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.DownloadStatus', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.DownloadStatus', 'bool', 'true' ] result = subprocess.run(command, capture_output=True, text=True) From bc1f695c49bc8063588b98e443fcadedeaf9b3ab Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 7 Aug 2025 18:03:16 +0530 Subject: [PATCH 17/25] Update run_l2.sh --- run_l2.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/run_l2.sh b/run_l2.sh index 92f3dc564..d0ab2c554 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -30,9 +30,6 @@ mkdir -p "$LIB_DIR" mkdir -p /media/apps/RDK-RRD-Test/etc/rrd touch /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json -cd /usr/tr69hostif -sh run_l2.sh -cd - apt-get remove systemd apt-get update && apt-get install -y tcpdump From c0013039b9ccc3b876a23f299a257ca90041b0ce Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Sun, 10 Aug 2025 20:18:20 +0530 Subject: [PATCH 18/25] Create pwrMgr.h --- src/pwrMgr.h | 356 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 356 insertions(+) create mode 100644 src/pwrMgr.h diff --git a/src/pwrMgr.h b/src/pwrMgr.h new file mode 100644 index 000000000..ddc93da91 --- /dev/null +++ b/src/pwrMgr.h @@ -0,0 +1,356 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2016 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +/** + * @file pwrMgr.h + * + * @brief IARM-Bus Power Manager Public API. + * + * This API defines the structures and functions for the IARM-Bus Power Manager interface. + */ + +/** +* @defgroup iarmmgrs +* @{ +* @defgroup hal +* @{ +**/ + +#ifndef _IARM_BUS_PWRMGR_H +#define _IARM_BUS_PWRMGR_H + +#include "libIARM.h" +#include "libIBusDaemon.h" + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @addtogroup IARM_PLAT_POWER_API + * @{ + */ + +#define IARM_BUS_PWRMGR_NAME "PWRMgr" /*!< Power manager IARM bus name */ + +/** + * @brief Represents the published Events from PWR Manager + */ +typedef enum _PWRMgr_EventId_t { + IARM_BUS_PWRMGR_EVENT_MODECHANGED = 0, /*!< Event to notify power mode change */ + IARM_BUS_PWRMGR_EVENT_DEEPSLEEP_TIMEOUT, /*!< Event to notify deepsleep timeout */ + IARM_BUS_PWRMGR_EVENT_RESET_SEQUENCE, /*!< Event to notify progress of reset key sequence*/ + IARM_BUS_PWRMGR_EVENT_REBOOTING, /*!< Event to notify that the device is about to reboot.*/ + IARM_BUS_PWRMGR_EVENT_THERMAL_MODECHANGED, /*!< Event to notify temperature level change */ + IARM_BUS_PWRMGR_EVENT_WAREHOUSEOPS_STATUSCHANGED, /*!< Event to notify ware house operation status changed */ + IARM_BUS_PWRMGR_EVENT_NETWORK_STANDBYMODECHANGED, /*!< Event to notify that the network standby mode changed.*/ + IARM_BUS_PWRMGR_EVENT_MAX, /*!< Max event id from this module */ +} IARM_Bus_PWRMgr_EventId_t; + + +/** + * @brief Enumerator which represents the possible temeperature states + */ +typedef enum _IARM_Bus_PWRMgr_ThermalState_t{ + IARM_BUS_PWRMGR_TEMPERATURE_NORMAL = 0, /* Temp is within normal operating range */ + IARM_BUS_PWRMGR_TEMPERATURE_HIGH, /* Temp is high, but just a warning as device can still operate */ + IARM_BUS_PWRMGR_TEMPERATURE_CRITICAL /* Temp is critical, should trigger a thermal reset */ +} IARM_Bus_PWRMgr_ThermalState_t; + +/** + * @brief Enumerator which represents the possible warehouse ops + */ +typedef enum _IARM_Bus_PWRMgr_WareHouseOps_t{ + IARM_BUS_PWRMGR_WAREHOUSE_RESET = 0, /* warehouse reset */ + IARM_BUS_PWRMGR_WAREHOUSE_CLEAR, /* warehouse clear*/ +} IARM_Bus_PWRMgr_WareHouseOps_t; + +/** + * @brief Enumerator which represents the possible warehouse ops + */ +typedef enum _IARM_Bus_PWRMgr_WareHouseOpsStatus_t{ + IARM_BUS_PWRMGR_WAREHOUSE_COMPLETED = 0, /* warehouse operation completed sucessfully */ + IARM_BUS_PWRMGR_WAREHOUSE_INPROGRESS, /* warehouse operation in progress*/ + IARM_BUS_PWRMGR_WAREHOUSE_FAILED, /* warehouse operation failed.*/ +} IARM_Bus_PWRMgr_WareHouseOpsStatus_t; + +/** + * @brief Enumerator which represents the possible wakeup sources + */ +typedef enum _WakeupSrcType_t { + WAKEUPSRC_VOICE = 0, + WAKEUPSRC_PRESENCE_DETECTION, + WAKEUPSRC_BLUETOOTH, + WAKEUPSRC_WIFI, + WAKEUPSRC_IR, + WAKEUPSRC_POWER_KEY, + WAKEUPSRC_TIMER, + WAKEUPSRC_CEC, + WAKEUPSRC_LAN, + WAKEUPSRC_MAX +} WakeupSrcType_t; + +/** + * @brief Structure which holds the event data. + */ +typedef struct _PWRMgr_EventData_t { + union { + struct _MODE_DATA{ + /* Declare Event Data structure for PWRMGR_EVENT_DUMMY0 */ + IARM_Bus_PowerState_t curState; /*!< Power manager current power state */ + IARM_Bus_PowerState_t newState; /*!< Power manager new power state */ + #ifdef ENABLE_DEEP_SLEEP + uint32_t deep_sleep_timeout; + #endif + bool nwStandbyMode; + } state; + #ifdef ENABLE_THERMAL_PROTECTION + struct _THERM_DATA{ + IARM_Bus_PWRMgr_ThermalState_t curLevel; + IARM_Bus_PWRMgr_ThermalState_t newLevel; + float curTemperature; + } therm; + #endif + bool bNetworkStandbyMode; + int32_t reset_sequence_progress; + } data; +}IARM_Bus_PWRMgr_EventData_t; + +/** + * @brief Structure which holds the Deep sleep timeout value. + */ +typedef struct _IARM_BUS_PWRMgr_DeepSleepTimeout_EventData_t { + unsigned int timeout; /*!< Timeout for deep sleep in seconds*/ +} IARM_BUS_PWRMgr_DeepSleepTimeout_EventData_t; + +/** + * @brief Structure which holds warehouse opn status value. + */ +typedef struct _IARM_BUS_PWRMgr_WareHouseOpn_EventData_t { + IARM_Bus_PWRMgr_WareHouseOps_t wareHouseOpn; /*!< WareHouse operation*/ + IARM_Bus_PWRMgr_WareHouseOpsStatus_t status; /*!< WareHouse operation status*/ +} IARM_BUS_PWRMgr_WareHouseOpn_EventData_t; + +/** + * Declare RPC API names and their arguments + */ +#define IARM_BUS_PWRMGR_API_SetPowerState "SetPowerState" /*!< Sets the powerstate of the device*/ + +/** + * @brief Structure which holds the new powerstate to be set to the device. + */ +typedef struct _IARM_Bus_PWRMgr_SetPowerState_Param_t { + IARM_Bus_PowerState_t newState; /*!< [in] New powerstate to be set */ + int keyCode; /*!< [in] Key code for the last key Pressed */ +} IARM_Bus_PWRMgr_SetPowerState_Param_t; + +#define IARM_BUS_PWRMGR_API_GetPowerState "GetPowerState" /*!< Retrives current power state of the box*/ + +/** + * @brief Structure which holds the current power state of the CPE. + */ +typedef struct _IARM_Bus_PWRMgr_GetPowerState_Param_t { + IARM_Bus_PowerState_t curState; /*!< Current powerstate of the box*/ + IARM_Bus_PowerState_t prevState; /*!< Current powerstate of the box*/ +} IARM_Bus_PWRMgr_GetPowerState_Param_t; + +#define IARM_BUS_PWRMGR_API_WareHouseReset "WareHouseReset" /*!< Reset the box to warehouse state*/ + +/** + * @brief Structure which holds the ware house reset time. + */ +typedef struct _IARM_Bus_PWRMgr_WareHouseReset_Param_t { + bool suppressReboot; /*!< STB should not be rebooted */ +} IARM_Bus_PWRMgr_WareHouseReset_Param_t; + +#define IARM_BUS_PWRMGR_API_WareHouseClear "WarehouseClear" /*!< */ + +#define IARM_BUS_PWRMGR_API_ColdFactoryReset "ColdFactoryReset" /*!< Reset the box to cold factory state*/ +#define IARM_BUS_PWRMGR_API_FactoryReset "FactoryReset" /*!< Reset the box to factory state*/ +#define IARM_BUS_PWRMGR_API_UserFactoryReset "UserFactoryReset" /*!< Reset the box to user factory state*/ + +#define IARM_BUS_PWRMGR_API_SetDeepSleepTimeOut "SetDeepSleepTimeOut" /*!< Sets the timeout for deep sleep*/ + +/** + * @brief Structure which holds the timeout value to set for Deep sleep. + */ +typedef struct _IARM_Bus_PWRMgr_SetDeepSleepTimeOut_Param_t { + unsigned int timeout; /*!< Timeout for deep sleep in seconds*/ +} IARM_Bus_PWRMgr_SetDeepSleepTimeOut_Param_t; + +#define IARM_BUS_PWRMGR_API_SetSleepTimer "SetSleepTimer" /*!< Sets sleep timer state and timeout*/ +#define IARM_BUS_PWRMGR_API_GetSleepTimer "GetSleepTimer" /*!< Gets sleep timer state and remaining */ + +/** + * @brief Structure which holds the sleep timer information. + */ +typedef struct _IARM_Bus_PWRMgr_SleepTimer_Param_t { + double time; /*!< timer duration*/ + int start; /*!< timer state, started=1 or stopped=0*/ +} IARM_Bus_PWRMgr_SleepTimer_Param_t; + +#ifdef ENABLE_THERMAL_PROTECTION + +/** + * @brief Structure which holds the data associated with thermal level. + */ +typedef struct _IARM_Bus_PWRMgr_GetThermalState_Param_t{ + IARM_Bus_PWRMgr_ThermalState_t curLevel; /*!< Current Thermal level */ + float curTemperature; /* !< Current temperature value */ +} IARM_Bus_PWRMgr_GetThermalState_Param_t; + +#define IARM_BUS_PWRMGR_API_GetThermalState "GetThermalState" /*!< Retrieves current thermal level of the box*/ + +/** + * @brief Structure which holds the thermal threshold value to be set to the device. + */ +typedef struct _IARM_Bus_PWRMgr_SetTempThresholds_Param_t{ + float tempHigh; /*!< New threshold at which TEMPERATURE_HIGH will be reported */ + float tempCritical; /*!< New threshold at which TEMPERATURE_CRITICAL will be reported */ +} IARM_Bus_PWRMgr_SetTempThresholds_Param_t; + +#define IARM_BUS_PWRMGR_API_SetTemperatureThresholds "SetTemperatureThresholds" /*!< Sets the thermal threshold for the device*/ + + +/** + * @brief Structure which holds the data associated with current temperature threshold. + */ +typedef struct _IARM_Bus_PWRMgr_GetTempThresholds_Param_t{ + float tempHigh; /*!< New threshold at which TEMPERATURE_HIGH will be reported */ + float tempCritical; /*!< New threshold at which TEMPERATURE_CRITICAL will be reported */ +} IARM_Bus_PWRMgr_GetTempThresholds_Param_t; + +#define IARM_BUS_PWRMGR_API_GetTemperatureThresholds "GetTemperatureThresholds" /*!< Gets the thermal threshold for the device*/ + +/** + * @brief Structure which holds the grace interval value to be set to the device. + */ +typedef struct _IARM_Bus_PWRMgr_SetOvertempGraceInterval_Param_t{ + int graceInterval; /*!< New over teamparature grace interval */ +} IARM_Bus_PWRMgr_SetOvertempGraceInterval_Param_t; + +#define IARM_BUS_PWRMGR_API_SetOvertempGraceInterval "SetOvertempGraceInterval" /*!< Sets the over temparature grace interval for the device*/ + +/** + * @brief Structure which holds the data associated with current over temparature grace interval. + */ +typedef struct _IARM_Bus_PWRMgr_GetOvertempGraceInterval_Param_t{ + int graceInterval; /*!< New over temparature grace interval */ +} IARM_Bus_PWRMgr_GetOvertempGraceInterval_Param_t; + +#define IARM_BUS_PWRMGR_API_GetOvertempGraceInterval "GetOvertempGraceInterval" /*!< Gets the over temparature grace interval for the device*/ + +/** @brief This function will be used to initialize thermal protection thread */ +extern void initializeThermalProtection(); +#endif //ENABLE_THERMAL_PROTECTION + +/** + * @brief Structure which holds the setting for whether video port is enabled in standby. + */ + +#define PWRMGR_MAX_VIDEO_PORT_NAME_LENGTH 16 +typedef struct _IARM_Bus_PWRMgr_StandbyVideoState_Param_t{ + char port[PWRMGR_MAX_VIDEO_PORT_NAME_LENGTH]; + int isEnabled; + int result; +} IARM_Bus_PWRMgr_StandbyVideoState_Param_t; +#define IARM_BUS_PWRMGR_API_SetStandbyVideoState "SetStandbyVideoState" +#define IARM_BUS_PWRMGR_API_GetStandbyVideoState "GetStandbyVideoState" + +#define IARM_BUS_PWRMGR_API_SetNetworkStandbyMode "SetNetworkStandbyMode" +#define IARM_BUS_PWRMGR_API_GetNetworkStandbyMode "GetNetworkStandbyMode" +typedef struct _IARM_Bus_PWRMgr_NetworkStandbyMode_Param_t { + bool bStandbyMode; /*!< Standby mode to set and get*/ +} IARM_Bus_PWRMgr_NetworkStandbyMode_Param_t; + +#define MAX_PWR_STATE_BEF_REBOOR_STR_LEN (32) +#define IARM_BUS_PWRMGR_API_GetPowerStateBeforeReboot "GetPowerStateBeforeReboot" /*!< Retrives power state before reboot*/ +/** + * @brief Structure which holds the power state before reboot of the CPE. + */ +typedef struct _IARM_Bus_PWRMgr_GetPowerStateBeforeReboot_Param_t { + char powerStateBeforeReboot [MAX_PWR_STATE_BEF_REBOOR_STR_LEN]; /*!< Powerstate before reboot of the box*/ +} IARM_Bus_PWRMgr_GetPowerStateBeforeReboot_Param_t; + + +#define PWRMGR_MAX_REBOOT_REASON_LENGTH 100 +#define PWRMGR_REBOOT_REASON_MAINTENANCE "MAINTENANCE_REBOOT" +/** + * @brief Structure to pass reboot reason argument with the reboot call. + */ +typedef struct _IARM_Bus_PWRMgr_RebootParam_t{ + char reboot_reason_custom[PWRMGR_MAX_REBOOT_REASON_LENGTH]; + char reboot_reason_other[PWRMGR_MAX_REBOOT_REASON_LENGTH]; + char requestor[PWRMGR_MAX_REBOOT_REASON_LENGTH]; +} IARM_Bus_PWRMgr_RebootParam_t; +#define IARM_BUS_PWRMGR_API_Reboot "performReboot" /*!< Reboots device.*/ +#ifdef ENABLE_SET_WAKEUP_SRC_CONFIG //ToDo Remove aftre rdkservices merge. +/** + * @brief Structure which holds the wakeup source type and the value to be set. + */ +typedef struct _IARM_Bus_PWRMgr_SetWakeupSrcConfig_Param_t{ + WakeupSrcType_t srcType; + bool config; +} IARM_Bus_PWRMgr_SetWakeupSrcConfig_Param_t; +#endif +/** + * @brief Structure which holds the wakeup source type and the value to be set and the power state. + */ +typedef struct _IARM_Bus_PWRMgr_WakeupSrcConfig_Param_t{ + uint32_t pwrMode; + uint32_t srcType; + uint32_t config; +} IARM_Bus_PWRMgr_WakeupSrcConfig_Param_t; +#define IARM_BUS_PWRMGR_API_SetWakeupSrcConfig "setWakeupSrcConfig" /*!< sets wakup configuration*/ +#define IARM_BUS_PWRMGR_API_GetWakeupSrcConfig "getWakeupSrcConfig" /*!< gets wakup configuration*/ + +/** + * Declare RPC API names and their arguments + */ +#define IARM_BUS_PWRMGR_API_handleDeepsleepTimeoutWakeup "handleDeepsleepTimeoutWakeup" /*!< Invoke when deepsleep timeout occurs*/ + + +#define IARM_BUS_DEEPSLEEPMGR_NAME "DEEPSLEEPMgr" /*!< Power manager IARM bus name */ + +typedef enum _DeepSleepStatus_t { + DeepSleepStatus_Failed = -1, /*!< Deepsleep operation failed*/ + DeepSleepStatus_NotStarted = 0, /*!< Deepsleep operation not started*/ + DeepSleepStatus_InProgress, /*!< Deepsleep operation in progress */ + DeepSleepStatus_Completed, /*!< Deepsleep operation completed */ +} DeepSleepStatus_t; + +/** Sets the timer for deep sleep ,timer is set explicitly by client of deep sleep manager, + * then the STB will accept the timer value, and go to sleep when sleep timer is expired. + */ +#define IARM_BUS_PWRMGR_API_GetLastWakeupReason "GetLastWakeupReason" +#define IARM_BUS_PWRMGR_API_GetLastWakeupKeyCode "GetLastWakeupKeycode" + +#ifdef __cplusplus +} +#endif +#endif + +/** @} */ // End of Doxygen Tag + +/** @} */ +/** @} */ From 3687a6fba8182b95f810c6a98793c0294e231a6d Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Sun, 10 Aug 2025 20:20:54 +0530 Subject: [PATCH 19/25] Update cov_build.sh --- cov_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cov_build.sh b/cov_build.sh index ec7c0f575..40038567b 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -64,7 +64,7 @@ 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 From ca91bc2cc4769a1eda4cebd901b0b093b9fa2b3f Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Sun, 10 Aug 2025 21:56:39 +0530 Subject: [PATCH 20/25] Create test_rrd_dynamic_with_download_harmful.py --- .../test_rrd_dynamic_with_download_harmful.py | 189 ++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 test/functional-tests/tests/test_rrd_dynamic_with_download_harmful.py 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 000000000..eaaa99f8f --- /dev/null +++ b/test/functional-tests/tests/test_rrd_dynamic_with_download_harmful.py @@ -0,0 +1,189 @@ +########################################################################## +# 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() From 11ecaafdf011d8a04d2e680b154f11f57360814a Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Sun, 10 Aug 2025 22:01:10 +0530 Subject: [PATCH 21/25] Update run_l2.sh --- run_l2.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run_l2.sh b/run_l2.sh index d0ab2c554..ef7c0fe23 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -60,6 +60,9 @@ rm -rf /opt/logs/remotedebugger.log* # 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 +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 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/ From c84940e094185f6e48af28ae29c1a9c2f18398f3 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 15 Aug 2025 11:58:35 +0530 Subject: [PATCH 22/25] Create test_category.py --- test/functional-tests/tests/test_category.py | 181 +++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 test/functional-tests/tests/test_category.py diff --git a/test/functional-tests/tests/test_category.py b/test/functional-tests/tests/test_category.py new file mode 100644 index 000000000..965cbd9c3 --- /dev/null +++ b/test/functional-tests/tests/test_category.py @@ -0,0 +1,181 @@ +########################################################################## +# 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_TEST = "Test" + reset_issuetype_rfc() + sleep(10) + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', + 'string', MISSING_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) + + remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd() From 7bf2b7c7ae55e5ab7dca39aa5ebda00f22008108 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 15 Aug 2025 12:00:39 +0530 Subject: [PATCH 23/25] Update run_l2.sh --- run_l2.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run_l2.sh b/run_l2.sh index ef7c0fe23..23c0fd1a2 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -63,6 +63,9 @@ pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_dy 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/ From 2d4f36ed8d99224725cd6db06490afc9823c29ea Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 15 Aug 2025 13:57:51 +0530 Subject: [PATCH 24/25] Update test_category.py --- test/functional-tests/tests/test_category.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/functional-tests/tests/test_category.py b/test/functional-tests/tests/test_category.py index 965cbd9c3..6a8151328 100644 --- a/test/functional-tests/tests/test_category.py +++ b/test/functional-tests/tests/test_category.py @@ -45,13 +45,13 @@ def reset_issuetype_rfc(): assert result.returncode == 0 def test_remote_debugger_trigger_event(): - MISSING_STRING_TEST = "Test" + STRING_TEST = "Test" reset_issuetype_rfc() - sleep(10) + #sleep(10) command = [ 'rbuscli', 'set', 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', - 'string', MISSING_STRING_TEST + 'string', STRING_TEST ] result = subprocess.run(command, capture_output=True, text=True) assert result.returncode == 0 @@ -176,6 +176,14 @@ def test_rdm_rrd_dwnld_status(): 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() From ffbc2cc3ce1990f38fdd7203fb724953d3fd3488 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 15 Aug 2025 14:07:01 +0530 Subject: [PATCH 25/25] Update test_category.py --- test/functional-tests/tests/test_category.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional-tests/tests/test_category.py b/test/functional-tests/tests/test_category.py index 6a8151328..e1c39166b 100644 --- a/test/functional-tests/tests/test_category.py +++ b/test/functional-tests/tests/test_category.py @@ -47,7 +47,7 @@ def reset_issuetype_rfc(): def test_remote_debugger_trigger_event(): STRING_TEST = "Test" reset_issuetype_rfc() - #sleep(10) + sleep(10) command = [ 'rbuscli', 'set', 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType',