Skip to content
Open
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
49 changes: 49 additions & 0 deletions Runner/suites/Multimedia/Video/Video_V4L2_Runner/README_Video.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,55 @@ The suite includes a **reboot-free video stack switcher** (upstream ↔ downstre

---

## Shikra Platform Support

**Shikra** is an upstream-only platform. The sole video driver is `qcom_iris`, which may be
modular (visible in `lsmod`) or compiled in as a built-in (bound under
`/sys/bus/platform/drivers/qcom_iris`). Both cases are detected automatically.

| Property | Value |
|---|---|
| Supported stack | `upstream` only (`--stack upstream` or `--stack auto`) |
| Downstream stack | Not supported — rejected with a clear error |
| Video driver | `qcom_iris` (modular or built-in) |
| Max H.264/HEVC encode Level | **4.0** (automatically applied to bundled fixtures) |

### Automatic Level cap for bundled encoder fixtures

On Shikra, Level 4.0 is the maximum supported H.264 and HEVC encode level.
The runner automatically rewrites the `Level` control to `4.0` in the four
bundled encoder configs before execution:

- `base_h264Encoder.json`
- `base_h265Encoder.json`
- `overlay_h264Encoder.json`
- `overlay_h265Encoder.json`

User-supplied configs passed via `--config` are **not** modified by default.
Set `VIDEO_POLICY_SCOPE=all` to apply the rewrite to every config.

### Extending the policy table

Additional per-platform control overrides can be injected at runtime without
modifying any source file:

```sh
# Apply a Profile override for Shikra H.264 encode in addition to the built-in Level cap
export VIDEO_POLICY_EXTRA="shikra|encode|h264|Profile|High"
./run-test.sh Video_V4L2_Runner --app /path/to/iris_v4l2_test --stack upstream
```

Format: `platform|mode|codec|control|value` (one row per line, pipe-separated).

### Example: run all configs on Shikra

```sh
# From the Runner/ directory on the device:
./run-test.sh Video_V4L2_Runner --app /path/to/iris_v4l2_test --stack upstream
```

---

## What’s New (since 2025‑10‑03)

- **Network stabilization delay (post-connect)**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
metadata:
name: video-v4l2-runner
format: "Lava-Test Test Definition 1.0"
description: "These scripts automate validation of video **encoding** and **decoding** on Qualcomm Linux platforms running a Yocto-based rootfs."
description: >
Automates V4L2 video encoding and decoding validation on Qualcomm Linux
platforms (LeMans, Monaco, Kodiak, Shikra) using iris_v4l2_test.
Shikra is upstream-only (qcom_iris driver); set VIDEO_STACK=upstream.
Level 4.0 is automatically applied to bundled Shikra encoder fixtures.
Set VIDEO_POLICY_SCOPE=all to extend the rewrite to user-supplied configs.
os:
- linux
scope:
Expand All @@ -10,10 +15,19 @@ metadata:
params:
# path to iris_v4l2_test binary
APP_PATH: "/usr/bin/iris_v4l2_test"
# specific config can be selected. Available: h264Decoder.json, h264Encoder.json, h265Decoder.json, h265Encoder.json, vp9Decoder.json. Default is to use all of them
# specific config can be selected. Available: base_h264Decoder.json,
# base_h264Encoder.json, base_h265Decoder.json, base_h265Encoder.json,
# base_vp9Decoder.json, overlay_*.json. Default is to use all of them.
CONFIG_PATH: "./"
# platform is autodetected by the test script
# platform is autodetected by the test script (lemans|monaco|kodiak|shikra)
PLATFORM: ""
# stack selection: auto|upstream|downstream|base|overlay|both
# Shikra supports upstream only; use VIDEO_STACK=upstream or leave as auto.
VIDEO_STACK: "auto"
# policy scope: bundled (default) | all
# 'bundled' restricts Level-4.0 rewrite to the four bundled encoder fixtures.
# 'all' applies the rewrite to every config including user-supplied ones.
VIDEO_POLICY_SCOPE: "bundled"
LOGLEVEL: 15
RETRY_ON_FAIL: 5
POST_TEST_SLEEP: 10
Expand All @@ -22,5 +36,5 @@ run:
steps:
- REPO_PATH=$PWD
- cd Runner/suites/Multimedia/Video/Video_V4L2_Runner/
- ./run.sh --app "${APP_PATH}" --config "${CONFIG_PATH}" --platform "${PLATFORM}" --loglevel "${LOGLEVEL}" --retry-on-fail "${RETRY_ON_FAIL}" --post-test-sleep "${POST_TEST_SLEEP}" || true
- VIDEO_POLICY_SCOPE="${VIDEO_POLICY_SCOPE}" ./run.sh --app "${APP_PATH}" --config "${CONFIG_PATH}" --platform "${PLATFORM}" --stack "${VIDEO_STACK}" --loglevel "${LOGLEVEL}" --retry-on-fail "${RETRY_ON_FAIL}" --post-test-sleep "${POST_TEST_SLEEP}" || true
- $REPO_PATH/Runner/utils/send-to-lava.sh Video_V4L2_Runner.res || true
169 changes: 159 additions & 10 deletions Runner/suites/Multimedia/Video/Video_V4L2_Runner/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ Usage: $0 [--config path.json|/path/dir] [--dir DIR] [--pattern GLOB]
[--repeat N] [--repeat-delay S] [--repeat-policy all|any]
[--junit FILE] [--dry-run] [--verbose]
[--stack auto|upstream|downstream|base|overlay|up|down|both]
[--platform lemans|monaco|kodiak]
[--downstream-fw PATH] [--force] # optional Kodiak firmware override
[--platform lemans|monaco|kodiak|shikra]
[--downstream-fw PATH] [--force]
[--app /path/to/iris_v4l2_test]
[--ssid SSID] [--password PASS]
[--ko-dir DIR[:DIR2:...]] # opt-in: search these dirs for .ko on failure
Expand All @@ -125,6 +125,23 @@ Usage: $0 [--config path.json|/path/dir] [--dir DIR] [--pattern GLOB]
# --- Media bundle (opt-in, local tar) ---
[--clips-tar /path/to/clips.tar.gz] # extract locally even if --dir/--config is used
[--clips-dest DIR] # extraction destination (defaults to cfg/dir root or testcase dir)

Platform notes:
shikra Upstream-only platform (qcom_iris driver, modular or built-in).
Downstream stack is not supported. --stack upstream (or auto) is
the only valid choice. Level 4.0 is the maximum supported H.264/HEVC
encode level and is automatically applied to the bundled encoder
fixtures (base_h264Encoder.json, base_h265Encoder.json,
overlay_h264Encoder.json, overlay_h265Encoder.json).

Environment variables:
VIDEO_POLICY_SCOPE bundled (default) | all
Controls which configs receive automatic platform policy rewrites.
'bundled' restricts rewrites to the bundled fixture configs above.
'all' applies the policy to every config, including user-supplied ones.
VIDEO_POLICY_EXTRA Additional policy rows in pipe-separated format:
platform|mode|codec|control|value (one row per line).
Example: VIDEO_POLICY_EXTRA="shikra|encode|h264|Profile|High"
EOF
}

Expand Down Expand Up @@ -475,13 +492,39 @@ fi

# Validate an explicitly requested Kodiak firmware override before downloads.
# Kodiak normally uses the firmware already provisioned by the image.
# --- Validate VIDEO_POLICY_SCOPE before any execution ---
# Only 'bundled' and 'all' are valid. An explicit non-empty value that is
# neither is a misconfiguration — fail fast rather than silently using bundled.
case "${VIDEO_POLICY_SCOPE:-}" in
""|bundled|all)
;;
*)
log_fail "$TESTNAME FAIL - invalid VIDEO_POLICY_SCOPE='${VIDEO_POLICY_SCOPE}'; accepted values: bundled, all"
printf '%s\n' "$TESTNAME FAIL" >"$RES_FILE"
exit 1
;;
esac

early_plat="$VIDEO_PLATFORM"
if [ -z "$early_plat" ]; then
early_plat="$(video_detect_platform)"
fi

early_stack="$(video_normalize_stack "$VIDEO_STACK")"

# Reject downstream|both on Shikra before package recovery or --stack both
# re-execution. Shikra is upstream-only; allowing the run to proceed would
# install the video overlay package set and then fail anyway.
if [ "$early_plat" = "shikra" ]; then
case "$early_stack" in
downstream|both)
log_fail "$TESTNAME FAIL - Shikra is upstream-only; --stack downstream/both is not supported"
printf '%s\n' "$TESTNAME FAIL" >"$RES_FILE"
exit 1
;;
esac
fi

if [ "$early_plat" = "kodiak" ]; then
case "$early_stack" in
downstream|both)
Expand Down Expand Up @@ -992,6 +1035,15 @@ case "$plat" in
fi
fi
;;
shikra)
if [ "$post_stack" = "upstream" ]; then
if video_qcom_iris_active; then
log_pass "Upstream validated: qcom_iris present (Shikra)"
else
log_warn "Upstream expected but qcom_iris not present (Shikra)"
fi
fi
;;
*)
log_warn "Unknown platform; skipping strict module validation"
;;
Expand All @@ -1017,15 +1069,27 @@ fi
if [ -z "$CFG" ]; then
if [ -n "$DIR" ]; then
base_dir="$DIR"
# Prune generated output directories (logs_*) before enumerating configs.
# Using -prune rather than ! -path avoids path-spelling issues with
# trailing slashes and relative roots (e.g. "./" vs "." vs absolute).
if [ -n "$PATTERN" ]; then
find "$base_dir" -type f -name "$PATTERN" 2>/dev/null | sort > "$CFG_LIST"
find "$base_dir" \
-name "logs_*" -prune -o \
-type f -name "$PATTERN" -print \
2>/dev/null | sort > "$CFG_LIST"
else
find "$base_dir" -type f -name "*.json" 2>/dev/null | sort > "$CFG_LIST"
find "$base_dir" \
-name "logs_*" -prune -o \
-type f -name "*.json" -print \
2>/dev/null | sort > "$CFG_LIST"
fi
log_info "Using custom config directory: $base_dir"
else
log_info "No --config passed, searching for JSON under testcase dir: $test_path"
find "$test_path" -type f -name "*.json" 2>/dev/null | sort > "$CFG_LIST"
find "$test_path" \
-name "logs_*" -prune -o \
-type f -name "*.json" -print \
2>/dev/null | sort > "$CFG_LIST"
fi
else
printf '%s\n' "$CFG" > "$CFG_LIST"
Expand Down Expand Up @@ -1211,9 +1275,94 @@ while IFS= read -r cfg; do
continue
fi

# -----------------------------------------------------------------------
Comment thread
vmadired2 marked this conversation as resolved.
# Stage the effective config once per test case, before the repeat loop.
# Both normal runs and retries use the same staged path so they cannot
# diverge. Platforms with no matching policy row use the original config
# unchanged (no-op path through video_policy_lookup).
#
# Policy rewrites are restricted to the bundled fixture configs by default
# (base_*.json and overlay_*.json) so that user-supplied configs passed via
# --config are not silently modified. Set VIDEO_POLICY_SCOPE=all to apply
# the policy to every config regardless of filename.
# -----------------------------------------------------------------------
effective_cfg="$cfg"
vpl_policy_file="$LOG_DIR/.policy_${id}.$$.txt"
# Resolve the config to an absolute path and compare against the actual
# bundled fixture paths in the suite directory. A config that merely has
# the same basename as a bundled fixture (e.g. /data/base_h264Encoder.json)
# is treated as user-supplied and is not rewritten by default.
vpl_cfg_resolved="$(cd "$(dirname "$cfg")" 2>/dev/null && pwd)/$(basename "$cfg")"
vpl_apply_policy=0
case "$vpl_cfg_resolved" in
"$SCRIPT_DIR/base_h264Encoder.json"|\
"$SCRIPT_DIR/base_h265Encoder.json"|\
"$SCRIPT_DIR/overlay_h264Encoder.json"|\
"$SCRIPT_DIR/overlay_h265Encoder.json")
vpl_apply_policy=1
;;
*)
if [ "${VIDEO_POLICY_SCOPE:-bundled}" = "all" ]; then
Comment thread
vmadired2 marked this conversation as resolved.
vpl_apply_policy=1
fi
;;
esac
if [ "$vpl_apply_policy" -eq 1 ]; then
video_policy_lookup "$plat" "$mode" "$codec" > "$vpl_policy_file" 2>/dev/null || true
fi

if [ -s "$vpl_policy_file" ]; then
vpl_staged="$cfg"
vpl_stage_ok=1
while IFS='|' read -r vpl_ctrl vpl_val; do
[ -z "$vpl_ctrl" ] && continue
vpl_result="$(video_stage_control_override \
"$vpl_staged" "$vpl_ctrl" "$vpl_val" "$LOG_DIR")"
vpl_rc=$?
if [ "$vpl_rc" -eq 2 ]; then
# Policy requires this control but the config does not declare it.
# Running the original config would silently use the platform default
# (potentially unsupported) value — fail preparation instead.
log_warn "[$id] Required control '$vpl_ctrl' is absent from config '$vpl_staged'; aborting preparation"
vpl_stage_ok=0
break
fi
if [ "$vpl_rc" -ne 0 ]; then
log_warn "[$id] Config staging failed for control '$vpl_ctrl'; aborting preparation"
vpl_stage_ok=0
break
fi
if [ -n "$vpl_result" ] && [ -f "$vpl_result" ]; then
vpl_staged="$vpl_result"
fi
done < "$vpl_policy_file"

if [ "$vpl_stage_ok" -eq 0 ]; then
rm -f "$vpl_policy_file" 2>/dev/null || true
log_fail "[$id] FAIL - config preparation failed"
printf '%s\n' "$id FAIL $pretty" >> "$LOG_DIR/summary.txt"
printf '%s\n' "$mode,$id,FAIL,$pretty,0,0,0" >> "$LOG_DIR/results.csv"
fail=$((fail + 1))
suite_rc=1
if [ "$STOP_ON_FAIL" -eq 1 ]; then
break
fi
continue
fi

if [ "$vpl_staged" != "$cfg" ]; then
effective_cfg="$vpl_staged"
log_info "[$id] Using staged config: $effective_cfg"
fi
fi
rm -f "$vpl_policy_file" 2>/dev/null || true

# Dry-run: print the effective (post-staging) config path and move on.
# Policy staging runs first so the displayed config reflects what a real
# Shikra run would actually execute (e.g. Level 4.0 instead of 5.0).
if [ "$DRY" -eq 1 ]; then
video_step "$id" "DRY RUN - print command"
log_info "[dry] [$id] $VIDEO_APP --config \"$cfg\" --loglevel $LOGLEVEL — $pretty"
log_info "[dry] [$id] $VIDEO_APP --config \"$effective_cfg\" --loglevel $LOGLEVEL — $pretty"
printf '%s\n' "$id DRY-RUN $pretty" >> "$LOG_DIR/summary.txt"
printf '%s\n' "$mode,$id,DRY-RUN,$pretty,0,0,0" >> "$LOG_DIR/results.csv"
continue
Expand All @@ -1231,7 +1380,7 @@ while IFS= read -r cfg; do
fi

video_step "$id" "Execute app"
log_info "[$id] CMD: $VIDEO_APP --config \"$cfg\" --loglevel $LOGLEVEL"
log_info "[$id] CMD: $VIDEO_APP --config \"$effective_cfg\" --loglevel $LOGLEVEL"

case "$APP_LAUNCH_SLEEP" in
''|*[!0-9]* )
Expand All @@ -1246,7 +1395,7 @@ while IFS= read -r cfg; do
;;
esac

if video_run_once "$cfg" "$logf" "$TIMEOUT" "$SUCCESS_RE" "$LOGLEVEL"; then
if video_run_once "$effective_cfg" "$logf" "$TIMEOUT" "$SUCCESS_RE" "$LOGLEVEL"; then
pass_runs=$((pass_runs + 1))
else
rc_val="$(awk -F'=' '/^END-RUN rc=/{print $2}' "$logf" 2>/dev/null | tail -n1 | tr -d ' ')"
Expand Down Expand Up @@ -1300,7 +1449,7 @@ while IFS= read -r cfg; do
fi

# (2) Retry on final failure (extra attempts outside REPEAT loop, before recording results)
if [ "$final" = "FAIL" ] && [ "$RETRY_ON_FAIL" -gt 0 ] 2>/dev/null; then
if [ "$final" = "FAIL" ] && [ "$RETRY_ON_FAIL" -gt 0 ] 2>/dev/null; then
r=1
log_info "[$id] RETRY_ON_FAIL: up to $RETRY_ON_FAIL additional attempt(s)"
while [ "$r" -le "$RETRY_ON_FAIL" ]; do
Expand All @@ -1309,7 +1458,7 @@ while IFS= read -r cfg; do
fi

log_info "[$id] retry attempt $r/$RETRY_ON_FAIL"
if video_run_once "$cfg" "$logf" "$TIMEOUT" "$SUCCESS_RE" "$LOGLEVEL"; then
if video_run_once "$effective_cfg" "$logf" "$TIMEOUT" "$SUCCESS_RE" "$LOGLEVEL"; then
pass_runs=$((pass_runs + 1))
final="PASS"
log_pass "[$id] RETRY succeeded — marking PASS"
Expand Down
38 changes: 6 additions & 32 deletions Runner/utils/audio_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2843,39 +2843,13 @@ audio_remoteproc_is_modem() {
}

# Return success when runtime platform evidence identifies a Shikra target.
# The preflight runs before the suites call detect_platform, so inspect both
# any already-populated platform variables and the standard runtime DT paths.
#
# All repository callers source functestlib.sh before audio_common.sh,
# including child user-session paths. platform_identity_matches() from
# functestlib.sh is therefore always available and is the single contract.
# If standalone sourcing is required, source functestlib.sh explicitly first.
audio_platform_is_shikra() {
apis_identity="${PLATFORM_MACHINE:-} ${PLATFORM_TARGET:-}"
apis_identity="$apis_identity ${PLATFORM_SOC_MACHINE:-}"
apis_identity="$apis_identity ${PLATFORM_DT_MODEL:-}"
apis_identity="$apis_identity ${PLATFORM_DT_COMPAT:-}"

for apis_file in \
/proc/device-tree/model \
/proc/device-tree/compatible \
/sys/firmware/devicetree/base/model \
/sys/firmware/devicetree/base/compatible
do
if [ -r "$apis_file" ]; then
apis_value="$(tr '\000' ' ' <"$apis_file" 2>/dev/null || true)"
apis_identity="$apis_identity $apis_value"
fi
done

apis_identity="$(
printf '%s\n' "$apis_identity" |
tr '[:upper:]' '[:lower:]'
)"

case "$apis_identity" in
*shikra*)
return 0
;;
*)
return 1
;;
esac
platform_identity_matches "shikra"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

platform_identity_matches is not defined in functestlib.sh or anywhere else at this PR head. Add the shared platform identity helpers to functestlib.sh in this PR and test both matching and non-matching platforms, or retain the previous working runtime-DT implementation.

}

# Reorder an inventory so a modem-hosted audio path is considered before DSP
Expand Down
Loading