diff --git a/.github/workflows/L1-tests.yml b/.github/workflows/L1-tests.yml index 307c71be2..9c66548b0 100644 --- a/.github/workflows/L1-tests.yml +++ b/.github/workflows/L1-tests.yml @@ -2,7 +2,7 @@ name: L1 Unit Tests on: pull_request: - branches: [ develop ] + branches: [ develop, support/1.7.4 ] env: AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME }} diff --git a/.github/workflows/L2-tests.yml b/.github/workflows/L2-tests.yml index d9650e42c..236150392 100644 --- a/.github/workflows/L2-tests.yml +++ b/.github/workflows/L2-tests.yml @@ -2,7 +2,7 @@ name: L2 Integration Tests on: pull_request: - branches: [ develop ] + branches: [ develop, support/1.7.4 ] env: AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 3589a1d08..1bb069d05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,142 @@ 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.7.4v2](https://github.com/rdkcentral/telemetry/compare/1.9.5...1.7.4v2) + +- RDKEMW-16851: [Cherry-pick #332] Fix for skipfrequency issue in top markers (#332) [`#391`](https://github.com/rdkcentral/telemetry/pull/391) +- Cherry-pick PRs 295, 299 Previous log fixes to 1.7.4 [`#340`](https://github.com/rdkcentral/telemetry/pull/340) +- Changelog updates for 1.7.4v1 release [`c6cdd1b`](https://github.com/rdkcentral/telemetry/commit/c6cdd1b6bfb700779df66d94fcc9d522abe926e6) + +#### [1.9.5](https://github.com/rdkcentral/telemetry/compare/1.9.4...1.9.5) + +> 11 June 2026 + +- RDKB-64847: Observed spike in load and CPU due to cpu_telemetry2_0 [`#383`](https://github.com/rdkcentral/telemetry/pull/383) +- Changelog updates for 1.9.5 release [`345cc22`](https://github.com/rdkcentral/telemetry/commit/345cc220dd9e366496b63adc061d4549a5da21f7) + +#### [1.9.4](https://github.com/rdkcentral/telemetry/compare/1.9.3...1.9.4) + +> 20 May 2026 + +- RDKEMW-18410: Xconf thread should wait Indefinitely for the NTP indicator [`9db3fba`](https://github.com/rdkcentral/telemetry/commit/9db3fba319b7854e128cdba25f1ee36a312b4a3b) +- Changelog updates for hotifx release 1.9.4 [`65e76ce`](https://github.com/rdkcentral/telemetry/commit/65e76ce1a771a4d44c9b52e0f4f76e467dd52b11) + +#### [1.9.3](https://github.com/rdkcentral/telemetry/compare/1.9.2...1.9.3) + +> 15 May 2026 + +- RDKEMW-18410: Xconf thread should wait for the NTP indicator for network connectivity [`#367`](https://github.com/rdkcentral/telemetry/pull/367) +- Changelog updates for hotifx release 1.9.3 [`15df0a2`](https://github.com/rdkcentral/telemetry/commit/15df0a22302942525308de78dd7e2213ed99b718) + +#### [1.9.2](https://github.com/rdkcentral/telemetry/compare/1.9.1...1.9.2) + +> 4 May 2026 + +- RDKB-64644: Potential Fix for SE051 ENGINE memory leak in telemetry HTTP pool [`#360`](https://github.com/rdkcentral/telemetry/pull/360) +- RDKEMW-15199:[SECVULN] Command injection via /opt/.telemetry/dca_temp… [`#355`](https://github.com/rdkcentral/telemetry/pull/355) +- Changelog updates for release 1.9.2 [`247ae04`](https://github.com/rdkcentral/telemetry/commit/247ae0464ce45a63c53705f3cc91bb2e16ffa92c) +- Changelog updates for release 1.9.2 [`5b6e065`](https://github.com/rdkcentral/telemetry/commit/5b6e0656dc612c571c5715bffb636565df3ed0f2) + +#### [1.9.1](https://github.com/rdkcentral/telemetry/compare/1.9.0...1.9.1) + +> 28 April 2026 + +- RDKB-64487: TSAN fixes for various issues [`#350`](https://github.com/rdkcentral/telemetry/pull/350) +- RDKB-64487: Code changes for thread hardening and safety under concurrent load [`#345`](https://github.com/rdkcentral/telemetry/pull/345) +- RDKB-64487: Code changes for Mutex locking and deadlock prevention [`#338`](https://github.com/rdkcentral/telemetry/pull/338) +- RDKEMW-16851: Fix for top log markers and the polling frequency [`#341`](https://github.com/rdkcentral/telemetry/pull/341) +- Adding agentic skills for code reviews [`#323`](https://github.com/rdkcentral/telemetry/pull/323) +- Changelog updates for 1.9.1 release [`1861d67`](https://github.com/rdkcentral/telemetry/commit/1861d67be43018e5dcc10f61bebd3d31d08244ec) +- Changelog updates for 1.9.1 release [`4675135`](https://github.com/rdkcentral/telemetry/commit/467513553c6fac2d63cf730ca4980c595ff355db) + +#### [1.9.0](https://github.com/rdkcentral/telemetry/compare/1.8.8...1.9.0) + +> 8 April 2026 + +- RDK-60291: RDK Coverity Defect Resolution [`#319`](https://github.com/rdkcentral/telemetry/pull/319) +- Changelog updates for 1.9.0 release [`c3239a5`](https://github.com/rdkcentral/telemetry/commit/c3239a5c22ad9da475210a2448777563c6b84390) + +#### [1.8.8](https://github.com/rdkcentral/telemetry/compare/1.8.7...1.8.8) + +> 7 April 2026 + +- DELIA-70280 : [Xione DE] rbus self-deadlock in XConf privacy mode fetch causing ~188s T2 init delay [`#303`](https://github.com/rdkcentral/telemetry/pull/303) +- Changelog updates for release 1.8.8 [`6e32097`](https://github.com/rdkcentral/telemetry/commit/6e32097d4d38675b49b7a400de3e65dc42c12334) + +#### [1.8.7](https://github.com/rdkcentral/telemetry/compare/1.8.6...1.8.7) + +> 3 April 2026 + +- RDKB-64163: Fix race conditions with config reload [`#312`](https://github.com/rdkcentral/telemetry/pull/312) +- Changelog updates for 1.8.7 release [`8254efd`](https://github.com/rdkcentral/telemetry/commit/8254efd57fe0c4f0a84dbbdfac2ab18e4f80d021) + +#### [1.8.6](https://github.com/rdkcentral/telemetry/compare/1.8.5...1.8.6) + +> 1 April 2026 + +- RDKB-64163: Fix for reporting hang with heavy parallel operations [`#307`](https://github.com/rdkcentral/telemetry/pull/307) +- Changelog updates for 1.8.6 release [`d876cce`](https://github.com/rdkcentral/telemetry/commit/d876cce0e4f7ded4831dd8a7542cf79e0035dc4d) + +#### [1.8.5](https://github.com/rdkcentral/telemetry/compare/1.8.4...1.8.5) + +> 24 March 2026 + +- RDKEMW-15233:[SERXIONE-8445/XIONE-18418] Develop Support Branch Integ… [`#299`](https://github.com/rdkcentral/telemetry/pull/299) +- Changelog updates for release 1.8.5 [`3d23970`](https://github.com/rdkcentral/telemetry/commit/3d2397047795a728ab1a22ce439c4743cf8a84e1) + +#### [1.8.4](https://github.com/rdkcentral/telemetry/compare/1.8.3...1.8.4) + +> 23 March 2026 + +- RDKEMW-15233 [SERXIONE-8445/XIONE-18418] Develop Support Branch Integration [`#295`](https://github.com/rdkcentral/telemetry/pull/295) +- RDKB-63834: Reject and Remove Corrupted Config Files In Persistance [`#284`](https://github.com/rdkcentral/telemetry/pull/284) +- Changelog updates for 1.8.4 release [`a336d80`](https://github.com/rdkcentral/telemetry/commit/a336d80cd23321dee1defba998cb6460b3474b31) + +#### [1.8.3](https://github.com/rdkcentral/telemetry/compare/1.8.2...1.8.3) + +> 19 March 2026 + +- RDKB-63722: Build fix for ssl crypto error in platforms with lower ssl version [`#291`](https://github.com/rdkcentral/telemetry/pull/291) +- Changelog updates for 1.8.3 release [`cac6d7f`](https://github.com/rdkcentral/telemetry/commit/cac6d7f0182481bb1d1664bd0bc1afce9e429e25) + +#### [1.8.2](https://github.com/rdkcentral/telemetry/compare/1.8.1...1.8.2) + +> 18 March 2026 + +- RDKB-63722:Analyze and fix/mitigate memory leaks from curl_easy_perform calls [`#287`](https://github.com/rdkcentral/telemetry/pull/287) +- Agentic development and maintenance support [`#278`](https://github.com/rdkcentral/telemetry/pull/278) +- RDKEMW-10467: Fix Invalid time values caused by drift [`#212`](https://github.com/rdkcentral/telemetry/pull/212) +- Changelog updates for release 1.8.2 [`28b5426`](https://github.com/rdkcentral/telemetry/commit/28b542668e814411234f0a0d594e5c5d35b98319) + +#### [1.8.1](https://github.com/rdkcentral/telemetry/compare/1.8.0...1.8.1) + +> 27 February 2026 + +- RDK-60476: Reduce default connection pool size to 1 [`#260`](https://github.com/rdkcentral/telemetry/pull/260) +- RDK-60805: Adding L1 unit test cases for reportprofiles [`#265`](https://github.com/rdkcentral/telemetry/pull/265) +- Changelog updates for 1.8.1 release [`074a1d3`](https://github.com/rdkcentral/telemetry/commit/074a1d32e33924ce0f39e7cd7aad5bd6750376d4) + +#### [1.8.0](https://github.com/rdkcentral/telemetry/compare/1.7.4...1.8.0) + +> 6 February 2026 + +- RDK-60312: Remove fork calls for curl transactions [`#242`](https://github.com/rdkcentral/telemetry/pull/242) +- RDK-60533: L1 unit test cases - protocol/rbusMethod and http [`#241`](https://github.com/rdkcentral/telemetry/pull/241) +- RDKB-63348 : Fix duplicate close calls on file descriptor [`#251`](https://github.com/rdkcentral/telemetry/pull/251) +- RDK-60519: Adding L1 unit test cases - dcautil & ccspinterface [`#240`](https://github.com/rdkcentral/telemetry/pull/240) +- RDK-60519: Adding L1 unit test cases for scheduler [`#238`](https://github.com/rdkcentral/telemetry/pull/238) +- RDK-60304: Adding L1 unit test cases to improve code coverage [`#237`](https://github.com/rdkcentral/telemetry/pull/237) +- RDK-60303: Adding L1 unit test cases to improve code coverage for protocol/http [`#231`](https://github.com/rdkcentral/telemetry/pull/231) +- Changelog updates for 1.8.0 release [`8440d51`](https://github.com/rdkcentral/telemetry/commit/8440d513de7bdfda8331e44099f22b82c8cf669e) + #### [1.7.4](https://github.com/rdkcentral/telemetry/compare/1.7.3...1.7.4) +> 16 January 2026 + - DELIA-69767: Replace popen() to prevent FD closures and improve logging [`#225`](https://github.com/rdkcentral/telemetry/pull/225) - RDK-60072: Adding L1 unit test cases to improve code coverage [`#234`](https://github.com/rdkcentral/telemetry/pull/234) - RDK-60072: Adding L1 unit test cases to improve code coverage [`#219`](https://github.com/rdkcentral/telemetry/pull/219) +- Changelog updates for 1.7.4 release [`f94578f`](https://github.com/rdkcentral/telemetry/commit/f94578fadfd969e832df3d2f1856c6e59ec1a905) #### [1.7.3](https://github.com/rdkcentral/telemetry/compare/1.7.2...1.7.3) diff --git a/source/bulkdata/reportprofiles.c b/source/bulkdata/reportprofiles.c index dbe48be5e..ec3115ac1 100644 --- a/source/bulkdata/reportprofiles.c +++ b/source/bulkdata/reportprofiles.c @@ -428,7 +428,6 @@ static void* reportOnDemand(void *input) if(!strncmp(action, ON_DEMAND_ACTION_UPLOAD, MAX_PROFILENAMES_LENGTH)) { T2Info("Upload XCONF report on demand \n"); - set_logdemand(true); generateDcaReport(false, true); } else if(!strncmp(action, ON_DEMAND_ACTION_ABORT, MAX_PROFILENAMES_LENGTH)) @@ -486,6 +485,10 @@ T2ERROR initReportProfiles() drop_root(); #endif + //Initialise the properties file RDK-58222 + T2InitProperties(); + T2Info("Initializing properties\n"); + #if defined (PRIVACYMODES_CONTROL) // Define scope { @@ -640,9 +643,6 @@ T2ERROR initReportProfiles() } - //Initialise the properties file RDK-58222 - T2InitProperties(); - T2Info("InitProperties is successful\n"); // This indicates telemetry has started FILE* bootFlag = NULL ; diff --git a/source/dcautil/dca.c b/source/dcautil/dca.c index abbc8c78f..93e2e1d48 100644 --- a/source/dcautil/dca.c +++ b/source/dcautil/dca.c @@ -275,6 +275,16 @@ int processTopPattern(char* profileName, Vector* topMarkerList, int profileExec { continue; } + if (topMarkerObj->cpuValue) + { + free(topMarkerObj->cpuValue); + topMarkerObj->cpuValue = NULL; + } + if (topMarkerObj->memValue) + { + free(topMarkerObj->memValue); + topMarkerObj->memValue = NULL; + } int tmp_skip_interval, is_skip_param; tmp_skip_interval = topMarkerObj->skipFreq; if(tmp_skip_interval <= 0) @@ -310,6 +320,16 @@ int processTopPattern(char* profileName, Vector* topMarkerList, int profileExec continue; } + if (topMarkerObj->cpuValue) + { + free(topMarkerObj->cpuValue); + topMarkerObj->cpuValue = NULL; + } + if (topMarkerObj->memValue) + { + free(topMarkerObj->memValue); + topMarkerObj->memValue = NULL; + } // If the skip frequency is set, skip the marker processing for this interval int tmp_skip_interval, is_skip_param; @@ -380,7 +400,7 @@ static int getLogSeekValue(hash_map_t *logSeekMap, const char *name, long *seek_ T2Debug("logSeekMap is null .. Setting seek value to 0 \n"); *seek_value = 0 ; } - + T2Debug("seekvalue for file %s is %ld\n", name, *seek_value); T2Debug("%s --out \n", __FUNCTION__); return rc; } @@ -525,6 +545,7 @@ static int getCountPatternMatch(FileDescriptor* fileDescriptor, GrepMarker* mark // Using the union for efficient memory handling marker->u.count = count; + T2Debug("Count Marker: Marker = %s Value %d\n", marker->markerName, marker->u.count); T2Debug("%s --out\n", __FUNCTION__); return 0; } @@ -635,7 +656,7 @@ static int getAbsolutePatternMatch(FileDescriptor* fileDescriptor, GrepMarker* m { marker->u.markerValue = result; } - + T2Debug("Absolute Marker: Marker = %s Value %s\n", marker->markerName, marker->u.markerValue); T2Debug("%s --out\n", __FUNCTION__); return 0; } diff --git a/source/dcautil/dcaproc.c b/source/dcautil/dcaproc.c index 2a9a4b592..203e25dc3 100644 --- a/source/dcautil/dcaproc.c +++ b/source/dcautil/dcaproc.c @@ -29,6 +29,7 @@ * @{ **/ +#define _GNU_SOURCE #include #include #include @@ -94,7 +95,8 @@ int getProcUsage(char *processName, TopMarker* marker, char* filename) pid_t *pid = NULL; pid_t *temp = NULL; memset(&pInfo, '\0', sizeof(procMemCpuInfo)); - memcpy(pInfo.processName, processName, strlen(processName) + 1); + strncpy(pInfo.processName, processName, BUF_LEN - 1); + pInfo.processName[BUF_LEN - 1] = '\0'; T2Debug("Command for collecting process info : \n pidof %s", processName); #ifdef LIBSYSWRAPPER_BUILD @@ -229,17 +231,7 @@ int getProcUsage(char *processName, TopMarker* marker, char* filename) if(0 != getProcInfo(&pInfo, filename)) { T2Debug("Process info - CPU: %s, Memory: %s \n", pInfo.cpuUse, pInfo.memUse); - - if (marker->cpuValue) - { - free(marker->cpuValue); - } marker->cpuValue = strdup(pInfo.cpuUse); - - if (marker->memValue) - { - free(marker->memValue); - } marker->memValue = strdup(pInfo.memUse); ret = 1; @@ -533,15 +525,24 @@ int getCPUInfo(procMemCpuInfo *pInfo, char* filename) char top_op[2048] = { '\0' }; int cmd_option = 0; int normalize = 1; + int read_from_file = 0; if(pInfo == NULL) { return 0; } - if((filename != NULL) && (access(filename, F_OK) != 0)) + if((filename != NULL) && (access(filename, F_OK) == 0)) { - T2Debug("%s ++in the savad temp log %s is not available \n", __FUNCTION__, filename); + /* TOPTEMP file is available - open directly in C, no shell spawning needed */ + T2Debug("%s ++in the saved temp log %s is available \n", __FUNCTION__, filename); + inFp = fopen(filename, "r"); + normalize = TOPITERATION; + read_from_file = 1; + } + else + { + T2Debug("%s ++in the saved temp log %s is not available \n", __FUNCTION__, filename); /* Check Whether -c option is supported */ #ifdef LIBSYSWRAPPER_BUILD ret = v_secure_system(" top -c -n 1 2> /dev/null 1> /dev/null"); @@ -554,53 +555,29 @@ int getCPUInfo(procMemCpuInfo *pInfo, char* filename) } #ifdef INTEL - /* Format Use: `top n 1 | grep Receiver` */ - if ( 1 == cmd_option ) - { -#ifdef LIBSYSWRAPPER_BUILD - inFp = v_secure_popen("r", "top -n 1 -c | grep -v grep |grep -i '%s'", pInfo->processName); -#else - sprintf(command, "top -n 1 -c | grep -v grep |grep -i '%s'", pInfo->processName); - inFp = popen(command, "r"); -#endif - } - else - { + /* Format Use: `top n 1 (-c)` */ #ifdef LIBSYSWRAPPER_BUILD - inFp = v_secure_popen("r", "top -n 1 | grep -i '%s'", pInfo->processName); + inFp = v_secure_popen("r", "top -n 1 %s", (cmd_option == 1) ? "-c" : ""); #else - sprintf(command, "top -n 1 | grep -i '%s'", pInfo->processName); - inFp = popen(command, "r"); + snprintf(command, CMD_LEN, "top -n 1 %s", (cmd_option == 1) ? "-c" : ""); + inFp = popen(command, "r"); #endif - } #else /* ps -C Receiver -o %cpu -o %mem */ //sprintf(command, "ps -C '%s' -o %%cpu -o %%mem | sed 1d", pInfo->processName); #ifdef LIBSYSWRAPPER_BUILD - inFp = v_secure_popen("r", "top -b -n 1 %s | grep -v grep | grep -i '%s'", (cmd_option == 1) ? "-c" : "", pInfo->processName); + inFp = v_secure_popen("r", "top -b -n 1 %s", (cmd_option == 1) ? "-c" : ""); #else - snprintf(command, CMD_LEN, "top -b -n 1 %s | grep -v grep | grep -i '%s'", (cmd_option == 1) ? "-c" : "", pInfo->processName); + snprintf(command, CMD_LEN, "top -b -n 1 %s", (cmd_option == 1) ? "-c" : ""); inFp = popen(command, "r"); #endif #endif } - else - { - T2Debug("%s ++in the savad temp log %s is available \n", __FUNCTION__, filename); -#ifdef LIBSYSWRAPPER_BUILD - inFp = v_secure_popen("r", "cat %s |grep -i '%s'", TOPTEMP, pInfo->processName); -#else - snprintf(command, sizeof(command), "cat %s |grep -i '%s'", filename, pInfo->processName); - inFp = popen(command, "r"); -#endif - normalize = TOPITERATION; - - } if(!(inFp)) { - T2Debug("failed in open v_scure_popen pipe! ret %d\n", pclose_ret); + T2Debug("failed in open v_secure_popen pipe! ret %d\n", pclose_ret); return 0; } @@ -608,6 +585,15 @@ int getCPUInfo(procMemCpuInfo *pInfo, char* filename) #ifdef INTEL while(fgets(top_op, 2048, inFp) != NULL) { + /* match by process name (case-insensitive), PID as fallback */ + if(strcasestr(top_op, pInfo->processName) == NULL) + { + int line_pid = 0; + if(pInfo->pid == NULL || sscanf(top_op, "%d", &line_pid) != 1 || line_pid != pInfo->pid[0]) + { + continue; + } + } if(sscanf(top_op, "%s %s %s %s %s %s %s %s", var1, var2, var3, var4, var5, var6, var7, var8) == 8) { total_cpu_usage += atof(var7); @@ -618,6 +604,15 @@ int getCPUInfo(procMemCpuInfo *pInfo, char* filename) #else while(fgets(top_op, 2048, inFp) != NULL) { + /* match by process name (case-insensitive), PID as fallback */ + if(strcasestr(top_op, pInfo->processName) == NULL) + { + int line_pid = 0; + if(pInfo->pid == NULL || sscanf(top_op, "%d", &line_pid) != 1 || line_pid != pInfo->pid[0]) + { + continue; + } + } if(sscanf(top_op, "%16s %16s %16s %16s %16s %16s %16s %512s %512s %512s", var1, var2, var3, var4, var5, var6, var7, var8, var9, var10) == 10) { total_cpu_usage += atof(var9); @@ -628,19 +623,24 @@ int getCPUInfo(procMemCpuInfo *pInfo, char* filename) snprintf(pInfo->cpuUse, sizeof(pInfo->cpuUse), "%.1lf", (float)(total_cpu_usage / normalize)); T2Debug("calculated CPU total value : %f Normalized value : %.1lf\n", total_cpu_usage, (float)(total_cpu_usage / normalize)); + if(read_from_file) + { + fclose(inFp); + } + else + { #ifdef LIBSYSWRAPPER_BUILD - pclose_ret = v_secure_pclose(inFp); + pclose_ret = v_secure_pclose(inFp); #else - pclose_ret = pclose(inFp); + pclose_ret = pclose(inFp); #endif - - if(pclose_ret != 0) - { - T2Debug("failed in closing pipe! ret %d\n", pclose_ret); + if(pclose_ret != 0) + { + T2Debug("failed in closing pipe! ret %d\n", pclose_ret); + } } - return ret; T2Debug("--out %s", __FUNCTION__); - + return ret; } #else //ENABLE_RDKC_SUPPORT & ENABLE_RDKB_SUPPORT diff --git a/source/dcautil/dcautil.h b/source/dcautil/dcautil.h index 1d25bf256..73487672b 100644 --- a/source/dcautil/dcautil.h +++ b/source/dcautil/dcautil.h @@ -53,7 +53,7 @@ void freeGResult(void *data); T2ERROR saveGrepConfig(char *name, Vector* grepMarkerList); T2ERROR getGrepResults(GrepSeekProfile **GSP, Vector *markerList, bool isClearSeekMap, bool check_rotated, char *customLogPath); #define PREFIX_SIZE 5 -#define BUF_LEN 16 +#define BUF_LEN 64 typedef struct proc_info { diff --git a/source/scheduler/scheduler.c b/source/scheduler/scheduler.c index bab6fa6a2..0046fb568 100644 --- a/source/scheduler/scheduler.c +++ b/source/scheduler/scheduler.c @@ -44,21 +44,21 @@ static ActivationTimeoutCB activationTimeoutCb; static Vector *profileList = NULL; static pthread_mutex_t scMutex; static bool sc_initialized = false; -static bool islogdemand = false; +static bool isretainSeekmap = true; static bool signalrecived_and_executing = true; static bool is_activation_time_out = false; -bool get_logdemand () +bool get_retainseekmap () { - T2Info(("get_logdemand ++in\n")); - return islogdemand; + T2Info(("get_retainseekmap ++in\n")); + return isretainSeekmap; } -void set_logdemand (bool value) +void set_retainseekmap (bool value) { - T2Info(("set_logdemand ++in\n")); - islogdemand = value; + T2Info(("set_retainseekmap ++in\n")); + isretainSeekmap = value; } void freeSchedulerProfile(void *data) @@ -297,14 +297,14 @@ void* TimeoutThread(void *arg) if(minThresholdTime == 0) { - if (get_logdemand() == true) + if (get_retainseekmap() == true) { - set_logdemand(false); - timeoutNotificationCb(tProfile->name, false); + timeoutNotificationCb(tProfile->name, false); // Passing clearseekvalue as false } else { - timeoutNotificationCb(tProfile->name, true); + set_retainseekmap(true); //After triggering LOG upload resetting the retainseekmap value to true so the next report generation doesn't affect + timeoutNotificationCb(tProfile->name, true); //Passing clearseek value as true } if(tProfile->terminated) { diff --git a/source/scheduler/scheduler.h b/source/scheduler/scheduler.h index 5bee6b9dd..356cf398e 100644 --- a/source/scheduler/scheduler.h +++ b/source/scheduler/scheduler.h @@ -60,8 +60,8 @@ T2ERROR unregisterProfileFromScheduler(const char* profileName); T2ERROR SendInterruptToTimeoutThread(char* profileName); -bool get_logdemand(); +bool get_retainseekmap(); -void set_logdemand(bool value); +void set_retainseekmap(bool value); #endif /* _SCHEDULER_H_ */ diff --git a/source/telemetry2_0.c b/source/telemetry2_0.c index c9dce45bd..f24396ca6 100644 --- a/source/telemetry2_0.c +++ b/source/telemetry2_0.c @@ -175,13 +175,12 @@ void sig_handler(int sig, siginfo_t* info, void* uc) else if ( sig == SIGUSR1 || sig == LOG_UPLOAD ) { T2Info(("LOG_UPLOAD received!\n")); - set_logdemand(false); + set_retainseekmap(false); ReportProfiles_Interrupt(); } else if (sig == LOG_UPLOAD_ONDEMAND || sig == SIGIO) { T2Info(("LOG_UPLOAD_ONDEMAND received!\n")); - set_logdemand(true); ReportProfiles_Interrupt(); } else if(sig == SIGUSR2 || sig == EXEC_RELOAD) diff --git a/source/test/bulkdata/profileTest.cpp b/source/test/bulkdata/profileTest.cpp index 3041e7ae0..0035d66a6 100644 --- a/source/test/bulkdata/profileTest.cpp +++ b/source/test/bulkdata/profileTest.cpp @@ -787,8 +787,8 @@ TEST_F(ProfileTest, privacymode_do_not_share) { } TEST_F(ProfileTest, generateDcaReport) { - // generateDcaReport may call set_logdemand - EXPECT_CALL(*g_schedulerMock, set_logdemand(_)) + // generateDcaReport may call set_retainseekmap + EXPECT_CALL(*g_schedulerMock, set_retainseekmap(_)) .Times(::testing::AtMost(2)); // Allow up to 2 calls generateDcaReport(false, true); diff --git a/source/test/dcautils/dcautilTest.cpp b/source/test/dcautils/dcautilTest.cpp index 398f612ea..817627654 100644 --- a/source/test/dcautils/dcautilTest.cpp +++ b/source/test/dcautils/dcautilTest.cpp @@ -371,7 +371,7 @@ TEST(GETPROCINFO, PMINFO_NULL) memset(&pInfo, '\0', sizeof(procMemCpuInfo)); memcpy(pInfo.processName, processName, strlen(processName) + 1); pInfo.total_instance = 0; - EXPECT_EQ(0,getProcInfo(&pInfo, NULL)); + EXPECT_NE(0,getProcInfo(&pInfo, NULL)); free(filename); } @@ -1104,33 +1104,38 @@ TEST_F(dcaTestFixture, processTopPattern2) .WillOnce(Return(0)); #endif FILE* fp = (FILE*)0xFFFFFFFF; - //getProcUsage + //getProcUsage - pidof #ifdef LIBSYSWRAPPER_BUILD EXPECT_CALL(*g_fileIOMock, v_secure_popen(_,_)) - .Times(3) - .WillOnce(Return(fp)) + .Times(2) .WillOnce(Return(fp)) .WillOnce(Return(fp)); #else EXPECT_CALL(*g_fileIOMock, popen(_,_)) - .Times(2) - .WillOnce(Return(fp)) + .Times(1) .WillOnce(Return(fp)); #endif #ifdef LIBSYSWRAPPER_BUILD EXPECT_CALL(*g_fileIOMock, v_secure_pclose(_)) - .Times(3) - .WillOnce(Return(0)) + .Times(2) .WillOnce(Return(0)) .WillOnce(Return(0)); #else EXPECT_CALL(*g_fileIOMock, pclose(_)) - .Times(2) - .WillOnce(Return(0)) + .Times(1) .WillOnce(Return(0)); #endif + // getCPUInfo reads TOPTEMP file directly via fopen + FILE* topfp = (FILE*)0xEEEEEEEE; + EXPECT_CALL(*g_fileIOMock, fopen(_,_)) + .Times(1) + .WillOnce(Return(topfp)); + EXPECT_CALL(*g_fileIOMock, fclose(_)) + .Times(1) + .WillOnce(Return(0)); + //getMEMinfo EXPECT_CALL(*g_fileIOMock, read(_,_,_)) .WillOnce([](int fd, void* buf, size_t count) { diff --git a/source/test/mocks/FileioMock.cpp b/source/test/mocks/FileioMock.cpp index 81cf54d17..10a918dcb 100644 --- a/source/test/mocks/FileioMock.cpp +++ b/source/test/mocks/FileioMock.cpp @@ -137,9 +137,15 @@ extern "C" int fscanf(FILE *stream, const char *format, ...) va_list args; va_start(args, format); static int call_count = 0; + static FileMock *last_mock = nullptr; if (g_fileIOMock == nullptr){ return fscanf_func(stream, format, args); } + /* Reset call_count when a new mock instance is active (i.e. new test started) */ + if (g_fileIOMock != last_mock) { + call_count = 0; + last_mock = g_fileIOMock; + } if (strcmp(format, "%d") == 0) { int *out_ptr = va_arg(args, int *); if (call_count == 0) { diff --git a/source/test/scheduler/schedulerTest.cpp b/source/test/scheduler/schedulerTest.cpp index 244f73e7f..0e77ec3f8 100644 --- a/source/test/scheduler/schedulerTest.cpp +++ b/source/test/scheduler/schedulerTest.cpp @@ -123,14 +123,14 @@ class rdklogTestFixture : public ::testing::Test { }; -TEST(GET_LOGDEMAND, TEST1) +TEST(GET_RETAINSEEKMAP, TEST1) { - EXPECT_EQ( false, get_logdemand()); + EXPECT_EQ( true, get_retainseekmap()); } -TEST(SET_LOGDEMAND, TEST1) +TEST(SET_RETAINSEEKMAP, TEST1) { - set_logdemand(true); + set_retainseekmap(true); } TEST(GETLAPSEDTIME, T1_GT_T2)