移植案例与原理 – XTS子系统之应用兼容性测试套件之一

​想了解更多内容,请访问:​

​51CTO和华为官方合作共建的鸿蒙技术社区​

​https://harmonyos.51cto.com​

XTS(X Test Suite)子系统是OpenHarmony生态认证测试套件的集合,当前包括:

  • acts(application compatibility test suite)应用兼容性测试套件,看护北向HAP兼容、OpenHarmony开发API兼容。
  • hats(Hardware Abstraction Test Suite )硬件抽象测试套,看护HDI层接口。
  • dcts(Distributed Compatibility Test Suite )分布式兼容性测试套,看护分布式兼容(待上线)

本文主要通过实例分析下ACTS应用兼容性测试套件移植案例,以及移植过程中特定的操作的原理。主要讲述的是轻量系统兼容性测试。轻量系统因系统能力限制,兼容性测试在系统初始化阶段进行;并且各设备烧录工具存在差异,导致自动化工具(xDevice工具)无法实现真正的自动适配,因此认证执行方式不对合作伙伴进行限制。流程如下:

步骤1 编译适配:XTS子系统加入到编译组件中,随版本一起编译;

步骤2 本地执行:完成兼容性测试;

1、编译适配XTS子系统

1.1 产品解决方案适配

需要在产品解决方案配置文件中增加增加xts_acts与xts_tools组件定义。下面看几个示例,文件vendorbestechnicxts_democonfig.json中的配置片段:

   {
"subsystem": "xts",
"components": [
{ "component": "xts_acts", "features":
[
"config_ohos_xts_acts_utils_lite_kv_store_data_path = "/data"",
"enable_ohos_test_xts_acts_use_thirdparty_lwip = true"
]
},
{ "component": "xts_tools", "features":[] }
]
}

文件vendorgoodixgr5515_sk_xts_democonfig.json中的配置片段:

    {
"subsystem": "xts",
"components": [
{ "component": "xts_acts", "features":
[
"config_ohos_xts_acts_utils_lite_kv_store_data_path = "/data""
]
},
{ "component": "xts_tools", "features":[] }
]
},

1.2 编译链接

需要通过链接选项指定需要链接的ACTS的部件编译库文件,会使用到 –whole-archive 和 –no-whole-archive这2个ld链接选项。–whole-archive 可以把 在其后面出现的静态库包含的函数和变量输出到动态库,–no-whole-archive 则关掉这个特性。在文件vendorgoodixgr5515_sk_xts_demoBUILD.gn中,对ACTS的编译文件进行链接。其中⑴到⑵处的链接选项为编译出的属于ACTS的组件测试库文件。

   executable("${fw_img_name}.elf") {
deps = [
"tests:drivers",
"tests:fs_test",
"tests:ohosdemo",
"tests:shell_test",
"//build/lite:ohos",
]

ldflags = [
"-Wl,--whole-archive",
# "-lfs_test",
# "-ldrivers_test",
# "-lapp_hello",
"-lshell_test",
"-lhctest",
"-lmodule_ActsBootstrapTest",
"-lmodule_ActsWifiIotTest",
"-lmodule_ActsUtilsFileTest",
"-lmodule_ActsKvStoreTest",
"-lmodule_ActsParameterTest",
"-lmodule_ActsSamgrTest",
"-lhuks_test_common",
"-lmodule_ActsHuksHalFunctionTest",
"-lmodule_ActsDfxFuncTest",
"-lmodule_ActsUpdaterFuncTest",
"-lmodule_ActsHieventLiteTest",
"-Wl,--no-whole-archive",
]
}

在文件vendorbestechnicxts_democonfig.json中,需要链接的ACTS部件测试库文件写在了bin_list里的force_link_libs里。

  "bin_list": [
{
"elf_name": "wifiiot",
"bsp_target_name": "best2600w_liteos",
"signature": "false",
"burn_name": "rtos_main",
"enable": "true",
"force_link_libs": [
"bootstrap",
"abilityms",
"bundlems",
"broadcast",
"hctest",
"module_ActsParameterTest",
"module_ActsBootstrapTest",
"module_ActsDfxFuncTest",
"module_ActsHieventLiteTest",
"module_ActsSamgrTest",
"module_ActsKvStoreTest"
]
},
.......
],

然后在文件devicesocbestechnicbes2600BUILD.gn里组装编译链接选项,相关代码片段如下:

  # config bin from vendor/bestechnic/<product_name>/config.json
foreach(bin_file, bin_list) {
......

if (build_enable == "true") {
......

# force link invisible function ,which ar to lib
ldflags += [ "-Wl,--whole-archive" ]
foreach(force_link_lib, bin_file.force_link_libs) {
ldflags += [ "-l${force_link_lib}" ]
}
ldflags += [ "-lbsp${bsp_target_name}" ]
ldflags += [ "-Wl,--no-whole-archive" ]
......
}
}

在文件vendor_asrmicroxts_democonfig.json中,存在这样的配置片段。

    "xts_list": [
{
"enable": "true",
"xts_modules": [
"ActsKvStoreTest",
"ActsDfxFuncTest",
"ActsHieventLiteTest",
"ActsSamgrTest",
"ActsParameterTest",
"ActsWifiServiceTest",
"ActsWifiIotTest",
"ActsBootstrapTest"
]
}
]

然后,在文件device_soc_asrmicroasr582xliteos_msdkBUILD.gn文件中组装编译链接选项。

 foreach(xts_item, xts_list) {
xts_enable = xts_item.enable
if(xts_enable == "true")
{
defines = [ "CFG_HARMONY_SUPPORT" ]
ldflags += [
"-Llibs",
"-Wl,--whole-archive",
"-lhctest",
"-lbootstrap",
"-lbroadcast",
]
foreach(xts_module, xts_item.xts_modules) {
ldflags += [ "-lmodule_${xts_module}" ]
}
ldflags += [ "-Wl,--no-whole-archive" ]
}
}

在产品解决方案配置文件中增加的bin_list、xts_list这些配置选项都不是config.json中的默认的标准选项。各个方案实现的风格差异比较大,建议使用第一种,写在文件vendorgoodixgr5515_sk_xts_demoBUILD.gn中会比较好。另外,需要使用hb命令触发debug版本(非debug版本不会触发测试编译)。

​想了解更多内容,请访问:​

​51CTO和华为官方合作共建的鸿蒙技术社区​

​https://harmonyos.51cto.com​

移植案例与原理 - XTS子系统之应用兼容性测试套件之一

文章版权声明

 1 原创文章作者:三七,如若转载,请注明出处: https://www.52hwl.com/92411.html

 2 温馨提示:软件侵权请联系469472785#qq.com(三天内删除相关链接)资源失效请留言反馈

 3 下载提示:如遇蓝奏云无法访问,请修改lanzous(把s修改成x)

 免责声明:本站为个人博客,所有软件信息均来自网络 修改版软件,加群广告提示为修改者自留,非本站信息,注意鉴别

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2024年1月16日 下午9:15
下一篇 2024年1月16日 下午9:16