Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cov_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fi
if [ ! -d tr69hostif ]; then
git clone https://github.com/rdkcentral/tr69hostif.git
fi
git clone https://github.com/rdkcentral/dcm-agent.git -b feature/logupload_copilot_lib
git clone https://github.com/rdkcentral/dcm-agent.git -b develop

cd dcm-agent
sh cov_build.sh
Expand Down
2 changes: 2 additions & 0 deletions run_l2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ mkdir -p "$LIB_DIR"
mkdir -p /media/apps/RDK-RRD-Test/etc/rrd

touch /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json
echo "AA:BB:CC:DD:EE:FF" >> /tmp/.estb_mac


apt-get remove systemd
apt-get update && apt-get install -y tcpdump
Expand Down
2 changes: 1 addition & 1 deletion src/rrd_archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ int rrd_archive_generate_filename(const char *mac, const char *issue_type, const
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s] Filename truncated\n", __FUNCTION__);
return -1;
}
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s] Generated filename: %s\n", __FUNCTION__, filename);
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s] Generated filename: %s\n", __FUNCTION__, filename);
return 0;
}

Expand Down
39 changes: 26 additions & 13 deletions src/uploadRRDLogs.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
/*
* uploadRRDLogs.c - Skeleton for C migration of uploadRRDLogs.sh
* If not stated otherwise in this file or this component's LICENSE file the

Check failure on line 2 in src/uploadRRDLogs.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'src/uploadRRDLogs.c' (Match: rdkb/components/opensource/ccsp/halinterface/rdkb/components/opensource/ccsp/halinterface/1, 15 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/halinterface/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: vlan_hal_emu.h)
* following copyright and licenses apply:

Check failure on line 3 in src/uploadRRDLogs.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'src/uploadRRDLogs.c' (Match: rdk/components/generic/wifi/rdk/components/generic/wifi/1d6340b, 20 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/wifi/+archive/1d6340bec4bf984e35de608e6f8a878f07dc3b4a.tar.gz, file: src/wifi_common_hal.c)
*
* This file is auto-generated following HLD and implementation instructions.
* Copyright 2018 RDK Management
*
* Modules: Main Orchestration, Config Manager, System Info, Log Processing, Archive, Upload, Logging
* See: .github/docs/uploadRRDLogs_HLD.md
*/

* Licensed under the Apache License, Version 2.0 (the "License");

Check failure on line 7 in src/uploadRRDLogs.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'GPL-2.0-only' license found in local file 'src/uploadRRDLogs.c' (Match: bluez/bluez/5.11, 16 lines, url: https://github.com/bluez/bluez/archive/refs/tags/5.11.tar.gz, file: android/hal-bluetooth.c)
* 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 <stdio.h>
#include <stdlib.h>
Expand All @@ -27,13 +36,13 @@

int rrd_upload_orchestrate(const char *upload_dir, const char *issue_type)
{
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Entry\n", __FUNCTION__);

// Validate input parameters
if (!upload_dir || !issue_type) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "%s: Invalid parameters\n", __FUNCTION__);
return 1;
}

RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Executing binary to upload Debug info of ISSUETYPE=%s\n", __FUNCTION__, issue_type);

// 2. Initialize logging subsystem
// Logging is initialized by RDK_LOGGER macros; no explicit init needed
Expand Down Expand Up @@ -61,6 +70,7 @@
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: MAC: %s, Timestamp: %s\n", __FUNCTION__, mac_addr, timestamp);

// 5. Validate and prepare log directory
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Checking %s size and contents\n", __FUNCTION__, upload_dir);
if (rrd_logproc_validate_source(upload_dir) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "%s: Invalid or empty upload directory: %s\n", __FUNCTION__, upload_dir);
return 6;
Expand All @@ -81,7 +91,7 @@

// 6.5. Handle LOGUPLOAD_ENABLE special case (matching shell script lines 128-131)
if (strcmp(issue_type_sanitized, "LOGUPLOAD_ENABLE") == 0) {
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Handling LOGUPLOAD_ENABLE - checking for live logs\n", __FUNCTION__);
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Check and upload live device logs for the issuetype\n", __FUNCTION__);
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message uses "issuetype" (all lowercase) which is inconsistent with other log messages that use "ISSUETYPE" or "issue_type". For consistency with the codebase style, this should be "issue type" (two words) or match the variable naming convention used elsewhere.

Suggested change
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Check and upload live device logs for the issuetype\n", __FUNCTION__);
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Check and upload live device logs for the issue type\n", __FUNCTION__);

Copilot uses AI. Check for mistakes.
if (rrd_logproc_handle_live_logs(upload_dir) != 0) {
RDK_LOG(RDK_LOG_WARN, LOG_REMDEBUG, "%s: Failed to handle live logs for LOGUPLOAD_ENABLE\n", __FUNCTION__);
}
Expand All @@ -97,30 +107,33 @@

// 8. Create archive in /tmp/rrd/ directory (matching shell script line 127)
const char *rrd_log_dir = "/tmp/rrd/";
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Creating %s tarfile from Debug Commands output\n", __FUNCTION__, archive_filename);
if (rrd_archive_create(upload_dir, rrd_log_dir, archive_filename) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "%s: Failed to create archive %s\n", __FUNCTION__, archive_filename);
return 10;
}
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Archive created: %s\n", __FUNCTION__, archive_filename);

// 9. Upload archive from /tmp/rrd/ directory
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Invoking uploadSTBLogs binary to upload %s file\n", __FUNCTION__, archive_filename);
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: uploadSTBLogs parameters - server: %s, protocol: %s, http_link: %s, file: %s\n",
__FUNCTION__, config.log_server, config.upload_protocol, config.http_upload_link, archive_filename);
if (rrd_upload_execute(config.log_server, config.upload_protocol, config.http_upload_link, rrd_log_dir, archive_filename, upload_dir) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "%s: Failed to upload archive\n", __FUNCTION__);
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "%s: RRD %s Debug Information Report upload Failed!!!\n", __FUNCTION__, issue_type_sanitized);
// Cleanup on failure (matching shell script lines 139-140)
char archive_fullpath[512];
snprintf(archive_fullpath, sizeof(archive_fullpath), "%s%s", rrd_log_dir, archive_filename);
rrd_archive_cleanup(archive_fullpath);
rrd_upload_cleanup_source_dir(upload_dir);
return 11;
}
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Archive uploaded successfully\n", __FUNCTION__);
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: RRD %s Debug Information Report upload Success\n", __FUNCTION__, issue_type_sanitized);

// 10. Cleanup archive and source directory (matching shell script line 143)
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Removing uploaded report %s\n", __FUNCTION__, archive_filename);
char archive_fullpath[512];
snprintf(archive_fullpath, sizeof(archive_fullpath), "%s%s", rrd_log_dir, archive_filename);
rrd_archive_cleanup(archive_fullpath);
rrd_upload_cleanup_source_dir(upload_dir);
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Cleanup complete\n", __FUNCTION__);

RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Exit\n", __FUNCTION__);
return 0;
Expand Down
76 changes: 62 additions & 14 deletions test/functional-tests/features/rrd_c_api_upload.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ Feature: Remote Debugger C API Upload Orchestration
And test log files are created in the upload directory
When I call rrd_upload_orchestrate with valid upload directory and issue type
Then the C API should return success code 0
And logs should contain "Executing binary to upload Debug info of ISSUETYPE"
And logs should contain "Logging ready"
And logs should contain "Configuration loaded"
And logs should contain "MAC:" for MAC address
And logs should contain "Timestamp:" for timestamp generation
And logs should contain "size and contents" for directory size check
And logs should contain "Log directory validated and prepared"
And logs should contain "Issue type sanitized"
And logs should contain "Archive filename:" with the generated filename
And logs should contain "Creating" for tarfile creation
And logs should contain "tarfile from Debug Commands output"
And logs should contain "Invoking uploadSTBLogs binary to upload"
And logs should contain "uploadSTBLogs parameters - server:"
And the archive should be created with correct naming format
And the archive should contain all log files from the directory
And the upload should be triggered successfully
Expand Down Expand Up @@ -107,17 +120,19 @@ Feature: Remote Debugger C API Upload Orchestration
Given the remote debugger is configured
And successful upload has completed
When I call rrd_upload_orchestrate with valid parameters
Then the archive file should be cleaned up
Then logs should contain "Debug Information Report upload Success"
And logs should contain "Removing uploaded report"
And logs should contain "Exit" for orchestration exit
And the archive file should be cleaned up
And temporary files should be removed
And logs should show "Cleanup complete"

Scenario: Test rrd_upload_orchestrate cleanup after upload failure
Given the remote debugger is configured
And upload will fail
When I call rrd_upload_orchestrate with valid parameters
Then the archive file should still be cleaned up
Then logs should contain "Debug Information Report upload Failed"
And the archive file should still be cleaned up
And error code 11 should be returned
And logs should show upload failure

Scenario: Test uploadDebugoutput wrapper function
Given the remote debugger is running
Expand Down Expand Up @@ -145,16 +160,49 @@ Feature: Remote Debugger C API Upload Orchestration
And logs should be prepared for upload
And archive should include live log data

Scenario: Verify rrd_upload_orchestrate logging throughout execution
Given the remote debugger is configured with debug logging
When I call rrd_upload_orchestrate with valid parameters
Then entry and exit logs should be present
And each step should log progress
And configuration values should be logged
And system info should be logged
And archive creation should be logged
And upload status should be logged
And cleanup should be logged
Scenario: Test remote debugger end-to-end with RFC trigger
Given the remote debugger process is running
And the issue type RFC is reset to empty string
When I set RFC parameter "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType" to test issue string
Then logs should contain "Received event for RRD_SET_ISSUE_EVENT"
And logs should contain "SUCCESS: Message sending Done"
And logs should contain "SUCCESS: Message Reception Done"
And logs should contain "MSG=" followed by the issue string
And logs should contain "Start Reading JSON File... /etc/rrd/remote_debugger.json"
And logs should contain "Json File parse Success... /etc/rrd/remote_debugger.json"
And logs should contain "Issue Data Node:" with node and subnode information
And logs should contain "Creating Directory"
And logs should contain "Found valid Commands"
And logs should contain "Adding Details of Debug commands to Output File"
And logs should contain "Starting remote_debugger_" service success message
And logs should contain "journalctl remote_debugger_" service success message
And logs should contain "Sleeping with timeout"
And logs should contain "Stopping remote_debugger_" service message
And logs should contain "Starting Upload Debug output via API"
And the output directory should contain generated files

Scenario: Test upload report validation with success path
Given the remote debugger has completed upload orchestration
When upload completes successfully
Then logs should contain "Debug Information Report upload Success"
And logs should contain "Removing uploaded report"
And logs should contain "Exit" for orchestration completion
And logs should contain "Logging ready" from orchestration initialization
And logs should contain "Configuration loaded" from orchestration setup

Scenario: Test upload report validation with failure path
Given the remote debugger has completed upload orchestration
When upload fails
Then logs should contain "Debug Information Report upload Failed"
And logs should contain "Logging ready" from orchestration initialization
And logs should contain "Configuration loaded" from orchestration setup
And cleanup should still occur

Scenario: Test upload report with legacy log compatibility
Given the remote debugger is using legacy logging
When upload completes
Then logs should contain either "RRD Upload Script Execution Success" or "RRD Upload Script Execution Failure"
And upload orchestration logs should confirm execution

Scenario: Test rrd_upload_orchestrate error propagation
Given the remote debugger is configured
Expand Down
Loading
Loading