RDKEMW-14720 : Unify Reboot Manager Codebase with >90% L1/L2 Coverage#16
RDKEMW-14720 : Unify Reboot Manager Codebase with >90% L1/L2 Coverage#16Saranya2421 wants to merge 9 commits into
Conversation
* Added Testcases for L1 and L2 integration * Create L1-tests.yml * Create L2-tests.yml * Update unittest/cyclic_reboot_gtest.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update run_l2.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update unit_test.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update L1-tests.yml * Addressing review comments * Fix for L1 Failure * L1 Fix * L1 error fix * Fixing L1 and L2 errors * Fix for L1 and L2 * L1 Fix * Fix for L2 error * Update L2-tests.yml * Update Makefile.am * Update test_system_cleanup.py * Increase L1 coverage * Create flowchart.md * Create sequence-diagram.md * Create HLD.md * Create LLD.md * Create testing.md * Create architecture.md * Create README.md * Update README.md * Handle cyclic reboot scenario --------- Co-authored-by: Saranya <saranya_elango@comcast.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces a unified reboot-manager codebase plus new L1 (gtest) and L2 (pytest) test coverage and supporting build/scripts/docs to reach high coverage targets.
Changes:
- Adds multiple new gtest binaries + mocks/stubs and a unit-test build harness (autotools) with coverage capture.
- Adds a new
update-prev-reboot-infoC implementation (reboot-reason-fetcher) and related platform/Parodus/JSON handling. - Adds L2 functional pytest scenarios, systemd units, and extensive documentation/diagrams.
Reviewed changes
Copilot reviewed 99 out of 99 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
unittest/utils_gtest.cpp |
Adds unit tests for timestamp + log append helpers (currently includes a non-existent header). |
unittest/system_cleanup_gtest.cpp |
Adds unit tests for cleanup/PID/log sync behaviors (currently includes a non-existent header). |
unittest/rebootreason_main_gtest.cpp |
Adds smoke test for lock helpers and gtest main for updater module. |
unittest/reboot_parodus_gtest.cpp |
Adds tests for parodus log/file handling and keypress copy behavior. |
unittest/reboot_json_gtest.cpp |
Adds tests for JSON persistence helpers and lock helpers. |
unittest/rbus_interface_gtest.cpp |
Adds RBUS interface tests with an in-test RBUS mock implementation. |
unittest/mocks/telemetry_busmessage_sender.h |
Adds telemetry stub header for unit-test builds. |
unittest/mocks/secure_wrapper_stub.c |
Adds a secure-wrapper stub for unit tests. |
unittest/mocks/secure_wrapper.h |
Adds a secure-wrapper stub header for unit tests. |
unittest/mocks/rdk_logger_stub.c |
Adds logger stubs to satisfy linkage in unit tests. |
unittest/mocks/rdk_debug.h |
Adds a lightweight RDK_LOG macro/config stub for unit tests. |
unittest/mocks/rbus_mock_types.h |
Adds minimal RBUS type/prototype definitions for unit tests. |
unittest/cyclic_reboot_gtest.cpp |
Adds cyclic reboot policy tests with RBUS stubs. |
unittest/configure.ac |
Adds autotools configuration for the unittest/ subpackage. |
unittest/Makefile.am |
Adds build rules for gtest binaries (currently missing many binaries used by unit_test.sh, and uses wrong source/include paths). |
unit_test.sh |
Adds a unit-test runner with optional coverage generation and lcov capture. |
tests/functional_tests/test/test_scenario_update_prev_reboot_skips_when_flags_missing.py |
Adds L2 scenario validating early-exit gating behavior. |
tests/functional_tests/test/test_scenario_update_prev_reboot_service_flow_after_stt_flag.py |
Adds L2 scenario for STT-flag service flow. |
tests/functional_tests/test/test_scenario_update_prev_reboot_generates_previous_files_and_flags.py |
Adds L2 scenario for previous file/flag generation (currently contains invalid ~ lines). |
tests/functional_tests/test/test_scenario_soft_reboot_updates_reboot_log_and_previous_reboot_info.py |
Adds L2 scenario validating log + JSON outputs after reboot. |
tests/functional_tests/test/test_scenario_soft_reboot_category_classification_matrix.py |
Adds L2 matrix scenario validating classification mapping. |
tests/functional_tests/test/test_scenario_reboot_info_log_previous_fields_present.py |
Adds L2 scenario validating previous reboot fields in log + JSON. |
tests/functional_tests/test/test_scenario_previous_reboot_info_string_in_messages.py |
Adds L2 scenario validating previous reboot info propagation into messages/log artifacts. |
tests/functional_tests/test/test_scenario_previous_reboot_info_json_format.py |
Adds L2 scenario validating JSON schema keys. |
tests/functional_tests/test/test_scenario_previous_parodus_file_has_software_reboot_info.py |
Adds L2 scenario validating previous parodus file content. |
tests/functional_tests/test/test_scenario_parodus_log_contains_reboot_reason.py |
Adds L2 scenario validating Parodus log update behavior. |
tests/functional_tests/test/test_scenario_kernel_panic_oops_updates_reboot_files_via_reboot_binary.py |
Adds L2 scenario validating kernel panic/oops classification output. |
tests/functional_tests/test/test_scenario_kernel_panic_oops_is_logged_in_messages.py |
Adds L2 scenario validating panic evidence appears in messages/logs. |
tests/functional_tests/test/test_scenario_hard_reboot_updates_hardpower_and_previousreboot.py |
Adds L2 scenario validating hardpower + previous reboot generation. |
tests/functional_tests/test/test_scenario_hard_reboot_unknown_defaults_to_null_mapping.py |
Adds L2 scenario validating unknown hardware fallback mapping. |
tests/functional_tests/test/test_scenario_bootup_reboot_files_and_log_created.py |
Adds L2 scenario validating bootup-triggered artifacts. |
tests/functional_tests/test/test_reboot_triggered.py |
Adds L2 baseline reboot trigger functional test. |
tests/functional_tests/test/test_reboot_crash_maintenance.py |
Adds L2 crash/maintenance categorization functional test. |
tests/functional_tests/test/test_cyclic_reboot.py |
Adds L2 functional coverage for cyclic reboot defer/reset behavior. |
tests/functional_tests/test/reboot_reason_test_common.py |
Adds common constants/helpers for functional tests. |
tests/functional_tests/test/helper_functions.py |
Adds helper functions used by functional tests. |
tests/functional_tests/test/conftest.py |
Adds pytest fixtures for running rebootnow and controlling environment (currently missing fixtures used by new tests). |
tests/functional_tests/features/*.feature |
Adds BDD-style feature specs mirroring the new functional test scenarios. |
services/update-reboot-info.service |
Adds systemd service unit for updater execution (currently points at a script not present in repo). |
services/update-reboot-info.path |
Adds systemd path unit triggering the updater service on STT flag changes. |
run_l2.sh |
Adds L2 runner script for pytest scenarios (currently invokes missing test module and starts a binary name that doesn’t match what this repo builds). |
reboot-reason-fetcher/src/rebootreason_main.c |
Adds the main orchestration for deriving/persisting previous reboot context. |
reboot-reason-fetcher/src/platform_hal.c |
Adds platform HW reason routing and mapping (currently missing NULL-arg guards in the top-level entry). |
reboot-reason-fetcher/src/parodus_log_update.c |
Adds Parodus log/file update + keypress copy helpers (contains a data-loss behavior when dest open fails). |
reboot-reason-fetcher/src/json.c |
Adds lock + JSON writers (currently writes unescaped strings into JSON). |
reboot-reason-fetcher/src/Makefile.am |
Adds build rules for the updater binary. |
reboot-reason-fetcher/include/update-reboot-info.h |
Adds public API/header constants and structs for updater module. |
reboot-helper/src/utils.c |
Adds reboot-helper utilities (timestamp/log + T2 wrappers). |
reboot-helper/src/rbus_interface.c |
Adds RBUS wrapper implementation with singleton handle. |
reboot-helper/src/cyclic_reboot.c |
Adds cyclic reboot handling implementation. |
reboot-helper/src/Makefile.am |
Adds build rules for librebootnow and rebootnow. |
reboot-helper/include/reboot.h |
Adds public reboot-helper header. |
reboot-helper/include/rbus_interface.h |
Adds public RBUS wrapper header. |
docs/reboot-reason-fetcher/diagrams/sequence-diagram.md |
Adds updater sequence diagram documentation. |
docs/reboot-reason-fetcher/diagrams/flowchart.md |
Adds updater flowchart documentation. |
docs/reboot-reason-fetcher/architecture.md |
Adds updater architecture documentation. |
docs/reboot-reason-fetcher/HLD.md |
Adds updater high-level design documentation. |
docs/reboot-helper/testing.md |
Adds build/test/validation guide. |
docs/reboot-helper/diagrams/sequence-diagram.md |
Adds reboot-helper sequence diagram documentation. |
docs/reboot-helper/diagrams/flowchart.md |
Adds reboot-helper flowchart documentation. |
docs/reboot-helper/architecture.md |
Adds reboot-helper architecture documentation. |
docs/reboot-helper/README.md |
Adds docs index/README for reboot-helper docs. |
docs/reboot-helper/LLD.md |
Adds reboot-helper low-level design documentation. |
docs/reboot-helper/HLD.md |
Adds reboot-helper high-level design documentation. |
cov_build.sh |
Adds CI build script used by L2 workflow. |
configure.ac |
Adds/updates top-level autotools config (currently has an invalid AC_CONFIG_SRCDIR invocation). |
README.md |
Expands top-level README with architecture, flows, usage, and testing instructions. |
NOTICE |
Adds/updates NOTICE file content. |
Makefile.am |
Sets up top-level automake subdirs + exported headers. |
LICENSE |
Adds Apache-2.0 license text. |
COPYING |
Adds COPYING indirection to LICENSE. |
CONTRIBUTING.md |
Adds contribution instructions. |
.github/workflows/L2-tests.yml |
Adds GitHub Actions L2 workflow using container environment. |
.github/workflows/L1-tests.yml |
Adds GitHub Actions L1 workflow using container environment. |
Comments suppressed due to low confidence (2)
tests/functional_tests/test/conftest.py:62
- Several new functional tests depend on fixtures that are not defined here (
ensure_update_binaryandrun_update_prev_reboot). As a result, pytest will error at collection time with “fixture not found”. Add these fixtures (and ensure they locate/execute theupdate-prev-reboot-info/updater binary consistently with the build/install paths used in CI).
tests/functional_tests/test/test_scenario_update_prev_reboot_generates_previous_files_and_flags.py:22 - The trailing
~lines are not valid Python syntax and will cause an immediateSyntaxError, preventing the functional test suite from running. Remove these stray editor artifacts.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| reboot_main_gtest_SOURCES = reboot_main_gtest.cpp \ | ||
| $(top_srcdir)/../rebootnow/src/utils.c \ | ||
| $(top_srcdir)/../rebootnow/src/cyclic_reboot.c \ | ||
| mocks/rdk_logger_stub.c | ||
| reboot_main_gtest_CPPFLAGS = $(COMMON_CPPFLAGS) | ||
| reboot_main_gtest_CPPFLAGS += -I$(srcdir)/mocks -I$(top_srcdir)/unittest/mocks | ||
| reboot_main_gtest_CPPFLAGS += -DT2_EVENT_ENABLED |
| FILE *out = fopen(destPath, "w"); | ||
| if (!out) { | ||
| RDK_LOG(RDK_LOG_ERROR,"LOG.RDK.REBOOTINFO","Failed to open %s: %s\n", destPath, strerror(errno)); | ||
| (void)unlink(PARODUS_REBOOT_INFO_FILE); | ||
| return ERROR_GENERAL; | ||
| } |
| [Unit] | ||
| Description=Update Previous reboot info | ||
| ConditionPathExists=/tmp/stt_received | ||
|
|
||
| [Service] | ||
| ExecStart=/lib/rdk/update_previous_reboot_info.sh |
| bin_PROGRAMS = reboot_utils_gtest reboot_rbus_gtest reboot_cyclic_gtest reboot_system_gtest reboot_main_gtest | ||
|
|
||
| AM_CPPFLAGS = -I$(srcdir)/mocks -I$(top_srcdir)/../rebootnow/include -I$(top_srcdir)/../rebootnow/src | ||
| AM_CXXFLAGS = -std=c++14 | ||
|
|
||
| # Only preprocessor defs and forced include here; no C++ standard flags | ||
| COMMON_CPPFLAGS = -DGTEST_ENABLE \ | ||
| -I$(srcdir)/mocks \ | ||
| -I$(top_srcdir)/../rebootnow/include \ | ||
| -I$(top_srcdir)/../rebootnow/src \ | ||
| -include $(srcdir)/mocks/rbus_mock_types.h \ | ||
| -include $(srcdir)/mocks/telemetry_busmessage_sender.h | ||
|
|
| pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_reboot_triggered.py | ||
| pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_bootup_reboot_files_and_log_created.py | ||
| pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_hard_reboot_unknown_defaults_to_null_mapping.py | ||
| pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_hard_reboot_updates_hardpower_and_previousreboot.py | ||
| pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_hardware_detection_paths_defined.py | ||
| pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_kernel_panic_oops_is_logged_in_messages.py |
| fprintf(fp, "{\n"); | ||
| fprintf(fp, "\"timestamp\":\"%s\",\n", info->timestamp); | ||
| fprintf(fp, "\"source\":\"%s\",\n", info->source); | ||
| fprintf(fp, "\"reason\":\"%s\",\n", info->reason); | ||
| fprintf(fp, "\"customReason\":\"%s\",\n", info->customReason); | ||
| fprintf(fp, "\"otherReason\":\"%s\"\n", info->otherReason); | ||
| fprintf(fp, "}\n"); |
| #include <gtest/gtest.h> | ||
| extern "C" { | ||
| #include "update-reboot-info.h" | ||
| } | ||
|
|
||
| #define GTEST_DEFAULT_RESULT_FILEPATH "/tmp/Gtest_Report/" | ||
| #define GTEST_DEFAULT_RESULT_FILENAME "reboot_main_gtest_report.json" | ||
| #define GTEST_REPORT_FILEPATH_SIZE 256 | ||
|
|
||
| // Smoke tests for helpers used by main.c | ||
| TEST(MainSmokeTest, acquire_release_lock_InvalidParams) { | ||
| EXPECT_EQ(acquire_lock(nullptr), ERROR_GENERAL); | ||
| EXPECT_EQ(release_lock(nullptr), ERROR_GENERAL); | ||
| } | ||
|
|
||
| // Note: We don't call main() directly; this suite ensures build/link of main.c | ||
| // via Makefile.am target using the same compilation unit. | ||
|
|
||
| GTEST_API_ int main(int argc, char *argv[]) { | ||
| char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE]; | ||
| memset(testresults_fullfilepath, 0, GTEST_REPORT_FILEPATH_SIZE); | ||
| snprintf(testresults_fullfilepath, GTEST_REPORT_FILEPATH_SIZE, "json:%s%s", | ||
| GTEST_DEFAULT_RESULT_FILEPATH, GTEST_DEFAULT_RESULT_FILENAME); |
| extern "C" { | ||
| #include "rebootnow.h" | ||
| } |
|
|
||
| /usr/local/bin/update-reboot-info & | ||
|
|
||
| # Run L2 Test cases |
| src_fd = open(srcPath, O_RDONLY); | ||
| if (src_fd < 0) { | ||
| RDK_LOG(RDK_LOG_ERROR,"LOG.RDK.REBOOTINFO","Failed to open source file %s: %s\n", srcPath, strerror(errno)); | ||
| return SUCCESS; | ||
| } |
mhughesacn
left a comment
There was a problem hiding this comment.
Hi @Saranya2421 : A few small changes requested please. (After you are done, I still have to clear stuff in the tool.) Thank you.
| # If not stated otherwise in this file or this component's LICENSE file the | ||
| # following copyright and licenses apply: | ||
| # | ||
| # Copyright 2020 RDK Management |
There was a problem hiding this comment.
If this file is written by RDK and not Comcast, please add a credit to the end of NOTICE:
Copyright 2020 RDK Management
Licensed under the Apache License, Version 2.0
If not, then use the Comcast header.
| # If not stated otherwise in this file or this component's LICENSE | ||
| # file the following copyright and licenses apply: | ||
| # | ||
| # Copyright 2018 RDK Management |
There was a problem hiding this comment.
If written by RDK or taken from elsewhere there, please add RDK credit to the end of NOTICE or otherwise use Comcast Copyright.
| conditions of these licenses. The LICENSE file contains the text of all the licenses which apply | ||
| within this component.. | ||
|
|
||
| Copyright 2026 Comcast Cable Communications Management, LLC |
There was a problem hiding this comment.
Sorry, my fault earlier: please delete these line (26/27) as they are a repeat of lines 4-6.
| @@ -0,0 +1 @@ | |||
| LICENSE | |||
There was a problem hiding this comment.
Apologies, I didn't spot this earlier: COPYING should be a soft link to LICENSE, not a file containing the text "LICENSE".
No description provided.