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
52 changes: 52 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Code Coverage

on:
pull_request:
branches: [ main ]

jobs:
execute-unit-code-coverage-report-on-release:
name: Test coverage report for release
runs-on: ubuntu-latest
container:
image: ghcr.io/rdkcentral/docker-rdk-ci:latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run unit tests with coverage flags enabled
run: |
sh run_ut.sh --enable-cov
- name: Caculate the code coverage summary
run: |
lcov --list tr69hostif_coverage.info | grep "Lines\|Total" > /tmp/coverage_summary.txt
cd -

- name: Update the coverage report to Pull request using actions
uses: actions/github-script@v4
with:
script: |
const fs = require('fs');
const lcov_result = fs.readFileSync('/tmp/coverage_summary.txt', 'utf8');

github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body:
'## Code Coverage Summary \n' +
' ' +
'```' +
lcov_result +
'```'
});
- name: Generate the html report
run: |
genhtml tr69hostif_coverage.info --output-directory /tmp/coverage_report
cd -
- name: Upload the coverage report to Pull request using actions
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: /tmp/coverage_report
Comment on lines +9 to +52

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI about 1 year ago

To fix the problem, explicitly set the permissions key for the job (or at the workflow root) to grant only the minimum required privileges. In this workflow, the job needs contents: read (to check out code) and issues: write (to create a comment on the pull request). The best way to fix this is to add a permissions block under the execute-unit-code-coverage-report-on-release job, specifying contents: read and issues: write. This change should be made directly under the job definition (after name: and before runs-on:) in .github/workflows/code-coverage.yml. No additional imports or definitions are needed.


Suggested changeset 1
.github/workflows/code-coverage.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml
--- a/.github/workflows/code-coverage.yml
+++ b/.github/workflows/code-coverage.yml
@@ -9,2 +9,5 @@
     name: Test coverage report for release
+    permissions:
+      contents: read
+      issues: write
     runs-on: ubuntu-latest
EOF
@@ -9,2 +9,5 @@
name: Test coverage report for release
permissions:
contents: read
issues: write
runs-on: ubuntu-latest
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [1.2.2](https://github.com/rdkcentral/tr69hostif/compare/1.2.1...1.2.2)

- RDKEMW-6193 Code Coverage support for tr69hostif [`#211`](https://github.com/rdkcentral/tr69hostif/pull/211)
- RDKEMW-6328: set AVHijack rfc to false [`#208`](https://github.com/rdkcentral/tr69hostif/pull/208)
- RDK-58323: Canary firmware updates [`#199`](https://github.com/rdkcentral/tr69hostif/pull/199)
- Merge tag '1.2.1' into develop [`17d019b`](https://github.com/rdkcentral/tr69hostif/commit/17d019b0bed5e8cc9c1f4fe68520c08fc530ff00)

#### [1.2.1](https://github.com/rdkcentral/tr69hostif/compare/1.2.0...1.2.1)

> 18 July 2025

- RDK-58526 : Default IPControl RFC for EU partners [`#203`](https://github.com/rdkcentral/tr69hostif/pull/203)
- RDK-57868 : Default IPControl RFC for EU partners [`#200`](https://github.com/rdkcentral/tr69hostif/pull/200)
- RDK-57867 : Default the IUI layer separation RFC globally for EntOS [`#193`](https://github.com/rdkcentral/tr69hostif/pull/193)
- 1.2.1 release changelog updates [`fe9e71f`](https://github.com/rdkcentral/tr69hostif/commit/fe9e71f712ffef234215145461d767ae7d1691a4)
- Merge tag '1.2.0' into develop [`9b98df0`](https://github.com/rdkcentral/tr69hostif/commit/9b98df0330008138a47b6f18a4314df6f0a7adc1)

#### [1.2.0](https://github.com/rdkcentral/tr69hostif/compare/1.1.9...1.2.0)
Expand Down
28 changes: 19 additions & 9 deletions run_ut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
# SPDX-License-Identifier: Apache-2.0
############################################################################


ENABLE_COV=false

if [ "x$1" = "x--enable-cov" ]; then
echo "Enabling coverage options"
export CXXFLAGS="-g -O0 -fprofile-arcs -ftest-coverage"
export CFLAGS="-g -O0 -fprofile-arcs -ftest-coverage"
export LDFLAGS="-lgcov --coverage"
ENABLE_COV=true
fi

apt-get update
apt-get -y install libtinyxml2-dev
apt-get -y install libsoup-3.0-dev
Expand Down Expand Up @@ -57,20 +68,19 @@ make
./dm_gtest
echo "********************"


lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.filtered.info
genhtml coverage.filtered.info --output-directory out


echo "**** Compiling DeviceInfo gtest ****"
cd $TOP_DIR/src/hostif/profiles/DeviceInfo/gtest
rm devieInfo_gtest
make
./devieInfo_gtest
echo "********************"

cd $TOP_DIR

lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.filtered.info
genhtml coverage.filtered.info --output-directory out
if [ "$ENABLE_COV" = true ]; then
lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info '/usr/*' '*/gtest/*' '*/mocks/*' --output-file filtered.info
lcov --extract filtered.info '*/src/hostif*' --output-file tr69hostif_coverage.info
lcov --list tr69hostif_coverage.info
fi

2 changes: 2 additions & 0 deletions src/hostif/handlers/include/hostIf_msgHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ void hostIf_Print_msgData(HOSTIF_MsgData_t *stMsgData);

void hostIf_Free_stMsgData (HOSTIF_MsgData_t *stMsgData);

void paramValueToString(const HOSTIF_MsgData_t *stMsgData, char *paramValueStr, size_t strSize);

bool hostIf_initalize_ConfigManger();
bool hostIf_ConfigProperties_Init();
class msgHandler {
Expand Down
56 changes: 54 additions & 2 deletions src/hostif/handlers/src/hostIf_msgHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in src/hostif/handlers/src/hostIf_msgHandler.cpp

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/hostif/handlers/src/hostIf_msgHandler.cpp' (Match: rdk/components/generic/tr69hostif/rdk/components/generic/tr69hostif/2102, 740 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/tr69hostif/+archive/rdk-dev-2102.tar.gz, file: src/hostif/handlers/src/hostIf_msgHandler.cpp)
*
* Copyright 2016 RDK Management
*
Expand Down Expand Up @@ -82,6 +82,52 @@
static std::atomic<bool> loggedSet200Within1Min {false};
static std::atomic<bool> loggedSet1000Within5Min {false};

#define PARAM_VALUE_STR_SIZE 128


void paramValueToString(const HOSTIF_MsgData_t *stMsgData, char *paramValueStr, size_t strSize)
{
if (!stMsgData || !paramValueStr || strSize == 0) {
if (paramValueStr && strSize > 0)
snprintf(paramValueStr, strSize, "<invalid input>");
return;
}

switch (stMsgData->paramtype) {
case hostIf_StringType:
case hostIf_DateTimeType:
snprintf(paramValueStr, strSize, "%s", (const char*)stMsgData->paramValue);
break;
case hostIf_IntegerType: {
int val = 0;
memcpy(&val, stMsgData->paramValue, sizeof(val));
snprintf(paramValueStr, strSize, "%d", val);
break;
}
case hostIf_UnsignedIntType: {
unsigned int val = 0;
memcpy(&val, stMsgData->paramValue, sizeof(val));
snprintf(paramValueStr, strSize, "%u", val);
break;
}
case hostIf_BooleanType: {
bool val = false;
memcpy(&val, stMsgData->paramValue, sizeof(val));
snprintf(paramValueStr, strSize, "%s", val ? "true" : "false");
break;
}
case hostIf_UnsignedLongType: {
unsigned long val = 0;
memcpy(&val, stMsgData->paramValue, sizeof(val));
snprintf(paramValueStr, strSize, "%lu", val);
break;
}
default:
snprintf(paramValueStr, strSize, "<unknown or unsupported type>");
break;
}
}

int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData)
{
LOG_ENTRY_EXIT;
Expand Down Expand Up @@ -137,13 +183,16 @@
ret = pMsgHandler->handleGetMsg(stMsgData);
auto endTime = std::chrono::high_resolution_clock::now();
auto timeTaken = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime).count();
char paramValueStr[PARAM_VALUE_STR_SIZE] = {0};
paramValueToString(stMsgData, paramValueStr, sizeof(paramValueStr));


// Calculate time taken in microseconds
RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s:%d] ret: %d, paramName: %s, paramValue: %s, timeTaken: %lld us\n",
__FUNCTION__, __LINE__, ret,
stMsgData->paramName,
stMsgData->paramValue,
paramValueStr,
timeTaken);
// Telemetry and debug log if processing time > 5 second (1,000,000 us)
if (timeTaken > 5000000) {
Expand Down Expand Up @@ -224,11 +273,14 @@
auto endTime = std::chrono::high_resolution_clock::now();
auto timeTakenset = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime).count();

char paramValueStr[128] = {0};
paramValueToString(stMsgData, paramValueStr, sizeof(paramValueStr));

RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF,
"[%s:%d] ret: %d, paramName: %s, paramValue: %s, timeTaken: %lld us\n",
__FUNCTION__, __LINE__, ret,
stMsgData->paramName,
stMsgData->paramValue,
paramValueStr,
timeTakenset);
// Telemetry and debug log if processing time > 5 seconds (5,000,000 us)
if (timeTakenset > 5000000) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,14 @@
</syntax>
</parameter>
</object>
<object base="Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.BTR.DebugMode." access="readOnly" minEntries="1" maxEntries="1" >
<parameter base="Enable" access="readWrite" notification="0" maxNotification="2" >
<syntax>
<boolean/>
<default type="factory" value="false"/>
</syntax>
</parameter>
</object>
<object base="Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.BTSplitAudio." access="readOnly" minEntries="0" maxEntries="1" >
<parameter base="Enable" access="readWrite" notification="0" maxNotification="2" >
<syntax>
Expand Down Expand Up @@ -4345,7 +4353,7 @@
<parameter base="Enable" access="readWrite" notification="0" maxNotification="2" >
<syntax>
<boolean/>
<default type="factory" value="true"/>
<default type="factory" value="false"/>
</syntax>
</parameter>
</object>
Expand Down
8 changes: 8 additions & 0 deletions src/hostif/parodusClient/waldb/data-model/data-model-stb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,14 @@
</syntax>
</parameter>
</object>
<object base="Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.TR069support." access="readOnly" minEntries="1" maxEntries="1" >
<parameter base="Enable" access="readWrite" notification="0" maxNotification="2" >
<syntax>
<boolean/>
<default type="factory" value="false"/>
</syntax>
</parameter>
</object>
<object base="Device.Services.STBService.1.Capabilities.VideoDecoder.X_RDKCENTRAL-COM_MPEGHPart2." access="readOnly" minEntries="1" maxEntries="1" >
<parameter base="ProfileLevelNumberOfEntries" access="readOnly" notification="0" maxNotification="2" >
<syntax>
Expand Down
8 changes: 8 additions & 0 deletions src/hostif/parodusClient/waldb/data-model/data-model-tv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,14 @@
</syntax>
</parameter>
</object>
<object base="Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.TR069support." access="readOnly" minEntries="1" maxEntries="1" >
<parameter base="Enable" access="readWrite" notification="0" maxNotification="2" >
<syntax>
<boolean/>
<default type="factory" value="false"/>
</syntax>
</parameter>
</object>
<object base="Device.DeviceInfo.X_RDKCENTRAL-COM_xBlueTooth.BLE.Tile.Cmd." access="readOnly" minEntries="0" maxEntries="1" >
<parameter base="Request" access="readWrite" notification="0" maxNotification="2" >
<syntax>
Expand Down
2 changes: 1 addition & 1 deletion src/unittest/stubs/ds/audioOutputPort.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in src/unittest/stubs/ds/audioOutputPort.hpp

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/unittest/stubs/ds/audioOutputPort.hpp' (Match: rdk/components/generic/devicesettings/rdk/components/generic/devicesettings/2102, 160 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/devicesettings/+archive/rdk-dev-2102.tar.gz, file: ds/include/audioOutputPort.hpp)
*
* Copyright 2016 RDK Management
*
Expand Down Expand Up @@ -173,7 +173,7 @@
void setSAD(std::vector<int> sad_list);
void enableARC(dsAudioARCTypes_t type, bool enable);
void enableMS12Config(const dsMS12FEATURE_t feature,const bool enable){}
dsError_t enableLEConfig(const bool enable);
dsError_t enableLEConfig(const bool enable) { return dsERR_NONE; };
bool GetLEConfig();
void setAudioDelay(const uint32_t audioDelayMs);
void setAudioDelayOffset(const uint32_t audioDelayOffsetMs);
Expand Down
2 changes: 1 addition & 1 deletion src/unittest/stubs/ds/host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Host {
AudioOutputPort &getAudioOutputPort(const std::string &name){};
AudioOutputPort &getAudioOutputPort(int id){};
void notifyPowerChange(const int mode);
float getCPUTemperature();
float getCPUTemperature() { return 42.5f; };
uint32_t getVersion(void);
void setVersion(uint32_t versionNumber);
void getHostEDID(std::vector<uint8_t> &edid) const;
Expand Down
2 changes: 1 addition & 1 deletion tr69hostif.service
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
##########################################################################
[Unit]
Description=TR69 Host Interface Daemon
After=lighttpd.service securemount.service
After=lighttpd.service securemount.service iarmbusd.service

[Service]
Type=notify
Expand Down
Loading