RDK-60544 : Migrate rebootNow script to C - L1/L2#4
Conversation
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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-resultsjob doesn't check out the repo, but it passespwdas the repo path togtest-json-result-push.pyand setssafe.directorytopwd. 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 anactions/checkoutstep (or mount${{ github.workspace }}into the container) and pass that path instead ofpwd.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Reason for Change :
Adding L1 and L2 testcases