Feature/rdkemw 18459 - #151
Open
Abhinavpv28 wants to merge 109 commits into
Open
Conversation
Comment on lines
+266
to
+273
| struct timespec deadline; | ||
| if (clock_gettime(CLOCK_MONOTONIC, &deadline) != 0) { | ||
| RDK_LOG(RDK_LOG_WARN, LOG_UPLOADSTB, | ||
| "[%s:%d] clock_gettime failed (errno=%d); falling back to polling for %s\n", | ||
| __FUNCTION__, __LINE__, errno, flag_path); | ||
| inotify_rm_watch(ifd, wd); | ||
| close(ifd); | ||
| } |
Comment on lines
+1109
to
+1118
| // Remove STT_FLAG to verify it's NOT created | ||
| unlink(STT_FLAG); | ||
|
|
||
| trigger_reboot_info_update(); | ||
|
|
||
| // STT_FLAG should NOT be created since PATH_FLAG_INVOCATION exists | ||
| struct stat st; | ||
| EXPECT_NE(stat(STT_FLAG, &st), 0); | ||
|
|
||
| unlink(PATH_FLAG_INVOCATION); |
Comment on lines
+1126
to
+1139
| // Ensure PATH_FLAG_INVOCATION does NOT exist | ||
| unlink(PATH_FLAG_INVOCATION); | ||
| // Ensure STT_FLAG does NOT exist | ||
| unlink(STT_FLAG); | ||
|
|
||
| trigger_reboot_info_update(); | ||
|
|
||
| // STT_FLAG should now exist | ||
| struct stat st; | ||
| EXPECT_EQ(stat(STT_FLAG, &st), 0); | ||
|
|
||
| // Cleanup | ||
| unlink(STT_FLAG); | ||
| } |
Comment on lines
414
to
418
| if (!mac_address || strlen(mac_address) == 0) { | ||
| RDK_LOG(RDK_LOG_ERROR, LOG_UPLOADSTB, | ||
| "[%s:%d] MAC address is NULL or empty\n", __FUNCTION__, __LINE__); | ||
| return false; | ||
| } |
Comment on lines
+1106
to
+1119
| TEST_F(HelperFunctionsTest, TriggerRebootInfoUpdate_FlagAlreadyPresent) { | ||
| // Create PATH_FLAG_INVOCATION so stat() succeeds | ||
| CreateFile(PATH_FLAG_INVOCATION); | ||
| // Remove STT_FLAG to verify it's NOT created | ||
| unlink(STT_FLAG); | ||
|
|
||
| trigger_reboot_info_update(); | ||
|
|
||
| // STT_FLAG should NOT be created since PATH_FLAG_INVOCATION exists | ||
| struct stat st; | ||
| EXPECT_NE(stat(STT_FLAG, &st), 0); | ||
|
|
||
| unlink(PATH_FLAG_INVOCATION); | ||
| } |
Comment on lines
+1125
to
+1139
| TEST_F(HelperFunctionsTest, TriggerRebootInfoUpdate_CreatesSTTFlag) { | ||
| // Ensure PATH_FLAG_INVOCATION does NOT exist | ||
| unlink(PATH_FLAG_INVOCATION); | ||
| // Ensure STT_FLAG does NOT exist | ||
| unlink(STT_FLAG); | ||
|
|
||
| trigger_reboot_info_update(); | ||
|
|
||
| // STT_FLAG should now exist | ||
| struct stat st; | ||
| EXPECT_EQ(stat(STT_FLAG, &st), 0); | ||
|
|
||
| // Cleanup | ||
| unlink(STT_FLAG); | ||
| } |
Code Coverage Summary |
| } | ||
|
|
||
| time_t now = time(NULL); | ||
| return generate_archive_name_at(buffer, buffer_size, mac_address, prefix, time(NULL)); |
Comment on lines
+1288
to
+1307
| // ---- trigger_reboot_info_update tests ---- | ||
|
|
||
| /** | ||
| * @test trigger_reboot_info_update does nothing when PATH_FLAG_INVOCATION exists. | ||
| * Covers: stat(PATH_FLAG_INVOCATION) succeeds → no STT_FLAG touch. | ||
| */ | ||
| TEST_F(HelperFunctionsTest, TriggerRebootInfoUpdate_FlagAlreadyPresent) { | ||
| // Create PATH_FLAG_INVOCATION so stat() succeeds | ||
| CreateFile(PATH_FLAG_INVOCATION); | ||
| // Remove STT_FLAG to verify it's NOT created | ||
| unlink(STT_FLAG); | ||
|
|
||
| trigger_reboot_info_update(); | ||
|
|
||
| // STT_FLAG should NOT be created since PATH_FLAG_INVOCATION exists | ||
| struct stat st; | ||
| EXPECT_NE(stat(STT_FLAG, &st), 0); | ||
|
|
||
| unlink(PATH_FLAG_INVOCATION); | ||
| } |
Comment on lines
+1309
to
+1327
| /** | ||
| * @test trigger_reboot_info_update creates STT_FLAG when PATH_FLAG_INVOCATION absent. | ||
| * Covers: stat(PATH_FLAG_INVOCATION) fails → open(STT_FLAG) path. | ||
| */ | ||
| TEST_F(HelperFunctionsTest, TriggerRebootInfoUpdate_CreatesSTTFlag) { | ||
| // Ensure PATH_FLAG_INVOCATION does NOT exist | ||
| unlink(PATH_FLAG_INVOCATION); | ||
| // Ensure STT_FLAG does NOT exist | ||
| unlink(STT_FLAG); | ||
|
|
||
| trigger_reboot_info_update(); | ||
|
|
||
| // STT_FLAG should now exist | ||
| struct stat st; | ||
| EXPECT_EQ(stat(STT_FLAG, &st), 0); | ||
|
|
||
| // Cleanup | ||
| unlink(STT_FLAG); | ||
| } |
Code Coverage Summary |
1 similar comment
Code Coverage Summary |
Comment on lines
+1294
to
+1307
| TEST_F(HelperFunctionsTest, TriggerRebootInfoUpdate_FlagAlreadyPresent) { | ||
| // Create PATH_FLAG_INVOCATION so stat() succeeds | ||
| CreateFile(PATH_FLAG_INVOCATION); | ||
| // Remove STT_FLAG to verify it's NOT created | ||
| unlink(STT_FLAG); | ||
|
|
||
| trigger_reboot_info_update(); | ||
|
|
||
| // STT_FLAG should NOT be created since PATH_FLAG_INVOCATION exists | ||
| struct stat st; | ||
| EXPECT_NE(stat(STT_FLAG, &st), 0); | ||
|
|
||
| unlink(PATH_FLAG_INVOCATION); | ||
| } |
Comment on lines
+1313
to
+1327
| TEST_F(HelperFunctionsTest, TriggerRebootInfoUpdate_CreatesSTTFlag) { | ||
| // Ensure PATH_FLAG_INVOCATION does NOT exist | ||
| unlink(PATH_FLAG_INVOCATION); | ||
| // Ensure STT_FLAG does NOT exist | ||
| unlink(STT_FLAG); | ||
|
|
||
| trigger_reboot_info_update(); | ||
|
|
||
| // STT_FLAG should now exist | ||
| struct stat st; | ||
| EXPECT_EQ(stat(STT_FLAG, &st), 0); | ||
|
|
||
| // Cleanup | ||
| unlink(STT_FLAG); | ||
| } |
Comment on lines
+1127
to
+1130
| g_mock_file_ops = nullptr; | ||
| // Close the real fd (mocked fclose didn't actually close it) | ||
| fclose(real_fp); | ||
| unlink(temp_file); |
Comment on lines
+307
to
+310
| /* Write completion sentinel for downstream consumers (reboot-manager, telemetry). | ||
| * /tmp/ is volatile — no stale-sentinel risk across reboots. | ||
| * Non-fatal: if open() fails, downstream services will time out and annotate gracefully. */ | ||
| { |
Comment on lines
1277
to
1282
| int dri_ret = create_dri_archive(ctx, dri_archive); | ||
|
|
||
| if (dri_ret == 0) { | ||
| #ifndef L2_TEST_ENABLED | ||
| sleep(60); | ||
| #endif | ||
|
|
||
| // Upload DRI logs using separate session state | ||
| SessionState dri_session = *session; // Copy current session config |
| __FUNCTION__, __LINE__, errno); | ||
| inotify_rm_watch(ifd, wd); | ||
| close(ifd); | ||
| return -1 |
Comment on lines
+242
to
+247
| int ifd = inotify_init1(IN_CLOEXEC); | ||
| if (ifd < 0) { | ||
| RDK_LOG(RDK_LOG_WARN, LOG_UPLOADSTB, | ||
| "[%s:%d] inotify_init1 failed (errno=%d); falling back to polling for %s\n", | ||
| __FUNCTION__, __LINE__, errno, flag_path); | ||
| } |
Comment on lines
+206
to
+214
| if (stat(PATH_FLAG_INVOCATION, &st) != 0) { | ||
| int fd = open(STT_FLAG, O_CREAT | O_WRONLY, 0644); | ||
| if (fd >= 0) { | ||
| close(fd); | ||
| RDK_LOG(RDK_LOG_INFO, LOG_UPLOADSTB, | ||
| "[%s:%d] Trigger reboot reason update: %s\n", | ||
| __FUNCTION__, __LINE__, STT_FLAG); | ||
| } | ||
| } |
Comment on lines
+193
to
+201
| * trigger_reboot_info_update - Touch STT_FLAG to trigger reboot-reason update. | ||
| * | ||
| * Called only after wait_for_reboot_reason() times out. | ||
| * Touching STT_FLAG (/tmp/stt_received) signals update-prev-reboot-info | ||
| * (reboot-manager) to perform an immediate reboot-reason update; reboot-manager | ||
| * watches STT_FLAG as its primary gate to run update_reboot_info(). | ||
| * | ||
| * Cross-repo interface: STT_FLAG is watched by reboot-manager. | ||
| */ |
Comment on lines
+939
to
+942
| * In that case query the network stack: if internet is reachable the clock | ||
| * is probably ahead of epoch so we retrieve the last-known-good time from | ||
| * systimemgr (via RBUS) and apply it with settimeofday(). This ensures | ||
| * archive timestamps are meaningful even without NTP. |
| EXPECT_EQ(result, 0); | ||
|
|
||
| g_mock_file_ops = nullptr; | ||
| fclose(real_fp); |
| EXPECT_EQ(result, 0); | ||
|
|
||
| g_mock_file_ops = nullptr; | ||
| fclose(real_fp); |
| EXPECT_EQ(result, 0); | ||
|
|
||
| g_mock_file_ops = nullptr; | ||
| fclose(real_fp); |
| EXPECT_EQ(result, (time_t)1700000000); | ||
|
|
||
| g_mock_file_ops = nullptr; | ||
| fclose(real_fp); |
| EXPECT_EQ(result, (time_t)1642780800); | ||
|
|
||
| g_mock_file_ops = nullptr; | ||
| fclose(real_fp); |
| __FUNCTION__, __LINE__, errno); | ||
| inotify_rm_watch(ifd, wd); | ||
| close(ifd); | ||
| return -1 |
Comment on lines
+201
to
+215
| int ifd = inotify_init1(IN_CLOEXEC); | ||
| if (ifd < 0) { | ||
| RDK_LOG(RDK_LOG_WARN, LOG_UPLOADSTB, | ||
| "[%s:%d] inotify_init1 failed (errno=%d); falling back to polling for %s\n", | ||
| __FUNCTION__, __LINE__, errno, flag_path); | ||
| } | ||
|
|
||
| int wd = inotify_add_watch(ifd, watch_dir, IN_CREATE | IN_MOVED_TO); | ||
| if (wd < 0) { | ||
| RDK_LOG(RDK_LOG_WARN, LOG_UPLOADSTB, | ||
| "[%s:%d] inotify_add_watch on %s failed (errno=%d); falling back to polling for %s\n", | ||
| __FUNCTION__, __LINE__, watch_dir, errno, flag_path); | ||
| close(ifd); | ||
| return -1; | ||
| } |
Comment on lines
+183
to
+191
| if (stat(PATH_FLAG_INVOCATION, &st) != 0) { | ||
| int fd = open(STT_FLAG, O_CREAT | O_WRONLY, 0644); | ||
| if (fd >= 0) { | ||
| close(fd); | ||
| RDK_LOG(RDK_LOG_INFO, LOG_UPLOADSTB, | ||
| "[%s:%d] Trigger reboot reason update: %s\n", | ||
| __FUNCTION__, __LINE__, STT_FLAG); | ||
| } | ||
| } |
| "[%s:%d] Reboot reason sentinel not present after %us. " | ||
| "trigger to request immediate update.\n", | ||
| __FUNCTION__, __LINE__, REBOOT_POLL_TIMEOUT_S); | ||
| trigger_reboot_info_update(); |
| "[%s:%d] Telemetry prevlogs sentinel not present after %us; " | ||
| "proceeding without telemetry sync\n", | ||
| __FUNCTION__, __LINE__, TELEMETRY_PREVLOGS_TIMEOUT_S); | ||
| } else { |
Comment on lines
+1221
to
+1223
| g_mock_file_ops = nullptr; | ||
| fclose(real_fp); | ||
| unlink(temp_file); |
Comment on lines
+1252
to
+1254
| g_mock_file_ops = nullptr; | ||
| fclose(real_fp); | ||
| unlink(temp_file); |
Comment on lines
+1283
to
+1285
| g_mock_file_ops = nullptr; | ||
| fclose(real_fp); | ||
| unlink(temp_file); |
Comment on lines
29
to
39
| @@ -35,10 +34,8 @@ typedef struct _dcmdHandle | |||
| BOOL isDCMRunning; | |||
| VOID *pRbusHandle; | |||
| VOID *pDcmSetHandle; | |||
| VOID *pLogSchedHandle; | |||
| VOID *pDifdSchedHandle; | |||
| INT8 *pExecBuff; | |||
| INT8 logCron[16]; | |||
| INT8 difdCron[16]; | |||
Comment on lines
32
to
34
| #include <stdbool.h> | ||
| #include <time.h> | ||
|
|
Comment on lines
+183
to
+191
| if (stat(PATH_FLAG_INVOCATION, &st) != 0) { | ||
| int fd = open(STT_FLAG, O_CREAT | O_WRONLY, 0644); | ||
| if (fd >= 0) { | ||
| close(fd); | ||
| RDK_LOG(RDK_LOG_INFO, LOG_UPLOADSTB, | ||
| "[%s:%d] Trigger reboot reason update: %s\n", | ||
| __FUNCTION__, __LINE__, STT_FLAG); | ||
| } | ||
| } |
Comment on lines
+201
to
+215
| int ifd = inotify_init1(IN_CLOEXEC); | ||
| if (ifd < 0) { | ||
| RDK_LOG(RDK_LOG_WARN, LOG_UPLOADSTB, | ||
| "[%s:%d] inotify_init1 failed (errno=%d); falling back to polling for %s\n", | ||
| __FUNCTION__, __LINE__, errno, flag_path); | ||
| } | ||
|
|
||
| int wd = inotify_add_watch(ifd, watch_dir, IN_CREATE | IN_MOVED_TO); | ||
| if (wd < 0) { | ||
| RDK_LOG(RDK_LOG_WARN, LOG_UPLOADSTB, | ||
| "[%s:%d] inotify_add_watch on %s failed (errno=%d); falling back to polling for %s\n", | ||
| __FUNCTION__, __LINE__, watch_dir, errno, flag_path); | ||
| close(ifd); | ||
| return -1; | ||
| } |
Comment on lines
+228
to
+233
| "[%s:%d] clock_gettime failed (errno=%d) \n", | ||
| __FUNCTION__, __LINE__, errno); | ||
| inotify_rm_watch(ifd, wd); | ||
| close(ifd); | ||
| return -1 | ||
| } |
Comment on lines
+239
to
+257
| while (!found) { | ||
| struct timespec now; | ||
| if (clock_gettime(CLOCK_MONOTONIC, &now) == 0 && | ||
| now.tv_sec >= deadline.tv_sec) { | ||
| break; /* timeout */ | ||
| } | ||
|
|
||
| struct timeval tv = {2, 0}; | ||
| fd_set fds; | ||
| FD_ZERO(&fds); | ||
| FD_SET(ifd, &fds); | ||
|
|
||
| int ret = select(ifd + 1, &fds, NULL, NULL, &tv); | ||
| if (ret < 0) { | ||
| if (errno == EINTR) { continue; } | ||
| break; | ||
| } | ||
| if (ret == 0) { continue; } /* heartbeat — re-check deadline */ | ||
|
|
Comment on lines
+883
to
+890
| /* NTP sync check (REQ-SYNC-002). | ||
| * If STT_FLAG is absent the system clock was not set from NTP this boot. | ||
| * In that case query the network stack: if internet is reachable the clock | ||
| * is probably ahead of epoch so we retrieve the last-known-good time from | ||
| * systimemgr (via RBUS) and apply it with settimeofday(). This ensures | ||
| * archive timestamps are meaningful even without NTP. | ||
| * If internet is not reachable we annotate the session and continue — the | ||
| * upload must not be blocked by a missing time source. */ |
Comment on lines
25
to
+28
| #include <gtest/gtest.h> | ||
| #include <gmock/gmock.h> | ||
| #include <thread> | ||
| #include <chrono> |
Comment on lines
414
to
418
| if (!mac_address || strlen(mac_address) == 0) { | ||
| RDK_LOG(RDK_LOG_ERROR, LOG_UPLOADSTB, | ||
| "[%s:%d] MAC address is NULL or empty\n", __FUNCTION__, __LINE__); | ||
| return false; | ||
| } |
Comment on lines
359
to
362
| bool used_fallback; /**< Whether fallback was used */ | ||
| bool success; /**< Overall success status */ | ||
| char archive_file[MAX_FILENAME_LENGTH]; /**< Generated archive filename */ | ||
| } SessionState; |
Comment on lines
+364
to
+365
| #define THUNDER_JSONRPC_URL "http://127.0.0.1:9998/jsonrpc" | ||
| #define INTERNET_CHECK_TIMEOUT_S 5L |
Comment on lines
32
to
34
| #include <stdbool.h> | ||
| #include <time.h> | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.