3434
3535TESTNAME=" Video_V4L2_Runner"
3636RES_FILE=" ./${TESTNAME} .res"
37- LOG_DIR=" ./logs_${TESTNAME} "
38- mkdir -p " $LOG_DIR "
3937TAR_URL=" https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/IRIS-Video-Files-v1.0/video_clips_iris.tar.gz"
40- extract_tar_from_url " $TAR_URL "
38+
4139
4240# ##############################################################################
4341# Knobs (override by env or CLI)
@@ -49,6 +47,7 @@ PATTERN="" # glob to filter configs
4947MAX=" ${MAX:- 0} " # run at most N tests (0=all)
5048STOP_ON_FAIL=" ${STOP_ON_FAIL:- 0} " # bail on first fail
5149DRY=0 # 1=dry-run
50+ EXTRACT_INPUT_CLIPS=" ${EXTRACT_INPUT_CLIPS:- true} " # true/false, controls extract_tar_from_url
5251SUCCESS_RE=" ${SUCCESS_RE:- SUCCESS} " # success marker regex in tool log
5352LOGLEVEL=" ${LOGLEVEL:- 15} " # iris_v4l2_test --loglevel
5453
@@ -62,12 +61,13 @@ usage() {
6261 cat << EOF
6362Usage: $0 [--config path.json] [--dir DIR] [--pattern GLOB]
6463 [--timeout S] [--strict] [--no-dmesg] [--max N] [--stop-on-fail]
65- [--loglevel N]
64+ [--loglevel N] [--extract-input-clips true|false]
6665 [--repeat N] [--repeat-delay S] [--repeat-policy all|any]
6766 [--junit FILE] [--dry-run]
6867EOF
6968}
7069
70+
7171CFG=" " ; DIR=" "
7272while [ $# -gt 0 ]; do
7373 case " $1 " in
@@ -85,25 +85,33 @@ while [ $# -gt 0 ]; do
8585 --repeat-policy) shift ; REPEAT_POLICY=" $1 " ;;
8686 --junit) shift ; JUNIT_OUT=" $1 " ;;
8787 --dry-run) DRY=1 ;;
88+ --extract-input-clips) shift ; EXTRACT_INPUT_CLIPS=" $1 " ;;
8889 --help|-h) usage; exit 0 ;;
8990 * ) log_warn " Unknown arg: $1 " ;;
9091 esac
9192 shift
9293done
9394
94- test_path=" $( find_test_case_by_name " $TESTNAME " 2> /dev/null || echo " " ) "
95- [ -n " $test_path " ] || test_path=" $SCRIPT_DIR "
95+ if [ " $EXTRACT_INPUT_CLIPS " = " true" ]; then
96+ extract_tar_from_url " $TAR_URL "
97+ fi
98+ test_path=" $( find_test_case_by_name " $TESTNAME " 2> /dev/null || echo " $SCRIPT_DIR " ) "
99+ # Run from the testcase directory so relative outputs (logs, .res) land next to run.sh
100+ cd " $test_path " || { log_error " cd failed: $test_path " ; echo " $TESTNAME FAIL" > " $RES_FILE " ; exit 1; }
101+
102+ LOG_DIR=" ./logs_${TESTNAME} "
103+ mkdir -p " $LOG_DIR "
96104
97105log_info " ----------------------------------------------------------------------"
98106log_info " ------------------ Starting $TESTNAME (generic runner) ----------------"
99107log_info " === Initialization ==="
100108log_info " TIMEOUT=${TIMEOUT} s STRICT=$STRICT DMESG_SCAN=$DMESG_SCAN SUCCESS_RE=$SUCCESS_RE "
101- log_info " LOGLEVEL=$LOGLEVEL "
109+ log_info " LOGLEVEL=$LOGLEVEL EXTRACT_INPUT_CLIPS= $EXTRACT_INPUT_CLIPS "
102110log_info " REPEAT=$REPEAT REPEAT_DELAY=${REPEAT_DELAY} s REPEAT_POLICY=$REPEAT_POLICY "
103111
104112# Required binaries (no external 'timeout' needed)
105113check_dependencies iris_v4l2_test grep sed awk find sort || {
106- log_skip " $TESTNAME SKIP – required tools missing"
114+ log_skip " $TESTNAME SKIP – required tools missing"
107115 echo " $TESTNAME SKIP" > " $RES_FILE "
108116 exit 0
109117}
@@ -154,27 +162,35 @@ ensure_clips_present_or_fetch() {
154162 cfg=" $1 " ; missing=0
155163 clips=" $( extract_input_clips " $cfg " ) "
156164 [ -z " $clips " ] && return 0
157- echo " $clips " | while IFS= read -r p; do
158- case " $p " in /* ) abs=" $p " ;; * ) abs=" $( cd " $( dirname " $cfg " ) " && pwd) /$p " ;; esac
165+ # Iterate without a subshell so 'missing' persists
166+ while IFS= read -r p; do
167+ [ -n " $p " ] || continue
168+ case " $p " in
169+ /* ) abs=" $p " ;;
170+ * ) abs=" $( cd " $( dirname " $cfg " ) " && pwd) /$p " ;;
171+ esac
159172 if [ ! -f " $abs " ]; then
160173 log_warn " Missing input clip: $abs "
161- if [ -n " $TAR_URL " ]; then
174+ if [ " $EXTRACT_INPUT_CLIPS " = " true " ] && [ -n " $TAR_URL " ]; then
162175 log_info " Attempting fetch via TAR_URL=$TAR_URL "
163176 extract_tar_from_url " $TAR_URL " || log_warn " Fetch/extract failed for TAR_URL"
177+ else
178+ log_warn " Skipping extraction of input clips as EXTRACT_INPUT_CLIPS is not true."
164179 fi
165- # shellcheck disable=SC2030
166180 [ ! -f " $abs " ] && missing=1
167181 fi
168- done
169- # shellcheck disable=SC2031
182+ done << EOF
183+ $( printf " %s\n" " $clips " )
184+ EOF
170185 [ $missing -eq 0 ]
171186}
172187
173188scan_dmesg_if_enabled () {
174189 [ " $DMESG_SCAN " -eq 1 ] || return 0
175190 MODS=' oom|memory|BUG|hung task|soft lockup|hard lockup|rcu|page allocation failure|I/O error'
176191 EXCL=' using dummy regulator|not found|EEXIST|probe deferred'
177- scan_dmesg_errors " $LOG_DIR " " $MODS " " $EXCL " && return 1 || return 0
192+ # Expect scan_dmesg_errors to return 0 when OK, non-zero if errors found.
193+ scan_dmesg_errors " $LOG_DIR " " $MODS " " $EXCL "
178194}
179195
180196# JUnit helpers
@@ -199,7 +215,7 @@ append_junit_case() {
199215}
200216
201217# ##############################################################################
202- # Per-config execution (with repeats) — uses run_with_timeout if available
218+ # Per-config execution (with repeats) — uses run_with_timeout if available
203219# ##############################################################################
204220have_rwt=0
205221if command -v run_with_timeout > /dev/null 2>&1 ; then
@@ -266,10 +282,12 @@ run_repeated() {
266282 all|* ) [ " $fail_runs " -eq 0 ] && final=" PASS" ;;
267283 esac
268284
269- if [ " $STRICT " -eq 1 ]; then
270- if ! scan_dmesg_if_enabled; then : ; else final=" FAIL" ; fi
271- else
272- scan_dmesg_if_enabled || true
285+ if [ " $DMESG_SCAN " -eq 1 ]; then
286+ if scan_dmesg_if_enabled; then
287+ : # OK
288+ else
289+ [ " $STRICT " -eq 1 ] && final=" FAIL"
290+ fi
273291 fi
274292
275293 append_junit_case " $id " " $name " " $mode " " $elapsed " " $final " " $logf "
@@ -293,22 +311,26 @@ CFG_LIST="$LOG_DIR/.cfgs"
293311: > " $CFG_LIST "
294312
295313if [ -z " $CFG " ]; then
296- log_info " No config argument passed, searching for JSON files in the current working directory (from where the script is executed). "
297- find " $test_path " -type f -name " *.json" 2> /dev/null | sort > " $CFG_LIST "
314+ log_info " No -- config passed, searching for JSON files under testcase dir: $test_path "
315+ find " $test_path " -type f -name " *.json" 2> /dev/null | sort > " $CFG_LIST "
298316elif [ -n " $CFG " ]; then
299317 printf " %s\n" " $CFG " > " $CFG_LIST "
300318fi
301319
302320if [ ! -s " $CFG_LIST " ]; then
321+ # Try DIR (if provided) or fallback to testcase dir with optional pattern
303322 [ -n " $DIR " ] || DIR=" $test_path "
304323 if [ -n " $PATTERN " ]; then
305324 find " $DIR " -type f -name " $PATTERN " 2> /dev/null | sort > " $CFG_LIST "
306325 else
307326 find " $DIR " -type f -name " *.json" 2> /dev/null | sort > " $CFG_LIST "
308327 fi
309- log_skip " $TESTNAME SKIP – no JSON configs found"
310- echo " $TESTNAME SKIP" > " $RES_FILE "
311- exit 0
328+ # Re-check after fallback search
329+ if [ ! -s " $CFG_LIST " ]; then
330+ log_skip " $TESTNAME SKIP - no JSON configs found"
331+ echo " $TESTNAME SKIP" > " $RES_FILE "
332+ exit 0
333+ fi
312334fi
313335
314336# ##############################################################################
@@ -338,7 +360,7 @@ while IFS= read -r cfg; do
338360 fi
339361
340362 if ! devices_present; then
341- log_skip " [$id ] SKIP – no /dev/video* nodes"
363+ log_skip " [$id ] SKIP – no /dev/video* nodes"
342364 echo " $id SKIP $base " >> " $LOG_DIR /summary.txt"
343365 echo " $id SKIP $base " >> " $LOG_DIR /summary_${mode} .txt"
344366 echo " $mode ,$id ,SKIP,$base ,0,0,0" >> " $LOG_DIR /results.csv"
0 commit comments