Skip to content

PR: #42:Fixing the negative scenarios in ut_kvp_getListCount() #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 19, 2024
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
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"args": [],
"stopAtEntry": false,
"externalConsole": false,
"cwd": "${workspaceFolder}/tests/bin/",
"program": "${workspaceFolder}/tests/bin/ut_control_test",
"environment": [ {"name": "LD_LIBRARY_PATH", "value":"${workspaceFolder}/tests/bin/"} ],
"cwd": "${workspaceFolder}/tests/build/bin/",
"program": "${workspaceFolder}/tests/build/bin/ut_control_test",
"environment": [ {"name": "LD_LIBRARY_PATH", "value":"${workspaceFolder}/tests/build/bin/"} ],
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
Expand Down
16 changes: 9 additions & 7 deletions src/ut_kvp.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,14 +598,16 @@ uint32_t ut_kvp_getListCount( ut_kvp_instance_t *pInstance, const char *pszKey)
return 0;
}

if (fy_node_is_sequence(node))
if (fy_node_is_sequence(node) == false)
{
count = fy_node_sequence_item_count(node);
if (count == -1)
{
UT_LOG_ERROR("fy_node_sequence_item_count() returned error\n ");
return 0;
}
return 0; // Early return on negative check
}

count = fy_node_sequence_item_count(node);
if (count == -1)
{
UT_LOG_ERROR("fy_node_sequence_item_count() returned error\n");
return 0;
}

return count;
Expand Down
10 changes: 6 additions & 4 deletions tests/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ NC="\e[39m"
# When the major version changes in the ut-core, what that signals is that the testings will have to be upgraded to support that version
# Therefore in that case it warns you but doesnt' chnage to that version, which could cause your tests to break.
# Change this to upgrade your UT-Core Major versions. Non ABI Changes 1.x.x are supported, between major revisions
UT_PROJECT_MAJOR_VERSION="3."
UT_PROJECT_MAJOR_VERSION="4."

# Clone the Unit Test Requirements
[email protected]:rdkcentral/ut-core.git
Expand All @@ -41,16 +41,18 @@ function check_next_revision()
pushd ./ut-core
# Set default UT_CORE_PROJECT_VERSION to next revision, if it's set then we don't need to tell you again
if [ -v ${UT_CORE_PROJECT_VERSION} ]; then
UT_CORE_PROJECT_VERSION=$(git tag | grep ^${UT_PROJECT_MAJOR_VERSION} | sort -r | head -n1)
UT_NEXT_VERSION=$(git tag | sort -r | head -n1)
UT_CORE_PROJECT_VERSION=$(git tag | grep ^${UT_PROJECT_MAJOR_VERSION} | sort -r | head -n1) # Selects the highest version of the tags starting with ${UT_PROJECT_MAJOR_VERSION}
UT_NEXT_VERSION=$(git tag | sort -r | head -n1) # Selects the highest version from the tags
if [ -z ${UT_CORE_PROJECT_VERSION} ]; then
UT_CORE_PROJECT_VERSION="${UT_NEXT_VERSION}" # Fallback if there is no version of tags are available starting with ${UT_PROJECT_MAJOR_VERSION}
fi
echo -e ${YELLOW}ut-core version selected:[${UT_CORE_PROJECT_VERSION}]${NC}
if [ "${UT_NEXT_VERSION}" != "${UT_CORE_PROJECT_VERSION}" ]; then
echo -e ${RED}--- New Version of ut-core released [${UT_NEXT_VERSION}] consider upgrading ---${NC}
fi
fi
popd > /dev/null
}

# Check if the common document configuration is present, if not clone it
if [ -d "./ut-core" ]; then
# ut-core exists so run the makefile from ut
Expand Down
3 changes: 3 additions & 0 deletions tests/src/ut_test_kvp.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ void test_ut_kvp_list(void)
uint32_t result;
int count;

count = ut_kvp_getListCount(gpMainTestInstance, "decodeTest/checkFloat");
UT_ASSERT( count == 0 );

count = ut_kvp_getListCount(gpMainTestInstance, "decodeTest/checkStringList");
UT_ASSERT( count == 3 );

Expand Down