@@ -140,23 +140,37 @@ unload_kernel_module() {
140140
141141# --- Dependency check ---
142142check_dependencies () {
143+ # Support both:
144+ # check_dependencies date awk sed
145+ # check_dependencies "$deps" where deps="date awk sed"
146+ if [ " $# " -eq 1 ]; then
147+ # Split the single string into args
148+ # shellcheck disable=SC2086
149+ set -- $1
150+ fi
151+
143152 missing=0
144153 missing_cmds=" "
154+
145155 for cmd in " $@ " ; do
156+ [ -n " $cmd " ] || continue
146157 if ! command -v " $cmd " > /dev/null 2>&1 ; then
147158 log_warn " Required command '$cmd ' not found in PATH."
148159 missing=1
149160 missing_cmds=" $missing_cmds $cmd "
150161 fi
151162 done
163+
152164 if [ " $missing " -ne 0 ]; then
153- testname=" ${TESTNAME:- } "
154- log_skip " ${ testname:- UnknownTest} SKIP: missing dependencies: $missing_cmds "
155- if [ -n " $testname " ]; then
156- echo " $testname SKIP" > " ./$testname .res"
165+ testname=" ${TESTNAME:- UnknownTest } "
166+ log_skip " $testname SKIP missing dependencies$missing_cmds "
167+ if [ -n " ${TESTNAME :- } " ]; then
168+ echo " $TESTNAME SKIP" > " ./$TESTNAME .res" 2> /dev/null || true
157169 fi
158170 exit 0
159171 fi
172+
173+ return 0
160174}
161175
162176# --- Test case directory lookup ---
@@ -3299,35 +3313,69 @@ detect_ufs_partition_block() {
32993313# ##############################################################################
33003314scan_dmesg_errors () {
33013315 prefix=" $1 "
3302- module_regex=" $2 " # e.g. 'qcom_camss|camss|isp'
3316+ module_regex=" $2 " # e.g. 'qcom_camss|camss|isp|CAM-ICP|CAMERA_ICP '
33033317 exclude_regex=" ${3:- " dummy regulator|supply [^ ]+ not found|using dummy regulator" } "
3304- shift 3
3305-
3306- mkdir -p " $prefix "
3307-
3318+ success_regex=" ${4:- } " # OPTIONAL: require success evidence (e.g. FW download done successfully)
3319+ success_min_hits=" ${5:- 1} " # OPTIONAL: minimum success hits required (default 1)
3320+
3321+ shift 5 2> /dev/null || true
3322+
3323+ mkdir -p " $prefix " 2> /dev/null || true
3324+
33083325 DMESG_SNAPSHOT=" $prefix /dmesg_snapshot.log"
33093326 DMESG_ERRORS=" $prefix /dmesg_errors.log"
3310- DATE_STAMP=$( date +%Y%m%d-%H%M%S)
3327+ DMESG_SUCCESS=" $prefix /dmesg_success.log"
3328+ DATE_STAMP=$( date +%Y%m%d-%H%M%S 2> /dev/null || echo " unknown-date" )
33113329 DMESG_HISTORY=" $prefix /dmesg_errors_$DATE_STAMP .log"
3312-
3330+
33133331 # Error patterns (edit as needed for your test coverage)
33143332 err_patterns=' Unknown symbol|probe failed|fail(ed)?|error|timed out|not found|invalid|corrupt|abort|panic|oops|unhandled|can.t (start|init|open|allocate|find|register)'
3315-
3316- rm -f " $DMESG_SNAPSHOT " " $DMESG_ERRORS "
3317- dmesg > " $DMESG_SNAPSHOT " 2> /dev/null
3318-
3319- # 1. Match lines with correct module and error pattern
3320- # 2. Exclude lines with harmless patterns (using dummy regulator etc)
3321- grep -iE " ^\[[^]]+\][[:space:]]+($module_regex ):.*($err_patterns )" " $DMESG_SNAPSHOT " \
3322- | grep -vEi " $exclude_regex " > " $DMESG_ERRORS " || true
3323-
3324- cp " $DMESG_ERRORS " " $DMESG_HISTORY "
3325-
3333+
3334+ rm -f " $DMESG_SNAPSHOT " " $DMESG_ERRORS " " $DMESG_SUCCESS " 2> /dev/null || true
3335+ dmesg > " $DMESG_SNAPSHOT " 2> /dev/null || true
3336+
3337+ # Robust match:
3338+ # - First filter by module_regex (anywhere in line)
3339+ # - Then filter by err_patterns
3340+ # - Exclude benign patterns
3341+ #
3342+ # This works for both:
3343+ # [..] module: error ...
3344+ # and:
3345+ # [..] CAM_INFO: ... fail ...
3346+ #
3347+ # Note: module_regex should be tight enough to avoid false positives.
3348+ grep -iE " ($module_regex )" " $DMESG_SNAPSHOT " 2> /dev/null \
3349+ | grep -iE " ($err_patterns )" 2> /dev/null \
3350+ | grep -vEi " $exclude_regex " 2> /dev/null > " $DMESG_ERRORS " || true
3351+
3352+ cp " $DMESG_ERRORS " " $DMESG_HISTORY " 2> /dev/null || true
3353+
33263354 if [ -s " $DMESG_ERRORS " ]; then
3327- log_info " dmesg scan: found non- benign module errors in $DMESG_ERRORS (history: $DMESG_HISTORY )"
3355+ log_info " dmesg scan found non benign module errors in $DMESG_ERRORS (history: $DMESG_HISTORY )"
33283356 return 0
33293357 fi
3330- log_info " No relevant, non-benign errors for modules [$module_regex ] in recent dmesg."
3358+
3359+ # Optional success evidence check (no extra greps in run.sh)
3360+ if [ -n " $success_regex " ]; then
3361+ grep -iE " ($success_regex )" " $DMESG_SNAPSHOT " 2> /dev/null > " $DMESG_SUCCESS " || true
3362+
3363+ hits=" $( wc -l < " $DMESG_SUCCESS " 2> /dev/null | awk ' {print $1}' ) "
3364+ case " $hits " in ' ' |* [!0-9]* ) hits=0 ;; esac
3365+
3366+ case " $success_min_hits " in ' ' |* [!0-9]* ) success_min_hits=1 ;; esac
3367+
3368+ if [ " $hits " -lt " $success_min_hits " ]; then
3369+ log_info " dmesg scan found no required success evidence for modules [$module_regex ] (need >=$success_min_hits hits). See $DMESG_SUCCESS "
3370+ return 2
3371+ fi
3372+
3373+ log_info " dmesg scan success evidence present in $DMESG_SUCCESS (hits=$hits )"
3374+ else
3375+ log_info " No relevant, non benign errors for modules [$module_regex ] in recent dmesg."
3376+ fi
3377+
3378+ # No errors
33313379 return 1
33323380}
33333381
0 commit comments