移植案例与原理 - XTS子系统之应用兼容性测试套件(1) 原创 精华

zhushangyuan_
发布于 2022-2-10 17:24
浏览
3收藏

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

【本文正在参与优质创作者激励】

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版本不会触发测试编译)。

©著作权归作者所有,如需转载,请注明出处,否则将追究法律责任
已于2022-2-10 17:27:15修改
3
收藏 3
回复
举报
回复
    相关推荐