From 990b42ff2f39b94d0c4aeb67fd6c3e27595c950e Mon Sep 17 00:00:00 2001 From: PiliLily Date: Sat, 8 Aug 2026 13:08:03 +0000 Subject: [PATCH 1/3] test: aggregate all risk inspection results Signed-off-by: PiliLily --- tests/risk-inspection/run_risk_autotests.sh | 48 ++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/tests/risk-inspection/run_risk_autotests.sh b/tests/risk-inspection/run_risk_autotests.sh index 0e960ed..94572a8 100755 --- a/tests/risk-inspection/run_risk_autotests.sh +++ b/tests/risk-inspection/run_risk_autotests.sh @@ -11,6 +11,10 @@ PROJECT_DIR="$(cd "$(dirname "$0")/../.." && pwd)" BUILD_DIR="${BUILD_DIR:-$PROJECT_DIR/build-risk-inspection}" RESULTS_DIR="$PROJECT_DIR/results/risk-inspection" LOG_FILE="$RESULTS_DIR/risk-autotests-$(date +%Y%m%d-%H%M%S).log" +TOTAL_COUNT=0 +PASS_COUNT=0 +FAIL_COUNT=0 +FAILED_TESTS=() mkdir -p "$RESULTS_DIR" exec > >(tee -a "$LOG_FILE") 2>&1 @@ -29,13 +33,43 @@ check_binary() { run() { local title="$1" + local status shift echo echo "============================================================" echo "正在执行:$title" - echo "执行命令:$*" + printf "执行命令:" + printf " %q" "$@" + echo + echo "============================================================" + + TOTAL_COUNT=$((TOTAL_COUNT + 1)) + if "$@"; then + PASS_COUNT=$((PASS_COUNT + 1)) + echo ">>> [PASS] $title" + else + status=$? + FAIL_COUNT=$((FAIL_COUNT + 1)) + FAILED_TESTS+=("$title (exit $status)") + echo ">>> [FAIL] $title (exit $status)" + fi +} + +print_summary() { + local failed + + echo + echo "============================================================" + echo "风险测试汇总" + echo "总计: $TOTAL_COUNT 通过: $PASS_COUNT 失败: $FAIL_COUNT" + if [[ "$FAIL_COUNT" -gt 0 ]]; then + echo "失败项:" + for failed in "${FAILED_TESTS[@]}"; do + echo " - $failed" + done + fi + echo "日志文件: $LOG_FILE" echo "============================================================" - "$@" } echo ">>> 项目目录: $PROJECT_DIR" @@ -93,6 +127,10 @@ run "补充验证:共享引擎组件异常输入安全性" \ run "补充验证:共享引擎视图异常输入安全性" \ "$BUILD_DIR/core/autotest/test-shared-engine-view" -txt -echo -echo ">>> 全部风险相关自动化测试执行完成" -echo ">>> 日志文件已保存到:$LOG_FILE" +print_summary + +if [[ "$FAIL_COUNT" -gt 0 ]]; then + exit 1 +fi + +echo ">>> 全部风险相关自动化测试通过" -- Gitee From fe081e8b66b08922d24f2a185bafee186c78c56b Mon Sep 17 00:00:00 2001 From: PiliLily Date: Sat, 8 Aug 2026 13:08:17 +0000 Subject: [PATCH 2/3] test: run risk checks from existing build script Signed-off-by: PiliLily --- tests/risk-inspection/build_risk_test_binaries.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/risk-inspection/build_risk_test_binaries.sh b/tests/risk-inspection/build_risk_test_binaries.sh index 1d4d2ef..58ee23e 100755 --- a/tests/risk-inspection/build_risk_test_binaries.sh +++ b/tests/risk-inspection/build_risk_test_binaries.sh @@ -14,6 +14,7 @@ BUILD_DIR="$PROJECT_DIR/build-risk-inspection" JOBS="$(command -v nproc >/dev/null 2>&1 && nproc || echo 4)" INSTALL_DEPS="auto" CLEAN_BUILD="no" +RUN_TESTS="no" usage() { cat <<'EOF' @@ -28,11 +29,13 @@ usage() { --clean 清理旧的 build-risk-inspection 后重新构建 --build-dir PATH 指定构建目录,默认 build-risk-inspection --jobs N 指定并行编译数,默认 nproc + --run-tests 编译成功后运行全部风险测试并生成汇总日志 -h, --help 显示帮助 示例: bash tests/risk-inspection/build_risk_test_binaries.sh --clean bash tests/risk-inspection/build_risk_test_binaries.sh --install-deps no + bash tests/risk-inspection/build_risk_test_binaries.sh --clean --run-tests EOF } @@ -109,6 +112,10 @@ while [[ $# -gt 0 ]]; do JOBS="${2:-}" shift 2 ;; + --run-tests) + RUN_TESTS="yes" + shift + ;; -h|--help) usage exit 0 @@ -194,3 +201,10 @@ print_binary "$BUILD_DIR/platform/test/platform-test" print_binary "$BUILD_DIR/modules/window-thumbnail/core/test/thumbnail-item-test" echo ">>> 风险检查二进制准备完成" + +if [[ "$RUN_TESTS" == "yes" ]]; then + echo ">>> 开始执行风险测试..." + BUILD_DIR="$BUILD_DIR" \ + RESULTS_DIR="$BUILD_DIR/risk-inspection-results" \ + bash "$PROJECT_DIR/tests/risk-inspection/run_risk_autotests.sh" +fi -- Gitee From c66c6455a080a3a4901c930024b2c603a6071707 Mon Sep 17 00:00:00 2001 From: PiliLily Date: Sat, 8 Aug 2026 13:08:35 +0000 Subject: [PATCH 3/3] docs: document risk inspection workflow Signed-off-by: PiliLily --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index a35f887..cb6b3c8 100644 --- a/README.md +++ b/README.md @@ -449,5 +449,20 @@ core,items和framework模块都有使用platform提供的功能。 ### [widgets](widgets) 为ukui-quick插件框架开发的一些插件或qml模块库。 +### 风险检查测试 + +`tests/risk-inspection` 提供 widget 加载、设置与 D-Bus 降级、窗口管理和窗口预览等高风险路径的批量测试入口。在 Debian/openKylin 环境中可以从仓库根目录运行: + +```bash +bash tests/risk-inspection/build_risk_test_binaries.sh \ + --clean \ + --install-deps no \ + --run-tests +``` + +脚本会使用独立的 `build-risk-inspection` 构建目录,执行全部 15 组测试,并把汇总日志写入 `build-risk-inspection/risk-inspection-results/`。如果任一测试失败,runner 仍会执行后续测试,最后列出失败项并返回非零状态。 + +在一次性 Debian/openKylin 构建环境中以 root 运行时,可以使用 `--install-deps yes` 安装依赖;普通开发环境建议先自行安装依赖并使用 `--install-deps no`。 + ### 其他 截止目前,ukui-quick仍在快速迭代中,文档相对来说不是那么完善。想要参与ukui-quick的开发,可以通过提交issue或PR与我们进行交流。 -- Gitee