Skip to content
Open
Show file tree
Hide file tree
Changes from 12 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 scripts/uploadRRDLogs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ OUTFILE='/tmp/DCMSettings.conf'
MAC=`getMacAddressOnly`
TIMESTAMP=`date "+%Y-%m-%d-%H-%M-%S%p"`
RRD_LOG_FILE="$LOG_PATH/remote-debugger.log"
ISSUETYPE=`echo $2 | tr '[a-z]' '[A-Z]'`
ISSUETYPE=$(printf '%s' "$2" | tr '[:lower:]' '[:upper:]' | tr -cd 'A-Z0-9_-')
RRD_LOG_PATH="$1"
RRD_LOG_DIR="/tmp/rrd/"
UPLOAD_DEBUG_FILE="${MAC}_${ISSUETYPE}_${TIMESTAMP}_RRD_DEBUG_LOGS.tgz"
Expand Down
72 changes: 35 additions & 37 deletions src/rrdMsgPackDecoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <stdarg.h>
#include <ctype.h>
#include <time.h>
#include <limits.h>
#include <stdint.h>
#include "rrdMsgPackDecoder.h"
#include "rrdCommon.h"

Expand All @@ -44,27 +46,9 @@ msgpack_object *__finder(const char *name,
{
if (MSGPACK_OBJECT_STR == map->ptr[i].key.type)
{
if (expect_type == map->ptr[i].val.type)
{
if (0 == match(&(map->ptr[i]), name))
{
return &map->ptr[i].val;
}
}
else if (MSGPACK_OBJECT_STR == map->ptr[i].val.type)
{
if (0 == strncmp(map->ptr[i].key.via.str.ptr, name, strlen(name)))
{
return &map->ptr[i].val;
}
}
else
{
if (0 == strncmp(map->ptr[i].key.via.str.ptr, name, strlen(name)))
{
if ((expect_type == map->ptr[i].val.type) && (0 == match(&(map->ptr[i]), name))) {
Comment thread
Kaavyashree2 marked this conversation as resolved.
Resolved
Comment thread
Kaavyashree2 marked this conversation as resolved.
Resolved
return &map->ptr[i].val;
}
}
}
}
errno = MISSING_ENTRY;
Expand Down Expand Up @@ -136,17 +120,17 @@ void *helper_convert(const void *buf, size_t len,
else if (NULL != wrapper && 0 != strcmp(wrapper, "parameters"))
{
inner = __finder(wrapper, expect_type, &msg.data.via.map);
subdoc_name = __finder("subdoc_name", expect_type, &msg.data.via.map);
version = __finder("version", expect_type, &msg.data.via.map);
transaction_id = __finder("transaction_id", expect_type, &msg.data.via.map);
if (((NULL != inner) && (0 == (process)(p, 4, inner, subdoc_name, version, transaction_id))) ||
((true == optional) && (NULL == inner)))
{
msgpack_unpacked_destroy(&msg);
errno = OK;
return p;
}
else
subdoc_name = __finder("subdoc_name",MSGPACK_OBJECT_STR, &msg.data.via.map);
version = __finder("version", MSGPACK_OBJECT_POSITIVE_INTEGER, &msg.data.via.map);
transaction_id = __finder("transaction_id", MSGPACK_OBJECT_POSITIVE_INTEGER, &msg.data.via.map);
Comment thread
rdkcentral-pr-monitor[bot] marked this conversation as resolved.
Resolved
if (((NULL != inner) &&
(0 == (process)(p, 4, inner, subdoc_name, version, transaction_id))) ||
((true == optional) && (NULL == inner))) {
msgpack_unpacked_destroy(&msg);
errno = OK;
return p;
}
else
{
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]:Invalid first element\n", __FUNCTION__, __LINE__);
errno = INVALID_FIRST_ELEMENT;
Expand Down Expand Up @@ -298,17 +282,26 @@ const char *remotedebuggerdoc_strerror(int errnum)
* @param msgpack_object_array *arr - The msgpack array containing the issue types.
* @return int - The required size of the issue type string.
*/
int getReqTotalSizeOfIssueTypesStr(msgpack_object_array *arr)
size_t getReqTotalSizeOfIssueTypesStr(msgpack_object_array *arr)
{
int index = 0, size = 0;
size_t index;
size_t size = 0;

for(index = 0; index < arr->size; index++)
{
if(arr->ptr[index].type == MSGPACK_OBJECT_STR)
{
if(arr->ptr[index].type == MSGPACK_OBJECT_STR) {
if (SIZE_MAX - size < arr->ptr[index].via.str.size) {
return 0;
}
size += arr->ptr[index].via.str.size;
}
}
return (size + arr->size + 1); /* Need to add Number of Required "," between each string*/

/* add commas and terminating NULL */
if (SIZE_MAX - size < arr->size + 1) {
return 0;
}
return size + arr->size + 1;
Comment thread
rdkcentral-pr-monitor[bot] marked this conversation as resolved.
Resolved
}

/*
Expand All @@ -322,7 +315,8 @@ int process_remotedebuggerparams(remotedebuggerparam_t *rrdParam, msgpack_object
{
int left = map->size;
uint8_t objects_left = 1;
int index = 0, resultLen = 0;
int index = 0;
size_t resultLen = 0;
msgpack_object_kv *p = NULL;
msgpack_object_array *arr = NULL;
p = map->ptr;
Expand All @@ -336,7 +330,11 @@ int process_remotedebuggerparams(remotedebuggerparam_t *rrdParam, msgpack_object
{
arr = &p->val.via.array;
resultLen = getReqTotalSizeOfIssueTypesStr(arr);
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Size:%d \n", __FUNCTION__, __LINE__,resultLen);
if (resultLen == 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: Invalid IssueType size\n", __FUNCTION__, __LINE__);
return -1;
}
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Size:%zu \n", __FUNCTION__, __LINE__,resultLen);
rrdParam->length = resultLen;
rrdParam->commandList = (char *)calloc(resultLen + 1, sizeof(char));
if(rrdParam->commandList != NULL)
Expand Down
33 changes: 20 additions & 13 deletions src/unittest/rrdUnitTestRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3263,39 +3263,45 @@ TEST(FinderTest, KeyTypeStrExpectTypeMatch)
EXPECT_STREQ(result->via.str.ptr, "value");
}

TEST(FinderTest, KeyTypeStrValTypeStrMatch)
TEST(FinderTest, KeyTypeStrValTypeAnyMatch)
{
msgpack_object_map map;
msgpack_object_kv kv;
kv.key.type = MSGPACK_OBJECT_STR;
kv.key.via.str.ptr = "name";
kv.key.via.str.size = strlen("name");
kv.val.type = MSGPACK_OBJECT_STR;
kv.val.via.str.ptr = "value";
kv.val.via.str.size = strlen("value");
kv.val.type = MSGPACK_OBJECT_NIL;
map.size = 1;
map.ptr = &kv;
msgpack_object *result = __finder("name", MSGPACK_OBJECT_NIL, &map);

ASSERT_NE(result, nullptr);
EXPECT_EQ(result->type, MSGPACK_OBJECT_STR);
EXPECT_STREQ(result->via.str.ptr, "value");
EXPECT_EQ(result->type, MSGPACK_OBJECT_NIL);
}

TEST(FinderTest, KeyTypeStrValTypeAnyMatch)
TEST(FinderTest, NameMatchesButTypeMismatchReturnsNull)
{
msgpack_object_map map;
msgpack_object_kv kv;

kv.key.type = MSGPACK_OBJECT_STR;
kv.key.via.str.ptr = "name";
kv.key.via.str.size = strlen("name");
kv.val.type = MSGPACK_OBJECT_NIL;
kv.key.via.str.ptr = "version";
kv.key.via.str.size = strlen("version");

kv.val.type = MSGPACK_OBJECT_STR;
kv.val.via.str.ptr = "abc";
kv.val.via.str.size = strlen("abc");

map.size = 1;
map.ptr = &kv;
msgpack_object *result = __finder("name", MSGPACK_OBJECT_NIL, &map);

ASSERT_NE(result, nullptr);
EXPECT_EQ(result->type, MSGPACK_OBJECT_NIL);
msgpack_object *result =
__finder("version",
MSGPACK_OBJECT_POSITIVE_INTEGER,
&map);

EXPECT_EQ(result, nullptr);
EXPECT_EQ(errno, MISSING_ENTRY);
}

/* --------------- Test get_msgpack_unpack_status() from rrdMsgPackDecoder --------------- */
Expand Down Expand Up @@ -3533,6 +3539,7 @@ TEST(HelperConvertTest, MsgPackWrapperConditionFalseProcessFails)

TEST(HelperConvertTest, MsgPackWrapperConditionFalseProcessSuccess)
{
errno = 0;
msgpack_sbuffer sbuf;
msgpack_packer pk;
msgpack_sbuffer_init(&sbuf);
Expand Down
8 changes: 4 additions & 4 deletions test/functional-tests/L2_Coverage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Remote Debugger L2 Coverage Report

**Generated:** 2026-10-28
**Generated:** 2026-11-04
**Component:** `remotedebugger` (`src/`)
**Test suite:** `test/functional-tests/`
**Coverage tool:** lcov (source-level instrumentation via `--coverage`)
Expand All @@ -19,7 +19,7 @@
| Test functions (`test_*`) | 118 |
| Mapped feature/test pairs | 19 / 22 |
| Unmatched test files | 4 |
| Line coverage (lcov) | 49.7% (1508 of 3034 lines) |
| Line coverage (lcov) | 49.6% (1507 of 3039 lines) |

**L2 Test Coverage**

Expand Down Expand Up @@ -110,9 +110,9 @@
| `rrdCommandSanity.c` | 93.1% (67/72) | 100.0% (3/3) | `███████████████████░` |
| `rrdDynamic.c` | 40.4% (59/146) | 40.0% (2/5) | `████████░░░░░░░░░░░░` |
| `rrdExecuteScript.c` | 94.1% (16/17) | 100.0% (2/2) | `███████████████████░` |
| `rrdMsgPackDecoder.c` | 0.0% (0/280) | 0.0% (0/15) | `░░░░░░░░░░░░░░░░░░░░` |
| `rrdMsgPackDecoder.c` | 0.0% (0/285) | 0.0% (0/15) | `░░░░░░░░░░░░░░░░░░░░` |
| `rrd_config.c` | 42.8% (95/222) | 66.7% (6/9) | `█████████░░░░░░░░░░░` |
| `rrd_sysinfo.c` | 32.1% (36/112) | 33.3% (2/6) | `██████░░░░░░░░░░░░░░` |
| `rrd_sysinfo.c` | 31.2% (35/112) | 33.3% (2/6) | `██████░░░░░░░░░░░░░░` |
| `rrd_logproc.c` | 48.6% (36/74) | 75.0% (3/4) | `██████████░░░░░░░░░░` |
| `rrd_archive.c` | 47.2% (126/267) | 72.7% (8/11) | `█████████░░░░░░░░░░░` |
| `rrd_upload.c` | 40.7% (37/91) | 60.0% (3/5) | `████████░░░░░░░░░░░░` |
Expand Down
Loading