Files
redrsoe2100 e2e680831c fix: add executable permission bit for all 3963 .sh test scripts
All .sh files under tests/ lacked the Git executable permission bit
(100644 instead of 100755), causing tmt run to fail with 'permission
denied' errors on Linux servers.

Fixes: woqidaideshi/openruyi-autotest#80
2026-07-06 14:36:45 +08:00

111 lines
3.3 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# library-prefix = realtime
#
# Kernel Realtime suite-level shared library
# Reuses LTP installation from functional/ltp/lib.sh
# Uses flag-file + reference counting for suite-level setup/cleanup.
#
# Usage in each test file:
# . "$(dirname "$0")/../lib.sh" # from test_realtime_*/ subdirectories
# Reuse LTP setup/cleanup from functional/ltp suite
. "$(dirname "${BASH_SOURCE[0]}")/../../ltp/lib.sh"
REALTIME_FLAG="/tmp/.beakerlib_realtime_suite"
# Run a single LTP Realtime functional test via run.sh
# Pass / Fail / Skip are mapped to tmt result states.
#
# Result determination (in order):
# 1. Timeout (rc=137) → FAIL
# 2. Non-zero exit code → FAIL
# 3. "Result: FAIL" in output → FAIL
# 4. Build errors (make: ***, Permission denied for ld/compiler) → FAIL
# 5. "test appears to have completed" in output → PASS
# 6. Otherwise → FAIL (unknown result)
#
# Usage: _realtimeRunCase <func_name>
_realtimeRunCase() {
local func="$1"
local out="/tmp/realtime_out_$$"
if [ ! -x "$LTP_INSTALL_DIR/testcases/realtime/run.sh" ]; then
rlFail "LTP Realtime runner not found ($LTP_INSTALL_DIR/testcases/realtime/run.sh)"
return 1
fi
cd "$LTP_INSTALL_DIR" 2>/dev/null || true
timeout --signal=KILL --kill-after=10 600 \
./testcases/realtime/run.sh -t "func/$func" 2>&1 | tee "$out"
local rc=${PIPESTATUS[0]}
# 1. Timeout
if [ "$rc" -eq 137 ]; then
rlFail "LTP Realtime $func 执行超时(被 kill"
rm -f "$out"
return 1
fi
# 2. Non-zero exit code
if [ "$rc" -ne 0 ]; then
rlFail "LTP Realtime $func 执行失败 (exit=$rc)"
rm -f "$out"
return 1
fi
# 3. Explicit failure marker from LTP
if grep -q "Result: FAIL" "$out"; then
rlFail "LTP Realtime $func 测试失败 (Result: FAIL)"
rm -f "$out"
return 1
fi
# 4. Build errors — test couldn't compile, results are invalid
if grep -qE 'make: \*\*\*|cannot open output file.*Permission denied' "$out"; then
rlFail "LTP Realtime $func 编译失败(权限不足或构建错误)"
rm -f "$out"
return 1
fi
# 5. Explicit success marker from LTP
if grep -q "test appears to have completed" "$out"; then
rlPass "LTP Realtime $func 测试通过"
rm -f "$out"
return 0
fi
# 6. Unknown result — not safe to assume pass
rlFail "LTP Realtime $func 结果未知(缺少 pass/fail 标记)"
rm -f "$out"
return 1
}
realtimeSetup() {
# Reuse LTP setup from functional/ltp suite
ltpSetup
if [ ! -f "$REALTIME_FLAG" ]; then
echo "ref=1" > "$REALTIME_FLAG"
else
local ref
ref=$(grep "^ref=" "$REALTIME_FLAG" | cut -d= -f2)
ref=$((ref + 1))
sed -i "s/^ref=.*/ref=$ref/" "$REALTIME_FLAG"
fi
rlCleanupAppend "realtimeCleanup"
}
realtimeCleanup() {
if [ ! -f "$REALTIME_FLAG" ]; then return 0; fi
local ref
ref=$(grep "^ref=" "$REALTIME_FLAG" | cut -d= -f2)
ref=$((ref - 1))
if [ "$ref" -le 0 ]; then
rm -f "$REALTIME_FLAG"
rlLogInfo "Realtime 测试套清理完成"
else
sed -i "s/^ref=.*/ref=$ref/" "$REALTIME_FLAG"
rlLogInfo "Realtime 保留(还有 $ref 个测试未完成)"
fi
}