|
| 1 | +# SuspendResume Validation Test |
| 2 | +Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. |
| 3 | +SPDX-License-Identifier: BSD-3-Clause-Clear |
| 4 | + |
| 5 | +## Overview |
| 6 | +This test case validates the system suspend/resume functionality on the target device using ADB-based remote control. It triggers a suspend cycle, waits for the device to resume, and validates the suspend/resume operation through multiple checks including suspend statistics, kernel logs, and Qualcomm-specific power management statistics. |
| 7 | + |
| 8 | +## Test Performs: |
| 9 | +1. Connects to device via ADB and obtains root access |
| 10 | +2. Remounts filesystems as read-write |
| 11 | +3. Mounts debugfs for accessing kernel statistics |
| 12 | +4. Captures initial suspend count from `/sys/power/suspend_stats/success` |
| 13 | +5. Triggers suspend using `rtcwake` (30-second timer) and `systemctl suspend` |
| 14 | +6. Waits for device to resume (40-second timeout) |
| 15 | +7. Validates suspend/resume cycle through three checks: |
| 16 | + - **Check 1**: Verifies suspend count incremented |
| 17 | + - **Check 2**: Verifies suspend entry markers in dmesg |
| 18 | + - **Check 3**: Verifies resume markers in dmesg |
| 19 | +8. Collects comprehensive debug statistics: |
| 20 | + - Kernel suspend statistics |
| 21 | + - Qualcomm power management statistics (AOSD, ADSP, CDSP, DDR, CXSD) |
| 22 | + - Complete qcom_stats and suspend_stats dumps |
| 23 | + |
| 24 | +## Usage |
| 25 | +Instructions: |
| 26 | +1. **Copy repo to Host Machine**: Clone or download the repository to your host machine where ADB is installed. |
| 27 | +2. **Connect Device**: Ensure the target device is connected via ADB and visible with `adb devices`. |
| 28 | +3. **Run Test**: Execute the test script which will remotely control the device via ADB. |
| 29 | + |
| 30 | +Run the SuspendResume test using: |
| 31 | +--- |
| 32 | + |
| 33 | +#### Quick Example |
| 34 | +```sh |
| 35 | +git clone <this-repo> |
| 36 | +cd <this-repo> |
| 37 | + |
| 38 | +# Ensure device is connected |
| 39 | +adb devices |
| 40 | + |
| 41 | +# Run the test |
| 42 | +cd Runner/suites/Kernel/Baseport/SuspendResume |
| 43 | +./run.sh |
| 44 | +``` |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## Prerequisites |
| 49 | +1. **ADB**: The `adb` command must be available on the host machine |
| 50 | +2. **Single Device Connection**: Exactly one target device must be connected via ADB |
| 51 | + - The test will automatically detect and validate device count |
| 52 | + - Multiple devices will cause the test to skip with an error message |
| 53 | +3. **Root Access**: Device must allow `adb root` for root access |
| 54 | +4. **Kernel Support**: Device must support: |
| 55 | + - `rtcwake` command for RTC-based wakeup |
| 56 | + - `systemctl suspend` for triggering suspend |
| 57 | + - Suspend statistics in `/sys/power/suspend_stats/` |
| 58 | + - Debugfs support for accessing kernel debug information |
| 59 | +5. **RTC Device**: `/dev/rtc0` must be present and functional |
| 60 | +6. **Framework Files**: `init_env` and `functestlib.sh` must be present and correctly configured |
| 61 | + |
| 62 | +## Configuration |
| 63 | +The test uses the following default configuration (can be modified in run.sh): |
| 64 | +```sh |
| 65 | +SUSPEND_DURATION=30 # seconds to suspend |
| 66 | +WAIT_TIMEOUT=40 # seconds to wait for device to resume |
| 67 | +``` |
| 68 | + |
| 69 | +## Result Format |
| 70 | +Test result will be saved in `SuspendResume.res` as: |
| 71 | + |
| 72 | +## Output |
| 73 | +A .res file is generated in the same directory: |
| 74 | +- `SuspendResume PASS` - All validation checks passed |
| 75 | +- `SuspendResume FAIL` - One or more validation checks failed |
| 76 | +- `SuspendResume SKIP` - ADB not available or prerequisites not met |
| 77 | + |
| 78 | +## Validation Checks |
| 79 | + |
| 80 | +### Check 1: Suspend Count Increment |
| 81 | +Verifies that `/sys/power/suspend_stats/success` incremented after suspend/resume cycle. |
| 82 | + |
| 83 | +### Check 2: Suspend Entry Markers |
| 84 | +Searches dmesg for suspend entry indicators: |
| 85 | +- `PM: suspend entry` |
| 86 | +- `Freezing user space processes` |
| 87 | + |
| 88 | +### Check 3: Resume Markers |
| 89 | +Searches dmesg for resume indicators: |
| 90 | +- `PM: suspend exit` |
| 91 | +- `Restarting tasks` |
| 92 | + |
| 93 | +## Debug Statistics Collected |
| 94 | + |
| 95 | +The test collects comprehensive power management statistics: |
| 96 | + |
| 97 | +### Kernel Suspend Stats |
| 98 | +- `/sys/kernel/debug/suspend_stats` - Overall suspend statistics |
| 99 | + |
| 100 | +### Qualcomm Power Stats |
| 101 | +- `/sys/kernel/debug/qcom_stats/aosd` - Always-On Subsystem Domain stats |
| 102 | +- `/sys/kernel/debug/qcom_stats/adsp` - Audio DSP stats |
| 103 | +- `/sys/kernel/debug/qcom_stats/adsp_island` - ADSP Island mode stats |
| 104 | +- `/sys/kernel/debug/qcom_stats/cdsp` - Compute DSP stats |
| 105 | +- `/sys/kernel/debug/qcom_stats/ddr` - DDR stats |
| 106 | +- `/sys/kernel/debug/qcom_stats/cxsd` - CX Subsystem Domain stats |
| 107 | + |
| 108 | +### Complete Dumps |
| 109 | +- All entries in `/sys/kernel/debug/qcom_stats/` |
| 110 | +- All entries in `/sys/power/suspend_stats/` |
| 111 | + |
| 112 | +## Skip Criteria |
| 113 | +The test will be skipped if: |
| 114 | +1. `adb` command is not found on the host machine |
| 115 | +2. No ADB devices are connected |
| 116 | +3. Multiple ADB devices are connected (only one device is allowed) |
| 117 | +4. Device is not responding to ADB commands |
| 118 | + |
| 119 | +## Failure Criteria |
| 120 | +The test will fail if: |
| 121 | +1. Device does not resume within the timeout period (40 seconds) |
| 122 | +2. Suspend count does not increment |
| 123 | +3. Suspend entry markers are not found in kernel log |
| 124 | +4. Resume markers are not found in kernel log |
| 125 | + |
| 126 | +## Sample Log - Success |
| 127 | +``` |
| 128 | +[INFO] 2026-02-01 20:30:00 - ----------------------------------------------------------------------------------------- |
| 129 | +[INFO] 2026-02-01 20:30:00 - -------------------Starting SuspendResume Testcase (ADB-based)---------------------------- |
| 130 | +[INFO] 2026-02-01 20:30:00 - === Test Initialization === |
| 131 | +[INFO] 2026-02-01 20:30:00 - Checking for connected ADB devices... |
| 132 | +[INFO] 2026-02-01 20:30:01 - Detected 1 device(s) |
| 133 | +[INFO] 2026-02-01 20:30:01 - Single device detected - proceeding with test |
| 134 | +[INFO] 2026-02-01 20:30:01 - Waiting for device to be ready... |
| 135 | +[INFO] 2026-02-01 20:30:02 - Obtaining root access... |
| 136 | +[INFO] 2026-02-01 20:30:04 - Remounting filesystems as read-write... |
| 137 | +[INFO] 2026-02-01 20:30:05 - Mounting debugfs... |
| 138 | +[INFO] 2026-02-01 20:30:06 - Capturing pre-suspend state... |
| 139 | +[INFO] 2026-02-01 20:30:06 - Initial suspend count: 5 |
| 140 | +[INFO] 2026-02-01 20:30:06 - Triggering suspend for 30 seconds... |
| 141 | +[INFO] 2026-02-01 20:30:06 - Command: rtcwake -d /dev/rtc0 -m no -s 30 && systemctl suspend |
| 142 | +[INFO] 2026-02-01 20:30:11 - Waiting for device to resume (timeout: 40s)... |
| 143 | +[PASS] 2026-02-01 20:30:38 - Device resumed successfully |
| 144 | +[INFO] 2026-02-01 20:30:41 - Post-resume phase: Validating suspend/resume cycle |
| 145 | +[INFO] 2026-02-01 20:30:42 - Current suspend count: 6 |
| 146 | +[PASS] 2026-02-01 20:30:42 - Validation 1 PASSED: Suspend count increased from 5 to 6 |
| 147 | +[INFO] 2026-02-01 20:30:42 - Checking for suspend entry markers in kernel log... |
| 148 | +[PASS] 2026-02-01 20:30:43 - Validation 2 PASSED: Suspend entry markers found |
| 149 | +[INFO] 2026-02-01 20:30:43 - Checking for resume markers in kernel log... |
| 150 | +[PASS] 2026-02-01 20:30:44 - Validation 3 PASSED: Resume markers found |
| 151 | +[INFO] 2026-02-01 20:30:44 - Collecting debug statistics... |
| 152 | +[PASS] 2026-02-01 20:30:50 - SuspendResume : Test Passed - Suspend/Resume cycle completed successfully |
| 153 | +``` |
| 154 | + |
| 155 | +## Sample Log - Failure (Device Not Resuming) |
| 156 | +``` |
| 157 | +[INFO] 2026-02-01 20:30:00 - ----------------------------------------------------------------------------------------- |
| 158 | +[INFO] 2026-02-01 20:30:00 - -------------------Starting SuspendResume Testcase (ADB-based)---------------------------- |
| 159 | +[INFO] 2026-02-01 20:30:00 - === Test Initialization === |
| 160 | +[INFO] 2026-02-01 20:30:00 - Checking for connected ADB devices... |
| 161 | +[INFO] 2026-02-01 20:30:01 - Detected 1 device(s) |
| 162 | +[INFO] 2026-02-01 20:30:01 - Single device detected - proceeding with test |
| 163 | +[INFO] 2026-02-01 20:30:01 - Waiting for device to be ready... |
| 164 | +[INFO] 2026-02-01 20:30:02 - Obtaining root access... |
| 165 | +[INFO] 2026-02-01 20:30:04 - Remounting filesystems as read-write... |
| 166 | +[INFO] 2026-02-01 20:30:05 - Mounting debugfs... |
| 167 | +[INFO] 2026-02-01 20:30:06 - Capturing pre-suspend state... |
| 168 | +[INFO] 2026-02-01 20:30:06 - Initial suspend count: 5 |
| 169 | +[INFO] 2026-02-01 20:30:06 - Triggering suspend for 30 seconds... |
| 170 | +[INFO] 2026-02-01 20:30:06 - Command: rtcwake -d /dev/rtc0 -m no -s 30 && systemctl suspend |
| 171 | +[INFO] 2026-02-01 20:30:11 - Waiting for device to resume (timeout: 40s)... |
| 172 | +[INFO] 2026-02-01 20:30:16 - Still waiting... (10s elapsed) |
| 173 | +[INFO] 2026-02-01 20:30:26 - Still waiting... (20s elapsed) |
| 174 | +[INFO] 2026-02-01 20:30:36 - Still waiting... (30s elapsed) |
| 175 | +[INFO] 2026-02-01 20:30:46 - Still waiting... (40s elapsed) |
| 176 | +[FAIL] 2026-02-01 20:30:51 - SuspendResume : Device did not resume within 40s timeout |
| 177 | +``` |
| 178 | + |
| 179 | +## Sample Log - Skip (Multiple Devices) |
| 180 | +``` |
| 181 | +[INFO] 2026-02-01 20:30:00 - ----------------------------------------------------------------------------------------- |
| 182 | +[INFO] 2026-02-01 20:30:00 - -------------------Starting SuspendResume Testcase (ADB-based)---------------------------- |
| 183 | +[INFO] 2026-02-01 20:30:00 - === Test Initialization === |
| 184 | +[INFO] 2026-02-01 20:30:00 - Checking for connected ADB devices... |
| 185 | +[INFO] 2026-02-01 20:30:01 - Detected 2 device(s) |
| 186 | +[FAIL] 2026-02-01 20:30:01 - Multiple ADB devices connected (2 devices) - please connect only one device |
| 187 | +[INFO] 2026-02-01 20:30:01 - Connected devices: |
| 188 | +List of devices attached |
| 189 | +ABC123456789 device |
| 190 | +DEF987654321 device |
| 191 | +``` |
| 192 | + |
| 193 | +## Sample Log - Skip (No Devices) |
| 194 | +``` |
| 195 | +[INFO] 2026-02-01 20:30:00 - ----------------------------------------------------------------------------------------- |
| 196 | +[INFO] 2026-02-01 20:30:00 - -------------------Starting SuspendResume Testcase (ADB-based)---------------------------- |
| 197 | +[INFO] 2026-02-01 20:30:00 - === Test Initialization === |
| 198 | +[INFO] 2026-02-01 20:30:00 - Checking for connected ADB devices... |
| 199 | +[INFO] 2026-02-01 20:30:01 - Detected 0 device(s) |
| 200 | +[FAIL] 2026-02-01 20:30:01 - No ADB devices connected - please connect a device |
| 201 | +``` |
| 202 | + |
| 203 | +## Integration with LAVA |
| 204 | +This test is designed to work with LAVA's ADB support framework. The YAML configuration file (`SuspendResume.yaml`) defines the test metadata and execution steps for LAVA integration. |
| 205 | + |
| 206 | +## Troubleshooting |
| 207 | + |
| 208 | +### Device Not Resuming |
| 209 | +- Check if RTC device (`/dev/rtc0`) is functional |
| 210 | +- Verify `rtcwake` command works manually |
| 211 | +- Check if suspend is supported: `cat /sys/power/state` |
| 212 | +- Increase `WAIT_TIMEOUT` if device takes longer to resume |
| 213 | + |
| 214 | +### ADB Connection Issues |
| 215 | +- Verify device is visible: `adb devices` |
| 216 | +- Ensure only one device is connected (disconnect other devices if multiple are shown) |
| 217 | +- Try `adb kill-server && adb start-server` |
| 218 | +- Check USB connection and drivers |
| 219 | + |
| 220 | +### Multiple Devices Connected |
| 221 | +- The test requires exactly one device to be connected |
| 222 | +- Disconnect all but one device before running the test |
| 223 | +- Use `adb devices` to verify only one device is listed |
| 224 | + |
| 225 | +### Permission Issues |
| 226 | +- Ensure `adb root` works on your device |
| 227 | +- Some devices may require unlocked bootloader for root access |
| 228 | + |
| 229 | +### Missing Statistics |
| 230 | +- Verify debugfs is mounted: `adb shell mount | grep debugfs` |
| 231 | +- Check if qcom_stats are available: `adb shell ls /sys/kernel/debug/qcom_stats/` |
| 232 | + |
| 233 | +## Notes |
| 234 | +- The test uses a 30-second suspend duration by default |
| 235 | +- A 40-second timeout is used to wait for device resume |
| 236 | +- All commands are executed remotely via ADB |
| 237 | +- The test is non-destructive and safe to run multiple times |
| 238 | +- Debug statistics collection is best-effort and won't fail the test if unavailable |
| 239 | + |
| 240 | +## License |
| 241 | +SPDX-License-Identifier: BSD-3-Clause-Clear |
0 commit comments