Skip to content

Commit 5ef48fe

Browse files
committed
(video): make stack switching and media fetch idempotent Add once-only guards for rootfs check, early bundle fetch, FW ops.
- Prevent duplicate rmmod/modprobe cycles and reduce kernel panic risk. - Harden modprobe/insmod with retries and persistent de-blacklist. - Kodiak: install upstream FW on base; apply downstream FW override once. - Preserve pre/post stack dumps and V4L node refresh; better dmesg hints. - lib_video.sh: robust clip discovery/fetch and ensure app executable. - run.sh/functestlib.sh/YAML: expose tunables and idempotent downloads. Signed-off-by: Srikanth Muppandam <[email protected]>
1 parent 78197b9 commit 5ef48fe

File tree

5 files changed

+2027
-609
lines changed

5 files changed

+2027
-609
lines changed

Runner/plans/video_pre-merge.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
metadata:
2+
format: Lava-Test Test Definition 1.0
3+
name: Video_V4L2_All
4+
description: "Single YAML: pass TARGET, STACK, iris path and downstream FW; run.sh handles the rest"
5+
maintainer:
6+
7+
os:
8+
- openembedded
9+
scope:
10+
- functional
11+
12+
run:
13+
steps:
14+
- cd Runner
15+
- export REPO_ROOT="$PWD"
16+
17+
# --- Job-level inputs (set per device/job) ---
18+
- export TARGET="${TARGET:-}" # e.g. Kodiak|LeMans|Monaco|Talos
19+
- export STACK="${STACK:-both}" # base|overlay|auto|both or synonyms: upstream|downstream
20+
- export IRIS_BIN="${IRIS_BIN:-}" # optional: /path/to/iris_v4l2_test
21+
- export DOWNSTREAM_FW="${DOWNSTREAM_FW:-}" # optional: firmware blob for overlay
22+
23+
# Normalize STACK -> MODE (one-liner synonyms)
24+
- export MODE_NORM="$(printf '%s' "$STACK" | tr '[:upper:]' '[:lower:]' | sed -e 's/^upstream$/base/' -e 's/^downstream$/overlay/')"
25+
- |
26+
case "$MODE_NORM" in base|overlay|auto|both) : ;; *) MODE_NORM="both" ;; esac
27+
echo "TARGET=$TARGET STACK=$STACK MODE_NORM=$MODE_NORM"
28+
29+
# Build args for run.sh (match your CLI exactly)
30+
- |
31+
ARGS=""
32+
[ -n "$TARGET" ] && ARGS="$ARGS --target \"$TARGET\""
33+
34+
if [ -n "$IRIS_BIN" ]; then
35+
ARGS="$ARGS --iris-bin \"$IRIS_BIN\""
36+
else
37+
IB="$(command -v iris_v4l2_test 2>/dev/null || true)"
38+
[ -n "$IB" ] && ARGS="$ARGS --iris-bin \"$IB\""
39+
fi
40+
41+
[ -n "$DOWNSTREAM_FW" ] && ARGS="$ARGS --downstream-fw \"$DOWNSTREAM_FW\""
42+
43+
echo "ARGS=$ARGS"
44+
45+
# Single call: run.sh handles base/overlay/auto and 'both' via its reexec shim
46+
- |
47+
cd "$REPO_ROOT/suites/Multimedia/Video/Video_V4L2_Runner"
48+
# shellcheck disable=SC2086
49+
sh -lc "./run.sh $ARGS --mode \"$MODE_NORM\"" || true
50+
51+
# Report result (AUSanity style)
52+
- "$REPO_ROOT/utils/send-to-lava.sh" "$REPO_ROOT/suites/Multimedia/Video/Video_V4L2_Runner/Video_V4L2_Runner.res" || true
53+
54+
# Optional roll-up (ignored if absent)
55+
- "$REPO_ROOT/utils/result_parse.sh" || true

Runner/suites/Multimedia/Video/Video_V4L2_Runner/README_Video.md

Lines changed: 79 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,28 @@ The suite includes a **reboot-free video stack switcher** (upstream ↔ downstre
1414

1515
---
1616

17-
## What’s New (since 2025‑09‑26)
18-
19-
- **Pre-download rootfs auto‑resize**
20-
- New `ensure_rootfs_min_size` (now in `functestlib.sh`) verifies `/` has at least **2 GiB** available and, if the root partition is `/dev/disk/by-partlabel/rootfs`, runs:
21-
```sh
22-
resize2fs /dev/disk/by-partlabel/rootfs
23-
```
24-
- Invoked **before** any clip bundle download.
25-
26-
- **Kodiak upstream: auto‑install backup firmware before switching**
27-
- `video_kodiak_install_firmware` (in `lib_video.sh`) looks for a recent backup blob under **`$VIDEO_FW_BACKUP_DIR`** (defaults to `/opt/video-fw-backups`) **and legacy `/opt` patterns**, then copies it to:
28-
```
29-
/lib/firmware/qcom/vpu/vpu20_p1_gen2.mbn
30-
```
31-
- Attempts **remoteproc stop → firmware swap → start**, with fallback to **module reload** and **platform unbind/bind**.
32-
- Automatically runs when `--platform kodiak --stack upstream`.
33-
34-
- **Network bootstrap before downloads (Ethernet → Wi‑Fi)**
35-
- `ensure_network_online` first tries wired DHCP; if still offline and **Wi‑Fi credentials are available**, it attempts:
36-
1) `nmcli dev wifi connect` (with a **key‑mgmt fallback** that creates a PSK connection if NM complains: `802-11-wireless-security.key-mgmt: property is missing`), then
37-
2) `wpa_supplicant + udhcpc` as a final fallback.
38-
- Credentials are taken from environment **`SSID`/`PASSWORD`** or an optional `./ssid_list.txt` (first line: `ssid password`).
39-
40-
- **App path hardening**
41-
- If `--app` points to a file that exists but is not executable, the runner does a best‑effort `chmod +x` and proceeds.
42-
43-
- **Platform‑aware hard gates & clearer logging**
44-
- Upstream/Downstream validation is **platform specific** (lemans/monaco vs. kodiak).
45-
- udev refresh + stale node pruning for `/dev/video*` and `/dev/media*` after any stack change.
17+
## What’s New (since 2025‑10‑03)
18+
19+
- **Network stabilization delay (post-connect)**
20+
After an interface comes up (DHCP/DNS), the runner now sleeps for a short grace period before the first TLS download to avoid immediate failures.
21+
- Env knob: `NET_STABILIZE_SLEEP` (default **5** seconds).
22+
23+
- **Downloader timeouts & retries (BusyBox‑friendly)**
24+
Clip bundle downloads honor BusyBox wget timeouts/retries and perform a final TLS‑lenient attempt when the clock is not yet sane.
25+
- Env knobs: `WGET_TIMEOUT_SECS` (default **120**), `WGET_TRIES` (default **2**).
26+
27+
- **SKIP instead of FAIL when offline**
28+
If the network is unreachable (or time is invalid for TLS) *and* required media clips are missing, **decode** cases are *SKIPPED* rather than failed. Encode cases continue to run.
29+
30+
- **App launch & inter‑test pacing**
31+
To reduce flakiness from back‑to‑back runs, the runner adds small sleeps **before** launching `iris_v4l2_test` and **between** tests.
32+
- Env knobs: `VIDEO_APP_LAUNCH_SLEEP` (default **1** second), `VIDEO_INTER_TEST_SLEEP` (default **1** second).
33+
34+
- **Module operations: gentle waits & retries**
35+
Module unload/load and blacklist scrubbing paths include short sleeps and a retry pass (`modprobe -r` retry with a small delay, 1s delays around remoteproc/module reloads). No new CLI needed.
36+
37+
- **CLI parity**
38+
`--stack both` is supported to run the suite twice in one invocation (BASE/upstream pass then OVERLAY/downstream pass).
4639

4740
---
4841

@@ -51,14 +44,33 @@ The suite includes a **reboot-free video stack switcher** (upstream ↔ downstre
5144
- Pure **V4L2** driver-level tests using `iris_v4l2_test`
5245
- **Encode** (YUV → H.264/H.265) and **Decode** (H.264/H.265/VP9 → YUV)
5346
- **Yocto**-friendly, POSIX shell with BusyBox-safe paths
54-
- Parse & run multiple JSON configs; auto-detect **encode/decode**
47+
- Parse & run multiple JSON configs, auto-detect **encode/decode**
5548
- **Auto-fetch** missing input clips (retries, BusyBox `wget` compatible)
5649
- **Rootfs size guard** (auto‑resize) **before** fetching assets
5750
- **Network bootstrap** (Ethernet → Wi‑Fi via `nmcli`/`wpa_supplicant`) when needed for downloads
5851
- Timeout, repeat, dry-run, JUnit XML, dmesg triage
5952
- **Stack switcher**: upstream ↔ downstream without reboot
6053
- **Kodiak firmware live swap** with backup/restore helpers
6154
- **udev refresh + prune** of stale device nodes
55+
- **Waits/retries/sleeps** integrated across networking, downloads, module ops, and app launches (see next section)
56+
57+
---
58+
59+
## Stability waits, retries & timeouts (defaults & overrides)
60+
61+
These are **environment variables** (not user‑visible CLI flags) so your LAVA job YAML can stay minimal. All are **optional**—defaults are sane.
62+
63+
| Env Var | Default | Purpose |
64+
|---|---:|---|
65+
| `NET_STABILIZE_SLEEP` | `5` | Sleep (seconds) after link/IP assignment before first download. Applied also when already online, to debounce DNS/routes. |
66+
| `WGET_TIMEOUT_SECS` | `120` | BusyBox wget timeout per attempt when fetching the clip bundle. |
67+
| `WGET_TRIES` | `2` | BusyBox wget retry count for clip bundle. |
68+
| `VIDEO_APP_LAUNCH_SLEEP` | `1` | Sleep (seconds) right before launching `iris_v4l2_test` for each case. |
69+
| `VIDEO_INTER_TEST_SLEEP` | `1` | Sleep (seconds) between cases to allow device/udev to settle. |
70+
71+
> Notes
72+
> - If download **stalls** or the system clock is invalid for TLS, the runner re-checks network health and treats it as **offline** → decode cases **SKIP** (not FAIL).
73+
> - Module management includes small internal waits (e.g., `modprobe -r` retry after 200ms, 1s delays around remoteproc/module reloads). These are built‑in, no extra env required.
6274
6375
---
6476

@@ -123,7 +135,7 @@ cd <target_path>/Runner
123135
| `--dry-run` | Print commands only |
124136
| `--verbose` | Verbose runner logs |
125137
| `--app /path/to/iris_v4l2_test` | Override test app path |
126-
| `--stack auto|upstream|downstream|base|overlay|up|down` | Select target stack |
138+
| `--stack auto|upstream|downstream|base|overlay|up|down|both` | Select target stack (use `both` for BASE→OVERLAY two-pass) |
127139
| `--platform lemans|monaco|kodiak` | Force platform (else auto-detect) |
128140
| `--downstream-fw PATH` | **Kodiak**: path to DS firmware (e.g. `vpu20_1v.mbn`) |
129141

@@ -151,13 +163,21 @@ If the target is offline when a clip bundle is needed:
151163
```
152164
- If still offline, uses `wpa_supplicant + udhcpc`
153165

166+
After connectivity, a **debounce wait** is applied:
167+
```sh
168+
# Default 5s (override via NET_STABILIZE_SLEEP)
169+
sleep "${NET_STABILIZE_SLEEP:-5}"
170+
```
171+
154172
**Provide credentials via:**
155173
```sh
156174
export SSID="WIFI_SSID"
157175
export PASSWORD="WIFI_PASSWORD"
158-
# or create ./ssid_list.txt with: WIFI_PASSWORD WIFI_PASSWORD
176+
# or create ./ssid_list.txt with: WIFI_SSID WIFI_PASSWORD
159177
```
160178

179+
When network remains unreachable and clips are missing, **decode cases are SKIPPED** (not failed).
180+
161181
---
162182

163183
## Stack Selection & Validation
@@ -174,6 +194,7 @@ The runner:
174194
1. Prints **pre/post** module snapshots and any runtime/persistent modprobe blocks
175195
2. Switches stacks without reboot (uses runtime blacklists under `/run/modprobe.d`)
176196
3. **Refreshes** `/dev/video*` & `/dev/media*` with udev and **prunes** stale nodes
197+
4. Applies small **waits/retries** around unload/load and de‑blacklist/blacklist paths
177198

178199
---
179200

@@ -183,14 +204,14 @@ The runner:
183204
When `--stack downstream` and you pass `--downstream-fw /path/to/vpu20_1v.mbn`:
184205
1. The blob is copied to: `/lib/firmware/qcom/vpu/vpu20_p1_gen2.mbn`
185206
2. Previous image is backed up to: `/opt/video-fw-backups/vpu20_p1_gen2.mbn.<timestamp>.bak`
186-
3. Runner tries **remoteproc restart**, then **module reload**, then **unbind/bind**
207+
3. Runner tries **remoteproc restart**, then **module reload**, then **unbind/bind** (with short waits between steps)
187208

188209
### Upstream (restore a backup before switch)
189210
When `--stack upstream` on **kodiak**, the runner tries to **restore a known‑good backup** to `/lib/firmware/qcom/vpu/vpu20_p1_gen2.mbn` **before** switching:
190211
- Search order:
191212
1. `$VIDEO_FW_BACKUP_DIR` (default `/opt/video-fw-backups`), newest `vpu20_p1_gen2.mbn.*.bak`
192213
2. Legacy `/opt` patterns (e.g., `vpu20_p1_gen2.mbn.*.bak`)
193-
- Then it attempts **remoteproc restart**; falls back as needed.
214+
- Then it attempts **remoteproc restart**; falls back as needed (with 1s waits).
194215

195216
**Tip:** If you maintain backups under a custom path:
196217
```sh
@@ -202,11 +223,16 @@ export VIDEO_FW_BACKUP_DIR=/opt
202223

203224
## Examples
204225

205-
### Run all configs with auto stack
226+
### Minimal: run all configs with sane defaults
206227
```sh
207228
./run.sh
208229
```
209230

231+
### Use `both` to run BASE then OVERLAY in one job
232+
```sh
233+
./run.sh --stack both
234+
```
235+
210236
### Force downstream on lemans/monaco
211237
```sh
212238
./run.sh --stack downstream
@@ -246,6 +272,22 @@ export PASSWORD="WIFI_PASSWORD"
246272
./run.sh --pattern '*h265*Decoder.json'
247273
```
248274

275+
### Override waits/timeouts (optional)
276+
```sh
277+
# Debounce network right after IP assignment
278+
export NET_STABILIZE_SLEEP=8
279+
280+
# BusyBox wget tuning
281+
export WGET_TIMEOUT_SECS=180
282+
export WGET_TRIES=3
283+
284+
# Pacing iris app & tests
285+
export VIDEO_APP_LAUNCH_SLEEP=2
286+
export VIDEO_INTER_TEST_SLEEP=3
287+
288+
./run.sh --stack upstream
289+
```
290+
249291
---
250292

251293
## Troubleshooting
@@ -260,6 +302,6 @@ export PASSWORD="WIFI_PASSWORD"
260302
The runner triggers udev and prunes stale nodes; verify udev is available and rules are active.
261303

262304
- **Download fails**
263-
Ensure time is sane (TLS), network is reachable, and provide Wi‑Fi creds via env or `ssid_list.txt`. The downloader uses BusyBox‑compatible flags with retries.
305+
Ensure time is sane (TLS), network is reachable, and provide Wi‑Fi creds via env or `ssid_list.txt`. The downloader uses BusyBox‑compatible flags with retries and a final TLS‑lenient attempt if needed. When the network remains unreachable, the runner **SKIPs** decode cases.
264306

265-
---
307+
---

0 commit comments

Comments
 (0)