|
1 | | -Overview |
| 1 | +# Reboot Health Check Test |
2 | 2 |
|
3 | | -This script automates a full reboot validation and health check for any embedded Linux system. |
4 | | -It ensures that after each reboot, the system: |
| 3 | +This test automates a full reboot validation and health check for an embedded Linux system. It ensures that after a reboot, the system: |
5 | 4 |
|
6 | | -Boots correctly to shell |
7 | | - |
8 | | -Key directories (/proc, /sys, /tmp, /dev) are available |
9 | | - |
10 | | -Kernel version is accessible |
11 | | - |
12 | | -Networking stack is functional |
13 | | - |
14 | | - |
15 | | -It supports auto-retry on failures, with configurable maximum retries. |
16 | | - |
17 | | -No dependency on cron, systemd, Yocto specifics — purely portable. |
| 5 | +- Boots into a stable shell |
| 6 | +- Key filesystems (`/proc`, `/sys`, `/tmp`, `/dev`) are accessible |
| 7 | +- Kernel version is accessible |
| 8 | +- Networking stack is functional |
18 | 9 |
|
| 10 | +This script is useful for validating device boot health as part of CI, flashing, or kernel testing workflows. |
19 | 11 |
|
20 | 12 | --- |
21 | 13 |
|
22 | | -Features |
23 | | - |
24 | | -Automatic setup of a temporary boot hook |
| 14 | +## Overview |
25 | 15 |
|
26 | | -Reboot and post-boot health validations |
| 16 | +The test script performs the following functional checks: |
27 | 17 |
|
28 | | -Detailed logs with PASS/FAIL results |
| 18 | +1. **Boot Validation** |
| 19 | + - Ensures the system boots into a stable shell. |
29 | 20 |
|
30 | | -Auto-retry mechanism up to a configurable limit |
31 | | - |
32 | | -Safe cleanup of temp files and hooks after success or failure |
33 | | - |
34 | | -Color-coded outputs for easy reading |
35 | | - |
36 | | -Lightweight and BusyBox compatible |
| 21 | +2. **Filesystem Accessibility** |
| 22 | + - Confirms that key filesystems (`/proc`, `/sys`, `/tmp`, `/dev`) are accessible. |
37 | 23 |
|
| 24 | +3. **Kernel Version Check** |
| 25 | + - Verifies that the kernel version is accessible. |
38 | 26 |
|
| 27 | +4. **Networking Stack Verification** |
| 28 | + - Checks that the networking stack is functional. |
39 | 29 |
|
40 | 30 | --- |
41 | | - |
42 | | -Usage |
43 | | - |
44 | | -Step 1: Copy the script to your device |
45 | | - |
46 | | -scp reboot_health_check_autoretry.sh root@<device_ip>:/tmp/ |
47 | | - |
48 | | -Step 2: Make it executable |
49 | | - |
50 | | -chmod +x /tmp/reboot_health_check_autoretry.sh |
51 | | - |
52 | | -Step 3: Run the script |
53 | | - |
54 | | -/tmp/reboot_health_check_autoretry.sh |
55 | | - |
56 | | -The script will automatically: |
57 | | - |
58 | | -Create a flag and self-copy to survive reboot |
59 | | - |
60 | | -Setup a temporary /etc/init.d/ hook |
61 | | - |
62 | | -Force reboot |
63 | | - |
64 | | -On reboot, validate the system |
65 | | - |
66 | | -Retry if needed |
67 | | - |
68 | | - |
| 31 | +## Files Used |
| 32 | + |
| 33 | +| File / Path | Description | |
| 34 | +|--------------------------------------------------|-----------------------------------------------------------------------------| |
| 35 | +| `run.sh` | Main script to execute the reboot validation test | |
| 36 | +| `/var/reboot_health/` | Directory to store log and retry-related files | |
| 37 | +| `/var/reboot_health/reboot_test.log` | Persistent log file for all test outputs | |
| 38 | +| `/var/reboot_health/reboot_retry_count` | File storing number of reboot retries (used internally) | |
| 39 | +| `/var/reboot_marker` | Temporary marker to differentiate pre- and post-reboot states | |
| 40 | +| `/etc/systemd/system/reboot-health.service` | systemd service file to autostart reboot health check after boot | |
| 41 | +| `/var/common/reboot_health_check.sh` | Actual reboot validation script that is called on system boot | |
69 | 42 |
|
70 | 43 | --- |
71 | 44 |
|
72 | | -Log File |
73 | | - |
74 | | -All outputs are stored in /tmp/reboot_test.log |
75 | | - |
76 | | -Summarizes all individual tests and overall result |
77 | | - |
78 | | - |
79 | 45 |
|
80 | 46 | --- |
81 | | - |
82 | | -Configuration |
83 | | - |
84 | | -Modify these inside the script if needed: |
85 | | - |
86 | | - |
| 47 | +## Service setup: |
| 48 | +1. Copy the `reboot-health.service` file to: |
| 49 | +Enable the service: |
| 50 | +systemctl`enable reboot-health.service` |
87 | 51 | --- |
88 | 52 |
|
89 | | -Pass/Fail Criteria |
90 | | - |
91 | | - |
92 | 53 | --- |
| 54 | +## Manual Run Instructions: |
93 | 55 |
|
94 | | -Limitations |
95 | | - |
96 | | -Requires basic /bin/sh shell (ash, bash, dash supported) |
97 | | - |
98 | | -Needs writable /tmp/ and /etc/init.d/ |
99 | | - |
100 | | -Does not rely on systemd, cron, or external daemons |
101 | | - |
102 | | - |
| 56 | +1. **make the script excuetable** |
| 57 | + `chmod +x run.sh` |
103 | 58 |
|
| 59 | +2. **Run the test using:** |
| 60 | + `./run-test.sh Reboot_health_check` |
104 | 61 | --- |
105 | 62 |
|
106 | | -Cleanup |
107 | | - |
108 | | -Script automatically: |
109 | | - |
110 | | -Removes temporary boot hook |
111 | | - |
112 | | -Deletes self-copy after successful completion |
113 | | - |
114 | | -Cleans retry counters |
115 | | - |
116 | | - |
117 | | -You don't need to manually intervene. |
118 | | - |
119 | | - |
120 | 63 | --- |
121 | | - |
122 | | -Example Run Output |
123 | | - |
124 | | -2025-04-26 19:45:20 [START] Reboot Health Test Started |
125 | | -2025-04-26 19:45:21 [STEP] Preparing system for reboot test... |
126 | | -2025-04-26 19:45:23 [INFO] System will reboot now to perform validation. |
127 | | -(reboots) |
128 | | - |
129 | | -2025-04-26 19:46:10 [STEP] Starting post-reboot validation... |
130 | | -2025-04-26 19:46:11 [PASS] Boot flag detected. System reboot successful. |
131 | | -2025-04-26 19:46:12 [PASS] Shell is responsive. |
132 | | -2025-04-26 19:46:12 [PASS] Directory /proc exists. |
133 | | -2025-04-26 19:46:12 [PASS] Directory /sys exists. |
134 | | -2025-04-26 19:46:12 [PASS] Directory /tmp exists. |
135 | | -2025-04-26 19:46:12 [PASS] Directory /dev exists. |
136 | | -2025-04-26 19:46:12 [PASS] Kernel version: 6.6.65 |
137 | | -2025-04-26 19:46:13 [PASS] Network stack active (ping localhost successful). |
138 | | -2025-04-26 19:46:13 [OVERALL PASS] Reboot + Health Check successful! |
| 64 | +## Sample output: |
| 65 | +```text |
| 66 | +[2025-05-22 18:11:00] [START] Reboot Health Test Started |
| 67 | +[2025-05-22 18:11:00] [INFO] Reboot marker not found. Rebooting now... |
| 68 | +Rebooting... |
| 69 | +
|
| 70 | +...system reboots... |
| 71 | +
|
| 72 | +[2025-05-22 18:11:10] [START] Reboot Health Test Started |
| 73 | +[2025-05-22 18:11:10] [PASS] System booted successfully and root shell obtained. |
| 74 | +[2025-05-22 18:11:10] [OVERALL PASS] Reboot + Health Check successful! |
| 75 | +``` |
| 76 | +--- |
| 77 | +--- |
| 78 | +## Notes: |
| 79 | +```text |
| 80 | +The device takes approximately 10 seconds to reach shell after reboot. |
| 81 | +Log file is persistent and accumulates output from all runs. |
| 82 | +You can manually clear logs using: |
| 83 | + `rm -f /var/reboot_health/reboot_test.log` |
| 84 | +``` |
| 85 | +--- |
| 86 | +## License: |
| 87 | +```text |
| 88 | +SPDX-License-Identifier: BSD-3-Clause-Clear |
| 89 | +(C) Qualcomm Technologies, Inc. and/or its subsidiaries. |
| 90 | +``` |
139 | 91 |
|
0 commit comments