diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml new file mode 100644 index 000000000..2e29b0b79 --- /dev/null +++ b/.github/workflows/code-coverage.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 98e67ffa2..76809d9ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/run_ut.sh b/run_ut.sh index c6143381c..92abdfec0 100644 --- a/run_ut.sh +++ b/run_ut.sh @@ -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 @@ -57,12 +68,6 @@ 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 @@ -70,7 +75,12 @@ 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 + diff --git a/src/hostif/handlers/include/hostIf_msgHandler.h b/src/hostif/handlers/include/hostIf_msgHandler.h index cc9512838..a385cf586 100644 --- a/src/hostif/handlers/include/hostIf_msgHandler.h +++ b/src/hostif/handlers/include/hostIf_msgHandler.h @@ -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 { diff --git a/src/hostif/handlers/src/hostIf_msgHandler.cpp b/src/hostif/handlers/src/hostIf_msgHandler.cpp index d2d1e3931..a73572299 100644 --- a/src/hostif/handlers/src/hostIf_msgHandler.cpp +++ b/src/hostif/handlers/src/hostIf_msgHandler.cpp @@ -82,6 +82,52 @@ static std::atomic loggedGet1000Within5Min {false}; static std::atomic loggedSet200Within1Min {false}; static std::atomic 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, ""); + 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, ""); + break; + } +} + int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) { LOG_ENTRY_EXIT; @@ -137,13 +183,16 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) ret = pMsgHandler->handleGetMsg(stMsgData); auto endTime = std::chrono::high_resolution_clock::now(); auto timeTaken = std::chrono::duration_cast(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) { @@ -224,11 +273,14 @@ int hostIf_SetMsgHandler(HOSTIF_MsgData_t *stMsgData) auto endTime = std::chrono::high_resolution_clock::now(); auto timeTakenset = std::chrono::duration_cast(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) { diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 7a0d81180..e97e68f0e 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -342,6 +342,14 @@ + + + + + + + + @@ -4345,7 +4353,7 @@ - + diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml b/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml index 6ab3a6bf8..ede3d12ff 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml @@ -461,6 +461,14 @@ + + + + + + + + diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml b/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml index 96c2790d9..bffa5bc07 100644 --- a/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml @@ -367,6 +367,14 @@ + + + + + + + + diff --git a/src/unittest/stubs/ds/audioOutputPort.hpp b/src/unittest/stubs/ds/audioOutputPort.hpp index 073740291..2821f7ad7 100644 --- a/src/unittest/stubs/ds/audioOutputPort.hpp +++ b/src/unittest/stubs/ds/audioOutputPort.hpp @@ -173,7 +173,7 @@ class AudioOutputPort : public Enumerable { void setSAD(std::vector 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); diff --git a/src/unittest/stubs/ds/host.hpp b/src/unittest/stubs/ds/host.hpp index a18c55f71..95ed08b3f 100644 --- a/src/unittest/stubs/ds/host.hpp +++ b/src/unittest/stubs/ds/host.hpp @@ -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 &edid) const; diff --git a/tr69hostif.service b/tr69hostif.service index 3a256e0d3..946b03e33 100644 --- a/tr69hostif.service +++ b/tr69hostif.service @@ -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