移植案例與原理 - XTS子系統(tǒng)之應(yīng)用兼容性測試套件之一
原創(chuàng)??51CTO和華為官方合作共建的鴻蒙技術(shù)社區(qū)??
??https://harmonyos.51cto.com??
XTS(X Test Suite)子系統(tǒng)是OpenHarmony生態(tài)認(rèn)證測試套件的集合,當(dāng)前包括:
- acts(application compatibility test suite)應(yīng)用兼容性測試套件,看護(hù)北向HAP兼容、OpenHarmony開發(fā)API兼容。
- hats(Hardware Abstraction Test Suite )硬件抽象測試套,看護(hù)HDI層接口。
- dcts(Distributed Compatibility Test Suite )分布式兼容性測試套,看護(hù)分布式兼容(待上線)
本文主要通過實(shí)例分析下ACTS應(yīng)用兼容性測試套件移植案例,以及移植過程中特定的操作的原理。主要講述的是輕量系統(tǒng)兼容性測試。輕量系統(tǒng)因系統(tǒng)能力限制,兼容性測試在系統(tǒng)初始化階段進(jìn)行;并且各設(shè)備燒錄工具存在差異,導(dǎo)致自動化工具(xDevice工具)無法實(shí)現(xiàn)真正的自動適配,因此認(rèn)證執(zhí)行方式不對合作伙伴進(jìn)行限制。流程如下:
步驟1 編譯適配:XTS子系統(tǒng)加入到編譯組件中,隨版本一起編譯;
步驟2 本地執(zhí)行:完成兼容性測試;
1、編譯適配XTS子系統(tǒng)
1.1 產(chǎn)品解決方案適配
需要在產(chǎn)品解決方案配置文件中增加增加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 編譯鏈接
需要通過鏈接選項(xiàng)指定需要鏈接的ACTS的部件編譯庫文件,會使用到 --whole-archive 和 --no-whole-archive這2個ld鏈接選項(xiàng)。–whole-archive 可以把 在其后面出現(xiàn)的靜態(tài)庫包含的函數(shù)和變量輸出到動態(tài)庫,–no-whole-archive 則關(guān)掉這個特性。在文件vendor\goodix\gr5515_sk_xts_demo\BUILD.gn中,對ACTS的編譯文件進(jìn)行鏈接。其中⑴到⑵處的鏈接選項(xiàng)為編譯出的屬于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里組裝編譯鏈接選項(xiàng),相關(guān)代碼片段如下:
# 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文件中組裝編譯鏈接選項(xiàng)。
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" ]
}
}
在產(chǎn)品解決方案配置文件中增加的bin_list、xts_list這些配置選項(xiàng)都不是config.json中的默認(rèn)的標(biāo)準(zhǔn)選項(xiàng)。各個方案實(shí)現(xiàn)的風(fēng)格差異比較大,建議使用第一種,寫在文件vendor\goodix\gr5515_sk_xts_demo\BUILD.gn中會比較好。另外,需要使用hb命令觸發(fā)debug版本(非debug版本不會觸發(fā)測試編譯)。
??51CTO和華為官方合作共建的鴻蒙技術(shù)社區(qū)??
??https://harmonyos.51cto.com??