Skip to content

Commit 2b4041c

Browse files
committed
Multimedia/Display: add weston-smoke test with LAVA-ready yaml
- Add run.sh and yaml using repo-standard LAVA step pattern - Emit weston-smoke.res for send-to-lava.sh Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
1 parent cb342de commit 2b4041c

3 files changed

Lines changed: 348 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# weston-smoke
2+
3+
Runs `weston-smoke` under a working Wayland session (existing Weston or private Weston started by helpers) and validates that the client actually exercised Wayland.
4+
5+
## What this test validates
6+
7+
- A connected DRM display exists (otherwise SKIP)
8+
- A usable Wayland socket is available (otherwise SKIP)
9+
- GPU acceleration is active when `display_is_cpu_renderer` helper exists (otherwise SKIP)
10+
- `weston-smoke` runs for roughly `DURATION`
11+
- Optional:
12+
- Wayland protocol activity validation using `WAYLAND_DEBUG=1` capture
13+
- Screenshot delta validation if screenshot tools exist and permissions allow
14+
15+
## Parameters (LAVA yaml `params:`)
16+
17+
- `DURATION` (default `30s`)
18+
- `VALIDATE_WAYLAND_PROTO` (default `1`)
19+
- `VALIDATE_SCREENSHOT` (default `0`)
20+
21+
## Logs and results
22+
23+
- `weston-smoke.res` contains `weston-smoke PASS/FAIL/SKIP`
24+
- `weston-smoke_run.log` contains WAYLAND_DEBUG output when protocol validation is enabled
25+
- `weston-smoke_stdout_*.log` contains extra logs (including screenshot helper output)
26+
Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,303 @@
1+
#!/bin/sh
2+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
3+
# SPDX-License-Identifier: BSD-3-Clause-Clear
4+
#
5+
# Validate weston-smoke runs under a working Wayland session.
6+
# - Wayland env resolution (adopts socket & fixes XDG_RUNTIME_DIR perms)
7+
# - Optional Wayland protocol validation via WAYLAND_DEBUG capture
8+
# - Optional screenshot-delta validation when tools and permissions allow
9+
# - CI-friendly PASS FAIL SKIP semantics, always exits 0
10+
11+
SCRIPT_DIR="$(
12+
cd "$(dirname "$0")" || exit 1
13+
pwd
14+
)"
15+
INIT_ENV=""
16+
SEARCH="$SCRIPT_DIR"
17+
18+
while [ "$SEARCH" != "/" ]; do
19+
if [ -f "$SEARCH/init_env" ]; then
20+
INIT_ENV="$SEARCH/init_env"
21+
break
22+
fi
23+
SEARCH=$(dirname "$SEARCH")
24+
done
25+
26+
if [ -z "$INIT_ENV" ]; then
27+
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
28+
exit 1
29+
fi
30+
31+
if [ -z "${__INIT_ENV_LOADED:-}" ]; then
32+
# shellcheck disable=SC1090
33+
. "$INIT_ENV"
34+
__INIT_ENV_LOADED=1
35+
fi
36+
37+
# shellcheck disable=SC1091
38+
. "$TOOLS/functestlib.sh"
39+
# shellcheck disable=SC1091
40+
. "$TOOLS/lib_display.sh"
41+
42+
TESTNAME="weston-smoke"
43+
RES_FILE="./${TESTNAME}.res"
44+
RUN_LOG="./${TESTNAME}_run.log"
45+
ts="$(date +%Y%m%d-%H%M%S 2>/dev/null || printf '%s' 0)"
46+
STDOUT_LOG="./${TESTNAME}_stdout_${ts}.log"
47+
48+
: >"$RES_FILE"
49+
: >"$RUN_LOG"
50+
: >"$STDOUT_LOG"
51+
52+
DURATION="${DURATION:-30s}"
53+
STOP_GRACE="${STOP_GRACE:-3s}"
54+
VALIDATE_WAYLAND_PROTO="${VALIDATE_WAYLAND_PROTO:-1}"
55+
VALIDATE_SCREENSHOT="${VALIDATE_SCREENSHOT:-0}"
56+
57+
log_info "Weston log directory: $SCRIPT_DIR"
58+
log_info "--------------------------------------------------------------------------"
59+
log_info "------------------- Starting ${TESTNAME} Testcase --------------------------"
60+
log_info "Config: DURATION=${DURATION} VALIDATE_WAYLAND_PROTO=${VALIDATE_WAYLAND_PROTO} VALIDATE_SCREENSHOT=${VALIDATE_SCREENSHOT}"
61+
62+
if command -v detect_platform >/dev/null 2>&1; then
63+
detect_platform
64+
fi
65+
66+
if command -v display_debug_snapshot >/dev/null 2>&1; then
67+
display_debug_snapshot "pre-display-check"
68+
fi
69+
70+
if command -v modetest >/dev/null 2>&1; then
71+
log_info "----- modetest -M msm -ac (capped at 200 lines) -----"
72+
modetest -M msm -ac 2>&1 | sed -n '1,200p' | while IFS= read -r l; do
73+
[ -n "$l" ] && log_info "[modetest] $l"
74+
done
75+
log_info "----- End modetest -M msm -ac -----"
76+
else
77+
log_warn "modetest not found in PATH skipping modetest snapshot."
78+
fi
79+
80+
have_connector=0
81+
if command -v display_connected_summary >/dev/null 2>&1; then
82+
sysfs_summary=$(display_connected_summary)
83+
if [ -n "$sysfs_summary" ] && [ "$sysfs_summary" != "none" ]; then
84+
have_connector=1
85+
log_info "Connected display (sysfs): $sysfs_summary"
86+
fi
87+
fi
88+
89+
if [ "$have_connector" -eq 0 ]; then
90+
log_warn "No connected DRM display found skipping ${TESTNAME}."
91+
echo "${TESTNAME} SKIP" >"$RES_FILE"
92+
exit 0
93+
fi
94+
95+
if command -v wayland_debug_snapshot >/dev/null 2>&1; then
96+
wayland_debug_snapshot "${TESTNAME}: start"
97+
fi
98+
99+
sock=""
100+
if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then
101+
sock=$(discover_wayland_socket_anywhere | head -n 1 || true)
102+
fi
103+
104+
if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then
105+
log_info "Found existing Wayland socket: $sock"
106+
if ! adopt_wayland_env_from_socket "$sock"; then
107+
log_warn "Failed to adopt env from $sock"
108+
fi
109+
fi
110+
111+
if [ -z "$sock" ] && command -v overlay_start_weston_drm >/dev/null 2>&1; then
112+
log_info "No usable Wayland socket trying overlay_start_weston_drm helper..."
113+
if command -v weston_force_primary_1080p60_if_not_60 >/dev/null 2>&1; then
114+
log_info "Pre-configuring primary output to ~60Hz before starting Weston best-effort"
115+
weston_force_primary_1080p60_if_not_60 || true
116+
fi
117+
if overlay_start_weston_drm; then
118+
if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then
119+
sock=$(discover_wayland_socket_anywhere | head -n 1 || true)
120+
fi
121+
if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then
122+
log_info "Overlay Weston created Wayland socket: $sock"
123+
if ! adopt_wayland_env_from_socket "$sock"; then
124+
log_warn "Failed to adopt env from $sock"
125+
fi
126+
else
127+
log_warn "overlay_start_weston_drm reported success but no Wayland socket was found."
128+
fi
129+
else
130+
log_warn "overlay_start_weston_drm returned non-zero private Weston may have failed to start."
131+
fi
132+
fi
133+
134+
if [ -z "$sock" ]; then
135+
log_warn "No Wayland socket found after autodetection skipping ${TESTNAME}."
136+
echo "${TESTNAME} SKIP" >"$RES_FILE"
137+
exit 0
138+
fi
139+
140+
if command -v wayland_connection_ok >/dev/null 2>&1; then
141+
if ! wayland_connection_ok; then
142+
log_fail "Wayland connection test failed cannot run ${TESTNAME}."
143+
echo "${TESTNAME} SKIP" >"$RES_FILE"
144+
exit 0
145+
fi
146+
log_info "Wayland connection test: OK"
147+
else
148+
log_warn "wayland_connection_ok helper not found continuing without explicit Wayland probe."
149+
fi
150+
151+
if command -v weston_force_primary_1080p60_if_not_60 >/dev/null 2>&1; then
152+
log_info "Ensuring primary output is ~60Hz best-effort"
153+
if weston_force_primary_1080p60_if_not_60; then
154+
log_info "Primary output is ~60Hz or was already ~60Hz."
155+
else
156+
log_warn "Unable to force ~60Hz continuing not a hard failure."
157+
fi
158+
else
159+
log_warn "weston_force_primary_1080p60_if_not_60 helper not found skipping ~60Hz enforcement."
160+
fi
161+
162+
if command -v display_is_cpu_renderer >/dev/null 2>&1; then
163+
if display_is_cpu_renderer auto; then
164+
log_skip "$TESTNAME SKIP: GPU HW acceleration not enabled CPU/software renderer detected"
165+
echo "${TESTNAME} SKIP" >"$RES_FILE"
166+
exit 0
167+
fi
168+
else
169+
log_warn "display_is_cpu_renderer helper not found continuing without GPU accel gating."
170+
fi
171+
172+
if ! check_dependencies weston-smoke; then
173+
log_fail "Required binary weston-smoke not found in PATH."
174+
echo "${TESTNAME} FAIL" >"$RES_FILE"
175+
exit 0
176+
fi
177+
178+
BIN=$(command -v weston-smoke)
179+
log_info "Using weston-smoke: $BIN"
180+
181+
shot_begin_rc=2
182+
if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then
183+
log_info "Screenshot delta validation enabled."
184+
if command -v display_screenshot_delta_begin >/dev/null 2>&1; then
185+
display_screenshot_delta_begin "$TESTNAME" "$SCRIPT_DIR" >>"$STDOUT_LOG" 2>&1
186+
shot_begin_rc=$?
187+
if [ "$shot_begin_rc" -eq 2 ]; then
188+
log_warn "Screenshot delta requested, tool unavailable or unauthorized skipping screenshot validation."
189+
elif [ "$shot_begin_rc" -ne 0 ]; then
190+
log_warn "Screenshot delta requested, unable to capture before screenshot."
191+
fi
192+
else
193+
log_warn "display_screenshot_delta_begin helper not found skipping screenshot validation."
194+
shot_begin_rc=2
195+
fi
196+
fi
197+
198+
log_info "Launching ${TESTNAME} for ${DURATION} ..."
199+
200+
start_ts=$(date +%s)
201+
202+
rc=0
203+
if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then
204+
log_info "Wayland protocol validation enabled (WAYLAND_DEBUG=1)."
205+
WAYLAND_DEBUG=1
206+
export WAYLAND_DEBUG
207+
else
208+
WAYLAND_DEBUG=""
209+
export WAYLAND_DEBUG
210+
fi
211+
212+
if command -v run_with_timeout >/dev/null 2>&1; then
213+
if command -v stdbuf >/dev/null 2>&1; then
214+
if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then
215+
run_with_timeout "$DURATION" stdbuf -oL -eL "$BIN" >>"$RUN_LOG" 2>&1
216+
else
217+
run_with_timeout "$DURATION" stdbuf -oL -eL "$BIN" >>"$STDOUT_LOG" 2>&1
218+
fi
219+
else
220+
log_warn "stdbuf not found running $BIN without output re-buffering."
221+
if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then
222+
run_with_timeout "$DURATION" "$BIN" >>"$RUN_LOG" 2>&1
223+
else
224+
run_with_timeout "$DURATION" "$BIN" >>"$STDOUT_LOG" 2>&1
225+
fi
226+
fi
227+
rc=$?
228+
else
229+
log_warn "run_with_timeout not found using naive sleep+kill fallback."
230+
if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then
231+
"$BIN" >>"$RUN_LOG" 2>&1 &
232+
else
233+
"$BIN" >>"$STDOUT_LOG" 2>&1 &
234+
fi
235+
cpid=$!
236+
dur_s=$(printf '%s\n' "$DURATION" | sed -n 's/^\([0-9][0-9]*\)s$/\1/p')
237+
[ -n "$dur_s" ] || dur_s=30
238+
sleep "$dur_s"
239+
kill "$cpid" 2>/dev/null || true
240+
rc=143
241+
fi
242+
243+
end_ts=$(date +%s)
244+
elapsed=$((end_ts - start_ts))
245+
246+
log_info "Client finished: rc=${rc} elapsed=${elapsed}s"
247+
248+
final="PASS"
249+
250+
if [ "$rc" -ne 0 ] && [ "$rc" -ne 143 ]; then
251+
final="FAIL"
252+
fi
253+
254+
if [ "$elapsed" -le 1 ]; then
255+
log_fail "Client exited too quickly (elapsed=${elapsed}s) expected ~${DURATION} runtime."
256+
final="FAIL"
257+
fi
258+
259+
if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then
260+
if command -v display_wayland_proto_validate >/dev/null 2>&1; then
261+
if display_wayland_proto_validate "$RUN_LOG"; then
262+
log_info "Wayland protocol validation passed."
263+
else
264+
log_fail "Wayland protocol validation failed missing surface/commit evidence in WAYLAND_DEBUG"
265+
final="FAIL"
266+
fi
267+
else
268+
log_warn "display_wayland_proto_validate helper not found skipping protocol validation."
269+
fi
270+
fi
271+
272+
if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then
273+
if [ "$shot_begin_rc" -eq 0 ]; then
274+
if command -v display_screenshot_delta_end >/dev/null 2>&1; then
275+
display_screenshot_delta_end "$TESTNAME" >>"$STDOUT_LOG" 2>&1
276+
src=$?
277+
if [ "$src" -eq 0 ]; then
278+
log_info "Screenshot delta validation passed."
279+
elif [ "$src" -eq 1 ]; then
280+
log_fail "Screenshot delta validation failed screenshots identical."
281+
final="FAIL"
282+
else
283+
log_warn "Screenshot delta validation skipped."
284+
fi
285+
else
286+
log_warn "display_screenshot_delta_end helper not found skipping screenshot validation."
287+
fi
288+
else
289+
log_warn "Screenshot delta validation skipped, before screenshot was not captured."
290+
fi
291+
fi
292+
293+
log_info "Final decision for ${TESTNAME}: ${final}"
294+
295+
echo "${TESTNAME} ${final}" >"$RES_FILE"
296+
297+
if [ "$final" = "PASS" ]; then
298+
log_pass "${TESTNAME} : PASS"
299+
exit 0
300+
fi
301+
302+
log_fail "${TESTNAME} : FAIL"
303+
exit 0
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
metadata:
2+
name: weston-smoke
3+
format: Lava-Test Test Definition 1.0
4+
description: "Run weston-smoke under an active Wayland session and validate basic protocol activity"
5+
maintainer:
6+
- "Qualcomm Linux Testkit"
7+
8+
params:
9+
DURATION: "30s" # Client runtime (default 30s)
10+
STOP_GRACE: "3s" # Reserved for future stop grace (default 3s)
11+
VALIDATE_WAYLAND_PROTO: 1 # 1 enables WAYLAND_DEBUG based protocol validation (default 1)
12+
VALIDATE_SCREENSHOT: 0 # 1 enables screenshot delta when allowed/tools exist (default 0)
13+
14+
run:
15+
steps:
16+
- REPO_PATH=$PWD
17+
- cd Runner/suites/Multimedia/Display/weston-smoke
18+
- ./run.sh || true
19+
- $REPO_PATH/Runner/utils/send-to-lava.sh weston-smoke.res

0 commit comments

Comments
 (0)