Skip to content

Commit 4cffdf8

Browse files
committed
Multimedia/Display: add weston-cliptest test
Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
1 parent 2df983b commit 4cffdf8

3 files changed

Lines changed: 336 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# weston-cliptest
2+
3+
Runs `weston-cliptest` 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-cliptest` 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-cliptest
28+
./run.sh
29+
cat weston-cliptest.res
Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
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-cliptest runs under a working Wayland session.
6+
# - Wayland env resolution (adopts socket & fixes XDG_RUNTIME_DIR perms)
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-cliptest"
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-cliptest; then
159+
log_fail "Required binary weston-cliptest not found in PATH."
160+
echo "$TESTNAME FAIL" >"$RES_FILE"
161+
exit 0
162+
fi
163+
164+
BIN=$(command -v weston-cliptest)
165+
log_info "Using weston-cliptest: $BIN"
166+
167+
if [ "$BUILD_FLAVOUR" = "overlay" ] && [ -f /usr/share/glvnd/egl_vendor.d/EGL_adreno.json ]; then
168+
__EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/EGL_adreno.json
169+
export __EGL_VENDOR_LIBRARY_FILENAMES
170+
log_info "EGL vendor override: /usr/share/glvnd/egl_vendor.d/EGL_adreno.json"
171+
fi
172+
173+
shot_begin_rc=2
174+
if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then
175+
log_info "Screenshot delta validation enabled."
176+
if command -v display_screenshot_delta_begin >/dev/null 2>&1; then
177+
display_screenshot_delta_begin "$TESTNAME" "$SCRIPT_DIR"
178+
shot_begin_rc=$?
179+
if [ "$shot_begin_rc" -eq 0 ]; then
180+
log_info "Screenshot(before) captured."
181+
else
182+
if [ "$shot_begin_rc" -eq 2 ]; then
183+
log_warn "Screenshot tool not available skipping screenshot-delta validation."
184+
else
185+
log_warn "Failed to capture screenshot(before) skipping screenshot-delta validation."
186+
fi
187+
fi
188+
else
189+
log_warn "display_screenshot_delta_begin helper not found skipping screenshot-delta validation."
190+
fi
191+
fi
192+
193+
log_info "Launching ${TESTNAME} for ${DURATION} ..."
194+
195+
start_ts=$(date +%s)
196+
197+
if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then
198+
log_info "Wayland protocol validation enabled (WAYLAND_DEBUG=1)."
199+
WAYLAND_DEBUG=1
200+
export WAYLAND_DEBUG
201+
fi
202+
203+
rc=0
204+
if command -v run_with_timeout >/dev/null 2>&1; then
205+
log_info "Using helper: run_with_timeout"
206+
if command -v stdbuf >/dev/null 2>&1; then
207+
run_with_timeout "$DURATION" stdbuf -oL -eL "$BIN" >>"$RUN_LOG" 2>&1
208+
rc=$?
209+
else
210+
run_with_timeout "$DURATION" "$BIN" >>"$RUN_LOG" 2>&1
211+
rc=$?
212+
fi
213+
else
214+
log_warn "run_with_timeout not found using naive sleep+kill fallback."
215+
"$BIN" >>"$RUN_LOG" 2>&1 &
216+
cpid=$!
217+
dur_s=$(printf '%s\n' "$DURATION" | sed -n 's/^\([0-9][0-9]*\)s$/\1/p')
218+
[ -n "$dur_s" ] || dur_s=30
219+
sleep "$dur_s"
220+
kill "$cpid" 2>/dev/null || true
221+
rc=143
222+
fi
223+
224+
end_ts=$(date +%s)
225+
elapsed=$((end_ts - start_ts))
226+
227+
log_info "Client finished: rc=${rc} elapsed=${elapsed}s"
228+
229+
tail -n 400 "$RUN_LOG" >"$STDOUT_LOG" 2>/dev/null || true
230+
231+
final="PASS"
232+
233+
if [ "$rc" -ne 0 ] && [ "$rc" -ne 143 ]; then
234+
final="FAIL"
235+
fi
236+
237+
if [ "$elapsed" -le 1 ]; then
238+
log_fail "Client exited too quickly (elapsed=${elapsed}s) expected ~${DURATION} runtime."
239+
final="FAIL"
240+
fi
241+
242+
if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then
243+
if command -v display_wayland_proto_validate >/dev/null 2>&1; then
244+
if display_wayland_proto_validate "$RUN_LOG"; then
245+
log_info "Wayland protocol validation passed."
246+
else
247+
log_fail "Wayland protocol validation failed (missing surface/commit evidence in WAYLAND_DEBUG)"
248+
final="FAIL"
249+
fi
250+
else
251+
log_warn "display_wayland_proto_validate helper not found skipping protocol validation."
252+
fi
253+
fi
254+
255+
if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then
256+
if [ "$shot_begin_rc" -eq 0 ]; then
257+
if command -v display_screenshot_delta_end >/dev/null 2>&1; then
258+
display_screenshot_delta_end "$TESTNAME"
259+
shot_end_rc=$?
260+
if [ "$shot_end_rc" -eq 0 ]; then
261+
log_info "Screenshot delta validation passed (visible change detected)."
262+
else
263+
if [ "$shot_end_rc" -eq 1 ]; then
264+
log_fail "Screenshot delta validation failed (no visible change detected)."
265+
final="FAIL"
266+
else
267+
log_warn "Screenshot delta validation skipped (tool unavailable or capture failed)."
268+
fi
269+
fi
270+
else
271+
log_warn "display_screenshot_delta_end helper not found skipping screenshot delta validation."
272+
fi
273+
else
274+
log_warn "Screenshot delta validation skipped (before screenshot was not captured)."
275+
fi
276+
fi
277+
278+
log_info "Final decision for ${TESTNAME}: ${final}"
279+
280+
echo "$TESTNAME $final" >"$RES_FILE"
281+
282+
if [ "$final" = "PASS" ]; then
283+
log_pass "${TESTNAME} : PASS"
284+
exit 0
285+
fi
286+
287+
log_fail "${TESTNAME} : FAIL"
288+
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-cliptest
3+
format: Lava-Test Test Definition 1.0
4+
description: "Run weston-cliptest 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-cliptest
18+
- ./run.sh || true
19+
- $REPO_PATH/Runner/utils/send-to-lava.sh weston-cliptest.res

0 commit comments

Comments
 (0)