Merged
feat: 支持ets_utils在Linux主机编译和运行单元测试 #2693
feat: 支持ets_utils在Linux主机编译和运行单元测试 #2693
Merged
jizaiyiAdd on Oct 19
jizaiyi
jizaiyi
Oct 19

一:关联的Issue

https://gitcode.com/openharmony/commonlibrary_ets_utils/issues/2523

二:修改原因

ets_utils 单元测试此前仅支持设备侧(rk3568 推文件)方式执行,无法在 linux 主机(host toolchain)上直接编译和运行,本地验证效率低。

三:修改描述

  • 新增 host UT 入口:根 BUILD.gn 新增 ets_utils_host_unittest 组(testonly,host_os == "linux" 时聚合 13 个 ($host_toolchain) 测试目标),并注册进 bundle.json test 列表
  • 新增 ets_utils_host_test.gni:ets_utils_host_test_bridge 模板,利用 public_configs 追加顺序使 host 专属编译选项(-Wno-unused-variable 等)在默认编译配置之后生效
  • 各模块 *_static 与测试目标增加 host 分支:追加 LINUX_PLATFORM/PREVIEW/ETS_UTILS_HOST_UT 宏,剥离 host 不可用依赖(c_utils/hitrace/ability_manager/libhicollie/icu/libbegetutil/qos_manager)
  • SDK 分支收窄与依赖规范化:console/timer/taskpool/worker/utils 共享库的 libhilog_linux 分支收窄为额外要求 product_name == "ohos-sdk";并将 console/timer 的 libhilog_linux 从 deps 改为 external_deps += [ "innerkits:libhilog_linux" ],与 taskpool/worker/utils 写法对齐(部件间依赖须使用 external_deps)
  • 源码 host 隔离:ETS_UTILS_HOST_UT 使 hitrace_helper.h 宏变为 no-op、跳过 app_image_observer/快照逻辑与 SetDebuggerPostTaskFunc;js_childprocess.cpp 对 bionic 专属 fdsan 做 LINUX_PLATFORM 降级
  • 补齐 host libstdc++ 下缺失的标准库头(atomic/algorithm/cstdint/mutex/limits/vector/iomanip)
  • 测试适配:std::latch C++20 兼容 shim;修复 PendingSharedRequestAfterGC flaky(有界泵循环);修复 taskpool 测试 isHandleInited_ 恢复与 TaskpoolTest135 重复删除;worker 测试宏与库对齐(ENABLE_WORKER_EVENTHANDLER/ENABLE_QOS)
  • 4 个文件 CRLF→LF 行尾归一化(worker.cpp/worker.h/js_process.cpp/concurrent_helper.cpp)

本 PR 修改内容基于 !2691(master 无新提交),并按检视意见额外调整:console/timer 的 libhilog_linux 从 deps 改为 external_deps(与 taskpool/worker/utils 对齐),仅调整 ohos-sdk 分支内的依赖声明方式;删除 13 个 host UT 测试目标 defines 中冗余的 PREVIEW 声明(linux host 工具链下该宏已由 napi 部件的 public ace_napi_config 传播提供,测试二进制的宏集合不变)。以上改动均不影响任何已验证的构建路径。

四:兼容性领域分析

不涉及。所有源码改动均限定在 host 工具链条件分支或 ETS_UTILS_HOST_UT 宏内,设备侧编译产物与运行时行为不变;测试侧宏对齐仅影响测试二进制。

五:CheckList(必填项)

1. 接口功能自检

  • rk3568 推UT文件执行(影响功能的必须执行)
  • xts测试套执行(影响功能的必须执行)

说明:代码主体与 !2691 已验证状态一致(host 13 套件 2074/2074 通过,rk3568 部件构建与全部设备 UT 目标重建通过);额外改动仅为 ohos-sdk 分支内 deps→external_deps 的声明方式调整,不影响上述任何构建路径。本 PR 为构建/测试基础设施变更,不改设备侧运行时逻辑。

2. 解决问题分类自检 (基于问题维度自检)

3. 接口功能用例看护自检(基于修改的功能点自检)

4. 稳定性专项自检(非Test代码必须执行)

  • 用例验证,门禁构建镜像启动一遍所有应用,无相关的异常出现

5. 压测专项自检

  • 压测填表验证,无相关的异常出现

6. 并发专项自检(taskpool/worker改动必须执行)

说明:taskpool/worker 目录改动均为 host 工具链条件分支、行尾归一化与测试宏对齐,设备侧编译产物与运行时行为不变,并发压测场景不涉及;图库/备忘录/畅连/游戏/48小时压测项均不涉及。

  • wukong压测2小时验证(非Test代码需要)
  • 线程泄露测试(修改涉及线程生命周期需要,执行命令 ps -AT|grep pid|grep OS_TaskWorker|wc -l)

7. 需求上库自检

  • 是否同步合入interface仓的相关d.ts(需求合入用同一个issue)

是否已执行L0用例

六:将上述测试的截图贴到下面

不涉及(无设备侧功能验证项;host UT 执行记录可按需补充)

likedislike
Pull Request has been successfully merged by openharmony_ci.
(Thank you for jizaiyi's contribution.)
jizaiyijizaiyi
Oct 19 Associated issue: [Bug]: 支持ets_utils在linux主机平台编译和运行单元测试
openharmony_ciopenharmony_ciCollaborators
Oct 19 Added label: waiting_on_author
openharmony_ci
openharmony_ciCollaborators
Oct 19 Comments:

感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接。


Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
openharmony_ciopenharmony_ciCollaborators
Oct 19 Added label: dco检查成功
jizaiyijizaiyi
Oct 19 Force-pushed 1 commits:cdde9b15-Support linux host UT for ets_utils
43 messages are collapsed here。 See more
openharmony_ci
openharmony_ciCollaborators
Oct 27 Comments:

您好,Committer @weng-changcheng @xliu-huanwei @gong_19901 ,请分配检视人员检视该PR,可以通过命令"assign [@someone_id]"分配检视人员,也可以直接评论"assign"分配给自己进行检视。


Hello, Committer @weng-changcheng @xliu-huanwei @gong_19901 . Please assign someone to review the PR. You can assign a reviewer by using the command "assign [@someone_id]", or you can comment "assign" to review the PR by yourself.

likedislike
openharmony_ciopenharmony_ciCollaborators
Oct 27 Closed associated issue
openharmony_ciopenharmony_ciCollaborators
Oct 27 Merged pull request, merge node SHA: 311a34d88eaa569a051656a8250501f676226c07
openharmony_ciopenharmony_ciCollaborators
Oct 27 Removed label: waiting_for_review
openharmony_ciopenharmony_ciCollaborators
Oct 27 Added label: merged