Skip to content

RDK-60544 : Migrate rebootNow script to C - L1/L2#4

Merged
Saranya2421 merged 29 commits into
developfrom
feature/RDK-60544
Mar 5, 2026
Merged

RDK-60544 : Migrate rebootNow script to C - L1/L2#4
Saranya2421 merged 29 commits into
developfrom
feature/RDK-60544

Conversation

@Saranya2421
Copy link
Copy Markdown
Contributor

Reason for Change :
Adding L1 and L2 testcases

Copilot AI review requested due to automatic review settings February 25, 2026 09:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds comprehensive L1 (unit) and L2 (functional) test coverage for the rebootNow script migration from shell to C. The PR introduces Google Test-based unit tests for individual components, mock implementations for external dependencies, build configuration for test compilation, and pytest-based functional tests with BDD feature files.

Changes:

  • Added L1 unit tests using Google Test/Google Mock for utils, rbus interface, cyclic reboot, system cleanup, and main reboot logic
  • Created mock implementations for external dependencies (rbus, telemetry, rdk_logger, secure_wrapper) to enable isolated unit testing
  • Added L2 functional tests using pytest to validate end-to-end behavior for reboot triggering, crash handling, cyclic reboot detection, PID guard, and system cleanup
  • Provided build scripts and configuration for running both unit and functional tests with code coverage support

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
unittest/utils_gtest.cpp Unit tests for utility functions (timestamp, file append, command execution)
unittest/system_cleanup_gtest.cpp Unit tests for system cleanup operations including log synchronization and PID file handling
unittest/reboot_main_gtest.cpp Comprehensive unit tests for main reboot logic covering argument parsing, categorization, and reboot sequence
unittest/rbus_interface_gtest.cpp Unit tests for RBUS parameter get/set operations with mock RBUS implementation
unittest/cyclic_reboot_gtest.cpp Unit tests for cyclic reboot detection and defer logic
unittest/mocks/*.c/h Mock implementations and stubs for external dependencies to enable unit testing
unittest/configure.ac Autoconf configuration for unit test build
unittest/Makefile.am Automake build rules for compiling and linking unit tests
unit_test.sh Shell script to build and execute all unit tests with coverage reporting
cov_build.sh Build script for coverage-enabled compilation
tests/functional_tests/test/*.py Pytest-based functional tests for L2 validation
tests/functional_tests/features/*.feature BDD feature files describing test scenarios
run_l2.sh Shell script to execute L2 functional tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread unittest/cyclic_reboot_gtest.cpp Outdated
Comment thread unittest/system_cleanup_gtest.cpp Outdated
Comment thread unittest/rbus_interface_gtest.cpp Outdated
Comment thread unit_test.sh Outdated
Comment thread run_l2.sh Outdated
Comment thread run_l2.sh Outdated
Comment thread run_l2.sh
Comment thread cov_build.sh
Comment thread cov_build.sh
Comment thread cov_build.sh
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 25, 2026 09:14
Saranya2421 and others added 3 commits February 25, 2026 14:45
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/functional_tests/test/test_reboot_crash_maintenance.py
Comment thread unit_test.sh
Comment thread unittest/system_cleanup_gtest.cpp Outdated
Comment thread unittest/rbus_interface_gtest.cpp Outdated
Comment thread unittest/Makefile.am Outdated
Comment thread run_l2.sh
Copilot AI review requested due to automatic review settings February 26, 2026 07:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 33 changed files in this pull request and generated 18 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread unittest/reboot_main_gtest.cpp
Comment thread unittest/system_cleanup_gtest.cpp Outdated
Comment thread rebootnow/src/cyclic_reboot.c
Comment thread tests/functional_tests/features/test_reboot_crash_maintenance.feature Outdated
Comment thread unittest/utils_gtest.cpp
Comment thread unittest/reboot_main_gtest.cpp
Comment thread unittest/system_cleanup_gtest.cpp Outdated
Comment thread tests/functional_tests/test/conftest.py
Comment thread unittest/Makefile.am Outdated
Comment thread unittest/utils_gtest.cpp
Copilot AI review requested due to automatic review settings February 26, 2026 08:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 33 changed files in this pull request and generated 16 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread unittest/system_cleanup_gtest.cpp
Comment thread unittest/system_cleanup_gtest.cpp
Comment thread unittest/cyclic_reboot_gtest.cpp
Comment thread unittest/reboot_main_gtest.cpp
Comment thread unit_test.sh
Comment thread unit_test.sh
Comment thread unittest/rbus_interface_gtest.cpp Outdated
Comment thread unittest/reboot_main_gtest.cpp
Comment thread tests/functional_tests/test/conftest.py Outdated
Comment thread unittest/Makefile.am Outdated
Copilot AI review requested due to automatic review settings February 26, 2026 11:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

.github/workflows/L1-tests.yml:59

  • The upload-test-results job doesn't check out the repo, but it passes pwd as the repo path to gtest-json-result-push.py and sets safe.directory to pwd. In a fresh job this directory is unlikely to be a git working tree, which can cause the upload script to fail or miss metadata. Add an actions/checkout step (or mount ${{ github.workspace }} into the container) and pass that path instead of pwd.
    steps:
      - name: Upload results
        if: github.repository_owner == 'rdkcentral'
        run: |
          echo "Contents in /tmp/Gtest_Report:"
          ls -l /tmp/Gtest_Report
          git config --global --add safe.directory `pwd`
          gtest-json-result-push.py /tmp/Gtest_Report https://rdkeorchestrationservice.apps.cloud.comcast.net/rdke_orchestration_api/push_unit_test_results `pwd`


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread configure.ac
Comment thread unittest/Makefile.am
Comment thread .github/workflows/L2-tests.yml Outdated
Comment thread .github/workflows/L2-tests.yml
Copilot AI review requested due to automatic review settings February 26, 2026 11:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rebootnow/src/system_cleanup.c
Comment thread rebootnow/src/main.c
Copilot AI review requested due to automatic review settings February 26, 2026 13:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 37 out of 37 changed files in this pull request and generated 9 comments.

Comments suppressed due to low confidence (2)

unittest/mocks/secure_wrapper.h:8

  • This header lacks an include guard / #pragma once. Without it, multiple inclusions can cause duplicate declaration warnings or other build issues in larger test code. Add a standard include guard to make it safe to include from multiple files.
#ifdef __cplusplus
extern "C" {
#endif
int v_secure_system(const char* fmt, ...);
#ifdef __cplusplus
}
#endif

unittest/mocks/rbus_mock_types.h:28

  • This mock header has no include guard / #pragma once. Since it is also force-included via -include, it’s easy for it to be pulled in multiple times and cause redefinition errors. Add an include guard to ensure idempotent inclusion.
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include <stdbool.h>

typedef void* rbusHandle_t;
typedef void* rbusValue_t;
typedef int rbusError_t;
#define RBUS_ERROR_SUCCESS 0

// Prototypes used by rbus_interface.c
rbusError_t rbus_open(rbusHandle_t* handle, const char* name);
void rbus_close(rbusHandle_t handle);
rbusError_t rbus_get(rbusHandle_t handle, const char* name, rbusValue_t* value);
rbusError_t rbus_set(rbusHandle_t handle, const char* name, rbusValue_t value, void* opts);

rbusValue_t rbusValue_Init(void* data);
void rbusValue_Release(rbusValue_t value);
const char* rbusValue_GetString(rbusValue_t value, int* len);
bool rbusValue_GetBoolean(rbusValue_t value);
int rbusValue_GetInt32(rbusValue_t value);
void rbusValue_SetBoolean(rbusValue_t value, bool v);
void rbusValue_SetInt32(rbusValue_t value, int v);
#ifdef __cplusplus
}
#endif


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rebootnow/src/main.c
Comment thread rebootnow/src/main.c
Comment thread unit_test.sh
Comment thread unittest/system_cleanup_gtest.cpp
Comment thread unittest/reboot_main_gtest.cpp
Comment thread unittest/mocks/unit_stubs.c Outdated
Comment thread unittest/Makefile.am Outdated
Comment thread tests/functional_tests/test/test_pid_guard.py Outdated
Comment thread unittest/system_cleanup_gtest.cpp
Copilot AI review requested due to automatic review settings February 27, 2026 07:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 39 out of 39 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/functional_tests/test/conftest.py
Comment thread rebootnow/src/system_cleanup.c
Comment thread rebootnow/src/cyclic_reboot.c
Comment thread .github/workflows/L1-tests.yml
Comment thread unit_test.sh
Comment thread unittest/reboot_main_gtest.cpp
Comment thread rebootnow/src/system_cleanup.c
Comment thread unittest/system_cleanup_gtest.cpp
Comment thread rebootnow/src/system_cleanup.c
Comment thread cov_build.sh
Copilot AI review requested due to automatic review settings February 27, 2026 08:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 42 out of 42 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rebootnow/src/system_cleanup.c
Comment thread rebootnow/src/cyclic_reboot.c
Copilot AI review requested due to automatic review settings February 27, 2026 13:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rebootnow/src/system_cleanup.c
Comment thread rebootnow/src/main.c
Comment thread .github/workflows/L2-tests.yml
Comment thread README.md
Comment thread docs/README.md
Comment thread rebootnow/src/system_cleanup.c
Comment thread docs/testing.md
Copy link
Copy Markdown
Contributor

@tdeva14 tdeva14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Saranya2421 Saranya2421 merged commit d751c26 into develop Mar 5, 2026
10 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants