|
| 1 | +# `resource-tuner` Test Runner (`run.sh`) |
| 2 | + |
| 3 | +A pinned **whitelist** test runner for `resource-tuner` that produces per-suite logs and an overall gating result for CI. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## What this runs |
| 8 | + |
| 9 | +Only these binaries are executed, in this order (anything else is ignored): |
| 10 | +``` |
| 11 | +/usr/bin/ClientDataManagerTests |
| 12 | +/usr/bin/ResourceProcessorTests |
| 13 | +/usr/bin/MemoryPoolTests |
| 14 | +/usr/bin/SignalConfigProcessorTests |
| 15 | +/usr/bin/DeviceInfoTests |
| 16 | +/usr/bin/ThreadPoolTests |
| 17 | +/usr/bin/MiscTests |
| 18 | +/usr/bin/SignalParsingTests |
| 19 | +/usr/bin/SafeOpsTests |
| 20 | +/usr/bin/ExtensionIntfTests |
| 21 | +/usr/bin/RateLimiterTests |
| 22 | +/usr/bin/SysConfigAPITests |
| 23 | +/usr/bin/ExtFeaturesParsingTests |
| 24 | +/usr/bin/RequestMapTests |
| 25 | +/usr/bin/TargetConfigProcessorTests |
| 26 | +/usr/bin/InitConfigParsingTests |
| 27 | +/usr/bin/RequestQueueTests |
| 28 | +/usr/bin/CocoTableTests |
| 29 | +/usr/bin/ResourceParsingTests |
| 30 | +/usr/bin/TimerTests |
| 31 | +/usr/bin/resource_tuner_tests |
| 32 | +``` |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +## Gating policy |
| 37 | + |
| 38 | +* **Service check (early gate):** If `resource-tuner.service` is **not active**, the test **SKIPs overall** and exits. |
| 39 | +* **Per‑suite SKIP conditions (neutral):** |
| 40 | + * Missing binary → **SKIP that suite**, continue. |
| 41 | + * Missing base configs → **SKIP that suite**, continue. |
| 42 | + * Missing test nodes for `resource_tuner_tests` → **SKIP that suite**, continue. |
| 43 | +* **Final result:** |
| 44 | + * If **any** suite **FAILS** → **overall FAIL**. |
| 45 | + * Else if **≥1** suite **PASS** → **overall PASS**. |
| 46 | + * Else (**everything SKIPPED**) → **overall SKIP**. |
| 47 | + |
| 48 | +> Skips are **neutral**: they never convert a passing run into a failure. |
| 49 | +
|
| 50 | +--- |
| 51 | + |
| 52 | +## Pre‑checks |
| 53 | + |
| 54 | +### 1) Service |
| 55 | +The runner uses the repo helper `check_systemd_services()` to verify **`resource-tuner.service`** is active. |
| 56 | +- On failure: overall **SKIP** (ends early). |
| 57 | +- Override service name: `SERVICE_NAME=your.service ./run.sh` |
| 58 | + |
| 59 | +### 2) Config presence |
| 60 | +Suites that parse configs require **at least one** of these base config trees: |
| 61 | + |
| 62 | +- `common/` (required files): |
| 63 | + - `InitConfig.yaml`, `PropertiesConfig.yaml`, `ResourcesConfig.yaml`, `SignalsConfig.yaml` |
| 64 | + |
| 65 | +- `custom/` (required files): |
| 66 | + - `InitConfig.yaml`, `PropertiesConfig.yaml`, `ResourcesConfig.yaml`, `SignalsConfig.yaml`, `TargetConfig.yaml`, `ExtFeaturesConfig.yaml` |
| 67 | + |
| 68 | +If **both** trees are missing required files/dirs, config‑parsing suites are **SKIP** only (neutral). |
| 69 | + |
| 70 | +> Override required file lists without editing the script: |
| 71 | +```bash |
| 72 | +export RT_REQUIRE_COMMON_FILES="InitConfig.yaml PropertiesConfig.yaml ResourcesConfig.yaml SignalsConfig.yaml" |
| 73 | +export RT_REQUIRE_CUSTOM_FILES="InitConfig.yaml PropertiesConfig.yaml ResourcesConfig.yaml SignalsConfig.yaml TargetConfig.yaml ExtFeaturesConfig.yaml" |
| 74 | +``` |
| 75 | + |
| 76 | +### 3) Test ResourceSysFsNodes |
| 77 | +`/etc/resource-tuner/tests/Configs/ResourceSysFsNodes` must exist and be non‑empty for **`/usr/bin/resource_tuner_tests`**. If missing/empty → **SKIP only that suite**. |
| 78 | + |
| 79 | +### 4) Base tools |
| 80 | +Requires: `awk`, `grep`, `date`, `printf`. If missing → **overall SKIP**. |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## CLI |
| 85 | + |
| 86 | +``` |
| 87 | +Usage: ./run.sh [--all] [--bin <name|absolute>] [--list] [--timeout SECS] |
| 88 | +``` |
| 89 | + |
| 90 | +- `--all` (default): run all approved suites. |
| 91 | +- `--bin NAME|PATH`: run a single approved suite. |
| 92 | +- `--list`: print approved list and presence coverage, then exit. |
| 93 | +- `--timeout SECS`: default per‑binary timeout **if** `run_with_timeout()` helper exists (else ignored). |
| 94 | + |
| 95 | +Per‑suite default timeouts (if helper is present): |
| 96 | +- `ThreadPoolTests`, `RateLimiterTests`: **1800s** |
| 97 | +- `resource_tuner_tests`: **2400s** |
| 98 | +- others: **1200s** (default) |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +## Output layout |
| 103 | + |
| 104 | +- **Overall status file:** `./resource-tuner.res` → `PASS` / `FAIL` / `SKIP` |
| 105 | +- **Logs directory:** `./logs/resource-tuner-YYYYMMDD-HHMMSS/` |
| 106 | + - Per‑suite logs: `SUITE.log` |
| 107 | + - Per‑suite result markers: `SUITE.res` (`PASS`/`FAIL`/`SKIP`) |
| 108 | + - Coverage summaries: `coverage.txt`, `missing_bins.txt`, `coverage_counts.env` |
| 109 | + - System snapshot: `dmesg_snapshot.log` |
| 110 | +- **Symlink to latest:** `./logs/resource-tuner-latest` |
| 111 | + |
| 112 | +**Parsing heuristics:** a suite is considered PASS if the binary exits 0 **or** its log contains |
| 113 | +`Run Successful`, `executed successfully`, or `Ran Successfully`. Strings like `Assertion failed`, `Terminating Suite`, `Segmentation fault`, `Backtrace`, or `fail/failed` mark **FAIL**. |
| 114 | + |
| 115 | +--- |
| 116 | + |
| 117 | +## Environment overrides |
| 118 | + |
| 119 | +- `SERVICE_NAME`: systemd unit to check (default: `resource-tuner.service`) |
| 120 | +- `RT_CONFIG_DIR`: root of config tree (default: `/etc/resource-tuner`) |
| 121 | +- `RT_REQUIRE_COMMON_FILES`, `RT_REQUIRE_CUSTOM_FILES`: *space‑separated* filenames that must exist in `common/` / `custom/` respectively to treat that tree as present. |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +## Examples |
| 126 | + |
| 127 | +Run all (normal CI mode): |
| 128 | +```bash |
| 129 | +./run.sh |
| 130 | +``` |
| 131 | + |
| 132 | +Run a single suite by basename: |
| 133 | +```bash |
| 134 | +./run.sh --bin ResourceParsingTests |
| 135 | +``` |
| 136 | + |
| 137 | +List suites and presence coverage: |
| 138 | +```bash |
| 139 | +./run.sh --list |
| 140 | +``` |
| 141 | + |
| 142 | +Use a different config root: |
| 143 | +```bash |
| 144 | +RT_CONFIG_DIR=/opt/rt/etc ./run.sh |
| 145 | +``` |
| 146 | + |
| 147 | +--- |
| 148 | + |
| 149 | +## Exit status |
| 150 | + |
| 151 | +The script writes the overall result to `resource-tuner.res`. The **process exit code is 0** in all cases in the current version (soft gating). If you want hard CI gating via non‑zero exit on FAIL, that can be added easily on request. |
| 152 | + |
| 153 | +--- |
| 154 | + |
| 155 | +## Troubleshooting |
| 156 | + |
| 157 | +- **Overall SKIP immediately** → service inactive. Check `systemctl status resource-tuner.service`. |
| 158 | +- **Suite SKIP (config)** → confirm required files exist under `common/` or `custom/` (see lists above). |
| 159 | +- **Suite SKIP (missing bin)** → verify the binary is installed and executable under `/usr/bin`. |
| 160 | +- **Suite FAIL** → inspect `logs/.../SUITE.log` for the first failure pattern or assertion. |
| 161 | +- **Very long runs** → a `run_with_timeout` helper (if available in your repo toolchain) will be used automatically. |
| 162 | + |
| 163 | +## License |
| 164 | +- SPDX-License-Identifier: BSD-3-Clause-Clear |
| 165 | +- (C) Qualcomm Technologies, Inc. and/or its subsidiaries. |
0 commit comments