Skip to content

Commit 776fc76

Browse files
committed
Multimedia/Display: add weston-editor test
Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
1 parent 7a019fc commit 776fc76

3 files changed

Lines changed: 339 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# weston-editor
2+
3+
Runs `weston-editor` inside an existing Wayland/Weston session and validates the client created and committed
4+
a Wayland surface using `WAYLAND_DEBUG` output.
5+
6+
## What it validates
7+
8+
- A connected DRM display is present (otherwise SKIP)
9+
- A usable Wayland socket exists (otherwise SKIP)
10+
- GPU acceleration is active (best-effort gating via `display_is_cpu_renderer auto`)
11+
- `weston-editor` binary exists (otherwise FAIL)
12+
- **Optional**: Wayland protocol activity (default enabled)
13+
- Checks for `wl_compositor.create_surface` and `wl_surface.commit` patterns in the client log
14+
- **Optional**: Screenshot delta (default disabled)
15+
- Captures before/after screenshots and validates hashes differ (visible change)
16+
- If `weston-screenshooter` is unauthorized or missing, screenshot validation is skipped
17+
18+
## Parameters (LAVA)
19+
20+
- `DURATION` (default `30s`)
21+
- `VALIDATE_WAYLAND_PROTO` (default `1`)
22+
- `VALIDATE_SCREENSHOT` (default `0`)
23+
24+
## Local run
25+
26+
```sh
27+
cd Runner/suites/Multimedia/Display/weston-editor
28+
./run.sh
29+
cat weston-editor.res
30+
Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
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-editor runs under a working Wayland session.
6+
# - Uses lib_display.sh to adopt Wayland env (socket + XDG_RUNTIME_DIR)
7+
# - CI-friendly logs and PASS/FAIL/SKIP semantics (LAVA-friendly: exits 0)
8+
# - Optional Wayland protocol validation (WAYLAND_DEBUG based)
9+
# - Optional screenshot delta validation (best-effort, skips if unauthorized)
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-editor"
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+
BUILD_FLAVOUR="base"
58+
if [ -f /usr/share/glvnd/egl_vendor.d/EGL_adreno.json ]; then
59+
BUILD_FLAVOUR="overlay"
60+
fi
61+
62+
log_info "Weston log directory: $SCRIPT_DIR"
63+
log_info "--------------------------------------------------------------------------"
64+
log_info "------------------- Starting ${TESTNAME} Testcase --------------------------"
65+
log_info "Config: DURATION=${DURATION} VALIDATE_WAYLAND_PROTO=${VALIDATE_WAYLAND_PROTO} VALIDATE_SCREENSHOT=${VALIDATE_SCREENSHOT} BUILD_FLAVOUR=${BUILD_FLAVOUR}"
66+
67+
if command -v detect_platform >/dev/null 2>&1; then
68+
detect_platform
69+
fi
70+
71+
if command -v display_debug_snapshot >/dev/null 2>&1; then
72+
display_debug_snapshot "pre-display-check"
73+
fi
74+
75+
if command -v modetest >/dev/null 2>&1; then
76+
log_info "----- modetest -M msm -ac (capped at 200 lines) -----"
77+
modetest -M msm -ac 2>&1 | sed -n '1,200p' | while IFS= read -r l; do
78+
[ -n "$l" ] && log_info "[modetest] $l"
79+
done
80+
log_info "----- End modetest -M msm -ac -----"
81+
else
82+
log_warn "modetest not found in PATH skipping modetest snapshot."
83+
fi
84+
85+
have_connector=0
86+
if command -v display_connected_summary >/dev/null 2>&1; then
87+
sysfs_summary=$(display_connected_summary)
88+
if [ -n "$sysfs_summary" ] && [ "$sysfs_summary" != "none" ]; then
89+
have_connector=1
90+
log_info "Connected display (sysfs): $sysfs_summary"
91+
fi
92+
fi
93+
94+
if [ "$have_connector" -eq 0 ]; then
95+
log_warn "No connected DRM display found, skipping ${TESTNAME}."
96+
echo "$TESTNAME SKIP" >"$RES_FILE"
97+
exit 0
98+
fi
99+
100+
if command -v wayland_debug_snapshot >/dev/null 2>&1; then
101+
wayland_debug_snapshot "${TESTNAME}: start"
102+
fi
103+
104+
sock=""
105+
if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then
106+
sock=$(discover_wayland_socket_anywhere | head -n 1 || true)
107+
fi
108+
109+
if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then
110+
log_info "Found existing Wayland socket: $sock"
111+
if ! adopt_wayland_env_from_socket "$sock"; then
112+
log_warn "Failed to adopt env from $sock"
113+
fi
114+
fi
115+
116+
if [ -z "$sock" ] && command -v overlay_start_weston_drm >/dev/null 2>&1; then
117+
log_info "No usable Wayland socket trying overlay_start_weston_drm helper..."
118+
if overlay_start_weston_drm; then
119+
if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then
120+
sock=$(discover_wayland_socket_anywhere | head -n 1 || true)
121+
fi
122+
if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then
123+
log_info "Overlay Weston created Wayland socket: $sock"
124+
if ! adopt_wayland_env_from_socket "$sock"; then
125+
log_warn "Failed to adopt env from $sock"
126+
fi
127+
fi
128+
else
129+
log_warn "overlay_start_weston_drm returned non-zero private Weston may have failed to start."
130+
fi
131+
fi
132+
133+
if [ -z "$sock" ]; then
134+
log_warn "No Wayland socket found after autodetection skipping ${TESTNAME}."
135+
echo "$TESTNAME SKIP" >"$RES_FILE"
136+
exit 0
137+
fi
138+
139+
if command -v wayland_connection_ok >/dev/null 2>&1; then
140+
if ! wayland_connection_ok; then
141+
log_fail "Wayland connection test failed cannot run ${TESTNAME}."
142+
echo "$TESTNAME SKIP" >"$RES_FILE"
143+
exit 0
144+
fi
145+
log_info "Wayland connection test: OK"
146+
fi
147+
148+
if command -v display_is_cpu_renderer >/dev/null 2>&1; then
149+
if display_is_cpu_renderer auto; then
150+
log_skip "$TESTNAME SKIP: GPU HW acceleration not enabled (CPU/software renderer detected)"
151+
echo "$TESTNAME SKIP" >"$RES_FILE"
152+
exit 0
153+
fi
154+
else
155+
log_warn "display_is_cpu_renderer helper not found continuing without GPU accel gating."
156+
fi
157+
158+
if ! check_dependencies weston-editor; then
159+
log_fail "Required binary weston-editor not found in PATH."
160+
echo "$TESTNAME FAIL" >"$RES_FILE"
161+
exit 0
162+
fi
163+
164+
BIN=$(command -v weston-editor)
165+
log_info "Using weston-editor: $BIN"
166+
167+
# If GLVND overlay exists, prefer it for EGL clients.
168+
if [ "$BUILD_FLAVOUR" = "overlay" ] && [ -f /usr/share/glvnd/egl_vendor.d/EGL_adreno.json ]; then
169+
__EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/EGL_adreno.json
170+
export __EGL_VENDOR_LIBRARY_FILENAMES
171+
log_info "EGL vendor override: /usr/share/glvnd/egl_vendor.d/EGL_adreno.json"
172+
fi
173+
174+
shot_begin_rc=2
175+
if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then
176+
log_info "Screenshot delta validation enabled."
177+
if command -v display_screenshot_delta_begin >/dev/null 2>&1; then
178+
display_screenshot_delta_begin "$TESTNAME" "$SCRIPT_DIR"
179+
shot_begin_rc=$?
180+
if [ "$shot_begin_rc" -eq 0 ]; then
181+
log_info "Screenshot(before) captured."
182+
else
183+
if [ "$shot_begin_rc" -eq 2 ]; then
184+
log_warn "Screenshot tool not available skipping screenshot-delta validation."
185+
else
186+
log_warn "Failed to capture screenshot(before) skipping screenshot-delta validation."
187+
fi
188+
fi
189+
else
190+
log_warn "display_screenshot_delta_begin helper not found skipping screenshot-delta validation."
191+
fi
192+
fi
193+
194+
log_info "Launching ${TESTNAME} for ${DURATION} ..."
195+
196+
start_ts=$(date +%s)
197+
198+
if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then
199+
log_info "Wayland protocol validation enabled (WAYLAND_DEBUG=1)."
200+
WAYLAND_DEBUG=1
201+
export WAYLAND_DEBUG
202+
fi
203+
204+
rc=0
205+
if command -v run_with_timeout >/dev/null 2>&1; then
206+
log_info "Using helper: run_with_timeout"
207+
if command -v stdbuf >/dev/null 2>&1; then
208+
run_with_timeout "$DURATION" stdbuf -oL -eL "$BIN" >>"$RUN_LOG" 2>&1
209+
rc=$?
210+
else
211+
run_with_timeout "$DURATION" "$BIN" >>"$RUN_LOG" 2>&1
212+
rc=$?
213+
fi
214+
else
215+
log_warn "run_with_timeout not found using naive sleep+kill fallback."
216+
"$BIN" >>"$RUN_LOG" 2>&1 &
217+
cpid=$!
218+
dur_s=$(printf '%s\n' "$DURATION" | sed -n 's/^\([0-9][0-9]*\)s$/\1/p')
219+
[ -n "$dur_s" ] || dur_s=30
220+
sleep "$dur_s"
221+
kill "$cpid" 2>/dev/null || true
222+
rc=143
223+
fi
224+
225+
end_ts=$(date +%s)
226+
elapsed=$((end_ts - start_ts))
227+
228+
log_info "Client finished: rc=${rc} elapsed=${elapsed}s"
229+
230+
tail -n 400 "$RUN_LOG" >"$STDOUT_LOG" 2>/dev/null || true
231+
232+
final="PASS"
233+
234+
# For these demo apps, timeout kill is expected (rc=143). Other non-zero is suspicious.
235+
if [ "$rc" -ne 0 ] && [ "$rc" -ne 143 ]; then
236+
final="FAIL"
237+
fi
238+
239+
if [ "$elapsed" -le 1 ]; then
240+
log_fail "Client exited too quickly (elapsed=${elapsed}s) expected ~${DURATION} runtime."
241+
final="FAIL"
242+
fi
243+
244+
if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then
245+
if command -v display_wayland_proto_validate >/dev/null 2>&1; then
246+
if display_wayland_proto_validate "$RUN_LOG"; then
247+
log_info "Wayland protocol validation passed."
248+
else
249+
log_fail "Wayland protocol validation failed (missing surface/commit evidence in WAYLAND_DEBUG)"
250+
final="FAIL"
251+
fi
252+
else
253+
log_warn "display_wayland_proto_validate helper not found skipping protocol validation."
254+
fi
255+
fi
256+
257+
if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then
258+
if [ "$shot_begin_rc" -eq 0 ]; then
259+
if command -v display_screenshot_delta_end >/dev/null 2>&1; then
260+
display_screenshot_delta_end "$TESTNAME"
261+
shot_end_rc=$?
262+
if [ "$shot_end_rc" -eq 0 ]; then
263+
log_info "Screenshot delta validation passed (visible change detected)."
264+
else
265+
if [ "$shot_end_rc" -eq 1 ]; then
266+
log_fail "Screenshot delta validation failed (no visible change detected)."
267+
final="FAIL"
268+
else
269+
log_warn "Screenshot delta validation skipped (tool unavailable or capture failed)."
270+
fi
271+
fi
272+
else
273+
log_warn "display_screenshot_delta_end helper not found skipping screenshot delta validation."
274+
fi
275+
else
276+
log_warn "Screenshot delta validation skipped (before screenshot was not captured)."
277+
fi
278+
fi
279+
280+
log_info "Final decision for ${TESTNAME}: ${final}"
281+
282+
echo "$TESTNAME $final" >"$RES_FILE"
283+
284+
if [ "$final" = "PASS" ]; then
285+
log_pass "${TESTNAME} : PASS"
286+
exit 0
287+
fi
288+
289+
log_fail "${TESTNAME} : FAIL"
290+
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-editor
3+
format: Lava-Test Test Definition 1.0
4+
description: "Run weston-editor under an active Wayland session and validate it creates/commits a surface"
5+
maintainer:
6+
- "Qualcomm Linux Testkit"
7+
8+
params:
9+
DURATION: "30s" # Client runtime (default 30s)
10+
STOP_GRACE: "3s" # Reserved (default 3s)
11+
VALIDATE_WAYLAND_PROTO: 1 # 1 enables WAYLAND_DEBUG protocol validation (default 1)
12+
VALIDATE_SCREENSHOT: 0 # 1 enables screenshot delta when tools allow (default 0)
13+
14+
run:
15+
steps:
16+
- REPO_PATH=$PWD
17+
- cd Runner/suites/Multimedia/Display/weston-editor
18+
- ./run.sh || true
19+
- $REPO_PATH/Runner/utils/send-to-lava.sh weston-editor.res

0 commit comments

Comments
 (0)