Skip to content

Commit ef79589

Browse files
committed
graphics: kmscube — fix binary check, robust frame parsing, and Weston handling
- Use 'check_dependencies kmscube' (not 'KMSCube') to avoid false SKIPs. - Run from the testcase dir; write ./KMSCube.res next to run.sh. - If Weston is running, stop it; run kmscube headless on DRM; relaunch Weston. - Parse 'Rendered N frames' and accept N or N-1 for leniency. - Support FRAME_COUNT override; log to KMSCube_run.log. - CI-friendly PASS/FAIL/SKIP and clearer logs. Signed-off-by: Srikanth Muppandam <[email protected]>
1 parent d31f4c5 commit ef79589

File tree

1 file changed

+67
-20
lines changed
  • Runner/suites/Multimedia/Graphics/KMSCube

1 file changed

+67
-20
lines changed

Runner/suites/Multimedia/Graphics/KMSCube/run.sh

Lines changed: 67 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
33
# SPDX-License-Identifier: BSD-3-Clause-Clear
44

5-
# KMSCube Validator Script (Yocto-Compatible)
5+
# KMSCube Validator Script (Yocto-Compatible, POSIX sh)
6+
7+
# --- Robustly find and source init_env ---------------------------------------
68
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
79
INIT_ENV=""
810
SEARCH="$SCRIPT_DIR"
@@ -19,56 +21,101 @@ if [ -z "$INIT_ENV" ]; then
1921
exit 1
2022
fi
2123

24+
# Only source once (idempotent)
2225
if [ -z "$__INIT_ENV_LOADED" ]; then
2326
# shellcheck disable=SC1090
2427
. "$INIT_ENV"
2528
fi
2629

30+
# Always source functestlib.sh, using $TOOLS exported by init_env
2731
# shellcheck disable=SC1090,SC1091
2832
. "$TOOLS/functestlib.sh"
2933

34+
# --- Test metadata -----------------------------------------------------------
3035
TESTNAME="KMSCube"
31-
FRAME_COUNT=999
32-
EXPECTED_FRAMES=$((FRAME_COUNT - 1))
33-
test_path=$(find_test_case_by_name "$TESTNAME")
36+
FRAME_COUNT="${FRAME_COUNT:-999}" # allow override via env
37+
EXPECTED_MIN=$((FRAME_COUNT - 1)) # tolerate off-by-one under-reporting
38+
39+
# Ensure we run from the testcase directory so .res/logs land next to run.sh
40+
test_path="$(find_test_case_by_name "$TESTNAME")"
3441
cd "$test_path" || exit 1
42+
3543
RES_FILE="./$TESTNAME.res"
3644
LOG_FILE="./${TESTNAME}_run.log"
3745
rm -f "$RES_FILE" "$LOG_FILE"
3846

3947
log_info "-------------------------------------------------------------------"
4048
log_info "------------------- Starting $TESTNAME Testcase -------------------"
4149

42-
if check_dependencies "$TESTNAME"; then
43-
log_fail "$TESTNAME : kmscube binary not found"
44-
echo "$TESTNAME SKIP" > "$RES_FILE"
45-
exit 1
50+
# --- Dependencies ------------------------------------------------------------
51+
# Note: check_dependencies returns 0 when present, non-zero if missing.
52+
check_dependencies kmscube || {
53+
log_skip "$TESTNAME SKIP: missing dependencies: kmscube"
54+
echo "$TESTNAME SKIP" >"$RES_FILE"
55+
exit 0
56+
}
57+
KMSCUBE_BIN="$(command -v kmscube 2>/dev/null || true)"
58+
log_info "Using kmscube: ${KMSCUBE_BIN:-<not found>}"
59+
60+
# --- Basic DRM availability guard -------------------------------------------
61+
set -- /dev/dri/card* 2>/dev/null
62+
if [ ! -e "$1" ]; then
63+
log_skip "$TESTNAME SKIP: no /dev/dri/card* nodes"
64+
echo "$TESTNAME SKIP" >"$RES_FILE"
65+
exit 0
4666
fi
4767

68+
# --- If Weston is running, stop it so KMS has control ------------------------
4869
weston_was_running=0
4970
if weston_is_running; then
5071
weston_stop
5172
weston_was_running=1
5273
fi
5374

54-
log_info "Running kmscube test with --count=$FRAME_COUNT..."
55-
if kmscube --count="$FRAME_COUNT" > "$LOG_FILE" 2>&1; then
56-
if grep -q "Rendered $EXPECTED_FRAMES frames" "$LOG_FILE"; then
57-
log_pass "$TESTNAME : Test Passed"
58-
echo "$TESTNAME PASS" > "$RES_FILE"
59-
else
60-
log_fail "$TESTNAME : Expected output not found (Rendered $EXPECTED_FRAMES frames)"
61-
echo "$TESTNAME FAIL" > "$RES_FILE"
62-
exit 1
75+
# --- Execute kmscube ---------------------------------------------------------
76+
log_info "Running kmscube with --count=${FRAME_COUNT} ..."
77+
if kmscube --count="${FRAME_COUNT}" >"$LOG_FILE" 2>&1; then :; else
78+
rc=$?
79+
log_fail "$TESTNAME : Execution failed (rc=$rc) — see $LOG_FILE"
80+
echo "$TESTNAME FAIL" >"$RES_FILE"
81+
if [ "$weston_was_running" -eq 1 ]; then
82+
log_info "Restarting Weston after failure"
83+
weston_start
6384
fi
85+
exit 1
86+
fi
87+
88+
# --- Parse 'Rendered N frames' (case-insensitive), use the last N -----------
89+
FRAMES_RENDERED="$(
90+
awk 'BEGIN{IGNORECASE=1}
91+
/Rendered[[:space:]][0-9]+[[:space:]]+frames/{
92+
# capture the numeric token on that line; remember the last match
93+
for(i=1;i<=NF;i++) if ($i ~ /^[0-9]+$/) n=$i
94+
last=n
95+
}
96+
END{if (last!="") print last}' "$LOG_FILE"
97+
)"
98+
[ -n "$FRAMES_RENDERED" ] || FRAMES_RENDERED=0
99+
[ "$EXPECTED_MIN" -lt 0 ] && EXPECTED_MIN=0
100+
log_info "kmscube reported: Rendered ${FRAMES_RENDERED} frames (requested ${FRAME_COUNT}, min acceptable ${EXPECTED_MIN})"
101+
102+
# --- Verdict -----------------------------------------------------------------
103+
if [ "$FRAMES_RENDERED" -ge "$EXPECTED_MIN" ]; then
104+
log_pass "$TESTNAME : PASS"
105+
echo "$TESTNAME PASS" >"$RES_FILE"
64106
else
65-
log_fail "$TESTNAME : Execution failed (non-zero exit code)"
66-
echo "$TESTNAME FAIL" > "$RES_FILE"
107+
log_fail "$TESTNAME : FAIL (rendered ${FRAMES_RENDERED} < ${EXPECTED_MIN})"
108+
echo "$TESTNAME FAIL" >"$RES_FILE"
109+
if [ "$weston_was_running" -eq 1 ]; then
110+
log_info "Restarting Weston after failure"
111+
weston_start
112+
fi
67113
exit 1
68114
fi
69115

116+
# --- Restore Weston if we stopped it -----------------------------------------
70117
if [ "$weston_was_running" -eq 1 ]; then
71-
log_info "weston realuching after $TESTNAME completion"
118+
log_info "Restarting Weston after $TESTNAME completion"
72119
weston_start
73120
fi
74121

0 commit comments

Comments
 (0)