diff --git a/Runner/suites/Multimedia/Display/weston-clickdot/README.md b/Runner/suites/Multimedia/Display/weston-clickdot/README.md new file mode 100644 index 00000000..1208d4e9 --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-clickdot/README.md @@ -0,0 +1,29 @@ +# weston-clickdot + +Runs `weston-clickdot` inside an existing Wayland/Weston session and validates the client created and committed +a Wayland surface using `WAYLAND_DEBUG` output. + +## What it validates + +- A connected DRM display is present (otherwise SKIP) +- A usable Wayland socket exists (otherwise SKIP) +- GPU acceleration is active (best-effort gating via `display_is_cpu_renderer auto`, otherwise continues) +- `weston-clickdot` binary exists (otherwise FAIL) +- **Optional**: Wayland protocol activity (default enabled) + - Checks for `wl_compositor.create_surface` and `wl_surface.commit` patterns in the client log +- **Optional**: Screenshot delta (default disabled) + - Captures before/after screenshots and validates hashes differ (visible change) + - If `weston-screenshooter` is unauthorized or missing, screenshot validation is skipped + +## Parameters (LAVA) + +- `DURATION` (default `30s`) +- `VALIDATE_WAYLAND_PROTO` (default `1`) +- `VALIDATE_SCREENSHOT` (default `0`) + +## Local run + +```sh +cd Runner/suites/Multimedia/Display/weston-clickdot +./run.sh +cat weston-clickdot.res diff --git a/Runner/suites/Multimedia/Display/weston-clickdot/run.sh b/Runner/suites/Multimedia/Display/weston-clickdot/run.sh new file mode 100755 index 00000000..928d55ae --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-clickdot/run.sh @@ -0,0 +1,284 @@ +#!/bin/sh +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear +# +# Validate weston-clickdot runs under a working Wayland session. +# - Wayland env resolution (adopts socket & fixes XDG_RUNTIME_DIR perms) +# - CI-friendly logs and PASS/FAIL/SKIP semantics (LAVA-friendly: exits 0) +# - Optional Wayland protocol validation (WAYLAND_DEBUG based) +# - Optional screenshot delta validation (best-effort, skips if unauthorized) + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" + +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2 + exit 1 +fi + +if [ -z "${__INIT_ENV_LOADED:-}" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" + __INIT_ENV_LOADED=1 +fi + +# shellcheck disable=SC1091 +. "$TOOLS/functestlib.sh" +# shellcheck disable=SC1091 +. "$TOOLS/lib_display.sh" + +TESTNAME="weston-clickdot" +RES_FILE="./${TESTNAME}.res" +RUN_LOG="./${TESTNAME}_run.log" +STDOUT_LOG="./${TESTNAME}_stdout_$(date +%Y%m%d-%H%M%S 2>/dev/null || echo 0).log" + +: >"$RES_FILE" +: >"$RUN_LOG" +: >"$STDOUT_LOG" + +DURATION="${DURATION:-30s}" +STOP_GRACE="${STOP_GRACE:-3s}" +VALIDATE_WAYLAND_PROTO="${VALIDATE_WAYLAND_PROTO:-1}" +VALIDATE_SCREENSHOT="${VALIDATE_SCREENSHOT:-0}" + +BUILD_FLAVOUR="base" +if [ -f /usr/share/glvnd/egl_vendor.d/EGL_adreno.json ]; then + BUILD_FLAVOUR="overlay" +fi + +log_info "Weston log directory: $SCRIPT_DIR" +log_info "--------------------------------------------------------------------------" +log_info "------------------- Starting ${TESTNAME} Testcase --------------------------" +log_info "Config: DURATION=${DURATION} VALIDATE_WAYLAND_PROTO=${VALIDATE_WAYLAND_PROTO} VALIDATE_SCREENSHOT=${VALIDATE_SCREENSHOT} BUILD_FLAVOUR=${BUILD_FLAVOUR}" + +if command -v detect_platform >/dev/null 2>&1; then + detect_platform +fi + +if command -v display_debug_snapshot >/dev/null 2>&1; then + display_debug_snapshot "pre-display-check" +fi + +if command -v modetest >/dev/null 2>&1; then + log_info "----- modetest -M msm -ac (capped at 200 lines) -----" + modetest -M msm -ac 2>&1 | sed -n '1,200p' | while IFS= read -r l; do + [ -n "$l" ] && log_info "[modetest] $l" + done + log_info "----- End modetest -M msm -ac -----" +else + log_warn "modetest not found in PATH skipping modetest snapshot." +fi + +have_connector=0 +if command -v display_connected_summary >/dev/null 2>&1; then + sysfs_summary=$(display_connected_summary) + if [ -n "$sysfs_summary" ] && [ "$sysfs_summary" != "none" ]; then + have_connector=1 + log_info "Connected display (sysfs): $sysfs_summary" + fi +fi + +if [ "$have_connector" -eq 0 ]; then + log_warn "No connected DRM display found, skipping ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 +fi + +if command -v wayland_debug_snapshot >/dev/null 2>&1; then + wayland_debug_snapshot "${TESTNAME}: start" +fi + +sock="" +if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then + sock=$(discover_wayland_socket_anywhere | head -n 1 || true) +fi + +if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then + log_info "Found existing Wayland socket: $sock" + if ! adopt_wayland_env_from_socket "$sock"; then + log_warn "Failed to adopt env from $sock" + fi +fi + +if [ -z "$sock" ] && command -v overlay_start_weston_drm >/dev/null 2>&1; then + log_info "No usable Wayland socket trying overlay_start_weston_drm helper..." + if overlay_start_weston_drm; then + if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then + sock=$(discover_wayland_socket_anywhere | head -n 1 || true) + fi + if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then + log_info "Overlay Weston created Wayland socket: $sock" + if ! adopt_wayland_env_from_socket "$sock"; then + log_warn "Failed to adopt env from $sock" + fi + fi + else + log_warn "overlay_start_weston_drm returned non-zero private Weston may have failed to start." + fi +fi + +if [ -z "$sock" ]; then + log_warn "No Wayland socket found after autodetection skipping ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 +fi + +if command -v wayland_connection_ok >/dev/null 2>&1; then + if ! wayland_connection_ok; then + log_fail "Wayland connection test failed cannot run ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 + fi + log_info "Wayland connection test: OK" +fi + +if command -v display_is_cpu_renderer >/dev/null 2>&1; then + if display_is_cpu_renderer auto; then + log_skip "$TESTNAME SKIP: GPU HW acceleration not enabled (CPU/software renderer detected)" + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 + fi +else + log_warn "display_is_cpu_renderer helper not found continuing without GPU accel gating." +fi + +if ! check_dependencies weston-clickdot; then + log_fail "Required binary weston-clickdot not found in PATH." + echo "$TESTNAME FAIL" >"$RES_FILE" + exit 0 +fi + +BIN=$(command -v weston-clickdot) +log_info "Using weston-clickdot: $BIN" + +if [ "$BUILD_FLAVOUR" = "overlay" ] && [ -f /usr/share/glvnd/egl_vendor.d/EGL_adreno.json ]; then + __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/EGL_adreno.json + export __EGL_VENDOR_LIBRARY_FILENAMES + log_info "EGL vendor override: /usr/share/glvnd/egl_vendor.d/EGL_adreno.json" +fi + +shot_begin_rc=2 +if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then + log_info "Screenshot delta validation enabled." + if command -v display_screenshot_delta_begin >/dev/null 2>&1; then + display_screenshot_delta_begin "$TESTNAME" "$SCRIPT_DIR" + shot_begin_rc=$? + if [ "$shot_begin_rc" -eq 0 ]; then + log_info "Screenshot(before) captured." + else + if [ "$shot_begin_rc" -eq 2 ]; then + log_warn "Screenshot tool not available skipping screenshot-delta validation." + else + log_warn "Failed to capture screenshot(before) skipping screenshot-delta validation." + fi + fi + else + log_warn "display_screenshot_delta_begin helper not found skipping screenshot-delta validation." + fi +fi + +log_info "Launching ${TESTNAME} for ${DURATION} ..." + +start_ts=$(date +%s) + +if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + log_info "Wayland protocol validation enabled (WAYLAND_DEBUG=1)." + WAYLAND_DEBUG=1 + export WAYLAND_DEBUG +fi + +rc=0 +if command -v run_with_timeout >/dev/null 2>&1; then + log_info "Using helper: run_with_timeout" + if command -v stdbuf >/dev/null 2>&1; then + run_with_timeout "$DURATION" stdbuf -oL -eL "$BIN" >>"$RUN_LOG" 2>&1 + rc=$? + else + run_with_timeout "$DURATION" "$BIN" >>"$RUN_LOG" 2>&1 + rc=$? + fi +else + log_warn "run_with_timeout not found using naive sleep+kill fallback." + "$BIN" >>"$RUN_LOG" 2>&1 & + cpid=$! + dur_s=$(printf '%s\n' "$DURATION" | sed -n 's/^\([0-9][0-9]*\)s$/\1/p') + [ -n "$dur_s" ] || dur_s=30 + sleep "$dur_s" + kill "$cpid" 2>/dev/null || true + rc=143 +fi + +end_ts=$(date +%s) +elapsed=$((end_ts - start_ts)) + +log_info "Client finished: rc=${rc} elapsed=${elapsed}s" + +tail -n 400 "$RUN_LOG" >"$STDOUT_LOG" 2>/dev/null || true + +final="PASS" + +if [ "$rc" -ne 0 ] && [ "$rc" -ne 143 ]; then + final="FAIL" +fi + +if [ "$elapsed" -le 1 ]; then + log_fail "Client exited too quickly (elapsed=${elapsed}s) expected ~${DURATION} runtime." + final="FAIL" +fi + +if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + if command -v display_wayland_proto_validate >/dev/null 2>&1; then + if display_wayland_proto_validate "$RUN_LOG"; then + log_info "Wayland protocol validation passed." + else + log_fail "Wayland protocol validation failed (missing surface/commit evidence in WAYLAND_DEBUG)" + final="FAIL" + fi + else + log_warn "display_wayland_proto_validate helper not found skipping protocol validation." + fi +fi + +if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then + if [ "$shot_begin_rc" -eq 0 ]; then + if command -v display_screenshot_delta_end >/dev/null 2>&1; then + display_screenshot_delta_end "$TESTNAME" + shot_end_rc=$? + if [ "$shot_end_rc" -eq 0 ]; then + log_info "Screenshot delta validation passed (visible change detected)." + else + if [ "$shot_end_rc" -eq 1 ]; then + log_fail "Screenshot delta validation failed (no visible change detected)." + final="FAIL" + else + log_warn "Screenshot delta validation skipped (tool unavailable or capture failed)." + fi + fi + else + log_warn "display_screenshot_delta_end helper not found skipping screenshot delta validation." + fi + else + log_warn "Screenshot delta validation skipped (before screenshot was not captured)." + fi +fi + +log_info "Final decision for ${TESTNAME}: ${final}" + +echo "$TESTNAME $final" >"$RES_FILE" + +if [ "$final" = "PASS" ]; then + log_pass "${TESTNAME} : PASS" + exit 0 +fi + +log_fail "${TESTNAME} : FAIL" +exit 0 diff --git a/Runner/suites/Multimedia/Display/weston-clickdot/weston-smoke.yaml b/Runner/suites/Multimedia/Display/weston-clickdot/weston-smoke.yaml new file mode 100755 index 00000000..01c81929 --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-clickdot/weston-smoke.yaml @@ -0,0 +1,19 @@ +metadata: + name: weston-clickdot + format: Lava-Test Test Definition 1.0 + description: "Run weston-clickdot under an active Wayland session and validate it creates/commits a surface" + maintainer: + - "Qualcomm Linux Testkit" + +params: + DURATION: "30s" # Client runtime (default 30s) + STOP_GRACE: "3s" # Reserved (default 3s) + VALIDATE_WAYLAND_PROTO: 1 # 1 enables WAYLAND_DEBUG protocol validation (default 1) + VALIDATE_SCREENSHOT: 0 # 1 enables screenshot delta when tools allow (default 0) + +run: + steps: + - REPO_PATH=$PWD + - cd Runner/suites/Multimedia/Display/weston-clickdot + - ./run.sh || true + - $REPO_PATH/Runner/utils/send-to-lava.sh weston-clickdot.res diff --git a/Runner/suites/Multimedia/Display/weston-cliptest/README.md b/Runner/suites/Multimedia/Display/weston-cliptest/README.md new file mode 100644 index 00000000..3079655c --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-cliptest/README.md @@ -0,0 +1,29 @@ +# weston-cliptest + +Runs `weston-cliptest` inside an existing Wayland/Weston session and validates the client created and committed +a Wayland surface using `WAYLAND_DEBUG` output. + +## What it validates + +- A connected DRM display is present (otherwise SKIP) +- A usable Wayland socket exists (otherwise SKIP) +- GPU acceleration is active (best-effort gating via `display_is_cpu_renderer auto`) +- `weston-cliptest` binary exists (otherwise FAIL) +- **Optional**: Wayland protocol activity (default enabled) + - Checks for `wl_compositor.create_surface` and `wl_surface.commit` patterns in the client log +- **Optional**: Screenshot delta (default disabled) + - Captures before/after screenshots and validates hashes differ (visible change) + - If `weston-screenshooter` is unauthorized or missing, screenshot validation is skipped + +## Parameters (LAVA) + +- `DURATION` (default `30s`) +- `VALIDATE_WAYLAND_PROTO` (default `1`) +- `VALIDATE_SCREENSHOT` (default `0`) + +## Local run + +```sh +cd Runner/suites/Multimedia/Display/weston-cliptest +./run.sh +cat weston-cliptest.res diff --git a/Runner/suites/Multimedia/Display/weston-cliptest/run.sh b/Runner/suites/Multimedia/Display/weston-cliptest/run.sh new file mode 100755 index 00000000..513ba306 --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-cliptest/run.sh @@ -0,0 +1,284 @@ +#!/bin/sh +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear +# +# Validate weston-cliptest runs under a working Wayland session. +# - Wayland env resolution (adopts socket & fixes XDG_RUNTIME_DIR perms) +# - CI-friendly logs and PASS/FAIL/SKIP semantics (LAVA-friendly: exits 0) +# - Optional Wayland protocol validation (WAYLAND_DEBUG based) +# - Optional screenshot delta validation (best-effort, skips if unauthorized) + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" + +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2 + exit 1 +fi + +if [ -z "${__INIT_ENV_LOADED:-}" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" + __INIT_ENV_LOADED=1 +fi + +# shellcheck disable=SC1091 +. "$TOOLS/functestlib.sh" +# shellcheck disable=SC1091 +. "$TOOLS/lib_display.sh" + +TESTNAME="weston-cliptest" +RES_FILE="./${TESTNAME}.res" +RUN_LOG="./${TESTNAME}_run.log" +STDOUT_LOG="./${TESTNAME}_stdout_$(date +%Y%m%d-%H%M%S 2>/dev/null || echo 0).log" + +: >"$RES_FILE" +: >"$RUN_LOG" +: >"$STDOUT_LOG" + +DURATION="${DURATION:-30s}" +STOP_GRACE="${STOP_GRACE:-3s}" +VALIDATE_WAYLAND_PROTO="${VALIDATE_WAYLAND_PROTO:-1}" +VALIDATE_SCREENSHOT="${VALIDATE_SCREENSHOT:-0}" + +BUILD_FLAVOUR="base" +if [ -f /usr/share/glvnd/egl_vendor.d/EGL_adreno.json ]; then + BUILD_FLAVOUR="overlay" +fi + +log_info "Weston log directory: $SCRIPT_DIR" +log_info "--------------------------------------------------------------------------" +log_info "------------------- Starting ${TESTNAME} Testcase --------------------------" +log_info "Config: DURATION=${DURATION} VALIDATE_WAYLAND_PROTO=${VALIDATE_WAYLAND_PROTO} VALIDATE_SCREENSHOT=${VALIDATE_SCREENSHOT} BUILD_FLAVOUR=${BUILD_FLAVOUR}" + +if command -v detect_platform >/dev/null 2>&1; then + detect_platform +fi + +if command -v display_debug_snapshot >/dev/null 2>&1; then + display_debug_snapshot "pre-display-check" +fi + +if command -v modetest >/dev/null 2>&1; then + log_info "----- modetest -M msm -ac (capped at 200 lines) -----" + modetest -M msm -ac 2>&1 | sed -n '1,200p' | while IFS= read -r l; do + [ -n "$l" ] && log_info "[modetest] $l" + done + log_info "----- End modetest -M msm -ac -----" +else + log_warn "modetest not found in PATH skipping modetest snapshot." +fi + +have_connector=0 +if command -v display_connected_summary >/dev/null 2>&1; then + sysfs_summary=$(display_connected_summary) + if [ -n "$sysfs_summary" ] && [ "$sysfs_summary" != "none" ]; then + have_connector=1 + log_info "Connected display (sysfs): $sysfs_summary" + fi +fi + +if [ "$have_connector" -eq 0 ]; then + log_warn "No connected DRM display found, skipping ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 +fi + +if command -v wayland_debug_snapshot >/dev/null 2>&1; then + wayland_debug_snapshot "${TESTNAME}: start" +fi + +sock="" +if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then + sock=$(discover_wayland_socket_anywhere | head -n 1 || true) +fi + +if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then + log_info "Found existing Wayland socket: $sock" + if ! adopt_wayland_env_from_socket "$sock"; then + log_warn "Failed to adopt env from $sock" + fi +fi + +if [ -z "$sock" ] && command -v overlay_start_weston_drm >/dev/null 2>&1; then + log_info "No usable Wayland socket trying overlay_start_weston_drm helper..." + if overlay_start_weston_drm; then + if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then + sock=$(discover_wayland_socket_anywhere | head -n 1 || true) + fi + if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then + log_info "Overlay Weston created Wayland socket: $sock" + if ! adopt_wayland_env_from_socket "$sock"; then + log_warn "Failed to adopt env from $sock" + fi + fi + else + log_warn "overlay_start_weston_drm returned non-zero private Weston may have failed to start." + fi +fi + +if [ -z "$sock" ]; then + log_warn "No Wayland socket found after autodetection skipping ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 +fi + +if command -v wayland_connection_ok >/dev/null 2>&1; then + if ! wayland_connection_ok; then + log_fail "Wayland connection test failed cannot run ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 + fi + log_info "Wayland connection test: OK" +fi + +if command -v display_is_cpu_renderer >/dev/null 2>&1; then + if display_is_cpu_renderer auto; then + log_skip "$TESTNAME SKIP: GPU HW acceleration not enabled (CPU/software renderer detected)" + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 + fi +else + log_warn "display_is_cpu_renderer helper not found continuing without GPU accel gating." +fi + +if ! check_dependencies weston-cliptest; then + log_fail "Required binary weston-cliptest not found in PATH." + echo "$TESTNAME FAIL" >"$RES_FILE" + exit 0 +fi + +BIN=$(command -v weston-cliptest) +log_info "Using weston-cliptest: $BIN" + +if [ "$BUILD_FLAVOUR" = "overlay" ] && [ -f /usr/share/glvnd/egl_vendor.d/EGL_adreno.json ]; then + __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/EGL_adreno.json + export __EGL_VENDOR_LIBRARY_FILENAMES + log_info "EGL vendor override: /usr/share/glvnd/egl_vendor.d/EGL_adreno.json" +fi + +shot_begin_rc=2 +if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then + log_info "Screenshot delta validation enabled." + if command -v display_screenshot_delta_begin >/dev/null 2>&1; then + display_screenshot_delta_begin "$TESTNAME" "$SCRIPT_DIR" + shot_begin_rc=$? + if [ "$shot_begin_rc" -eq 0 ]; then + log_info "Screenshot(before) captured." + else + if [ "$shot_begin_rc" -eq 2 ]; then + log_warn "Screenshot tool not available skipping screenshot-delta validation." + else + log_warn "Failed to capture screenshot(before) skipping screenshot-delta validation." + fi + fi + else + log_warn "display_screenshot_delta_begin helper not found skipping screenshot-delta validation." + fi +fi + +log_info "Launching ${TESTNAME} for ${DURATION} ..." + +start_ts=$(date +%s) + +if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + log_info "Wayland protocol validation enabled (WAYLAND_DEBUG=1)." + WAYLAND_DEBUG=1 + export WAYLAND_DEBUG +fi + +rc=0 +if command -v run_with_timeout >/dev/null 2>&1; then + log_info "Using helper: run_with_timeout" + if command -v stdbuf >/dev/null 2>&1; then + run_with_timeout "$DURATION" stdbuf -oL -eL "$BIN" >>"$RUN_LOG" 2>&1 + rc=$? + else + run_with_timeout "$DURATION" "$BIN" >>"$RUN_LOG" 2>&1 + rc=$? + fi +else + log_warn "run_with_timeout not found using naive sleep+kill fallback." + "$BIN" >>"$RUN_LOG" 2>&1 & + cpid=$! + dur_s=$(printf '%s\n' "$DURATION" | sed -n 's/^\([0-9][0-9]*\)s$/\1/p') + [ -n "$dur_s" ] || dur_s=30 + sleep "$dur_s" + kill "$cpid" 2>/dev/null || true + rc=143 +fi + +end_ts=$(date +%s) +elapsed=$((end_ts - start_ts)) + +log_info "Client finished: rc=${rc} elapsed=${elapsed}s" + +tail -n 400 "$RUN_LOG" >"$STDOUT_LOG" 2>/dev/null || true + +final="PASS" + +if [ "$rc" -ne 0 ] && [ "$rc" -ne 143 ]; then + final="FAIL" +fi + +if [ "$elapsed" -le 1 ]; then + log_fail "Client exited too quickly (elapsed=${elapsed}s) expected ~${DURATION} runtime." + final="FAIL" +fi + +if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + if command -v display_wayland_proto_validate >/dev/null 2>&1; then + if display_wayland_proto_validate "$RUN_LOG"; then + log_info "Wayland protocol validation passed." + else + log_fail "Wayland protocol validation failed (missing surface/commit evidence in WAYLAND_DEBUG)" + final="FAIL" + fi + else + log_warn "display_wayland_proto_validate helper not found skipping protocol validation." + fi +fi + +if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then + if [ "$shot_begin_rc" -eq 0 ]; then + if command -v display_screenshot_delta_end >/dev/null 2>&1; then + display_screenshot_delta_end "$TESTNAME" + shot_end_rc=$? + if [ "$shot_end_rc" -eq 0 ]; then + log_info "Screenshot delta validation passed (visible change detected)." + else + if [ "$shot_end_rc" -eq 1 ]; then + log_fail "Screenshot delta validation failed (no visible change detected)." + final="FAIL" + else + log_warn "Screenshot delta validation skipped (tool unavailable or capture failed)." + fi + fi + else + log_warn "display_screenshot_delta_end helper not found skipping screenshot delta validation." + fi + else + log_warn "Screenshot delta validation skipped (before screenshot was not captured)." + fi +fi + +log_info "Final decision for ${TESTNAME}: ${final}" + +echo "$TESTNAME $final" >"$RES_FILE" + +if [ "$final" = "PASS" ]; then + log_pass "${TESTNAME} : PASS" + exit 0 +fi + +log_fail "${TESTNAME} : FAIL" +exit 0 diff --git a/Runner/suites/Multimedia/Display/weston-cliptest/weston-cliptest.yaml b/Runner/suites/Multimedia/Display/weston-cliptest/weston-cliptest.yaml new file mode 100755 index 00000000..eb01aef0 --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-cliptest/weston-cliptest.yaml @@ -0,0 +1,19 @@ +metadata: + name: weston-cliptest + format: Lava-Test Test Definition 1.0 + description: "Run weston-cliptest under an active Wayland session and validate it creates/commits a surface" + maintainer: + - "Qualcomm Linux Testkit" + +params: + DURATION: "30s" # Client runtime (default 30s) + STOP_GRACE: "3s" # Reserved (default 3s) + VALIDATE_WAYLAND_PROTO: 1 # 1 enables WAYLAND_DEBUG protocol validation (default 1) + VALIDATE_SCREENSHOT: 0 # 1 enables screenshot delta when tools allow (default 0) + +run: + steps: + - REPO_PATH=$PWD + - cd Runner/suites/Multimedia/Display/weston-cliptest + - ./run.sh || true + - $REPO_PATH/Runner/utils/send-to-lava.sh weston-cliptest.res diff --git a/Runner/suites/Multimedia/Display/weston-editor/README.md b/Runner/suites/Multimedia/Display/weston-editor/README.md new file mode 100644 index 00000000..b28ec28c --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-editor/README.md @@ -0,0 +1,30 @@ +# weston-editor + +Runs `weston-editor` inside an existing Wayland/Weston session and validates the client created and committed +a Wayland surface using `WAYLAND_DEBUG` output. + +## What it validates + +- A connected DRM display is present (otherwise SKIP) +- A usable Wayland socket exists (otherwise SKIP) +- GPU acceleration is active (best-effort gating via `display_is_cpu_renderer auto`) +- `weston-editor` binary exists (otherwise FAIL) +- **Optional**: Wayland protocol activity (default enabled) + - Checks for `wl_compositor.create_surface` and `wl_surface.commit` patterns in the client log +- **Optional**: Screenshot delta (default disabled) + - Captures before/after screenshots and validates hashes differ (visible change) + - If `weston-screenshooter` is unauthorized or missing, screenshot validation is skipped + +## Parameters (LAVA) + +- `DURATION` (default `30s`) +- `VALIDATE_WAYLAND_PROTO` (default `1`) +- `VALIDATE_SCREENSHOT` (default `0`) + +## Local run + +```sh +cd Runner/suites/Multimedia/Display/weston-editor +./run.sh +cat weston-editor.res + diff --git a/Runner/suites/Multimedia/Display/weston-editor/run.sh b/Runner/suites/Multimedia/Display/weston-editor/run.sh new file mode 100755 index 00000000..6ff0fc36 --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-editor/run.sh @@ -0,0 +1,286 @@ +#!/bin/sh +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear +# +# Validate weston-editor runs under a working Wayland session. +# - Uses lib_display.sh to adopt Wayland env (socket + XDG_RUNTIME_DIR) +# - CI-friendly logs and PASS/FAIL/SKIP semantics (LAVA-friendly: exits 0) +# - Optional Wayland protocol validation (WAYLAND_DEBUG based) +# - Optional screenshot delta validation (best-effort, skips if unauthorized) + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" + +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2 + exit 1 +fi + +if [ -z "${__INIT_ENV_LOADED:-}" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" + __INIT_ENV_LOADED=1 +fi + +# shellcheck disable=SC1091 +. "$TOOLS/functestlib.sh" +# shellcheck disable=SC1091 +. "$TOOLS/lib_display.sh" + +TESTNAME="weston-editor" +RES_FILE="./${TESTNAME}.res" +RUN_LOG="./${TESTNAME}_run.log" +STDOUT_LOG="./${TESTNAME}_stdout_$(date +%Y%m%d-%H%M%S 2>/dev/null || echo 0).log" + +: >"$RES_FILE" +: >"$RUN_LOG" +: >"$STDOUT_LOG" + +DURATION="${DURATION:-30s}" +STOP_GRACE="${STOP_GRACE:-3s}" +VALIDATE_WAYLAND_PROTO="${VALIDATE_WAYLAND_PROTO:-1}" +VALIDATE_SCREENSHOT="${VALIDATE_SCREENSHOT:-0}" + +BUILD_FLAVOUR="base" +if [ -f /usr/share/glvnd/egl_vendor.d/EGL_adreno.json ]; then + BUILD_FLAVOUR="overlay" +fi + +log_info "Weston log directory: $SCRIPT_DIR" +log_info "--------------------------------------------------------------------------" +log_info "------------------- Starting ${TESTNAME} Testcase --------------------------" +log_info "Config: DURATION=${DURATION} VALIDATE_WAYLAND_PROTO=${VALIDATE_WAYLAND_PROTO} VALIDATE_SCREENSHOT=${VALIDATE_SCREENSHOT} BUILD_FLAVOUR=${BUILD_FLAVOUR}" + +if command -v detect_platform >/dev/null 2>&1; then + detect_platform +fi + +if command -v display_debug_snapshot >/dev/null 2>&1; then + display_debug_snapshot "pre-display-check" +fi + +if command -v modetest >/dev/null 2>&1; then + log_info "----- modetest -M msm -ac (capped at 200 lines) -----" + modetest -M msm -ac 2>&1 | sed -n '1,200p' | while IFS= read -r l; do + [ -n "$l" ] && log_info "[modetest] $l" + done + log_info "----- End modetest -M msm -ac -----" +else + log_warn "modetest not found in PATH skipping modetest snapshot." +fi + +have_connector=0 +if command -v display_connected_summary >/dev/null 2>&1; then + sysfs_summary=$(display_connected_summary) + if [ -n "$sysfs_summary" ] && [ "$sysfs_summary" != "none" ]; then + have_connector=1 + log_info "Connected display (sysfs): $sysfs_summary" + fi +fi + +if [ "$have_connector" -eq 0 ]; then + log_warn "No connected DRM display found, skipping ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 +fi + +if command -v wayland_debug_snapshot >/dev/null 2>&1; then + wayland_debug_snapshot "${TESTNAME}: start" +fi + +sock="" +if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then + sock=$(discover_wayland_socket_anywhere | head -n 1 || true) +fi + +if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then + log_info "Found existing Wayland socket: $sock" + if ! adopt_wayland_env_from_socket "$sock"; then + log_warn "Failed to adopt env from $sock" + fi +fi + +if [ -z "$sock" ] && command -v overlay_start_weston_drm >/dev/null 2>&1; then + log_info "No usable Wayland socket trying overlay_start_weston_drm helper..." + if overlay_start_weston_drm; then + if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then + sock=$(discover_wayland_socket_anywhere | head -n 1 || true) + fi + if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then + log_info "Overlay Weston created Wayland socket: $sock" + if ! adopt_wayland_env_from_socket "$sock"; then + log_warn "Failed to adopt env from $sock" + fi + fi + else + log_warn "overlay_start_weston_drm returned non-zero private Weston may have failed to start." + fi +fi + +if [ -z "$sock" ]; then + log_warn "No Wayland socket found after autodetection skipping ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 +fi + +if command -v wayland_connection_ok >/dev/null 2>&1; then + if ! wayland_connection_ok; then + log_fail "Wayland connection test failed cannot run ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 + fi + log_info "Wayland connection test: OK" +fi + +if command -v display_is_cpu_renderer >/dev/null 2>&1; then + if display_is_cpu_renderer auto; then + log_skip "$TESTNAME SKIP: GPU HW acceleration not enabled (CPU/software renderer detected)" + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 + fi +else + log_warn "display_is_cpu_renderer helper not found continuing without GPU accel gating." +fi + +if ! check_dependencies weston-editor; then + log_fail "Required binary weston-editor not found in PATH." + echo "$TESTNAME FAIL" >"$RES_FILE" + exit 0 +fi + +BIN=$(command -v weston-editor) +log_info "Using weston-editor: $BIN" + +# If GLVND overlay exists, prefer it for EGL clients. +if [ "$BUILD_FLAVOUR" = "overlay" ] && [ -f /usr/share/glvnd/egl_vendor.d/EGL_adreno.json ]; then + __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/EGL_adreno.json + export __EGL_VENDOR_LIBRARY_FILENAMES + log_info "EGL vendor override: /usr/share/glvnd/egl_vendor.d/EGL_adreno.json" +fi + +shot_begin_rc=2 +if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then + log_info "Screenshot delta validation enabled." + if command -v display_screenshot_delta_begin >/dev/null 2>&1; then + display_screenshot_delta_begin "$TESTNAME" "$SCRIPT_DIR" + shot_begin_rc=$? + if [ "$shot_begin_rc" -eq 0 ]; then + log_info "Screenshot(before) captured." + else + if [ "$shot_begin_rc" -eq 2 ]; then + log_warn "Screenshot tool not available skipping screenshot-delta validation." + else + log_warn "Failed to capture screenshot(before) skipping screenshot-delta validation." + fi + fi + else + log_warn "display_screenshot_delta_begin helper not found skipping screenshot-delta validation." + fi +fi + +log_info "Launching ${TESTNAME} for ${DURATION} ..." + +start_ts=$(date +%s) + +if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + log_info "Wayland protocol validation enabled (WAYLAND_DEBUG=1)." + WAYLAND_DEBUG=1 + export WAYLAND_DEBUG +fi + +rc=0 +if command -v run_with_timeout >/dev/null 2>&1; then + log_info "Using helper: run_with_timeout" + if command -v stdbuf >/dev/null 2>&1; then + run_with_timeout "$DURATION" stdbuf -oL -eL "$BIN" >>"$RUN_LOG" 2>&1 + rc=$? + else + run_with_timeout "$DURATION" "$BIN" >>"$RUN_LOG" 2>&1 + rc=$? + fi +else + log_warn "run_with_timeout not found using naive sleep+kill fallback." + "$BIN" >>"$RUN_LOG" 2>&1 & + cpid=$! + dur_s=$(printf '%s\n' "$DURATION" | sed -n 's/^\([0-9][0-9]*\)s$/\1/p') + [ -n "$dur_s" ] || dur_s=30 + sleep "$dur_s" + kill "$cpid" 2>/dev/null || true + rc=143 +fi + +end_ts=$(date +%s) +elapsed=$((end_ts - start_ts)) + +log_info "Client finished: rc=${rc} elapsed=${elapsed}s" + +tail -n 400 "$RUN_LOG" >"$STDOUT_LOG" 2>/dev/null || true + +final="PASS" + +# For these demo apps, timeout kill is expected (rc=143). Other non-zero is suspicious. +if [ "$rc" -ne 0 ] && [ "$rc" -ne 143 ]; then + final="FAIL" +fi + +if [ "$elapsed" -le 1 ]; then + log_fail "Client exited too quickly (elapsed=${elapsed}s) expected ~${DURATION} runtime." + final="FAIL" +fi + +if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + if command -v display_wayland_proto_validate >/dev/null 2>&1; then + if display_wayland_proto_validate "$RUN_LOG"; then + log_info "Wayland protocol validation passed." + else + log_fail "Wayland protocol validation failed (missing surface/commit evidence in WAYLAND_DEBUG)" + final="FAIL" + fi + else + log_warn "display_wayland_proto_validate helper not found skipping protocol validation." + fi +fi + +if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then + if [ "$shot_begin_rc" -eq 0 ]; then + if command -v display_screenshot_delta_end >/dev/null 2>&1; then + display_screenshot_delta_end "$TESTNAME" + shot_end_rc=$? + if [ "$shot_end_rc" -eq 0 ]; then + log_info "Screenshot delta validation passed (visible change detected)." + else + if [ "$shot_end_rc" -eq 1 ]; then + log_fail "Screenshot delta validation failed (no visible change detected)." + final="FAIL" + else + log_warn "Screenshot delta validation skipped (tool unavailable or capture failed)." + fi + fi + else + log_warn "display_screenshot_delta_end helper not found skipping screenshot delta validation." + fi + else + log_warn "Screenshot delta validation skipped (before screenshot was not captured)." + fi +fi + +log_info "Final decision for ${TESTNAME}: ${final}" + +echo "$TESTNAME $final" >"$RES_FILE" + +if [ "$final" = "PASS" ]; then + log_pass "${TESTNAME} : PASS" + exit 0 +fi + +log_fail "${TESTNAME} : FAIL" +exit 0 diff --git a/Runner/suites/Multimedia/Display/weston-editor/weston-editor.yaml b/Runner/suites/Multimedia/Display/weston-editor/weston-editor.yaml new file mode 100755 index 00000000..7fb6be4e --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-editor/weston-editor.yaml @@ -0,0 +1,19 @@ +metadata: + name: weston-editor + format: Lava-Test Test Definition 1.0 + description: "Run weston-editor under an active Wayland session and validate it creates/commits a surface" + maintainer: + - "Qualcomm Linux Testkit" + +params: + DURATION: "30s" # Client runtime (default 30s) + STOP_GRACE: "3s" # Reserved (default 3s) + VALIDATE_WAYLAND_PROTO: 1 # 1 enables WAYLAND_DEBUG protocol validation (default 1) + VALIDATE_SCREENSHOT: 0 # 1 enables screenshot delta when tools allow (default 0) + +run: + steps: + - REPO_PATH=$PWD + - cd Runner/suites/Multimedia/Display/weston-editor + - ./run.sh || true + - $REPO_PATH/Runner/utils/send-to-lava.sh weston-editor.res diff --git a/Runner/suites/Multimedia/Display/weston-flower/README.md b/Runner/suites/Multimedia/Display/weston-flower/README.md new file mode 100644 index 00000000..a001993e --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-flower/README.md @@ -0,0 +1,28 @@ +# weston-flower + +Runs `weston-flower` under a working Wayland session (existing Weston or private Weston started by helpers) and validates that the client actually exercised Wayland. + +## What this test validates + +- A connected DRM display exists (otherwise SKIP) +- A usable Wayland socket is available (otherwise SKIP) +- GPU acceleration is active when `display_is_cpu_renderer` helper exists (otherwise SKIP) +- `weston-flower` runs for roughly `DURATION` +- Optional: + - Wayland protocol activity validation using `WAYLAND_DEBUG=1` capture + - Screenshot delta validation if screenshot tools exist and permissions allow + +## Parameters (LAVA yaml `params:`) + +- `DURATION` (default `30s`) +- `VALIDATE_WAYLAND_PROTO` (default `1`) + - When enabled, the script captures `WAYLAND_DEBUG=1` output and checks for `create_surface` and `commit`. +- `VALIDATE_SCREENSHOT` (default `0`) + - When enabled, tries to capture before and after screenshots and checks for delta. + - If screenshots are unauthorized or tool is missing, screenshot validation is skipped. + +## Logs and results + +- `weston-flower.res` contains `weston-flower PASS/FAIL/SKIP` +- `weston-flower_run.log` contains WAYLAND_DEBUG output when protocol validation is enabled +- `weston-flower_stdout_*.log` contains extra logs (including screenshot helper output) diff --git a/Runner/suites/Multimedia/Display/weston-flower/run.sh b/Runner/suites/Multimedia/Display/weston-flower/run.sh new file mode 100755 index 00000000..cbdf01b5 --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-flower/run.sh @@ -0,0 +1,339 @@ +#!/bin/sh +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear +# +# Validate weston-flower runs under a working Wayland session. +# - Wayland env resolution (adopts socket & fixes XDG_RUNTIME_DIR perms) +# - Optional Wayland protocol validation via WAYLAND_DEBUG capture +# - Optional screenshot-delta validation when tools and permissions allow +# - CI-friendly PASS FAIL SKIP semantics, always exits 0 + +# ---------- Source init_env and functestlib ---------- +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" + +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2 + exit 1 +fi + +if [ -z "${__INIT_ENV_LOADED:-}" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" + __INIT_ENV_LOADED=1 +fi + +# shellcheck disable=SC1091 +. "$TOOLS/functestlib.sh" +# shellcheck disable=SC1091 +. "$TOOLS/lib_display.sh" + +TESTNAME="weston-flower" +RES_FILE="./${TESTNAME}.res" +RUN_LOG="./${TESTNAME}_run.log" +STDOUT_LOG="./${TESTNAME}_stdout_$(date +%Y%m%d-%H%M%S 2>/dev/null || date +%s).log" + +: >"$RES_FILE" +: >"$RUN_LOG" +: >"$STDOUT_LOG" + +# --------------------------------------------------------------------------- +# Config +# --------------------------------------------------------------------------- +DURATION="${DURATION:-30s}" +STOP_GRACE="${STOP_GRACE:-3s}" +VALIDATE_WAYLAND_PROTO="${VALIDATE_WAYLAND_PROTO:-1}" +VALIDATE_SCREENSHOT="${VALIDATE_SCREENSHOT:-0}" + +BUILD_FLAVOUR="base" +if [ -f /usr/share/glvnd/egl_vendor.d/EGL_adreno.json ]; then + BUILD_FLAVOUR="overlay" +fi + +log_info "Weston log directory: $SCRIPT_DIR" +log_info "--------------------------------------------------------------------------" +log_info "------------------- Starting ${TESTNAME} Testcase --------------------------" +log_info "Config: DURATION=${DURATION} VALIDATE_WAYLAND_PROTO=${VALIDATE_WAYLAND_PROTO} VALIDATE_SCREENSHOT=${VALIDATE_SCREENSHOT} BUILD_FLAVOUR=${BUILD_FLAVOUR}" + +if command -v detect_platform >/dev/null 2>&1; then + detect_platform +fi + +# --------------------------------------------------------------------------- +# Display snapshot +# --------------------------------------------------------------------------- +if command -v display_debug_snapshot >/dev/null 2>&1; then + display_debug_snapshot "pre-display-check" +fi + +if command -v modetest >/dev/null 2>&1; then + log_info "----- modetest -M msm -ac (capped at 200 lines) -----" + modetest -M msm -ac 2>&1 | sed -n '1,200p' | while IFS= read -r l; do + [ -n "$l" ] && log_info "[modetest] $l" + done + log_info "----- End modetest -M msm -ac -----" +else + log_warn "modetest not found in PATH skipping modetest snapshot." +fi + +have_connector=0 +if command -v display_connected_summary >/dev/null 2>&1; then + sysfs_summary=$(display_connected_summary) + if [ -n "$sysfs_summary" ] && [ "$sysfs_summary" != "none" ]; then + have_connector=1 + log_info "Connected display (sysfs): $sysfs_summary" + fi +fi + +if [ "$have_connector" -eq 0 ]; then + log_warn "No connected DRM display found skipping ${TESTNAME}." + echo "${TESTNAME} SKIP" >"$RES_FILE" + exit 0 +fi + +# --------------------------------------------------------------------------- +# Wayland / Weston environment +# --------------------------------------------------------------------------- +if command -v wayland_debug_snapshot >/dev/null 2>&1; then + wayland_debug_snapshot "${TESTNAME}: start" +fi + +sock="" + +if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then + sock=$(discover_wayland_socket_anywhere | head -n 1 || true) +fi + +if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then + log_info "Found existing Wayland socket: $sock" + if ! adopt_wayland_env_from_socket "$sock"; then + log_warn "Failed to adopt env from $sock" + fi +fi + +if [ -z "$sock" ] && command -v overlay_start_weston_drm >/dev/null 2>&1; then + log_info "No usable Wayland socket trying overlay_start_weston_drm helper..." + if command -v weston_force_primary_1080p60_if_not_60 >/dev/null 2>&1; then + log_info "Pre-configuring primary output to ~60Hz before starting Weston best-effort" + weston_force_primary_1080p60_if_not_60 || true + fi + if overlay_start_weston_drm; then + if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then + sock=$(discover_wayland_socket_anywhere | head -n 1 || true) + fi + if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then + log_info "Overlay Weston created Wayland socket: $sock" + if ! adopt_wayland_env_from_socket "$sock"; then + log_warn "Failed to adopt env from $sock" + fi + else + log_warn "overlay_start_weston_drm reported success but no Wayland socket was found." + fi + else + log_warn "overlay_start_weston_drm returned non-zero private Weston may have failed to start." + fi +fi + +if [ -z "$sock" ]; then + log_warn "No Wayland socket found after autodetection skipping ${TESTNAME}." + echo "${TESTNAME} SKIP" >"$RES_FILE" + exit 0 +fi + +if command -v wayland_connection_ok >/dev/null 2>&1; then + if ! wayland_connection_ok; then + log_fail "Wayland connection test failed cannot run ${TESTNAME}." + echo "${TESTNAME} SKIP" >"$RES_FILE" + exit 0 + fi + log_info "Wayland connection test: OK" +else + log_warn "wayland_connection_ok helper not found continuing without explicit Wayland probe." +fi + +# --------------------------------------------------------------------------- +# Ensure primary output is ~60Hz best-effort +# --------------------------------------------------------------------------- +if command -v weston_force_primary_1080p60_if_not_60 >/dev/null 2>&1; then + log_info "Ensuring primary output is ~60Hz best-effort" + if weston_force_primary_1080p60_if_not_60; then + log_info "Primary output is ~60Hz or was already ~60Hz." + else + log_warn "Unable to force ~60Hz continuing not a hard failure." + fi +else + log_warn "weston_force_primary_1080p60_if_not_60 helper not found skipping ~60Hz enforcement." +fi + +# --- Skip if CPU/software renderer is active --- +if command -v display_is_cpu_renderer >/dev/null 2>&1; then + if display_is_cpu_renderer auto; then + log_skip "$TESTNAME SKIP: GPU HW acceleration not enabled CPU/software renderer detected" + echo "${TESTNAME} SKIP" >"$RES_FILE" + exit 0 + fi +else + log_warn "display_is_cpu_renderer helper not found continuing without GPU accel gating." +fi + +# --------------------------------------------------------------------------- +# Binary +# --------------------------------------------------------------------------- +if ! check_dependencies weston-flower; then + log_fail "Required binary weston-flower not found in PATH." + echo "${TESTNAME} FAIL" >"$RES_FILE" + exit 0 +fi + +BIN=$(command -v weston-flower) +log_info "Using weston-flower: $BIN" + +# --------------------------------------------------------------------------- +# Optional screenshot delta begin +# --------------------------------------------------------------------------- +shot_begin_rc=2 +if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then + log_info "Screenshot delta validation enabled." + if command -v display_screenshot_delta_begin >/dev/null 2>&1; then + display_screenshot_delta_begin "$TESTNAME" "$SCRIPT_DIR" >>"$STDOUT_LOG" 2>&1 + shot_begin_rc=$? + if [ "$shot_begin_rc" -eq 2 ]; then + log_warn "Screenshot delta requested, tool unavailable or unauthorized skipping screenshot validation." + elif [ "$shot_begin_rc" -ne 0 ]; then + log_warn "Screenshot delta requested, unable to capture before screenshot." + fi + else + log_warn "display_screenshot_delta_begin helper not found skipping screenshot validation." + shot_begin_rc=2 + fi +fi + +# --------------------------------------------------------------------------- +# Run client with timeout +# - If VALIDATE_WAYLAND_PROTO=1 capture WAYLAND_DEBUG into RUN_LOG +# --------------------------------------------------------------------------- +log_info "Launching ${TESTNAME} for ${DURATION} ..." + +start_ts=$(date +%s) + +rc=0 +if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + log_info "Wayland protocol validation enabled (WAYLAND_DEBUG=1)." + WAYLAND_DEBUG=1 + export WAYLAND_DEBUG +else + WAYLAND_DEBUG="" + export WAYLAND_DEBUG +fi + +if command -v run_with_timeout >/dev/null 2>&1; then + if command -v stdbuf >/dev/null 2>&1; then + if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + run_with_timeout "$DURATION" stdbuf -oL -eL "$BIN" >>"$RUN_LOG" 2>&1 + else + run_with_timeout "$DURATION" stdbuf -oL -eL "$BIN" >>"$STDOUT_LOG" 2>&1 + fi + else + log_warn "stdbuf not found running $BIN without output re-buffering." + if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + run_with_timeout "$DURATION" "$BIN" >>"$RUN_LOG" 2>&1 + else + run_with_timeout "$DURATION" "$BIN" >>"$STDOUT_LOG" 2>&1 + fi + fi + rc=$? +else + log_warn "run_with_timeout not found using naive sleep+kill fallback." + if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + "$BIN" >>"$RUN_LOG" 2>&1 & + else + "$BIN" >>"$STDOUT_LOG" 2>&1 & + fi + cpid=$! + dur_s=$(printf '%s\n' "$DURATION" | sed -n 's/^\([0-9][0-9]*\)s$/\1/p') + [ -n "$dur_s" ] || dur_s=30 + sleep "$dur_s" + kill "$cpid" 2>/dev/null || true + rc=143 +fi + +end_ts=$(date +%s) +elapsed=$((end_ts - start_ts)) + +log_info "Client finished: rc=${rc} elapsed=${elapsed}s" + +# --------------------------------------------------------------------------- +# Validation +# --------------------------------------------------------------------------- +final="PASS" + +# Exit code: accept 0 and 143 as non-fatal here +if [ "$rc" -ne 0 ] && [ "$rc" -ne 143 ]; then + final="FAIL" +fi + +# Duration sanity +if [ "$elapsed" -le 1 ]; then + log_fail "Client exited too quickly (elapsed=${elapsed}s) expected ~${DURATION} runtime." + final="FAIL" +fi + +# Wayland protocol validation +if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + if command -v display_wayland_proto_validate >/dev/null 2>&1; then + if display_wayland_proto_validate "$RUN_LOG"; then + log_info "Wayland protocol validation passed." + else + log_fail "Wayland protocol validation failed missing surface/commit evidence in WAYLAND_DEBUG" + final="FAIL" + fi + else + log_warn "display_wayland_proto_validate helper not found skipping protocol validation." + fi +fi + +# Screenshot delta end +if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then + if [ "$shot_begin_rc" -eq 0 ]; then + if command -v display_screenshot_delta_end >/dev/null 2>&1; then + display_screenshot_delta_end "$TESTNAME" >>"$STDOUT_LOG" 2>&1 + src=$? + if [ "$src" -eq 0 ]; then + log_info "Screenshot delta validation passed." + elif [ "$src" -eq 1 ]; then + log_fail "Screenshot delta validation failed screenshots identical." + final="FAIL" + else + log_warn "Screenshot delta validation skipped." + fi + else + log_warn "display_screenshot_delta_end helper not found skipping screenshot validation." + fi + else + log_warn "Screenshot delta validation skipped, before screenshot was not captured." + fi +fi + +log_info "Final decision for ${TESTNAME}: ${final}" + +# --------------------------------------------------------------------------- +# Emit result & exit +# --------------------------------------------------------------------------- +echo "${TESTNAME} ${final}" >"$RES_FILE" + +if [ "$final" = "PASS" ]; then + log_pass "${TESTNAME} : PASS" + exit 0 +fi + +log_fail "${TESTNAME} : FAIL" +exit 0 diff --git a/Runner/suites/Multimedia/Display/weston-flower/weston-flower.yaml b/Runner/suites/Multimedia/Display/weston-flower/weston-flower.yaml new file mode 100755 index 00000000..5315872e --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-flower/weston-flower.yaml @@ -0,0 +1,19 @@ +metadata: + name: weston-flower + format: Lava-Test Test Definition 1.0 + description: "Run weston-flower under an active Wayland session and validate basic protocol activity" + maintainer: + - "Qualcomm Linux Testkit" + +params: + DURATION: "30s" # Client runtime (default 30s) + STOP_GRACE: "3s" # Reserved for future stop grace (default 3s) + VALIDATE_WAYLAND_PROTO: 1 # 1 enables WAYLAND_DEBUG based protocol validation (default 1) + VALIDATE_SCREENSHOT: 0 # 1 enables screenshot delta when allowed/tools exist (default 0) + +run: + steps: + - REPO_PATH=$PWD + - cd Runner/suites/Multimedia/Display/weston-flower + - ./run.sh || true + - $REPO_PATH/Runner/utils/send-to-lava.sh weston-flower.res diff --git a/Runner/suites/Multimedia/Display/weston-resizor/README.md b/Runner/suites/Multimedia/Display/weston-resizor/README.md new file mode 100644 index 00000000..10a17af7 --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-resizor/README.md @@ -0,0 +1,29 @@ +# weston-resizor + +Runs `weston-resizor` inside an existing Wayland/Weston session and validates the client created and committed +a Wayland surface using `WAYLAND_DEBUG` output. + +## What it validates + +- A connected DRM display is present (otherwise SKIP) +- A usable Wayland socket exists (otherwise SKIP) +- GPU acceleration is active (best-effort gating via `display_is_cpu_renderer auto`) +- `weston-resizor` binary exists (otherwise FAIL) +- **Optional**: Wayland protocol activity (default enabled) + - Checks for `wl_compositor.create_surface` and `wl_surface.commit` patterns in the client log +- **Optional**: Screenshot delta (default disabled) + - Captures before/after screenshots and validates hashes differ (visible change) + - If `weston-screenshooter` is unauthorized or missing, screenshot validation is skipped + +## Parameters (LAVA) + +- `DURATION` (default `30s`) +- `VALIDATE_WAYLAND_PROTO` (default `1`) +- `VALIDATE_SCREENSHOT` (default `0`) + +## Local run + +```sh +cd Runner/suites/Multimedia/Display/weston-resizor +./run.sh +cat weston-resizor.res diff --git a/Runner/suites/Multimedia/Display/weston-resizor/run.sh b/Runner/suites/Multimedia/Display/weston-resizor/run.sh new file mode 100755 index 00000000..6c5759d8 --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-resizor/run.sh @@ -0,0 +1,284 @@ +#!/bin/sh +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear +# +# Validate weston-resizor runs under a working Wayland session. +# - Wayland env resolution (adopts socket & fixes XDG_RUNTIME_DIR perms) +# - CI-friendly logs and PASS/FAIL/SKIP semantics (LAVA-friendly: exits 0) +# - Optional Wayland protocol validation (WAYLAND_DEBUG based) +# - Optional screenshot delta validation (best-effort, skips if unauthorized) + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" + +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2 + exit 1 +fi + +if [ -z "${__INIT_ENV_LOADED:-}" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" + __INIT_ENV_LOADED=1 +fi + +# shellcheck disable=SC1091 +. "$TOOLS/functestlib.sh" +# shellcheck disable=SC1091 +. "$TOOLS/lib_display.sh" + +TESTNAME="weston-resizor" +RES_FILE="./${TESTNAME}.res" +RUN_LOG="./${TESTNAME}_run.log" +STDOUT_LOG="./${TESTNAME}_stdout_$(date +%Y%m%d-%H%M%S 2>/dev/null || echo 0).log" + +: >"$RES_FILE" +: >"$RUN_LOG" +: >"$STDOUT_LOG" + +DURATION="${DURATION:-30s}" +STOP_GRACE="${STOP_GRACE:-3s}" +VALIDATE_WAYLAND_PROTO="${VALIDATE_WAYLAND_PROTO:-1}" +VALIDATE_SCREENSHOT="${VALIDATE_SCREENSHOT:-0}" + +BUILD_FLAVOUR="base" +if [ -f /usr/share/glvnd/egl_vendor.d/EGL_adreno.json ]; then + BUILD_FLAVOUR="overlay" +fi + +log_info "Weston log directory: $SCRIPT_DIR" +log_info "--------------------------------------------------------------------------" +log_info "------------------- Starting ${TESTNAME} Testcase --------------------------" +log_info "Config: DURATION=${DURATION} VALIDATE_WAYLAND_PROTO=${VALIDATE_WAYLAND_PROTO} VALIDATE_SCREENSHOT=${VALIDATE_SCREENSHOT} BUILD_FLAVOUR=${BUILD_FLAVOUR}" + +if command -v detect_platform >/dev/null 2>&1; then + detect_platform +fi + +if command -v display_debug_snapshot >/dev/null 2>&1; then + display_debug_snapshot "pre-display-check" +fi + +if command -v modetest >/dev/null 2>&1; then + log_info "----- modetest -M msm -ac (capped at 200 lines) -----" + modetest -M msm -ac 2>&1 | sed -n '1,200p' | while IFS= read -r l; do + [ -n "$l" ] && log_info "[modetest] $l" + done + log_info "----- End modetest -M msm -ac -----" +else + log_warn "modetest not found in PATH skipping modetest snapshot." +fi + +have_connector=0 +if command -v display_connected_summary >/dev/null 2>&1; then + sysfs_summary=$(display_connected_summary) + if [ -n "$sysfs_summary" ] && [ "$sysfs_summary" != "none" ]; then + have_connector=1 + log_info "Connected display (sysfs): $sysfs_summary" + fi +fi + +if [ "$have_connector" -eq 0 ]; then + log_warn "No connected DRM display found, skipping ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 +fi + +if command -v wayland_debug_snapshot >/dev/null 2>&1; then + wayland_debug_snapshot "${TESTNAME}: start" +fi + +sock="" +if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then + sock=$(discover_wayland_socket_anywhere | head -n 1 || true) +fi + +if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then + log_info "Found existing Wayland socket: $sock" + if ! adopt_wayland_env_from_socket "$sock"; then + log_warn "Failed to adopt env from $sock" + fi +fi + +if [ -z "$sock" ] && command -v overlay_start_weston_drm >/dev/null 2>&1; then + log_info "No usable Wayland socket trying overlay_start_weston_drm helper..." + if overlay_start_weston_drm; then + if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then + sock=$(discover_wayland_socket_anywhere | head -n 1 || true) + fi + if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then + log_info "Overlay Weston created Wayland socket: $sock" + if ! adopt_wayland_env_from_socket "$sock"; then + log_warn "Failed to adopt env from $sock" + fi + fi + else + log_warn "overlay_start_weston_drm returned non-zero private Weston may have failed to start." + fi +fi + +if [ -z "$sock" ]; then + log_warn "No Wayland socket found after autodetection skipping ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 +fi + +if command -v wayland_connection_ok >/dev/null 2>&1; then + if ! wayland_connection_ok; then + log_fail "Wayland connection test failed cannot run ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 + fi + log_info "Wayland connection test: OK" +fi + +if command -v display_is_cpu_renderer >/dev/null 2>&1; then + if display_is_cpu_renderer auto; then + log_skip "$TESTNAME SKIP: GPU HW acceleration not enabled (CPU/software renderer detected)" + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 + fi +else + log_warn "display_is_cpu_renderer helper not found continuing without GPU accel gating." +fi + +if ! check_dependencies weston-resizor; then + log_fail "Required binary weston-resizor not found in PATH." + echo "$TESTNAME FAIL" >"$RES_FILE" + exit 0 +fi + +BIN=$(command -v weston-resizor) +log_info "Using weston-resizor: $BIN" + +if [ "$BUILD_FLAVOUR" = "overlay" ] && [ -f /usr/share/glvnd/egl_vendor.d/EGL_adreno.json ]; then + __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/EGL_adreno.json + export __EGL_VENDOR_LIBRARY_FILENAMES + log_info "EGL vendor override: /usr/share/glvnd/egl_vendor.d/EGL_adreno.json" +fi + +shot_begin_rc=2 +if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then + log_info "Screenshot delta validation enabled." + if command -v display_screenshot_delta_begin >/dev/null 2>&1; then + display_screenshot_delta_begin "$TESTNAME" "$SCRIPT_DIR" + shot_begin_rc=$? + if [ "$shot_begin_rc" -eq 0 ]; then + log_info "Screenshot(before) captured." + else + if [ "$shot_begin_rc" -eq 2 ]; then + log_warn "Screenshot tool not available skipping screenshot-delta validation." + else + log_warn "Failed to capture screenshot(before) skipping screenshot-delta validation." + fi + fi + else + log_warn "display_screenshot_delta_begin helper not found skipping screenshot-delta validation." + fi +fi + +log_info "Launching ${TESTNAME} for ${DURATION} ..." + +start_ts=$(date +%s) + +if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + log_info "Wayland protocol validation enabled (WAYLAND_DEBUG=1)." + WAYLAND_DEBUG=1 + export WAYLAND_DEBUG +fi + +rc=0 +if command -v run_with_timeout >/dev/null 2>&1; then + log_info "Using helper: run_with_timeout" + if command -v stdbuf >/dev/null 2>&1; then + run_with_timeout "$DURATION" stdbuf -oL -eL "$BIN" >>"$RUN_LOG" 2>&1 + rc=$? + else + run_with_timeout "$DURATION" "$BIN" >>"$RUN_LOG" 2>&1 + rc=$? + fi +else + log_warn "run_with_timeout not found using naive sleep+kill fallback." + "$BIN" >>"$RUN_LOG" 2>&1 & + cpid=$! + dur_s=$(printf '%s\n' "$DURATION" | sed -n 's/^\([0-9][0-9]*\)s$/\1/p') + [ -n "$dur_s" ] || dur_s=30 + sleep "$dur_s" + kill "$cpid" 2>/dev/null || true + rc=143 +fi + +end_ts=$(date +%s) +elapsed=$((end_ts - start_ts)) + +log_info "Client finished: rc=${rc} elapsed=${elapsed}s" + +tail -n 400 "$RUN_LOG" >"$STDOUT_LOG" 2>/dev/null || true + +final="PASS" + +if [ "$rc" -ne 0 ] && [ "$rc" -ne 143 ]; then + final="FAIL" +fi + +if [ "$elapsed" -le 1 ]; then + log_fail "Client exited too quickly (elapsed=${elapsed}s) expected ~${DURATION} runtime." + final="FAIL" +fi + +if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + if command -v display_wayland_proto_validate >/dev/null 2>&1; then + if display_wayland_proto_validate "$RUN_LOG"; then + log_info "Wayland protocol validation passed." + else + log_fail "Wayland protocol validation failed (missing surface/commit evidence in WAYLAND_DEBUG)" + final="FAIL" + fi + else + log_warn "display_wayland_proto_validate helper not found skipping protocol validation." + fi +fi + +if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then + if [ "$shot_begin_rc" -eq 0 ]; then + if command -v display_screenshot_delta_end >/dev/null 2>&1; then + display_screenshot_delta_end "$TESTNAME" + shot_end_rc=$? + if [ "$shot_end_rc" -eq 0 ]; then + log_info "Screenshot delta validation passed (visible change detected)." + else + if [ "$shot_end_rc" -eq 1 ]; then + log_fail "Screenshot delta validation failed (no visible change detected)." + final="FAIL" + else + log_warn "Screenshot delta validation skipped (tool unavailable or capture failed)." + fi + fi + else + log_warn "display_screenshot_delta_end helper not found skipping screenshot delta validation." + fi + else + log_warn "Screenshot delta validation skipped (before screenshot was not captured)." + fi +fi + +log_info "Final decision for ${TESTNAME}: ${final}" + +echo "$TESTNAME $final" >"$RES_FILE" + +if [ "$final" = "PASS" ]; then + log_pass "${TESTNAME} : PASS" + exit 0 +fi + +log_fail "${TESTNAME} : FAIL" +exit 0 diff --git a/Runner/suites/Multimedia/Display/weston-resizor/weston-resizor.yaml b/Runner/suites/Multimedia/Display/weston-resizor/weston-resizor.yaml new file mode 100755 index 00000000..7b5bfb2b --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-resizor/weston-resizor.yaml @@ -0,0 +1,19 @@ +metadata: + name: weston-resizor + format: Lava-Test Test Definition 1.0 + description: "Run weston-resizor under an active Wayland session and validate it creates/commits a surface" + maintainer: + - "Qualcomm Linux Testkit" + +params: + DURATION: "30s" # Client runtime (default 30s) + STOP_GRACE: "3s" # Reserved (default 3s) + VALIDATE_WAYLAND_PROTO: 1 # 1 enables WAYLAND_DEBUG protocol validation (default 1) + VALIDATE_SCREENSHOT: 0 # 1 enables screenshot delta when tools allow (default 0) + +run: + steps: + - REPO_PATH=$PWD + - cd Runner/suites/Multimedia/Display/weston-resizor + - ./run.sh || true + - $REPO_PATH/Runner/utils/send-to-lava.sh weston-resizor.res diff --git a/Runner/suites/Multimedia/Display/weston-scaler/README.md b/Runner/suites/Multimedia/Display/weston-scaler/README.md new file mode 100644 index 00000000..9fb9b093 --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-scaler/README.md @@ -0,0 +1,38 @@ +# weston-scaler + +Runs `weston-scaler` as a Wayland client and validates it actually ran in a usable Wayland session. + +## What this test validates + +1. **Display presence (DRM connector)** + If no connected display is detected, the test **SKIPs**. + +2. **Wayland availability** + Reuses existing Wayland socket if present, otherwise tries to start a private Weston using helpers from `lib_display.sh`. + If no socket can be found, the test **SKIPs**. + +3. **GPU acceleration gating (optional but default behavior)** + If CPU/software renderer is detected, the test **SKIPs** (to avoid “false green” on llvmpipe). + +4. **Client execution evidence** + - By default, enables **client-side Wayland protocol validation** using `WAYLAND_DEBUG=1` and checks for + `wl_compositor.create_surface` + `wl_surface.commit` in the client log. + - Optionally, can perform **screenshot-delta** validation (before/after) when screenshot tools exist. + +## Files + +- `run.sh` – main runner (writes `weston-scaler.res` and `weston-scaler_run.log`) +- `weston-scaler.yaml` – LAVA job fragment / example +- `weston-scaler.res` – output result file (generated) + +## Parameters (LAVA/job params) + +- `DURATION` (default `30s`): how long to run the client +- `VALIDATE_WAYLAND_PROTO` (default `1`): enable `WAYLAND_DEBUG=1` and protocol evidence check +- `VALIDATE_SCREENSHOT` (default `0`): enable screenshot-before/after delta validation + +## Expected result semantics + +- `PASS` – client ran for expected duration (or timed out) and validations passed +- `FAIL` – client exited too quickly, bad exit code, missing Wayland evidence, or screenshot delta check failed +- `SKIP` – no display, no Wayland socket, or GPU accel not enabled diff --git a/Runner/suites/Multimedia/Display/weston-scaler/run.sh b/Runner/suites/Multimedia/Display/weston-scaler/run.sh new file mode 100755 index 00000000..75a06831 --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-scaler/run.sh @@ -0,0 +1,286 @@ +#!/bin/sh +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear +# +# Validate weston-scaler runs under a working Wayland session. +# - Uses lib_display.sh to adopt Wayland env (socket + XDG_RUNTIME_DIR) +# - CI-friendly logs and PASS/FAIL/SKIP semantics (LAVA-friendly: exits 0) +# - Optional Wayland protocol validation (WAYLAND_DEBUG based) +# - Optional screenshot delta validation (best-effort, skips if unauthorized) + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" + +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2 + exit 1 +fi + +if [ -z "${__INIT_ENV_LOADED:-}" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" + __INIT_ENV_LOADED=1 +fi + +# shellcheck disable=SC1091 +. "$TOOLS/functestlib.sh" +# shellcheck disable=SC1091 +. "$TOOLS/lib_display.sh" + +TESTNAME="weston-scaler" +RES_FILE="./${TESTNAME}.res" +RUN_LOG="./${TESTNAME}_run.log" +STDOUT_LOG="./${TESTNAME}_stdout_$(date +%Y%m%d-%H%M%S 2>/dev/null || echo 0).log" + +: >"$RES_FILE" +: >"$RUN_LOG" +: >"$STDOUT_LOG" + +DURATION="${DURATION:-30s}" +STOP_GRACE="${STOP_GRACE:-3s}" +VALIDATE_WAYLAND_PROTO="${VALIDATE_WAYLAND_PROTO:-1}" +VALIDATE_SCREENSHOT="${VALIDATE_SCREENSHOT:-0}" + +BUILD_FLAVOUR="base" +if [ -f /usr/share/glvnd/egl_vendor.d/EGL_adreno.json ]; then + BUILD_FLAVOUR="overlay" +fi + +log_info "Weston log directory: $SCRIPT_DIR" +log_info "--------------------------------------------------------------------------" +log_info "------------------- Starting ${TESTNAME} Testcase --------------------------" +log_info "Config: DURATION=${DURATION} VALIDATE_WAYLAND_PROTO=${VALIDATE_WAYLAND_PROTO} VALIDATE_SCREENSHOT=${VALIDATE_SCREENSHOT} BUILD_FLAVOUR=${BUILD_FLAVOUR}" + +if command -v detect_platform >/dev/null 2>&1; then + detect_platform +fi + +if command -v display_debug_snapshot >/dev/null 2>&1; then + display_debug_snapshot "pre-display-check" +fi + +if command -v modetest >/dev/null 2>&1; then + log_info "----- modetest -M msm -ac (capped at 200 lines) -----" + modetest -M msm -ac 2>&1 | sed -n '1,200p' | while IFS= read -r l; do + [ -n "$l" ] && log_info "[modetest] $l" + done + log_info "----- End modetest -M msm -ac -----" +else + log_warn "modetest not found in PATH skipping modetest snapshot." +fi + +have_connector=0 +if command -v display_connected_summary >/dev/null 2>&1; then + sysfs_summary=$(display_connected_summary) + if [ -n "$sysfs_summary" ] && [ "$sysfs_summary" != "none" ]; then + have_connector=1 + log_info "Connected display (sysfs): $sysfs_summary" + fi +fi + +if [ "$have_connector" -eq 0 ]; then + log_warn "No connected DRM display found, skipping ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 +fi + +if command -v wayland_debug_snapshot >/dev/null 2>&1; then + wayland_debug_snapshot "${TESTNAME}: start" +fi + +sock="" +if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then + sock=$(discover_wayland_socket_anywhere | head -n 1 || true) +fi + +if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then + log_info "Found existing Wayland socket: $sock" + if ! adopt_wayland_env_from_socket "$sock"; then + log_warn "Failed to adopt env from $sock" + fi +fi + +if [ -z "$sock" ] && command -v overlay_start_weston_drm >/dev/null 2>&1; then + log_info "No usable Wayland socket trying overlay_start_weston_drm helper..." + if overlay_start_weston_drm; then + if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then + sock=$(discover_wayland_socket_anywhere | head -n 1 || true) + fi + if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then + log_info "Overlay Weston created Wayland socket: $sock" + if ! adopt_wayland_env_from_socket "$sock"; then + log_warn "Failed to adopt env from $sock" + fi + fi + else + log_warn "overlay_start_weston_drm returned non-zero private Weston may have failed to start." + fi +fi + +if [ -z "$sock" ]; then + log_warn "No Wayland socket found after autodetection skipping ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 +fi + +if command -v wayland_connection_ok >/dev/null 2>&1; then + if ! wayland_connection_ok; then + log_fail "Wayland connection test failed cannot run ${TESTNAME}." + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 + fi + log_info "Wayland connection test: OK" +fi + +if command -v display_is_cpu_renderer >/dev/null 2>&1; then + if display_is_cpu_renderer auto; then + log_skip "$TESTNAME SKIP: GPU HW acceleration not enabled (CPU/software renderer detected)" + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 + fi +else + log_warn "display_is_cpu_renderer helper not found continuing without GPU accel gating." +fi + +if ! check_dependencies weston-scaler; then + log_fail "Required binary weston-scaler not found in PATH." + echo "$TESTNAME FAIL" >"$RES_FILE" + exit 0 +fi + +BIN=$(command -v weston-scaler) +log_info "Using weston-scaler: $BIN" + +# If GLVND overlay exists, prefer it for EGL clients. +if [ "$BUILD_FLAVOUR" = "overlay" ] && [ -f /usr/share/glvnd/egl_vendor.d/EGL_adreno.json ]; then + __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/EGL_adreno.json + export __EGL_VENDOR_LIBRARY_FILENAMES + log_info "EGL vendor override: /usr/share/glvnd/egl_vendor.d/EGL_adreno.json" +fi + +shot_begin_rc=2 +if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then + log_info "Screenshot delta validation enabled." + if command -v display_screenshot_delta_begin >/dev/null 2>&1; then + display_screenshot_delta_begin "$TESTNAME" "$SCRIPT_DIR" + shot_begin_rc=$? + if [ "$shot_begin_rc" -eq 0 ]; then + log_info "Screenshot(before) captured." + else + if [ "$shot_begin_rc" -eq 2 ]; then + log_warn "Screenshot tool not available skipping screenshot-delta validation." + else + log_warn "Failed to capture screenshot(before) skipping screenshot-delta validation." + fi + fi + else + log_warn "display_screenshot_delta_begin helper not found skipping screenshot-delta validation." + fi +fi + +log_info "Launching ${TESTNAME} for ${DURATION} ..." + +start_ts=$(date +%s) + +if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + log_info "Wayland protocol validation enabled (WAYLAND_DEBUG=1)." + WAYLAND_DEBUG=1 + export WAYLAND_DEBUG +fi + +rc=0 +if command -v run_with_timeout >/dev/null 2>&1; then + log_info "Using helper: run_with_timeout" + if command -v stdbuf >/dev/null 2>&1; then + run_with_timeout "$DURATION" stdbuf -oL -eL "$BIN" >>"$RUN_LOG" 2>&1 + rc=$? + else + run_with_timeout "$DURATION" "$BIN" >>"$RUN_LOG" 2>&1 + rc=$? + fi +else + log_warn "run_with_timeout not found using naive sleep+kill fallback." + "$BIN" >>"$RUN_LOG" 2>&1 & + cpid=$! + dur_s=$(printf '%s\n' "$DURATION" | sed -n 's/^\([0-9][0-9]*\)s$/\1/p') + [ -n "$dur_s" ] || dur_s=30 + sleep "$dur_s" + kill "$cpid" 2>/dev/null || true + rc=143 +fi + +end_ts=$(date +%s) +elapsed=$((end_ts - start_ts)) + +log_info "Client finished: rc=${rc} elapsed=${elapsed}s" + +tail -n 400 "$RUN_LOG" >"$STDOUT_LOG" 2>/dev/null || true + +final="PASS" + +# For these demo apps, timeout kill is expected (rc=143). Other non-zero is suspicious. +if [ "$rc" -ne 0 ] && [ "$rc" -ne 143 ]; then + final="FAIL" +fi + +if [ "$elapsed" -le 1 ]; then + log_fail "Client exited too quickly (elapsed=${elapsed}s) expected ~${DURATION} runtime." + final="FAIL" +fi + +if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + if command -v display_wayland_proto_validate >/dev/null 2>&1; then + if display_wayland_proto_validate "$RUN_LOG"; then + log_info "Wayland protocol validation passed." + else + log_fail "Wayland protocol validation failed (missing surface/commit evidence in WAYLAND_DEBUG)" + final="FAIL" + fi + else + log_warn "display_wayland_proto_validate helper not found skipping protocol validation." + fi +fi + +if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then + if [ "$shot_begin_rc" -eq 0 ]; then + if command -v display_screenshot_delta_end >/dev/null 2>&1; then + display_screenshot_delta_end "$TESTNAME" + shot_end_rc=$? + if [ "$shot_end_rc" -eq 0 ]; then + log_info "Screenshot delta validation passed (visible change detected)." + else + if [ "$shot_end_rc" -eq 1 ]; then + log_fail "Screenshot delta validation failed (no visible change detected)." + final="FAIL" + else + log_warn "Screenshot delta validation skipped (tool unavailable or capture failed)." + fi + fi + else + log_warn "display_screenshot_delta_end helper not found skipping screenshot delta validation." + fi + else + log_warn "Screenshot delta validation skipped (before screenshot was not captured)." + fi +fi + +log_info "Final decision for ${TESTNAME}: ${final}" + +echo "$TESTNAME $final" >"$RES_FILE" + +if [ "$final" = "PASS" ]; then + log_pass "${TESTNAME} : PASS" + exit 0 +fi + +log_fail "${TESTNAME} : FAIL" +exit 0 diff --git a/Runner/suites/Multimedia/Display/weston-scaler/weston-scaler.yaml b/Runner/suites/Multimedia/Display/weston-scaler/weston-scaler.yaml new file mode 100755 index 00000000..fedcf411 --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-scaler/weston-scaler.yaml @@ -0,0 +1,18 @@ +metadata: + name: weston-scaler + description: > + Run weston-scaler under Wayland/Weston. + Params below are OPTIONAL overrides; run.sh applies the same defaults when unset. + format: "Lava-Test-Shell Test Definition 1.0" + +params: + DURATION: "30s" # Runtime duration (e.g., 10s, 30s, 60s). Default: 30s + VALIDATE_WAYLAND_PROTO: "1" # 1=enable WAYLAND_DEBUG protocol evidence checks. Default: 1 + VALIDATE_SCREENSHOT: "0" # 1=enable screenshot-delta if tools exist. Default: 0 + +run: + steps: + - REPO_PATH=$PWD + - cd Runner/suites/Multimedia/Display/weston-scaler + - ./run.sh || true + - $REPO_PATH/Runner/utils/send-to-lava.sh weston-scaler.res diff --git a/Runner/suites/Multimedia/Display/weston-smoke/README.md b/Runner/suites/Multimedia/Display/weston-smoke/README.md new file mode 100644 index 00000000..9fad7c9b --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-smoke/README.md @@ -0,0 +1,26 @@ +# weston-smoke + +Runs `weston-smoke` under a working Wayland session (existing Weston or private Weston started by helpers) and validates that the client actually exercised Wayland. + +## What this test validates + +- A connected DRM display exists (otherwise SKIP) +- A usable Wayland socket is available (otherwise SKIP) +- GPU acceleration is active when `display_is_cpu_renderer` helper exists (otherwise SKIP) +- `weston-smoke` runs for roughly `DURATION` +- Optional: + - Wayland protocol activity validation using `WAYLAND_DEBUG=1` capture + - Screenshot delta validation if screenshot tools exist and permissions allow + +## Parameters (LAVA yaml `params:`) + +- `DURATION` (default `30s`) +- `VALIDATE_WAYLAND_PROTO` (default `1`) +- `VALIDATE_SCREENSHOT` (default `0`) + +## Logs and results + +- `weston-smoke.res` contains `weston-smoke PASS/FAIL/SKIP` +- `weston-smoke_run.log` contains WAYLAND_DEBUG output when protocol validation is enabled +- `weston-smoke_stdout_*.log` contains extra logs (including screenshot helper output) + diff --git a/Runner/suites/Multimedia/Display/weston-smoke/run.sh b/Runner/suites/Multimedia/Display/weston-smoke/run.sh new file mode 100755 index 00000000..83b03d9a --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-smoke/run.sh @@ -0,0 +1,299 @@ +#!/bin/sh +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear +# +# Validate weston-smoke runs under a working Wayland session. +# - Wayland env resolution (adopts socket & fixes XDG_RUNTIME_DIR perms) +# - Optional Wayland protocol validation via WAYLAND_DEBUG capture +# - Optional screenshot-delta validation when tools and permissions allow +# - CI-friendly PASS FAIL SKIP semantics, always exits 0 + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" + +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2 + exit 1 +fi + +if [ -z "${__INIT_ENV_LOADED:-}" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" + __INIT_ENV_LOADED=1 +fi + +# shellcheck disable=SC1091 +. "$TOOLS/functestlib.sh" +# shellcheck disable=SC1091 +. "$TOOLS/lib_display.sh" + +TESTNAME="weston-smoke" +RES_FILE="./${TESTNAME}.res" +RUN_LOG="./${TESTNAME}_run.log" +STDOUT_LOG="./${TESTNAME}_stdout_$(date +%Y%m%d-%H%M%S 2>/dev/null || date +%s).log" + +: >"$RES_FILE" +: >"$RUN_LOG" +: >"$STDOUT_LOG" + +DURATION="${DURATION:-30s}" +STOP_GRACE="${STOP_GRACE:-3s}" +VALIDATE_WAYLAND_PROTO="${VALIDATE_WAYLAND_PROTO:-1}" +VALIDATE_SCREENSHOT="${VALIDATE_SCREENSHOT:-0}" + +log_info "Weston log directory: $SCRIPT_DIR" +log_info "--------------------------------------------------------------------------" +log_info "------------------- Starting ${TESTNAME} Testcase --------------------------" +log_info "Config: DURATION=${DURATION} VALIDATE_WAYLAND_PROTO=${VALIDATE_WAYLAND_PROTO} VALIDATE_SCREENSHOT=${VALIDATE_SCREENSHOT}" + +if command -v detect_platform >/dev/null 2>&1; then + detect_platform +fi + +if command -v display_debug_snapshot >/dev/null 2>&1; then + display_debug_snapshot "pre-display-check" +fi + +if command -v modetest >/dev/null 2>&1; then + log_info "----- modetest -M msm -ac (capped at 200 lines) -----" + modetest -M msm -ac 2>&1 | sed -n '1,200p' | while IFS= read -r l; do + [ -n "$l" ] && log_info "[modetest] $l" + done + log_info "----- End modetest -M msm -ac -----" +else + log_warn "modetest not found in PATH skipping modetest snapshot." +fi + +have_connector=0 +if command -v display_connected_summary >/dev/null 2>&1; then + sysfs_summary=$(display_connected_summary) + if [ -n "$sysfs_summary" ] && [ "$sysfs_summary" != "none" ]; then + have_connector=1 + log_info "Connected display (sysfs): $sysfs_summary" + fi +fi + +if [ "$have_connector" -eq 0 ]; then + log_warn "No connected DRM display found skipping ${TESTNAME}." + echo "${TESTNAME} SKIP" >"$RES_FILE" + exit 0 +fi + +if command -v wayland_debug_snapshot >/dev/null 2>&1; then + wayland_debug_snapshot "${TESTNAME}: start" +fi + +sock="" +if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then + sock=$(discover_wayland_socket_anywhere | head -n 1 || true) +fi + +if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then + log_info "Found existing Wayland socket: $sock" + if ! adopt_wayland_env_from_socket "$sock"; then + log_warn "Failed to adopt env from $sock" + fi +fi + +if [ -z "$sock" ] && command -v overlay_start_weston_drm >/dev/null 2>&1; then + log_info "No usable Wayland socket trying overlay_start_weston_drm helper..." + if command -v weston_force_primary_1080p60_if_not_60 >/dev/null 2>&1; then + log_info "Pre-configuring primary output to ~60Hz before starting Weston best-effort" + weston_force_primary_1080p60_if_not_60 || true + fi + if overlay_start_weston_drm; then + if command -v discover_wayland_socket_anywhere >/dev/null 2>&1; then + sock=$(discover_wayland_socket_anywhere | head -n 1 || true) + fi + if [ -n "$sock" ] && command -v adopt_wayland_env_from_socket >/dev/null 2>&1; then + log_info "Overlay Weston created Wayland socket: $sock" + if ! adopt_wayland_env_from_socket "$sock"; then + log_warn "Failed to adopt env from $sock" + fi + else + log_warn "overlay_start_weston_drm reported success but no Wayland socket was found." + fi + else + log_warn "overlay_start_weston_drm returned non-zero private Weston may have failed to start." + fi +fi + +if [ -z "$sock" ]; then + log_warn "No Wayland socket found after autodetection skipping ${TESTNAME}." + echo "${TESTNAME} SKIP" >"$RES_FILE" + exit 0 +fi + +if command -v wayland_connection_ok >/dev/null 2>&1; then + if ! wayland_connection_ok; then + log_fail "Wayland connection test failed cannot run ${TESTNAME}." + echo "${TESTNAME} SKIP" >"$RES_FILE" + exit 0 + fi + log_info "Wayland connection test: OK" +else + log_warn "wayland_connection_ok helper not found continuing without explicit Wayland probe." +fi + +if command -v weston_force_primary_1080p60_if_not_60 >/dev/null 2>&1; then + log_info "Ensuring primary output is ~60Hz best-effort" + if weston_force_primary_1080p60_if_not_60; then + log_info "Primary output is ~60Hz or was already ~60Hz." + else + log_warn "Unable to force ~60Hz continuing not a hard failure." + fi +else + log_warn "weston_force_primary_1080p60_if_not_60 helper not found skipping ~60Hz enforcement." +fi + +if command -v display_is_cpu_renderer >/dev/null 2>&1; then + if display_is_cpu_renderer auto; then + log_skip "$TESTNAME SKIP: GPU HW acceleration not enabled CPU/software renderer detected" + echo "${TESTNAME} SKIP" >"$RES_FILE" + exit 0 + fi +else + log_warn "display_is_cpu_renderer helper not found continuing without GPU accel gating." +fi + +if ! check_dependencies weston-smoke; then + log_fail "Required binary weston-smoke not found in PATH." + echo "${TESTNAME} FAIL" >"$RES_FILE" + exit 0 +fi + +BIN=$(command -v weston-smoke) +log_info "Using weston-smoke: $BIN" + +shot_begin_rc=2 +if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then + log_info "Screenshot delta validation enabled." + if command -v display_screenshot_delta_begin >/dev/null 2>&1; then + display_screenshot_delta_begin "$TESTNAME" "$SCRIPT_DIR" >>"$STDOUT_LOG" 2>&1 + shot_begin_rc=$? + if [ "$shot_begin_rc" -eq 2 ]; then + log_warn "Screenshot delta requested, tool unavailable or unauthorized skipping screenshot validation." + elif [ "$shot_begin_rc" -ne 0 ]; then + log_warn "Screenshot delta requested, unable to capture before screenshot." + fi + else + log_warn "display_screenshot_delta_begin helper not found skipping screenshot validation." + shot_begin_rc=2 + fi +fi + +log_info "Launching ${TESTNAME} for ${DURATION} ..." + +start_ts=$(date +%s) + +rc=0 +if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + log_info "Wayland protocol validation enabled (WAYLAND_DEBUG=1)." + WAYLAND_DEBUG=1 + export WAYLAND_DEBUG +else + WAYLAND_DEBUG="" + export WAYLAND_DEBUG +fi + +if command -v run_with_timeout >/dev/null 2>&1; then + if command -v stdbuf >/dev/null 2>&1; then + if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + run_with_timeout "$DURATION" stdbuf -oL -eL "$BIN" >>"$RUN_LOG" 2>&1 + else + run_with_timeout "$DURATION" stdbuf -oL -eL "$BIN" >>"$STDOUT_LOG" 2>&1 + fi + else + log_warn "stdbuf not found running $BIN without output re-buffering." + if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + run_with_timeout "$DURATION" "$BIN" >>"$RUN_LOG" 2>&1 + else + run_with_timeout "$DURATION" "$BIN" >>"$STDOUT_LOG" 2>&1 + fi + fi + rc=$? +else + log_warn "run_with_timeout not found using naive sleep+kill fallback." + if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + "$BIN" >>"$RUN_LOG" 2>&1 & + else + "$BIN" >>"$STDOUT_LOG" 2>&1 & + fi + cpid=$! + dur_s=$(printf '%s\n' "$DURATION" | sed -n 's/^\([0-9][0-9]*\)s$/\1/p') + [ -n "$dur_s" ] || dur_s=30 + sleep "$dur_s" + kill "$cpid" 2>/dev/null || true + rc=143 +fi + +end_ts=$(date +%s) +elapsed=$((end_ts - start_ts)) + +log_info "Client finished: rc=${rc} elapsed=${elapsed}s" + +final="PASS" + +if [ "$rc" -ne 0 ] && [ "$rc" -ne 143 ]; then + final="FAIL" +fi + +if [ "$elapsed" -le 1 ]; then + log_fail "Client exited too quickly (elapsed=${elapsed}s) expected ~${DURATION} runtime." + final="FAIL" +fi + +if [ "$VALIDATE_WAYLAND_PROTO" -ne 0 ]; then + if command -v display_wayland_proto_validate >/dev/null 2>&1; then + if display_wayland_proto_validate "$RUN_LOG"; then + log_info "Wayland protocol validation passed." + else + log_fail "Wayland protocol validation failed missing surface/commit evidence in WAYLAND_DEBUG" + final="FAIL" + fi + else + log_warn "display_wayland_proto_validate helper not found skipping protocol validation." + fi +fi + +if [ "$VALIDATE_SCREENSHOT" -ne 0 ]; then + if [ "$shot_begin_rc" -eq 0 ]; then + if command -v display_screenshot_delta_end >/dev/null 2>&1; then + display_screenshot_delta_end "$TESTNAME" >>"$STDOUT_LOG" 2>&1 + src=$? + if [ "$src" -eq 0 ]; then + log_info "Screenshot delta validation passed." + elif [ "$src" -eq 1 ]; then + log_fail "Screenshot delta validation failed screenshots identical." + final="FAIL" + else + log_warn "Screenshot delta validation skipped." + fi + else + log_warn "display_screenshot_delta_end helper not found skipping screenshot validation." + fi + else + log_warn "Screenshot delta validation skipped, before screenshot was not captured." + fi +fi + +log_info "Final decision for ${TESTNAME}: ${final}" + +echo "${TESTNAME} ${final}" >"$RES_FILE" + +if [ "$final" = "PASS" ]; then + log_pass "${TESTNAME} : PASS" + exit 0 +fi + +log_fail "${TESTNAME} : FAIL" +exit 0 diff --git a/Runner/suites/Multimedia/Display/weston-smoke/weston-smoke.yaml b/Runner/suites/Multimedia/Display/weston-smoke/weston-smoke.yaml new file mode 100755 index 00000000..22af3ee9 --- /dev/null +++ b/Runner/suites/Multimedia/Display/weston-smoke/weston-smoke.yaml @@ -0,0 +1,19 @@ +metadata: + name: weston-smoke + format: Lava-Test Test Definition 1.0 + description: "Run weston-smoke under an active Wayland session and validate basic protocol activity" + maintainer: + - "Qualcomm Linux Testkit" + +params: + DURATION: "30s" # Client runtime (default 30s) + STOP_GRACE: "3s" # Reserved for future stop grace (default 3s) + VALIDATE_WAYLAND_PROTO: 1 # 1 enables WAYLAND_DEBUG based protocol validation (default 1) + VALIDATE_SCREENSHOT: 0 # 1 enables screenshot delta when allowed/tools exist (default 0) + +run: + steps: + - REPO_PATH=$PWD + - cd Runner/suites/Multimedia/Display/weston-smoke + - ./run.sh || true + - $REPO_PATH/Runner/utils/send-to-lava.sh weston-smoke.res diff --git a/Runner/utils/functestlib.sh b/Runner/utils/functestlib.sh index af503462..f168f743 100755 --- a/Runner/utils/functestlib.sh +++ b/Runner/utils/functestlib.sh @@ -858,89 +858,143 @@ weston_pids() { echo "$pids" } -# Is Weston running? +# Is Weston running weston_is_running() { [ -n "$(weston_pids)" ] } -# Stop all Weston processes +# Stop all Weston processes, also stop socket activation and instances weston_stop() { + if command -v systemctl >/dev/null 2>&1; then + log_info "Stopping Weston, stopping weston.socket to prevent auto restart" + systemctl stop weston.socket >/dev/null 2>&1 || true + + log_info "Stopping Weston, stopping weston.service" + systemctl stop weston.service >/dev/null 2>&1 || true + + log_info "Stopping Weston, stopping weston@root.service if present" + systemctl stop weston@root.service >/dev/null 2>&1 || true + + # Stop any active weston@*.service instances + units="$(systemctl list-units 'weston@*.service' --no-legend --no-pager 2>/dev/null | awk '{print $1}')" + if [ -n "$units" ]; then + for u in $units; do + log_info "Stopping Weston, stopping instance unit $u" + systemctl stop "$u" >/dev/null 2>&1 || true + done + fi + fi + if weston_is_running; then - log_info "Stopping Weston..." - pkill -x weston - for i in $(seq 1 10); do - log_info "Waiting for Weston to stop with $i attempt " + log_info "Stopping Weston processes" + pkill -TERM -x weston >/dev/null 2>&1 || true + + i=1 + while [ "$i" -le 10 ]; do + log_info "Waiting for Weston to stop, attempt $i of 10" + if ! weston_is_running; then + log_info "Weston stopped successfully" + return 0 + fi + sleep 1 + i=$((i + 1)) + done + + log_warn "Weston still running after grace period, sending SIGKILL" + pkill -KILL -x weston >/dev/null 2>&1 || true + + i=1 + while [ "$i" -le 5 ]; do + log_info "Waiting for Weston to stop after SIGKILL, attempt $i of 5" if ! weston_is_running; then log_info "Weston stopped successfully" return 0 fi sleep 1 + i=$((i + 1)) done - log_error "Failed to stop Weston after waiting." + + log_error "Failed to stop Weston completely" return 1 - else - log_info "Weston is not running." fi + + log_info "Weston is not running" return 0 } # Start weston with correct env if not running weston_start() { if weston_is_running; then - log_info "Weston already running." + log_info "Weston already running" return 0 fi - + if command -v systemctl >/dev/null 2>&1; then - log_info "Attempting to start via systemd: weston.service" + log_info "Attempting to start Weston, enabling weston.socket if available" + systemctl start weston.socket >/dev/null 2>&1 || true + sleep 1 + + log_info "Attempting to start Weston via weston.service" systemctl start weston.service >/dev/null 2>&1 || true sleep 1 if weston_is_running; then - log_info "Weston started via systemd (weston.service)." + log_info "Weston started via weston.service" return 0 fi - - log_info "Attempting to start via systemd: weston@.service" - systemctl start weston@.service >/dev/null 2>&1 || true + + log_info "Attempting to start Weston via weston@root.service" + systemctl start weston@root.service >/dev/null 2>&1 || true sleep 1 if weston_is_running; then - log_info "Weston started via systemd (weston@.service)." + log_info "Weston started via weston@root.service" return 0 fi - - log_warn "systemd start did not bring Weston up; will try direct spawn." + + # Try one enabled weston@ instance if any exists + enabled_unit="$(systemctl list-unit-files 'weston@*.service' --no-legend --no-pager 2>/dev/null | awk '$2=="enabled"{print $1; exit}')" + if [ -n "$enabled_unit" ]; then + log_info "Attempting to start Weston via enabled instance $enabled_unit" + systemctl start "$enabled_unit" >/dev/null 2>&1 || true + sleep 1 + if weston_is_running; then + log_info "Weston started via instance $enabled_unit" + return 0 + fi + fi + + log_warn "systemd start did not bring Weston up, trying direct spawn" fi - - # Minimal-friendly direct spawn (no headless module guesses here). + + # Minimal-friendly direct spawn ensure_xdg_runtime_dir - + if ! command -v weston >/dev/null 2>&1; then - log_fail "weston binary not found in PATH." + log_fail "weston binary not found in PATH" return 1 fi - - log_info "Attempting to spawn Weston (no backend override). Log: /tmp/weston.self.log" + + log_info "Spawning Weston directly, log file is /tmp/weston.self.log" ( nohup weston --log=/tmp/weston.self.log >/dev/null 2>&1 & ) || true - + tries=0 - while [ $tries -lt 5 ]; do + while [ "$tries" -lt 8 ]; do if weston_is_running; then - log_info "Weston is now running (PID(s): $(weston_pids))." + log_info "Weston is now running, PID list is $(weston_pids)" return 0 fi - if [ -n "$(find_wayland_sockets | head -n1)" ]; then - log_info "A Wayland socket appeared after spawn." + if [ -n "$(find_wayland_sockets 2>/dev/null | head -n 1)" ]; then + log_info "Wayland socket appeared after spawn" return 0 fi sleep 1 - tries=$((tries+1)) + tries=$((tries + 1)) done - + if [ -f /tmp/weston.self.log ]; then - log_warn "Weston spawn failed; last log lines:" + log_warn "Weston spawn failed, last log lines follow" tail -n 20 /tmp/weston.self.log 2>/dev/null | sed 's/^/[weston.log] /' || true else - log_warn "Weston spawn failed; no log file present." + log_warn "Weston spawn failed, no log file present" fi return 1 } diff --git a/Runner/utils/lib_display.sh b/Runner/utils/lib_display.sh index 1e10ff14..40ba5509 100755 --- a/Runner/utils/lib_display.sh +++ b/Runner/utils/lib_display.sh @@ -1411,3 +1411,181 @@ display_is_cpu_renderer() { ;; esac } + +############################################################################### +# Wayland protocol validation (client-side) +############################################################################### +# Validate that the client actually created a surface and committed buffers. +# Expects WAYLAND_DEBUG output in the provided logfile. +# +# Usage: +# display_wayland_proto_validate "/path/to/run.log" +# Returns: +# 0 = looks good (surface + commit seen) +# 1 = missing required evidence +display_wayland_proto_validate() { + logf="${1:-}" + [ -n "$logf" ] && [ -f "$logf" ] || return 1 + + # Accept both wl_compositor@X and wl_compositor#X formats + # Accept commit() with or without parentheses in logs + if grep -Eq 'wl_compositor[@#][0-9]+\.create_surface' "$logf" && + grep -Eq 'wl_surface[@#][0-9]+\.commit' "$logf"; then + return 0 + fi + + return 1 +} + +############################################################################### +# Screenshot capture + delta validation +############################################################################### +# Uses weston-screenshooter when available. +# If the compositor rejects capture (unauthorized / protocol failure), +# treat it as "not available" so tests do not FAIL due to policy. +# +# Returns convention: +# 0 = success +# 1 = tool exists but capture failed +# 2 = tool not available or not permitted (unauthorized / protocol failure) + +display_screenshot_tool() { + if command -v weston-screenshooter >/dev/null 2>&1; then + echo "weston-screenshooter" + return 0 + fi + return 1 +} + +display_take_screenshot() { + out="${1:-}" + [ -n "$out" ] || return 1 + + tool="$(display_screenshot_tool 2>/dev/null || true)" + [ -n "$tool" ] || return 2 + + tmp_log="$(mktemp /tmp/weston_shot_XXXXXX.log 2>/dev/null || true)" + [ -n "$tmp_log" ] || tmp_log="/tmp/weston_shot.log" + + rc=0 + case "$tool" in + weston-screenshooter) + # capture stdout+stderr to inspect authorization failures + weston-screenshooter "$out" >"$tmp_log" 2>&1 || rc=$? + ;; + *) + rm -f "$tmp_log" 2>/dev/null || true + return 2 + ;; + esac + + # If compositor rejects capture, treat as "not permitted" (skip) + if grep -qiE 'unauthorized|protocol failure' "$tmp_log" 2>/dev/null; then + rm -f "$tmp_log" 2>/dev/null || true + rm -f "$out" 2>/dev/null || true + return 2 + fi + + rm -f "$tmp_log" 2>/dev/null || true + + [ "$rc" -eq 0 ] || return 1 + [ -s "$out" ] || return 1 + return 0 +} + +display_hash_file() { + f="${1:-}" + [ -n "$f" ] && [ -f "$f" ] || return 1 + + if command -v sha256sum >/dev/null 2>&1; then + sha256sum "$f" | awk '{print $1}' + return 0 + fi + if command -v md5sum >/dev/null 2>&1; then + md5sum "$f" | awk '{print $1}' + return 0 + fi + return 1 +} + +# Begin screenshot-delta session (captures "before" shot). +# Usage: +# display_screenshot_delta_begin "testname" "/path/to/outdir" +# Side effects: +# sets DISPLAY_SHOT_BEFORE and DISPLAY_SHOT_DIR +# Returns: +# 0 ok +# 2 tool missing or not permitted +# 1 capture failed +display_screenshot_delta_begin() { + tn="${1:-weston-test}" + od="${2:-.}" + + ts="$(date +%Y%m%d_%H%M%S 2>/dev/null || date +%s)" + DISPLAY_SHOT_DIR="$od" + DISPLAY_SHOT_BEFORE="${od}/${tn}_before_${ts}.png" + + rc=0 + display_take_screenshot "$DISPLAY_SHOT_BEFORE" || rc=$? + + if [ "$rc" -eq 0 ]; then + log_info "Screenshot before captured: $DISPLAY_SHOT_BEFORE" + return 0 + fi + + if [ "$rc" -eq 2 ]; then + log_warn "Screenshot tool not available or not permitted skipping screenshot delta validation" + DISPLAY_SHOT_BEFORE="" + return 2 + fi + + log_warn "Failed to capture screenshot before skipping screenshot delta validation" + DISPLAY_SHOT_BEFORE="" + return 1 +} + +# End screenshot-delta session (captures "after" and compares hash). +# Usage: +# display_screenshot_delta_end "testname" +# Returns: +# 0 changed (PASS) +# 1 identical (FAIL) +# 2 not available or skipped +display_screenshot_delta_end() { + tn="${1:-weston-test}" + [ -n "${DISPLAY_SHOT_BEFORE:-}" ] || return 2 + + od="${DISPLAY_SHOT_DIR:-.}" + ts="$(date +%Y%m%d_%H%M%S 2>/dev/null || date +%s)" + after="${od}/${tn}_after_${ts}.png" + + rc=0 + display_take_screenshot "$after" || rc=$? + + if [ "$rc" -eq 2 ]; then + log_warn "Screenshot tool not available or not permitted skipping screenshot delta validation" + return 2 + fi + if [ "$rc" -ne 0 ]; then + log_warn "Failed to capture screenshot after skipping screenshot delta validation" + return 2 + fi + + log_info "Screenshot after captured: $after" + + h1="$(display_hash_file "$DISPLAY_SHOT_BEFORE" 2>/dev/null || true)" + h2="$(display_hash_file "$after" 2>/dev/null || true)" + + if [ -z "$h1" ] || [ -z "$h2" ]; then + log_warn "Could not hash screenshots skipping screenshot delta validation" + return 2 + fi + + if [ "$h1" = "$h2" ]; then + log_warn "Screenshot delta check identical no visible change detected" + return 1 + fi + + log_info "Screenshot delta check changed visual validation OK" + return 0 +}