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

原创
系统 OpenHarmony
本文主要通过实例分析下ACTS应用兼容性测试套件移植案例,以及移植过程中特定的操作的原理。

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

​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组件定义。下面看几个示例,文件vendor\bestechnic\xts_demo\config.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":[] }
]
}

文件vendor\goodix\gr5515_sk_xts_demo\config.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 则关掉这个特性。在文件vendor\goodix\gr5515_sk_xts_demo\BUILD.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",
]
}

在文件vendor\bestechnic\xts_demo\config.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"
]
},
.......
],

然后在文件device\soc\bestechnic\bes2600\BUILD.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_asrmicro\xts_demo\config.json中,存在这样的配置片段。

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

然后,在文件device_soc_asrmicro\asr582x\liteos_m\sdk\BUILD.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中的默认的标准选项。各个方案实现的风格差异比较大,建议使用第一种,写在文件vendor\goodix\gr5515_sk_xts_demo\BUILD.gn中会比较好。另外,需要使用hb命令触发debug版本(非debug版本不会触发测试编译)。

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

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

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

责任编辑:jianghua 来源: 鸿蒙社区
相关推荐

2022-02-16 15:48:26

ACTS应用XTS子系统鸿蒙

2021-12-27 16:22:19

鸿蒙HarmonyOS应用

2022-01-26 15:16:24

utilsOpenHarmon鸿蒙

2023-04-17 19:43:54

兼容性测试软件测试

2022-01-25 17:12:36

startup子系统syspara系统鸿蒙

2023-02-06 16:11:22

代码研发鸿蒙

2021-10-06 19:06:25

微软Windows 11Windows

2012-05-16 11:30:39

2012-01-04 10:45:01

2009-08-17 10:22:19

C# Windows

2009-09-01 18:55:09

Windows 7兼容

2009-10-15 10:56:19

开放式布线系统

2023-07-10 09:38:06

兼容性测试方案

2009-03-07 09:49:07

Windows 7兼容性

2015-10-30 18:00:45

应用程序兼容性FireEye

2012-04-24 10:08:12

HTML5

2022-08-22 09:01:59

类型兼容性TypeScript

2009-04-25 09:15:11

微软Windows 7操作系统

2009-09-15 08:33:01

2021-08-12 16:37:54

MozillaFirefox用户代理
点赞
收藏

51CTO技术栈公众号