@@ -49,15 +49,38 @@ rm -f "$RES_FILE" "$LOG_FILE"
4949log_info " -------------------------------------------------------------------"
5050log_info " ------------------- Starting $TESTNAME Testcase -------------------"
5151
52- # --- Dependencies ------------------------------------------------------------
53- # Note: check_dependencies returns 0 when present, non-zero if missing.
54- check_dependencies kmscube || {
55- log_skip " $TESTNAME SKIP: missing dependencies: kmscube"
56- echo " $TESTNAME SKIP" > " $RES_FILE "
52+ # ---------------------------------------------------------------------------
53+ # Display snapshot
54+ # ---------------------------------------------------------------------------
55+ if command -v display_debug_snapshot > /dev/null 2>&1 ; then
56+ display_debug_snapshot " pre-display-check"
57+ fi
58+
59+ # Always print modetest as part of the snapshot (best-effort).
60+ if command -v modetest > /dev/null 2>&1 ; then
61+ log_info " ----- modetest -M msm -ac (capped at 200 lines) -----"
62+ modetest -M msm -ac 2>&1 | sed -n ' 1,200p' | while IFS= read -r l; do
63+ [ -n " $l " ] && log_info " [modetest] $l "
64+ done
65+ log_info " ----- End modetest -M msm -ac -----"
66+ else
67+ log_warn " modetest not found in PATH skipping modetest snapshot."
68+ fi
69+
70+ have_connector=0
71+ if command -v display_connected_summary > /dev/null 2>&1 ; then
72+ sysfs_summary=$( display_connected_summary)
73+ if [ -n " $sysfs_summary " ] && [ " $sysfs_summary " != " none" ]; then
74+ have_connector=1
75+ log_info " Connected display (sysfs): $sysfs_summary "
76+ fi
77+ fi
78+
79+ if [ " $have_connector " -eq 0 ]; then
80+ log_warn " No connected DRM display found, skipping ${TESTNAME} ."
81+ echo " ${TESTNAME} SKIP" > " $RES_FILE "
5782 exit 0
58- }
59- KMSCUBE_BIN=" $( command -v kmscube 2> /dev/null || true) "
60- log_info " Using kmscube: ${KMSCUBE_BIN:- <not found>} "
83+ fi
6184
6285# --- Basic DRM availability guard -------------------------------------------
6386set -- /dev/dri/card* 2> /dev/null
@@ -66,44 +89,94 @@ if [ ! -e "$1" ]; then
6689 echo " $TESTNAME SKIP" > " $RES_FILE "
6790 exit 0
6891fi
92+ # --- Dependencies ------------------------------------------------------------
93+ # With patched check_dependencies(): ask for return code instead of exit
94+ if ! CHECK_DEPS_NO_EXIT=1 check_dependencies kmscube; then
95+ log_skip " $TESTNAME SKIP: missing dependencies: kmscube"
96+ echo " $TESTNAME SKIP" > " $RES_FILE "
97+ exit 0
98+ fi
6999
70- # --- If Weston is running, stop it so KMS has control ------------------------
100+ KMSCUBE_BIN=" $( command -v kmscube 2> /dev/null || true) "
101+ log_info " Using kmscube: ${KMSCUBE_BIN:- <not found>} "
102+
103+ # --- Track Weston state (restore at end if needed) ---------------------------
71104weston_was_running=0
72105if weston_is_running; then
73- weston_stop
74106 weston_was_running=1
75107fi
76-
77- # --- Skip if only CPU/software renderer is active (GPU HW accel not enabled) ---
108+ # --- GPU acceleration gating (avoid auto/Wayland for kmscube) ----------------
109+ # KMSCube is a DRM/KMS test. Using "auto" can start/adopt Weston and steal DRM master.
78110if command -v display_is_cpu_renderer > /dev/null 2>&1 ; then
79- if display_is_cpu_renderer auto; then
80- log_skip " $TESTNAME SKIP: GPU HW acceleration not enabled (CPU/software renderer detected)"
81- echo " ${TESTNAME} SKIP" > " $RES_FILE "
82- exit 0
111+ if display_is_cpu_renderer gbm > /dev/null 2>&1 ; then
112+ if display_is_cpu_renderer gbm; then
113+ log_skip " $TESTNAME SKIP: GPU HW acceleration not enabled (CPU/software renderer detected on GBM)"
114+ echo " $TESTNAME SKIP" > " $RES_FILE "
115+ exit 0
116+ fi
117+ else
118+ log_warn " display_is_cpu_renderer gbm not supported, falling back to auto (may touch Wayland/Weston)."
119+ if display_is_cpu_renderer auto; then
120+ log_skip " $TESTNAME SKIP: GPU HW acceleration not enabled (CPU/software renderer detected)"
121+ echo " $TESTNAME SKIP" > " $RES_FILE "
122+ exit 0
123+ fi
83124 fi
84125else
85- log_warn " display_is_cpu_renderer helper not found and cannot enforce GPU accel gating (continuing)."
126+ log_warn " display_is_cpu_renderer helper not found, cannot enforce GPU accel gating (continuing)."
127+ fi
128+
129+ # --- Ensure Weston is NOT running before kmscube (DRM master) -----------------
130+ # Stop weston after gating too, because some helpers may have started it.
131+ if weston_is_running; then
132+ log_info " Weston is running, stopping it so kmscube can modeset (DRM master)"
133+ weston_stop > /dev/null 2>&1 || true
134+ fi
135+
136+ # Double-check and be strict: kmscube will fail if weston still holds DRM master.
137+ if weston_is_running; then
138+ log_warn " Weston still running after weston_stop, kmscube may fail to set mode"
86139fi
87140
88- # --- Execute kmscube ---------------------------------------------------------
141+ # --- Execute kmscube (avoid Wayland env leakage) ------------------------------
142+ unset WAYLAND_DISPLAY
143+ # Keep XDG_RUNTIME_DIR intact for system sanity, but force GBM platform for EGL where honored.
144+ EGL_PLATFORM_SAVED=" ${EGL_PLATFORM:- } "
145+ export EGL_PLATFORM=gbm
146+
89147log_info " Running kmscube with --count=${FRAME_COUNT} ..."
90148if kmscube --count=" ${FRAME_COUNT} " > " $LOG_FILE " 2>&1 ; then : ; else
91149 rc=$?
92150 log_fail " $TESTNAME : Execution failed (rc=$rc ) — see $LOG_FILE "
93151 cat " $LOG_FILE "
94152 echo " $TESTNAME FAIL" > " $RES_FILE "
153+
154+ # Restore EGL_PLATFORM
155+ if [ -n " $EGL_PLATFORM_SAVED " ]; then
156+ export EGL_PLATFORM=" $EGL_PLATFORM_SAVED "
157+ else
158+ unset EGL_PLATFORM
159+ fi
160+
161+ # Restore Weston if it was running before
95162 if [ " $weston_was_running " -eq 1 ]; then
96163 log_info " Restarting Weston after failure"
97- weston_start
164+ weston_start > /dev/null 2>&1 || true
98165 fi
99166 exit 1
100167fi
101168
102- # --- Parse 'Rendered N frames' (case-insensitive), use the last N -----------
169+ # Restore EGL_PLATFORM
170+ if [ -n " $EGL_PLATFORM_SAVED " ]; then
171+ export EGL_PLATFORM=" $EGL_PLATFORM_SAVED "
172+ else
173+ unset EGL_PLATFORM
174+ fi
175+
176+ # --- Parse 'Rendered N frames' (case-insensitive), use the last N ------------
103177FRAMES_RENDERED=" $(
104178 awk ' BEGIN{IGNORECASE=1}
105179 /Rendered[[:space:]][0-9]+[[:space:]]+frames/{
106- # capture the numeric token on that line; remember the last match
107180 for(i=1;i<=NF;i++) if ($i ~ /^[0-9]+$/) n=$i
108181 last=n
109182 }
@@ -120,17 +193,18 @@ if [ "$FRAMES_RENDERED" -ge "$EXPECTED_MIN" ]; then
120193else
121194 log_fail " $TESTNAME : FAIL (rendered ${FRAMES_RENDERED} < ${EXPECTED_MIN} )"
122195 echo " $TESTNAME FAIL" > " $RES_FILE "
196+
123197 if [ " $weston_was_running " -eq 1 ]; then
124198 log_info " Restarting Weston after failure"
125- weston_start
199+ weston_start > /dev/null 2>&1 || true
126200 fi
127201 exit 1
128202fi
129203
130204# --- Restore Weston if we stopped it -----------------------------------------
131205if [ " $weston_was_running " -eq 1 ]; then
132206 log_info " Restarting Weston after $TESTNAME completion"
133- weston_start
207+ weston_start > /dev/null 2>&1 || true
134208fi
135209
136210log_info " ------------------- Completed $TESTNAME Testcase ------------------"
0 commit comments