@@ -293,6 +293,12 @@ export INTER_TEST_SLEEP
293293# --- EARLY dependency check (bail out fast) ---
294294
295295# Ensure the app is executable if a path was provided but lacks +x
296+ if [ -n " $VIDEO_APP " ] && [ -f " $VIDEO_APP " ] && [ ! -x " $VIDEO_APP " ]; then
297+ chmod +x " $VIDEO_APP " 2> /dev/null || true
298+ if [ ! -x " $VIDEO_APP " ]; then
299+ log_warn " App $VIDEO_APP is not executable and chmod failed; attempting to run anyway."
300+ fi
301+ fi
296302
297303# --- Optional: unpack a custom module tarball **once** (no env exports) ---
298304KVER=" $( uname -r 2> /dev/null || printf ' %s' unknown) "
@@ -308,16 +314,13 @@ if [ -n "$KO_TARBALL" ] && [ -f "$KO_TARBALL" ]; then
308314 fi
309315 ;;
310316 * )
311- # not a tar? treat as a directory if user passed one by mistake
312317 :
313318 ;;
314319 esac
315320 fi
316- # decide whether the tar contained a full tree or loose .ko’s
317321 if [ -d " $DEST /lib/modules/$KVER " ]; then
318322 KO_TREE=" $DEST "
319323 else
320- # find first dir that has at least one .ko (bounded depth)
321324 first_ko_dir=" $( find " $DEST " -type f -name ' *.ko*' -maxdepth 3 2> /dev/null | head -n1 | xargs -r dirname) "
322325 if [ -n " $first_ko_dir " ]; then
323326 if [ -n " $KO_DIRS " ]; then
@@ -327,7 +330,6 @@ if [ -n "$KO_TARBALL" ] && [ -f "$KO_TARBALL" ]; then
327330 fi
328331 fi
329332 fi
330- # quiet summary (only if user opted-in)
331333 log_info " Custom module source prepared (tree='${KO_TREE:- none} ', dirs='${KO_DIRS:- none} ', prefer_custom=$KO_PREFER_CUSTOM )"
332334fi
333335
@@ -689,7 +691,7 @@ if [ "${VIDEO_STACK}" = "both" ]; then
689691 overlay_reason=" missing --downstream-fw"
690692 fi
691693
692- if [ " $rc_base " -eq 0 ] && [ " $rc_overlay " -eq 0 ]; then
694+ if [ " $rc_base " -eq 0 ] && [ " $rc_overlay " -eq 0 ] ; then
693695 if [ " $base_status " = " PASS" ] && [ " $overlay_status " = " SKIP" ]; then
694696 if [ -n " $overlay_reason " ]; then
695697 log_info " [both] upstream/base executed and PASS; downstream/overlay SKIP ($overlay_reason ). Overall PASS."
@@ -720,7 +722,6 @@ if [ -n "$VIDEO_FW_DS" ]; then
720722 log_info " Downstream FW override: $VIDEO_FW_DS "
721723fi
722724if [ -n " $KO_TREE$KO_DIRS$KO_TARBALL " ]; then
723- # print only when user actually provided custom sources
724725 if [ -n " $KO_TREE " ]; then
725726 log_info " Custom module tree (modprobe -d): $KO_TREE "
726727 fi
776777# --- Optional cleanup: robust capture + normalization of post-stack value ---
777778video_dump_stack_state " pre"
778779
780+ # --- Custom .ko staging (only if user provided --ko-dir) ---
781+ if [ -n " ${KO_DIRS:- } " ]; then
782+ case " $( video_normalize_stack " $VIDEO_STACK " ) " in
783+ downstream|overlay|down)
784+ KVER=" $( uname -r 2> /dev/null || printf ' %s' unknown) "
785+
786+ if command -v video_find_module_file > /dev/null 2>&1 ; then
787+ modpath=" $( video_find_module_file iris_vpu " $KO_DIRS " 2> /dev/null | tail -n1 | tr -d ' \r' ) "
788+ else
789+ modpath=" "
790+ fi
791+
792+ if [ -n " $modpath " ] && [ -f " $modpath " ]; then
793+ log_info " Using custom iris_vpu candidate: $modpath "
794+ if command -v video_ensure_moddir_install > /dev/null 2>&1 ; then
795+ video_ensure_moddir_install " $modpath " " $KVER " > /dev/null 2>&1 || true
796+ fi
797+ if command -v depmod > /dev/null 2>&1 ; then
798+ depmod -a " $KVER " > /dev/null 2>&1 || true
799+ fi
800+ else
801+ log_warn " KO_DIRS set, but iris_vpu.ko not found under: $KO_DIRS "
802+ fi
803+ ;;
804+ esac
805+ fi
806+
779807video_step " " " Apply desired stack = $VIDEO_STACK "
780808
781809stack_tmp=" $LOG_DIR /.ensure_stack.$$ .out"
@@ -804,6 +832,28 @@ log_info "Video stack (post): $post_stack"
804832
805833video_dump_stack_state " post"
806834
835+ # --- Custom .ko load assist (only if user provided --ko-dir) ---
836+ if [ -n " ${KO_DIRS:- } " ]; then
837+ case " $( video_normalize_stack " $VIDEO_STACK " ) " in
838+ downstream|overlay|down)
839+ if ! video_has_module_loaded iris_vpu 2> /dev/null; then
840+ if command -v video_find_module_file > /dev/null 2>&1 ; then
841+ modpath2=" $( video_find_module_file iris_vpu " $KO_DIRS " 2> /dev/null | tail -n1 | tr -d ' \r' ) "
842+ else
843+ modpath2=" "
844+ fi
845+
846+ if [ " $KO_PREFER_CUSTOM " = " 1" ] && [ -n " $modpath2 " ] && [ -f " $modpath2 " ]; then
847+ if command -v video_insmod_with_deps > /dev/null 2>&1 ; then
848+ log_info " Prefer custom: insmod with deps: $modpath2 "
849+ video_insmod_with_deps " $modpath2 " > /dev/null 2>&1 || true
850+ fi
851+ fi
852+ fi
853+ ;;
854+ esac
855+ fi
856+
807857# Always refresh/prune device nodes (even if no switch occurred)
808858video_step " " " Refresh V4L device nodes (udev trigger + prune stale)"
809859video_clean_and_refresh_v4l || true
@@ -1193,7 +1243,6 @@ while IFS= read -r cfg; do
11931243 r=1
11941244 log_info " [$id ] RETRY_ON_FAIL: up to $RETRY_ON_FAIL additional attempt(s)"
11951245 while [ " $r " -le " $RETRY_ON_FAIL " ]; do
1196- # optional delay between retries, reuse REPEAT_DELAY for consistency
11971246 if [ " $REPEAT_DELAY " -gt 0 ] 2> /dev/null; then
11981247 sleep " $REPEAT_DELAY "
11991248 fi
@@ -1205,7 +1254,6 @@ while IFS= read -r cfg; do
12051254 log_pass " [$id ] RETRY succeeded — marking PASS"
12061255 break
12071256 else
1208- # capture latest rc marker for visibility
12091257 rc_val=" $( awk -F' =' ' /^END-RUN rc=/{print $2}' " $logf " 2> /dev/null | tail -n1 | tr -d ' ' ) "
12101258 if [ -n " $rc_val " ]; then
12111259 case " $rc_val " in
@@ -1253,7 +1301,6 @@ while IFS= read -r cfg; do
12531301 fi
12541302 fi
12551303
1256- # (6) Post-test settle sleep
12571304 case " $POST_TEST_SLEEP " in
12581305 ' ' |* [!0-9]* )
12591306 :
0 commit comments