Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,45 +1,26 @@
# `resource-tuner` Test Runner (`run.sh`)
# `userspace-resource-manager` Test Runner (`run.sh`)

A pinned **whitelist** test runner for `resource-tuner` that produces per-suite logs and an overall gating result for CI.
A pinned **whitelist** test runner for `userspace-resource-manager` that produces per-suite logs and an overall gating result for CI.

---

## What this runs

Only these binaries are executed, in this order (anything else is ignored):
```
/usr/bin/ClientDataManagerTests
/usr/bin/ResourceProcessorTests
/usr/bin/MemoryPoolTests
/usr/bin/SignalConfigProcessorTests
/usr/bin/DeviceInfoTests
/usr/bin/ThreadPoolTests
/usr/bin/MiscTests
/usr/bin/SignalParsingTests
/usr/bin/SafeOpsTests
/usr/bin/ExtensionIntfTests
/usr/bin/RateLimiterTests
/usr/bin/SysConfigAPITests
/usr/bin/ExtFeaturesParsingTests
/usr/bin/RequestMapTests
/usr/bin/TargetConfigProcessorTests
/usr/bin/InitConfigParsingTests
/usr/bin/RequestQueueTests
/usr/bin/CocoTableTests
/usr/bin/ResourceParsingTests
/usr/bin/TimerTests
/usr/bin/resource_tuner_tests
/usr/bin/UrmComponentTests
/usr/bin/UrmIntegrationTests
```

---

## Gating policy

* **Service check (early gate):** If `resource-tuner.service` is **not active**, the test **SKIPs overall** and exits.
* **Service check (early gate):** If `urm.service` is **not active**, the test **SKIPs overall** and exits.
* **Per‑suite SKIP conditions (neutral):**
* Missing binary → **SKIP that suite**, continue.
* Missing base configs → **SKIP that suite**, continue.
* Missing test nodes for `resource_tuner_tests` → **SKIP that suite**, continue.
* Missing test nodes → **SKIP that suite**, continue.
* **Final result:**
* If **any** suite **FAILS** → **overall FAIL**.
* Else if **≥1** suite **PASS** → **overall PASS**.
Expand All @@ -52,29 +33,31 @@ Only these binaries are executed, in this order (anything else is ignored):
## Pre‑checks

### 1) Service
The runner uses the repo helper `check_systemd_services()` to verify **`resource-tuner.service`** is active.
The runner uses the repo helper `check_systemd_services()` to verify **`urm.service`** is active.
- On failure: overall **SKIP** (ends early).
- Override service name: `SERVICE_NAME=your.service ./run.sh`

### 2) Config presence
Suites that parse configs require **at least one** of these base config trees:
Suites that parse configs require **all** of these base config trees:

- `common/` (required files):
- `InitConfig.yaml`, `PropertiesConfig.yaml`, `ResourcesConfig.yaml`, `SignalsConfig.yaml`

- `custom/` (required files):
- `InitConfig.yaml`, `PropertiesConfig.yaml`, `ResourcesConfig.yaml`, `SignalsConfig.yaml`, `TargetConfig.yaml`, `ExtFeaturesConfig.yaml`
- `tests/configs/` (required files):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests/configs/ required-file list is missing Baseline.yaml, but run.sh currently requires it through RT_REQUIRE_TEST_FILES. Please add Baseline.yaml here so the README matches the implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, also renamed RT_REQUIRE_TEST_FILES to URM_REQUIRE_TEST_FILES, to align with project naming

- `InitConfig.yaml`, `PropertiesConfig.yaml`, `ResourcesConfig.yaml`, `SignalsConfig.yaml`, `TargetConfig.yaml`, `ExtFeaturesConfig.yaml`, `Baseline.yaml`

If **both** trees are missing required files/dirs, config‑parsing suites are **SKIP** only (neutral).
- `tests/nodes/` (must exist and be non-empty):

If **any** of these trees are missing required files/dirs, config‑parsing suites are **SKIP** only (neutral).

> Override required file lists without editing the script:
```bash
export RT_REQUIRE_COMMON_FILES="InitConfig.yaml PropertiesConfig.yaml ResourcesConfig.yaml SignalsConfig.yaml"
export RT_REQUIRE_CUSTOM_FILES="InitConfig.yaml PropertiesConfig.yaml ResourcesConfig.yaml SignalsConfig.yaml TargetConfig.yaml ExtFeaturesConfig.yaml"
export URM_REQUIRE_COMMON_FILES="InitConfig.yaml PropertiesConfig.yaml ResourcesConfig.yaml SignalsConfig.yaml"
export URM_REQUIRE_TEST_FILES="InitConfig.yaml PropertiesConfig.yaml ResourcesConfig.yaml SignalsConfig.yaml TargetConfig.yaml ExtFeaturesConfig.yaml Baseline.yaml"
```

### 3) Test ResourceSysFsNodes
`/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**.
### 3) Test test nodes
`/etc/urm/tests/nodes` must exist and be non‑empty for **`/usr/bin/UrmIntegrationTests`** and **`/usr/bin/UrmComponentTests`**. If missing/empty → **SKIP only that suite**.

### 4) Base tools
Requires: `awk`, `grep`, `date`, `printf`. If missing → **overall SKIP**.
Expand All @@ -93,21 +76,21 @@ Usage: ./run.sh [--all] [--bin <name|absolute>] [--list] [--timeout SECS]
- `--timeout SECS`: default per‑binary timeout **if** `run_with_timeout()` helper exists (else ignored).

Per‑suite default timeouts (if helper is present):
- `ThreadPoolTests`, `RateLimiterTests`: **1800s**
- `resource_tuner_tests`: **2400s**
- `UrmComponentTests`: **1800s**
- `UrmIntegrationTests`: **2400s**
- others: **1200s** (default)

---

## Output layout

- **Overall status file:** `./resource-tuner.res` → `PASS` / `FAIL` / `SKIP`
- **Logs directory:** `./logs/resource-tuner-YYYYMMDD-HHMMSS/`
- **Overall status file:** `./userspace-resource-manager.res` → `PASS` / `FAIL` / `SKIP`
- **Logs directory:** `./logs/userspace-resource-manager-YYYYMMDD-HHMMSS/`
- Per‑suite logs: `SUITE.log`
- Per‑suite result markers: `SUITE.res` (`PASS`/`FAIL`/`SKIP`)
- Coverage summaries: `coverage.txt`, `missing_bins.txt`, `coverage_counts.env`
- System snapshot: `dmesg_snapshot.log`
- **Symlink to latest:** `./logs/resource-tuner-latest`
- **Symlink to latest:** `./logs/userspace-resource-manager-latest`

**Parsing heuristics:** a suite is considered PASS if the binary exits 0 **or** its log contains
`Run Successful`, `executed successfully`, or `Ran Successfully`. Strings like `Assertion failed`, `Terminating Suite`, `Segmentation fault`, `Backtrace`, or `fail/failed` mark **FAIL**.
Expand All @@ -116,9 +99,9 @@ Per‑suite default timeouts (if helper is present):

## Environment overrides

- `SERVICE_NAME`: systemd unit to check (default: `resource-tuner.service`)
- `RT_CONFIG_DIR`: root of config tree (default: `/etc/resource-tuner`)
- `RT_REQUIRE_COMMON_FILES`, `RT_REQUIRE_CUSTOM_FILES`: *space‑separated* filenames that must exist in `common/` / `custom/` respectively to treat that tree as present.
- `SERVICE_NAME`: systemd unit to check (default: `urm.service`)
- `URM_CONFIG_DIR`: root of config tree (default: `/etc/urm`)
- `URM_REQUIRE_COMMON_FILES`, `URM_REQUIRE_TEST_FILES`: *space‑separated* filenames that must exist in `common/` / `tests/` respectively to treat that tree as present.

---

Expand All @@ -131,7 +114,7 @@ Run all (normal CI mode):

Run a single suite by basename:
```bash
./run.sh --bin ResourceParsingTests
./run.sh --bin UrmComponentTests
```

List suites and presence coverage:
Expand All @@ -141,21 +124,21 @@ List suites and presence coverage:

Use a different config root:
```bash
RT_CONFIG_DIR=/opt/rt/etc ./run.sh
URM_CONFIG_DIR=/opt/rt/etc ./run.sh
```

---

## Exit status

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.
The script writes the overall result to `userspace-resource-manager.res`. The **process exit code is 0** in case of SUCCESS, while the **exit code is 1** in case of overall FAILURE.

---

## Troubleshooting

- **Overall SKIP immediately** → service inactive. Check `systemctl status resource-tuner.service`.
- **Suite SKIP (config)** → confirm required files exist under `common/` or `custom/` (see lists above).
- **Overall SKIP immediately** → service inactive. Check `systemctl status urm.service`.
- **Suite SKIP (config)** → confirm required files exist under `common/`, `tests/configs` and `tests/nodes` (see lists above).
- **Suite SKIP (missing bin)** → verify the binary is installed and executable under `/usr/bin`.
- **Suite FAIL** → inspect `logs/.../SUITE.log` for the first failure pattern or assertion.
- **Very long runs** → a `run_with_timeout` helper (if available in your repo toolchain) will be used automatically.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause# resource-tuner test runner (pinned whitelist)
# SPDX-License-Identifier: BSD-3-Clause
# userspace-resource-manager test runner (pinned whitelist)

# ---------- Repo env + helpers ----------
SCRIPT_DIR="$(
Expand Down Expand Up @@ -37,7 +38,7 @@ export PATH="/usr/sbin:/sbin:/usr/bin:/bin:${PATH}"
# shellcheck disable=SC3045
( ulimit -c unlimited ) >/dev/null 2>&1 || true

TESTNAME="resource-tuner"
TESTNAME="userspace-resource-manager"
test_path="$(find_test_case_by_name "$TESTNAME")"
cd "$test_path" || exit 1
RES_FILE="./${TESTNAME}.res"
Expand All @@ -62,42 +63,20 @@ fi

# ---------- Approved list (pinned whitelist) ----------
APPROVED_TESTS="
/usr/bin/ClientDataManagerTests
/usr/bin/ResourceProcessorTests
/usr/bin/MemoryPoolTests
/usr/bin/SignalConfigProcessorTests
/usr/bin/DeviceInfoTests
/usr/bin/ThreadPoolTests
/usr/bin/MiscTests
/usr/bin/SignalParsingTests
/usr/bin/SafeOpsTests
/usr/bin/ExtensionIntfTests
/usr/bin/RateLimiterTests
/usr/bin/SysConfigAPITests
/usr/bin/ExtFeaturesParsingTests
/usr/bin/RequestMapTests
/usr/bin/TargetConfigProcessorTests
/usr/bin/InitConfigParsingTests
/usr/bin/RequestQueueTests
/usr/bin/CocoTableTests
/usr/bin/ResourceParsingTests
/usr/bin/TimerTests
/usr/bin/resource_tuner_tests
/usr/bin/UrmComponentTests
/usr/bin/UrmIntegrationTests
"

# Suites that need base configs (accept either common/ OR custom/)
SUITES_REQUIRE_BASE_CFGS="ResourceProcessorTests SignalConfigProcessorTests SysConfigAPITests \
ExtFeaturesParsingTests TargetConfigProcessorTests InitConfigParsingTests \
ResourceParsingTests ExtensionIntfTests resource_tuner_tests"
# Suites that need base configs (all of common/, tests/configs and tests/nodes are needed)
SUITES_REQUIRE_BASE_CFGS="UrmComponentTests UrmIntegrationTests"

# ---------- CLI ----------
print_usage() {
cat <<EOF
Usage: $0 [--all] [--bin <name|absolute>] [--list] [--timeout SECS]
Policy:
- Service INACTIVE => overall SKIP (end early)
- Base configs: suites require common/ OR custom/ (skip only if BOTH missing)
- resource_tuner_tests additionally needs tests/Configs/ResourceSysFsNodes
- Base configs: suites require common/, tests/configs and tests/nodes (skip if any of them are missing)
- Any test FAIL => overall FAIL
- No FAIL & PASS>0 => overall PASS
- No FAIL & PASS=0 => overall SKIP (everything skipped)
Expand Down Expand Up @@ -180,10 +159,10 @@ parse_and_score_log() {
}
per_suite_timeout() {
case "$1" in
ThreadPoolTests|RateLimiterTests)
UrmComponentTests)
echo 1800
;;
resource_tuner_tests)
UrmIntegrationTests)
echo 2400
;;
*)
Expand Down Expand Up @@ -225,18 +204,18 @@ if command -v log_soc_info >/dev/null 2>&1; then
fi

# ---------- Service gate (use repo helper) ----------
SERVICE_NAME="${SERVICE_NAME:-resource-tuner.service}"
SERVICE_NAME="${SERVICE_NAME:-urm.service}"
log_info "[SERVICE] Checking $SERVICE_NAME via check_systemd_services()"
if check_systemd_services "$SERVICE_NAME"; then
log_pass "[SERVICE] $SERVICE_NAME is active"
else
log_warn "[SERVICE] $SERVICE_NAME not active — attempting enable/start"

if command -v systemctl >/dev/null 2>&1; then
systemctl enable resource-tuner >/dev/null 2>&1 || true
systemctl enable urm >/dev/null 2>&1 || true
systemctl daemon-reload >/dev/null 2>&1 || true
systemctl start resource-tuner >/dev/null 2>&1 || true
systemctl status resource-tuner --no-pager -l >/dev/null 2>&1 || true
systemctl start urm >/dev/null 2>&1 || true
systemctl status urm --no-pager -l >/dev/null 2>&1 || true
else
log_warn "[SERVICE] systemctl not available; cannot auto-start $SERVICE_NAME"
fi
Expand All @@ -250,64 +229,57 @@ else
fi
fi

# ---------- Config preflight (check both common/ and custom/) ----------
RT_CONFIG_DIR="${RT_CONFIG_DIR:-/etc/resource-tuner}"
COMMON_DIR="$RT_CONFIG_DIR/common"
CUSTOM_DIR="$RT_CONFIG_DIR/custom"
TEST_NODES_DIR="$RT_CONFIG_DIR/tests/Configs/ResourceSysFsNodes"
# ---------- Config preflight (check both common/ and tests/) ----------
URM_CONFIG_DIR="${URM_CONFIG_DIR:-/etc/urm}"
COMMON_CONFIGS_DIR="$URM_CONFIG_DIR/common"
TEST_CONFIGS_DIR="$URM_CONFIG_DIR/tests/configs"
TEST_NODES_DIR="$URM_CONFIG_DIR/tests/nodes"

COMMON_OK=1
CUSTOM_OK=1
NODES_OK=1
COMMON_CONFIGS_OK=1
TEST_CONFIGS_OK=1
TEST_NODES_OK=1

REQ_COMMON_FILES="${RT_REQUIRE_COMMON_FILES:-InitConfig.yaml PropertiesConfig.yaml ResourcesConfig.yaml SignalsConfig.yaml}"
REQ_CUSTOM_FILES="${RT_REQUIRE_CUSTOM_FILES:-InitConfig.yaml PropertiesConfig.yaml ResourcesConfig.yaml SignalsConfig.yaml TargetConfig.yaml ExtFeaturesConfig.yaml}"
REQ_COMMON_FILES="${URM_REQUIRE_COMMON_FILES:-InitConfig.yaml PropertiesConfig.yaml ResourcesConfig.yaml SignalsConfig.yaml}"
REQ_TEST_CONFIGS="${URM_REQUIRE_TEST_FILES:-InitConfig.yaml PropertiesConfig.yaml ResourcesConfig.yaml SignalsConfig.yaml TargetConfig.yaml ExtFeaturesConfig.yaml Baseline.yaml}"

# common/
if [ ! -d "$COMMON_DIR" ]; then
log_warn "[CFG] Missing dir: $COMMON_DIR"
COMMON_OK=0
if [ ! -d "$COMMON_CONFIGS_DIR" ]; then
log_warn "[CFG] Missing dir: $COMMON_CONFIGS_DIR"
COMMON_CONFIGS_OK=0
else
for f in $REQ_COMMON_FILES; do
if [ ! -f "$COMMON_DIR/$f" ]; then
log_warn "[CFG] Missing file: $COMMON_DIR/$f"
COMMON_OK=0
if [ ! -f "$COMMON_CONFIGS_DIR/$f" ]; then
log_warn "[CFG] Missing file: $COMMON_CONFIGS_DIR/$f"
COMMON_CONFIGS_OK=0
fi
done
fi

# custom/
if [ ! -d "$CUSTOM_DIR" ]; then
log_warn "[CFG] Missing dir: $CUSTOM_DIR"
CUSTOM_OK=0
# tests/configs
if [ ! -d "$TEST_CONFIGS_DIR" ]; then
log_warn "[CFG] Missing dir: $TEST_CONFIGS_DIR"
TEST_CONFIGS_OK=0
else
for f in $REQ_CUSTOM_FILES; do
if [ ! -f "$CUSTOM_DIR/$f" ]; then
log_warn "[CFG] Missing file: $CUSTOM_DIR/$f"
CUSTOM_OK=0
for f in $REQ_TEST_CONFIGS; do
if [ ! -f "$TEST_CONFIGS_DIR/$f" ]; then
log_warn "[CFG] Missing file: $TEST_CONFIGS_DIR/$f"
TEST_CONFIGS_OK=0
fi
done
cn="$(
find "$CUSTOM_DIR/ResourceSysFsNodes" -mindepth 1 -maxdepth 1 -type f -print 2>/dev/null \
| wc -l | awk '{print $1}'
)"
if [ -n "$cn" ]; then
log_info "[CFG] custom/ResourceSysFsNodes entries: $cn"
fi
fi

# tests nodes (hard requirement for resource_tuner_tests)
# tests/nodes (hard requirement for UrmIntegrationTests and UrmComponentTests)
if [ ! -d "$TEST_NODES_DIR" ]; then
log_warn "[CFG] Missing dir: $TEST_NODES_DIR"
NODES_OK=0
TEST_NODES_OK=0
else
count_nodes="$(
find "$TEST_NODES_DIR" -mindepth 1 -maxdepth 1 -type f -print 2>/dev/null \
| wc -l | awk '{print $1}'
)"
if [ "${count_nodes:-0}" -le 0 ]; then
log_warn "[CFG] $TEST_NODES_DIR is empty"
NODES_OK=0
TEST_NODES_OK=0
fi
fi

Expand Down Expand Up @@ -399,26 +371,17 @@ run_one() {
return 2
fi

# base config requirement: accept common OR custom; skip only if BOTH missing
# base config requirement: common configs, tests/configs as well as tests/nodes
# If any of them are missing, skip.
if suite_requires_base_cfgs "$name"; then
if [ $COMMON_OK -eq 0 ] && [ $CUSTOM_OK -eq 0 ]; then
log_skip "[CFG] Base configs missing (common/ AND custom/) — skipping $name"
if [ $COMMON_CONFIGS_OK -eq 0 ] || [ $TEST_CONFIGS_OK -eq 0 ] || [ $TEST_NODES_OK -eq 0 ]; then
log_skip "[CFG] Base configs missing (one or more of common/, tests/configs or tests/nodes not found) — skipping $name"
echo "SKIP" >"$tres"
echo "[SKIP] $name – base configs missing" >>"$LOGDIR/summary.txt"
return 2
fi
fi

# resource_tuner_tests also needs test nodes
if [ "$name" = "resource_tuner_tests" ]; then
if [ $NODES_OK -eq 0 ]; then
log_skip "[CFG] Test ResourceSysFsNodes missing/empty — skipping $name"
echo "SKIP" >"$tres"
echo "[SKIP] $name – test nodes missing" >>"$LOGDIR/summary.txt"
return 2
fi
fi

# resolve binary
if [ ! -x "$bin" ] && command -v "$bin" >/dev/null 2>&1; then
bin="$(command -v "$bin")"
Expand Down
Loading
Loading