Skip to content

Commit ad239c2

Browse files
authored
Merge pull request qualcomm-linux#202 from smuppand/video-fix
Video V4L2: platform-aware LAVA plan, custom KO_* module sources, Kodiak FW handling, and docs
2 parents 12577b9 + a5d75b8 commit ad239c2

File tree

4 files changed

+378
-62
lines changed

4 files changed

+378
-62
lines changed

Runner/plans/video_pre-merge.yaml

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
metadata:
22
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"
3+
name: Video_V4L2_With_Secrets
4+
description: "Run Video V4L2 runner; use LAVA secrets for Wi-Fi; auto-args for kodiak vs lemans/monaco; run base & overlay"
55
maintainer:
66
77
os:
88
- openembedded
99
scope:
1010
- functional
11-
11+
1212
run:
1313
steps:
1414
- cd Runner
1515
- 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)
16+
- export TARGET="${TARGET:-}" # expected values: kodiak | lemans | monaco (case-insensitive)
17+
18+
# Read Wi-Fi credentials from LAVA-provided secrets (exported as env vars in the job)
19+
- export SSID="${LAVA_WIFI_SSID:-}"
20+
- export PASSWORD="${LAVA_WIFI_PASSWORD:-}"
21+
22+
# Build args for run.sh based on TARGET; always pass secrets; add downstream FW only for kodiak
3023
- |
24+
RPATH="$REPO_ROOT/suites/Multimedia/Video/Video_V4L2_Runner/run.sh"
25+
RESFILE="$REPO_ROOT/suites/Multimedia/Video/Video_V4L2_Runner/Video_V4L2_Runner.res"
3126
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"
27+
TL="$(printf '%s' "${TARGET:-}" | tr '[:upper:]' '[:lower:]')"
28+
case "$TL" in
29+
kodiak)
30+
ARGS="$ARGS --platform kodiak --app /data/vendor/iris_test_app/iris_v4l2_test --ssid \"$SSID\" --password \"$PASSWORD\" --downstream-fw /data/vendor/iris_test_app/vpu20_p1_gen2.mbn"
31+
;;
32+
lemans)
33+
ARGS="$ARGS --platform lemans --ssid \"$SSID\" --password \"$PASSWORD\"" --app /data/vendor/iris_test_app/iris_v4l2_test
34+
;;
35+
monaco)
36+
ARGS="$ARGS --platform monaco --ssid \"$SSID\" --password \"$PASSWORD\"" --app /data/vendor/iris_test_app/iris_v4l2_test
37+
;;
38+
*)
39+
# Unknown or not provided: still pass secrets; platform autodetect in run.sh
40+
ARGS="$ARGS --ssid \"$SSID\" --password \"$PASSWORD\""
41+
;;
42+
esac
43+
echo "TARGET=${TARGET:-unset} ARGS=$ARGS"
44+
45+
# Run base (upstream) then overlay (downstream)
46+
# shellcheck disable=SC2086
47+
sh -lc "$RPATH --stack base $ARGS" || true
48+
"$REPO_ROOT/utils/send-to-lava.sh" "$RESFILE" || true
49+
4850
# 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
51+
sh -lc "$RPATH --stack overlay $ARGS" || true
52+
"$REPO_ROOT/utils/send-to-lava.sh" "$RESFILE" || 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: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ The suite includes a **reboot-free video stack switcher** (upstream ↔ downstre
3737
- **CLI parity**
3838
`--stack both` is supported to run the suite twice in one invocation (BASE/upstream pass then OVERLAY/downstream pass).
3939

40+
- **NEW (opt‑in) custom module sources**
41+
You can now point the runner at alternative module locations without disturbing the default flow. If you **do nothing**, behavior is unchanged.
42+
- `--ko-dir DIR[:DIR2:...]` — search these dir(s) for `.ko*` files when resolving modules.
43+
- `--ko-tree ROOT` — use `modprobe -d ROOT` (expects `ROOT/lib/modules/$(uname -r)`).
44+
- `--ko-tar FILE.tar[.gz|.xz|.zst]` — unpack once under `/run/iris_mods/$KVER`; auto-derives a `--ko-tree` or `--ko-dir`.
45+
- `--ko-prefer-custom` — prefer custom sources before the system tree.
46+
- The loader now logs **path resolution** and **load method** lines, e.g.:
47+
- `resolve-path: qcom_iris via KO_DIRS => /data/kos/qcom_iris.ko`
48+
- `load-path: modprobe(system): qcom_iris` / `load-path: insmod: /tmp/qcom_iris.ko`
49+
4050
---
4151

4252
## Features
@@ -53,6 +63,7 @@ The suite includes a **reboot-free video stack switcher** (upstream ↔ downstre
5363
- **Kodiak firmware live swap** with backup/restore helpers
5464
- **udev refresh + prune** of stale device nodes
5565
- **Waits/retries/sleeps** integrated across networking, downloads, module ops, and app launches (see next section)
66+
- **(Opt‑in)** custom module sources with **non-exported** CLI flags (`--ko-*`); defaults remain untouched
5667

5768
---
5869

@@ -68,8 +79,8 @@ These are **environment variables** (not user‑visible CLI flags) so your LAVA
6879
| `VIDEO_APP_LAUNCH_SLEEP` | `1` | Sleep (seconds) right before launching `iris_v4l2_test` for each case. |
6980
| `VIDEO_INTER_TEST_SLEEP` | `1` | Sleep (seconds) between cases to allow device/udev to settle. |
7081

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).
82+
> Notes
83+
> - 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).
7384
> - 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.
7485
7586
---
@@ -138,6 +149,12 @@ cd <target_path>/Runner
138149
| `--stack auto|upstream|downstream|base|overlay|up|down|both` | Select target stack (use `both` for BASE→OVERLAY two-pass) |
139150
| `--platform lemans|monaco|kodiak` | Force platform (else auto-detect) |
140151
| `--downstream-fw PATH` | **Kodiak**: path to DS firmware (e.g. `vpu20_1v.mbn`) |
152+
| `--ko-dir DIR[:DIR2:...]` | *(Opt‑in)* Additional directories to search for `.ko*` files during resolution |
153+
| `--ko-tree ROOT` | *(Opt‑in)* Use `modprobe -d ROOT` (expects `ROOT/lib/modules/$(uname -r)`) |
154+
| `--ko-tar FILE.tar[.gz|.xz|.zst]` | *(Opt‑in)* Unpack once into `/run/iris_mods/$KVER`; auto-derives `--ko-tree` or `--ko-dir` |
155+
| `--ko-prefer-custom` | *(Opt‑in)* Prefer custom module sources (KO_DIRS/KO_TREE) before system |
156+
157+
> **Default remains unchanged.** If you omit all `--ko-*` flags, the runner uses the system module tree and `modinfo`/`modprobe` resolution only.
141158
142159
---
143160

@@ -288,6 +305,34 @@ export VIDEO_INTER_TEST_SLEEP=3
288305
./run.sh --stack upstream
289306
```
290307

308+
### (Opt‑in) Use custom module sources
309+
**Default behavior is unchanged.** Only use these when you want to test modules from a non-system location.
310+
311+
#### Use a prepared tree (modprobe -d)
312+
```sh
313+
./run.sh --ko-tree /opt/custom-kmods --stack upstream
314+
```
315+
316+
#### Search one or more directories of loose .ko files
317+
```sh
318+
./run.sh --ko-dir /data/kos:/mnt/usb/venus_kos --stack downstream
319+
```
320+
321+
#### Prefer custom before system
322+
```sh
323+
./run.sh --ko-dir /sdcard/kos --ko-prefer-custom --stack upstream
324+
```
325+
326+
#### Unpack a tarball of modules and auto-wire paths
327+
```sh
328+
./run.sh --ko-tar /sdcard/iris_kmods_${KVER}.tar.xz --stack upstream
329+
# The runner unpacks into /run/iris_mods/$KVER and derives --ko-tree or --ko-dir.
330+
```
331+
332+
> While resolving and loading modules, the runner logs lines like:
333+
> - `resolve-path: venus_core via KO_TREE => /run/iris_mods/6.9.0/lib/modules/6.9.0/venus_core.ko`
334+
> - `load-path: insmod: /data/kos/qcom_iris.ko` or `load-path: modprobe(system): qcom_iris`
335+
291336
---
292337

293338
## Troubleshooting
@@ -304,4 +349,5 @@ export VIDEO_INTER_TEST_SLEEP=3
304349
- **Download fails**
305350
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.
306351

307-
---
352+
---
353+

Runner/suites/Multimedia/Video/Video_V4L2_Runner/run.sh

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ if [ -z "$INIT_ENV" ]; then
2525
fi
2626

2727
# Only source once (idempotent)
28+
# NOTE: We intentionally **do not export** any new vars. They stay local to this shell.
2829
if [ -z "${__INIT_ENV_LOADED:-}" ]; then
2930
# shellcheck disable=SC1090
3031
. "$INIT_ENV"
@@ -62,6 +63,16 @@ if [ -z "${REPEAT_POLICY:-}" ]; then REPEAT_POLICY="all"; fi
6263
JUNIT_OUT=""
6364
VERBOSE="0"
6465

66+
# --- Stabilizers (opt-in) ---
67+
RETRY_ON_FAIL="0" # extra attempts after a FAIL
68+
POST_TEST_SLEEP="0" # settle time after each case
69+
70+
# --- Custom module source (opt-in; default is untouched) ---
71+
KO_DIRS="" # colon-separated list of dirs that contain .ko files
72+
KO_TREE="" # alt root that has lib/modules/$KVER
73+
KO_TARBALL="" # optional tarball that we unpack once
74+
KO_PREFER_CUSTOM="0" # 1 = try custom first; default 0 = system first
75+
6576
if [ -z "${VIDEO_STACK:-}" ]; then VIDEO_STACK="auto"; fi
6677
if [ -z "${VIDEO_PLATFORM:-}" ]; then VIDEO_PLATFORM=""; fi
6778
if [ -z "${VIDEO_FW_DS:-}" ]; then VIDEO_FW_DS=""; fi
@@ -94,8 +105,15 @@ Usage: $0 [--config path.json|/path/dir] [--dir DIR] [--pattern GLOB]
94105
[--downstream-fw PATH] [--force]
95106
[--app /path/to/iris_v4l2_test]
96107
[--ssid SSID] [--password PASS]
108+
[--ko-dir DIR[:DIR2:...]] # opt-in: search these dirs for .ko on failure
109+
[--ko-tree ROOT] # opt-in: modprobe -d ROOT (expects lib/modules/\$(uname -r))
110+
[--ko-tar FILE.tar[.gz|.xz]] # opt-in: unpack once under /run/iris_mods/\$KVER, set --ko-tree/--ko-dir accordingly
111+
[--ko-prefer-custom] # opt-in: try custom sources before system
97112
[--app-launch-sleep S] [--inter-test-sleep S]
98113
[--log-flavor NAME] # internal: e.g. upstream or downstream (used by --stack both)
114+
# --- Stabilizers ---
115+
[--retry-on-fail N] # retry up to N times if a case ends FAIL
116+
[--post-test-sleep S] # sleep S seconds after each case
99117
EOF
100118
}
101119

@@ -190,6 +208,22 @@ while [ $# -gt 0 ]; do
190208
shift
191209
PASSWORD="$1"
192210
;;
211+
--ko-dir)
212+
shift
213+
KO_DIRS="$1"
214+
;;
215+
--ko-tree)
216+
shift
217+
KO_TREE="$1"
218+
;;
219+
--ko-tar)
220+
shift
221+
KO_TARBALL="$1"
222+
;;
223+
--ko-prefer-custom)
224+
KO_PREFER_CUSTOM="1"
225+
;;
226+
193227
--app-launch-sleep)
194228
shift
195229
APP_LAUNCH_SLEEP="$1"
@@ -202,6 +236,15 @@ while [ $# -gt 0 ]; do
202236
shift
203237
LOG_FLAVOR="$1"
204238
;;
239+
# --- Stabilizers ---
240+
--retry-on-fail)
241+
shift
242+
RETRY_ON_FAIL="$1"
243+
;;
244+
--post-test-sleep)
245+
shift
246+
POST_TEST_SLEEP="$1"
247+
;;
205248
--help|-h)
206249
usage
207250
exit 0
@@ -234,6 +277,44 @@ export INTER_TEST_SLEEP
234277
# --- EARLY dependency check (bail out fast) ---
235278

236279
# Ensure the app is executable if a path was provided but lacks +x
280+
281+
# --- Optional: unpack a custom module tarball **once** (no env exports) ---
282+
KVER="$(uname -r 2>/dev/null || printf '%s' unknown)"
283+
if [ -n "$KO_TARBALL" ] && [ -f "$KO_TARBALL" ]; then
284+
DEST="/run/iris_mods/$KVER"
285+
if [ ! -d "$DEST" ]; then
286+
mkdir -p "$DEST" 2>/dev/null || true
287+
case "$KO_TARBALL" in
288+
*.tar|*.tar.gz|*.tgz|*.tar.xz|*.txz|*.tar.zst)
289+
if command -v tar >/dev/null 2>&1; then
290+
# best-effort; keep extraction bounded to DEST
291+
tar -xf "$KO_TARBALL" -C "$DEST" 2>/dev/null || true
292+
fi
293+
;;
294+
*)
295+
# not a tar? treat as a directory if user passed one by mistake
296+
:
297+
;;
298+
esac
299+
fi
300+
# decide whether the tar contained a full tree or loose .ko’s
301+
if [ -d "$DEST/lib/modules/$KVER" ]; then
302+
KO_TREE="$DEST"
303+
else
304+
# find first dir that has at least one .ko (bounded depth)
305+
first_ko_dir="$(find "$DEST" -type f -name '*.ko*' -maxdepth 3 2>/dev/null | head -n1 | xargs -r dirname)"
306+
if [ -n "$first_ko_dir" ]; then
307+
if [ -n "$KO_DIRS" ]; then
308+
KO_DIRS="$first_ko_dir:$KO_DIRS"
309+
else
310+
KO_DIRS="$first_ko_dir"
311+
fi
312+
fi
313+
fi
314+
# quiet summary (only if user opted-in)
315+
log_info "Custom module source prepared (tree='${KO_TREE:-none}', dirs='${KO_DIRS:-none}', prefer_custom=$KO_PREFER_CUSTOM)"
316+
fi
317+
237318
if [ -n "$VIDEO_APP" ] && [ -f "$VIDEO_APP" ] && [ ! -x "$VIDEO_APP" ]; then
238319
chmod +x "$VIDEO_APP" 2>/dev/null || true
239320
if [ ! -x "$VIDEO_APP" ]; then
@@ -497,6 +578,14 @@ if [ "${VIDEO_STACK}" = "both" ]; then
497578
args="$args --inter-test-sleep $(printf %s "$INTER_TEST_SLEEP")"
498579
fi
499580

581+
# --- Stabilizers passthrough ---
582+
if [ -n "${RETRY_ON_FAIL:-}" ]; then
583+
args="$args --retry-on-fail $(printf %s "$RETRY_ON_FAIL")"
584+
fi
585+
if [ -n "${POST_TEST_SLEEP:-}" ]; then
586+
args="$args --post-test-sleep $(printf %s "$POST_TEST_SLEEP")"
587+
fi
588+
500589
printf "%s" "$args"
501590
}
502591

@@ -564,6 +653,15 @@ log_info "APP=$VIDEO_APP"
564653
if [ -n "$VIDEO_FW_DS" ]; then
565654
log_info "Downstream FW override: $VIDEO_FW_DS"
566655
fi
656+
if [ -n "$KO_TREE$KO_DIRS$KO_TARBALL" ]; then
657+
# print only when user actually provided custom sources
658+
if [ -n "$KO_TREE" ]; then
659+
log_info "Custom module tree (modprobe -d): $KO_TREE"
660+
fi
661+
if [ -n "$KO_DIRS" ]; then
662+
log_info "Custom ko dir(s): $KO_DIRS (prefer_custom=$KO_PREFER_CUSTOM)"
663+
fi
664+
fi
567665
if [ -n "$VIDEO_FW_BACKUP_DIR" ]; then
568666
log_info "FW backup override: $VIDEO_FW_BACKUP_DIR"
569667
fi
@@ -1019,6 +1117,38 @@ while IFS= read -r cfg; do
10191117
fi
10201118
fi
10211119

1120+
# (2) Retry on final failure (extra attempts outside REPEAT loop, before recording results)
1121+
if [ "$final" = "FAIL" ] && [ "$RETRY_ON_FAIL" -gt 0 ] 2>/dev/null; then
1122+
r=1
1123+
log_info "[$id] RETRY_ON_FAIL: up to $RETRY_ON_FAIL additional attempt(s)"
1124+
while [ "$r" -le "$RETRY_ON_FAIL" ]; do
1125+
# optional delay between retries, reuse REPEAT_DELAY for consistency
1126+
if [ "$REPEAT_DELAY" -gt 0 ] 2>/dev/null; then
1127+
sleep "$REPEAT_DELAY"
1128+
fi
1129+
1130+
log_info "[$id] retry attempt $r/$RETRY_ON_FAIL"
1131+
if video_run_once "$cfg" "$logf" "$TIMEOUT" "$SUCCESS_RE" "$LOGLEVEL"; then
1132+
pass_runs=$((pass_runs + 1))
1133+
final="PASS"
1134+
log_pass "[$id] RETRY succeeded — marking PASS"
1135+
break
1136+
else
1137+
# capture latest rc marker for visibility
1138+
rc_val="$(awk -F'=' '/^END-RUN rc=/{print $2}' "$logf" 2>/dev/null | tail -n1 | tr -d ' ')"
1139+
if [ -n "$rc_val" ]; then
1140+
case "$rc_val" in
1141+
139) log_warn "[$id] Retry exited rc=139 (SIGSEGV)." ;;
1142+
134) log_warn "[$id] Retry exited rc=134 (SIGABRT)." ;;
1143+
137) log_warn "[$id] Retry exited rc=137 (SIGKILL/OOM?)." ;;
1144+
*) : ;;
1145+
esac
1146+
fi
1147+
fi
1148+
r=$((r + 1))
1149+
done
1150+
fi
1151+
10221152
{
10231153
printf 'RESULT id=%s mode=%s pretty="%s" final=%s pass_runs=%s fail_runs=%s elapsed=%s\n' \
10241154
"$id" "$mode" "$pretty" "$final" "$pass_runs" "$fail_runs" "$elapsed"
@@ -1052,6 +1182,15 @@ while IFS= read -r cfg; do
10521182
fi
10531183
fi
10541184

1185+
# (6) Post-test settle sleep
1186+
case "$POST_TEST_SLEEP" in
1187+
''|*[!0-9]* )
1188+
:
1189+
;;
1190+
0) : ;;
1191+
*) log_info "Post-test sleep ${POST_TEST_SLEEP}s"; sleep "$POST_TEST_SLEEP" ;;
1192+
esac
1193+
10551194
if [ "$MAX" -gt 0 ] && [ "$total" -ge "$MAX" ]; then
10561195
log_info "Reached MAX=$MAX tests; stopping"
10571196
break

0 commit comments

Comments
 (0)