移植案例與原理 - XTS子系統之應用兼容性測試套件之一
原創??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",
"http://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版本不會觸發測試編譯)。
??https://harmonyos.51cto.com??