Skip to content

Commit 01767d2

Browse files
committed
Updated wayland, video and lib gstreamer sh scripts based on review comments
Signed-off-by: Nitin Nakka <nitinn@qti.qualcomm.com>
1 parent 77b5d42 commit 01767d2

3 files changed

Lines changed: 189 additions & 57 deletions

File tree

Runner/suites/Multimedia/GSTreamer/Display/Waylandsink_Playback/run.sh

Lines changed: 117 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
3-
# SPDX-License-Identifier: BSD-3-Clause per legal request.
3+
# SPDX-License-Identifier: BSD-3-Clause
44
# Waylandsink Playback validation using GStreamer
55
# Tests video playback using waylandsink with videotestsrc
66
# Validates Weston/Wayland server and display connectivity
@@ -54,6 +54,23 @@ result="FAIL"
5454
reason="unknown"
5555

5656
# -------------------- Defaults --------------------
57+
# Validate environment variables if set
58+
if [ -n "$VIDEO_DURATION" ] && ! echo "$VIDEO_DURATION" | grep -q "^[0-9]\+$"; then
59+
log_warn "VIDEO_DURATION must be numeric (got '$VIDEO_DURATION')"
60+
echo "$TESTNAME SKIP" >"$RES_FILE"
61+
exit 0
62+
fi
63+
if [ -n "$RUNTIMESEC" ] && ! echo "$RUNTIMESEC" | grep -q "^[0-9]\+$"; then
64+
log_warn "RUNTIMESEC must be numeric (got '$RUNTIMESEC')"
65+
echo "$TESTNAME SKIP" >"$RES_FILE"
66+
exit 0
67+
fi
68+
if [ -n "$VIDEO_FRAMERATE" ] && ! echo "$VIDEO_FRAMERATE" | grep -q "^[0-9]\+$"; then
69+
log_warn "VIDEO_FRAMERATE must be numeric (got '$VIDEO_FRAMERATE')"
70+
echo "$TESTNAME SKIP" >"$RES_FILE"
71+
exit 0
72+
fi
73+
5774
duration="${VIDEO_DURATION:-${RUNTIMESEC:-30}}"
5875
pattern="${VIDEO_PATTERN:-smpte}"
5976
width="${VIDEO_WIDTH:-1920}"
@@ -75,10 +92,24 @@ while [ $# -gt 0 ]; do
7592
echo "$TESTNAME SKIP" >"$RES_FILE"
7693
exit 0
7794
fi
78-
# Parse WIDTHxHEIGHT format (e.g., 1920x1080)
95+
# Parse and validate WIDTHxHEIGHT format (e.g., 1920x1080)
7996
if [ -n "$2" ]; then
97+
# Validate format contains 'x'
98+
if ! echo "$2" | grep -q "x"; then
99+
log_warn "Invalid resolution format '$2' - must be WIDTHxHEIGHT"
100+
echo "$TESTNAME SKIP" >"$RES_FILE"
101+
exit 0
102+
fi
103+
80104
width="${2%%x*}"
81105
height="${2#*x}"
106+
107+
# Validate both width and height are numeric
108+
if ! echo "$width" | grep -q "^[0-9]\+$" || ! echo "$height" | grep -q "^[0-9]\+$"; then
109+
log_warn "Width and height must be numeric values (got width='$width', height='$height')"
110+
echo "$TESTNAME SKIP" >"$RES_FILE"
111+
exit 0
112+
fi
82113
fi
83114
shift 2
84115
;;
@@ -89,8 +120,14 @@ while [ $# -gt 0 ]; do
89120
echo "$TESTNAME SKIP" >"$RES_FILE"
90121
exit 0
91122
fi
92-
# If $2 is empty, keep default and shift 2
93-
[ -n "$2" ] && duration="$2"
123+
if [ -n "$2" ]; then
124+
if ! echo "$2" | grep -q "^[0-9]\+$"; then
125+
log_warn "Duration must be a numeric value (got '$2')"
126+
echo "$TESTNAME SKIP" >"$RES_FILE"
127+
exit 0
128+
fi
129+
duration="$2"
130+
fi
94131
shift 2
95132
;;
96133

@@ -111,8 +148,15 @@ while [ $# -gt 0 ]; do
111148
echo "$TESTNAME SKIP" >"$RES_FILE"
112149
exit 0
113150
fi
114-
# If $2 is empty, keep default and shift 2
115-
[ -n "$2" ] && width="$2"
151+
# Validate width is numeric
152+
if [ -n "$2" ]; then
153+
if ! echo "$2" | grep -q "^[0-9]\+$"; then
154+
log_warn "Width must be a numeric value (got '$2')"
155+
echo "$TESTNAME SKIP" >"$RES_FILE"
156+
exit 0
157+
fi
158+
width="$2"
159+
fi
116160
shift 2
117161
;;
118162

@@ -122,8 +166,15 @@ while [ $# -gt 0 ]; do
122166
echo "$TESTNAME SKIP" >"$RES_FILE"
123167
exit 0
124168
fi
125-
# If $2 is empty, keep default and shift 2
126-
[ -n "$2" ] && height="$2"
169+
# Validate height is numeric
170+
if [ -n "$2" ]; then
171+
if ! echo "$2" | grep -q "^[0-9]\+$"; then
172+
log_warn "Height must be a numeric value (got '$2')"
173+
echo "$TESTNAME SKIP" >"$RES_FILE"
174+
exit 0
175+
fi
176+
height="$2"
177+
fi
127178
shift 2
128179
;;
129180

@@ -133,8 +184,14 @@ while [ $# -gt 0 ]; do
133184
echo "$TESTNAME SKIP" >"$RES_FILE"
134185
exit 0
135186
fi
136-
# If $2 is empty, keep default and shift 2
137-
[ -n "$2" ] && framerate="$2"
187+
if [ -n "$2" ]; then
188+
if ! echo "$2" | grep -q "^[0-9]\+$"; then
189+
log_warn "Framerate must be a numeric value (got '$2')"
190+
echo "$TESTNAME SKIP" >"$RES_FILE"
191+
exit 0
192+
fi
193+
framerate="$2"
194+
fi
138195
shift 2
139196
;;
140197

@@ -210,14 +267,8 @@ EOF
210267
done
211268

212269
# -------------------- Pre-checks --------------------
213-
check_dependencies "gst-launch-1.0 gst-inspect-1.0" >/dev/null 2>&1 || {
214-
log_warn "Missing gstreamer runtime (gst-launch-1.0/gst-inspect-1.0)"
215-
echo "$TESTNAME SKIP" >"$RES_FILE"
216-
exit 0
217-
}
218-
219-
check_dependencies "grep head sed" >/dev/null 2>&1 || {
220-
log_warn "Missing required tools (grep, head, sed)"
270+
check_dependencies "gst-launch-1.0 gst-inspect-1.0 grep head sed" >/dev/null 2>&1 || {
271+
log_skip "Missing required tools (gst-launch-1.0, gst-inspect-1.0, grep, head, sed)"
221272
echo "$TESTNAME SKIP" >"$RES_FILE"
222273
exit 0
223274
}
@@ -354,23 +405,59 @@ elapsed=$((end_ts - start_ts))
354405
log_info "Playback finished: rc=${gstRc} elapsed=${elapsed}s"
355406

356407
# -------------------- Validation --------------------
357-
# Check for GStreamer errors in log
408+
# Duration threshold (allow 2s slack)
409+
min_duration=$((duration - 2))
410+
411+
# Check for GStreamer errors in both run log and GST debug log
412+
run_log_ok=1
413+
gst_log_ok=1
414+
415+
# Validate run log
358416
if ! gstreamer_validate_log "$RUN_LOG" "$TESTNAME"; then
417+
run_log_ok=0
418+
fi
419+
420+
# Validate last 1000 lines of GST debug log if it exists and has content
421+
if [ -s "$GST_LOG" ]; then
422+
# Create temp file with last 1000 lines
423+
tail -n 1000 "$GST_LOG" > "${GST_LOG}.tail"
424+
if ! gstreamer_validate_log "${GST_LOG}.tail" "$TESTNAME"; then
425+
gst_log_ok=0
426+
fi
427+
rm -f "${GST_LOG}.tail"
428+
fi
429+
430+
if [ "$run_log_ok" -eq 0 ] || [ "$gst_log_ok" -eq 0 ]; then
359431
result="FAIL"
360-
reason="GStreamer errors detected in log"
432+
if [ "$run_log_ok" -eq 0 ] && [ "$gst_log_ok" -eq 0 ]; then
433+
reason="GStreamer errors detected in both run log and GST debug log"
434+
elif [ "$run_log_ok" -eq 0 ]; then
435+
reason="GStreamer errors detected in run log"
436+
else
437+
reason="GStreamer errors detected in GST debug log"
438+
fi
361439
else
362-
# Accept 0 (normal) and 143 (timeout/SIGTERM) as success
363-
if [ "$gstRc" -eq 0 ] || [ "$gstRc" -eq 143 ]; then
364-
if [ "$elapsed" -ge "$((duration - 2))" ]; then
365-
result="PASS"
366-
reason="Playback completed successfully (rc=$gstRc, elapsed=${elapsed}s)"
367-
else
368-
result="FAIL"
369-
reason="Playback exited too quickly (elapsed=${elapsed}s, expected ~${duration}s)"
370-
fi
440+
# First check if it ran long enough
441+
if [ "$elapsed" -ge "$min_duration" ]; then
442+
# If it ran long enough, check exit code
443+
case "$gstRc" in
444+
0) # Normal exit
445+
result="PASS"
446+
reason="Playback completed successfully (elapsed=${elapsed}/${duration}s)"
447+
;;
448+
124|137|143) # Timeout/kill signals - expected for long duration tests
449+
result="PASS"
450+
reason="Playback completed via ${gstRc} (SIGTERM=143, SIGKILL=137, GNU timeout=124) after ${elapsed}/${duration}s"
451+
;;
452+
*) # Unexpected return code
453+
result="FAIL"
454+
reason="Playback failed with unexpected exit code (rc=$gstRc, elapsed=${elapsed}/${duration}s)"
455+
;;
456+
esac
371457
else
458+
# Didn't run long enough - always fail regardless of return code
372459
result="FAIL"
373-
reason="Playback failed (rc=$gstRc)"
460+
reason="Playback exited too quickly (elapsed=${elapsed}s, minimum required=${min_duration}s)"
374461
fi
375462
fi
376463

Runner/suites/Multimedia/GSTreamer/Video/Video_Encode_Decode/run.sh

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
3-
# SPDX-License-Identifier: BSD-3-Clause per legal request.
3+
# SPDX-License-Identifier: BSD-3-Clause
44
# Video Encode/Decode validation using GStreamer with V4L2 hardware accelerated codecs
55
# Supports: v4l2h264dec, v4l2h265dec, v4l2h264enc, v4l2h265enc
66
# Uses videotestsrc for encoding, then decodes the encoded files
@@ -60,8 +60,8 @@ total_tests=0
6060

6161
# -------------------- Defaults (LAVA env vars -> defaults; CLI overrides) --------------------
6262
testMode="${VIDEO_TEST_MODE:-all}"
63-
codecList="${VIDEO_CODECS:-h264,h265,vp9}"
64-
resolutionList="${VIDEO_RESOLUTIONS:-4k}"
63+
codecList="${VIDEO_CODECS:-h264,h265}"
64+
resolutionList="${VIDEO_RESOLUTIONS:-480p,4k}"
6565
duration="${VIDEO_DURATION:-${RUNTIMESEC:-30}}"
6666
framerate="${VIDEO_FRAMERATE:-30}"
6767
gstDebugLevel="${VIDEO_GST_DEBUG:-${GST_DEBUG_LEVEL:-2}}"
@@ -126,8 +126,19 @@ while [ $# -gt 0 ]; do
126126
echo "$TESTNAME SKIP" >"$RES_FILE"
127127
exit 0
128128
fi
129-
# If empty, keep default; otherwise use provided value
130-
[ -n "$2" ] && duration="$2"
129+
# If empty or non-numeric, keep default; otherwise use provided value
130+
if [ -n "$2" ]; then
131+
case "$2" in
132+
''|*[!0-9]*)
133+
log_warn "Invalid --duration '$2' (must be numeric)"
134+
echo "$TESTNAME SKIP" >"$RES_FILE"
135+
exit 0
136+
;;
137+
*)
138+
duration="$2"
139+
;;
140+
esac
141+
fi
131142
shift 2
132143
;;
133144

@@ -247,14 +258,8 @@ case "$gstDebugLevel" in 1|2|3|4|5|6|7|8|9) : ;; *)
247258
esac
248259

249260
# -------------------- Pre-checks --------------------
250-
check_dependencies "gst-launch-1.0 gst-inspect-1.0" >/dev/null 2>&1 || {
251-
log_warn "Missing gstreamer runtime (gst-launch-1.0/gst-inspect-1.0)"
252-
echo "$TESTNAME SKIP" >"$RES_FILE"
253-
exit 0
254-
}
255-
256-
check_dependencies "awk grep head sed tr stat" >/dev/null 2>&1 || {
257-
log_warn "Missing required tools (awk, grep, head, sed, tr, stat)"
261+
check_dependencies "gst-launch-1.0 gst-inspect-1.0 awk grep head sed tr stat" >/dev/null 2>&1 || {
262+
log_skip "Missing required tools (gst-launch-1.0, gst-inspect-1.0, awk, grep, head, sed, tr, stat)"
258263
echo "$TESTNAME SKIP" >"$RES_FILE"
259264
exit 0
260265
}
@@ -538,7 +543,8 @@ if [ "$need_vp9_clip" -eq 1 ] && [ "$testMode" != "encode" ]; then
538543
log_info "Converting IVF to WebM container using GStreamer..."
539544

540545
# Use GStreamer pipeline to remux IVF to WebM (Matroska container)
541-
if gst-launch-1.0 filesrc location="$vp9_clip_ivf" ! ivfparse ! matroskamux ! filesink location="$vp9_clip_webm" >/dev/null 2>&1; then
546+
pipeline="filesrc location=\"$vp9_clip_ivf\" ! ivfparse ! matroskamux ! filesink location=\"$vp9_clip_webm\""
547+
if gstreamer_run_gstlaunch_timeout 30 "$pipeline" >/dev/null 2>&1; then
542548
log_pass "Successfully converted IVF to WebM (320x240)"
543549
else
544550
log_fail "GStreamer IVF to WebM conversion failed"
@@ -568,8 +574,9 @@ if [ "$testMode" = "all" ] || [ "$testMode" = "encode" ]; then
568574

569575
for res in $resolutions; do
570576
params=$(gstreamer_resolution_to_wh "$res")
571-
width=$(printf '%s' "$params" | awk '{print $1}')
572-
height=$(printf '%s' "$params" | awk '{print $2}')
577+
set -- $params
578+
width="$1"
579+
height="$2"
573580

574581
total_tests=$((total_tests + 1))
575582
run_encode_test "$codec" "$res" "$width" "$height" || true

0 commit comments

Comments
 (0)