[经验分享] 【TOOLS使用】OpenHarmony XTS环境配置及测试 原创 精华

诚迈_雨哥 显示全部楼层 发表于 2023-12-19 17:54:10

OpenHarmony XTS环境配置及测试

1.XTS 概述

1.1.适用范围

XTS中acts和hats的测试,本文以RK3568开发板多媒体音频模块为例进行说明

1.2.适用对象

OpenHarmony XTS测试人员

2.环境准备

在window上安装以下软件:

3.测试包的下载或者本地编译

3.1.本地编译

编译命令target_subsystem后面指定自己的部件名称,比如电源是 powermgr,音视频是multimedia。在虚拟机切换到代码目录下,按照如下操作:

$cd test\xts\acts  
$./build.sh system_size=standard target_subsystem=multimedia product_name=rk3568  

本地编译后生成的文件目录

.\out\rk3568\suites
│  
├─acts
│  │  run.bat
│  │  run.sh
│  │  
│  ├─config
│  │      acts.json
│  │      user_config.xml
│  │      validator.json
│  │  
│  ├─testcases
│  │      ActsAudioCapturerChangeInfoJsTest.hap
│  │      ActsAudioCapturerChangeInfoJsTest.json
│  │      ActsAudioCapturerChangeInfoJsTest.moduleInfo
│  │      ActsAudioCapturerEnhanceTest.hap
│  │      ActsAudioCapturerEnhanceTest.json
│  │      ActsAudioCapturerEnhanceTest.moduleInfo
│  │      ActsAudioCapturerJsTest.hap
│  │      ActsAudioCapturerJsTest.json
│  │      ActsAudioCapturerJsTest.moduleInfo
│  │      ActsAudioEventManagementJsTest.hap
│  │      ActsAudioEventManagementJsTest.json
│  │      ActsAudioEventManagementJsTest.moduleInfo
│  │      ActsAudioInterruptJsTest.hap
│  │      ActsAudioInterruptJsTest.json
│  │      ActsAudioInterruptJsTest.moduleInfo
│  │      ActsAudioManagerEnhanceTest.hap
│  │      ActsAudioManagerEnhanceTest.json
│  │      ActsAudioManagerEnhanceTest.moduleInfo
│  │      ActsAudioManagerJsTest.hap
│  │      ActsAudioManagerJsTest.json
│  │      ActsAudioManagerJsTest.moduleInfo
│  │      ActsAudioNapiEtsTest.hap
│  │      ActsAudioNapiEtsTest.json
│  │      ActsAudioNapiEtsTest.moduleInfo
│  │      ActsAudioPlayerJsTest.hap
│  │      ActsAudioPlayerJsTest.json
│  │      ActsAudioPlayerJsTest.moduleInfo
│  │      ActsAudioRecorderJsTest.hap
│  │      ActsAudioRecorderJsTest.json
│  │      ActsAudioRecorderJsTest.moduleInfo
│  │      ActsAudioRendererChangeInfoJsTest.hap
│  │      ActsAudioRendererChangeInfoJsTest.json
│  │      ActsAudioRendererChangeInfoJsTest.moduleInfo
│  │      ActsAudioRendererEnhanceTest.hap
│  │      ActsAudioRendererEnhanceTest.json
│  │      ActsAudioRendererEnhanceTest.moduleInfo
│  │      ActsAudioRendererJsTest.hap
│  │      ActsAudioRendererJsTest.json
│  │      ActsAudioRendererJsTest.moduleInfo
│  │      ActsAudioVOIPJsTest.hap
│  │      ActsAudioVOIPJsTest.json
│  │      ActsAudioVOIPJsTest.moduleInfo
│  │      ......
│  └─tools
├─acts-validator
│  │  run.bat
│  │  run.sh
│  │  
│  ├─config
│  │      acts.json
│  │      user_config.xml
│  │      validator.json
│  │  
│  └─tools
└─haps
        ActsAudioCapturerChangeInfoJsTest.hap
        ActsAudioCapturerChangeInfoJsTest.hap.md5.stamp
        ActsAudioCapturerEnhanceTest.hap
        ActsAudioCapturerEnhanceTest.hap.md5.stamp
        ActsAudioCapturerJsTest.hap
        ActsAudioCapturerJsTest.hap.md5.stamp
        ActsAudioEventManagementJsTest.hap
        ActsAudioEventManagementJsTest.hap.md5.stamp
        ActsAudioInterruptJsTest.hap
        ActsAudioInterruptJsTest.hap.md5.stamp
        ActsAudioManagerEnhanceTest.hap
        ActsAudioManagerEnhanceTest.hap.md5.stamp
        ActsAudioManagerJsTest.hap
        ActsAudioManagerJsTest.hap.md5.stamp
        ActsAudioNapiEtsTest.hap
        ActsAudioNapiEtsTest.hap.md5.stamp
        ActsAudioPlayerJsTest.hap
        ActsAudioPlayerJsTest.hap.md5.stamp
        ActsAudioRecorderJsTest.hap
        ActsAudioRecorderJsTest.hap.md5.stamp
        ActsAudioRendererChangeInfoJsTest.hap
        ActsAudioRendererChangeInfoJsTest.hap.md5.stamp
        ActsAudioRendererEnhanceTest.hap
        ActsAudioRendererEnhanceTest.hap.md5.stamp
        ActsAudioRendererJsTest.hap
        ActsAudioRendererJsTest.hap.md5.stamp
        ActsAudioVOIPJsTest.hap
        ActsAudioVOIPJsTest.hap.md5.stamp
        ......

3.2.从CI门禁下载

门禁链接:http://ci.openharmony.cn/workbench/cicd/dailybuild/dailylist

ci_all.PNG

解压缩之后

XTS配置及问题汇总V1.02945.png

CI下载的全量包中xts文件目录

Suites  // xts测试包
│  
├─acts
│  │  run.bat             // windows 下 cmd执行的批处理文件
│  │  run.sh
│  │  
│  ├─config
│  │      acts.json       // 测试的总入口
│  │      user_config.xml // hdc 配置文件,根据个人环境需要重新配置
│  │  
│  ├─developertest
│  │   
│  ├─reports              // 测试完成后生成的报告目录
│  │  └─2023-12-18-19-03-40
│  │      └─log
│  │              device_hilog_AceEtsComponentFiveTest.log
│  │              task_log.log
│  │          
│  ├─resource
│  │      app_capture_screen_test_config.json
│  │      capturescreentest.py
│  │      distributedcalc.png
│  │      distributedcalc.pngraw
│  │      keyboard.png
│  │      keyboard.pngraw
│  │      launcher.png
│  │      launcher.pngraw
│  │      note.png
│  │      note.pngraw
│  │      notification_bar.png
│  │      notification_bar.pngraw
│  │      photos.png
│  │      photos.pngraw
│  │      printscreen
│  │      process.txt
│  │      settings.png
│  │      settings.pngraw
│  │  
│  ├─testcases            // 待测试的组件
│  │      AceEtsComponentFiveTest.hap
│  │      AceEtsComponentFiveTest.json
│  │      AceEtsComponentFiveTest.moduleInfo
│  │      ......
│  └─tools                // 仅当从门径上下载的测试包才生成此压缩包,本地不会生成
│          xdevice-0.0.0.tar.gz
│          xdevice-extension-0.0.0.tar.gz
│      
└─haps
        AceEtsComponentFiveTest.hap
        AceEtsComponentFiveTest.hap.md5.stamp
        AceEtsComponentFourTest.hap
        AceEtsComponentFourTest.hap.md5.stamp

3.3.下载资源包(测试时使用)

包括了测试用例运行时需要的图片、音频、脚本、参数文件等 https://gitee.com/openharmony-sig/compatibility/tree/master/test_suite/resource

4.拼凑文件和修改脚本

4.1.文件拼凑到一个测试目录

XTS配置及问题汇总V1.04554.png

4.2.修改 config/user_config.xml

XTS配置及问题汇总V1.04583.png

开发板上电进入主界面,USB线已连接,Ip,port和sn参数见下图:

XTS配置及问题汇总V1.04621.png

4.3.运行run.bat测试文件

在cmd 运行 >run.bat

4.3.1.如果报告如下错误: error: Setup script exited with error: SandboxViolation

【错误提示】 Processing xdevice-0.0.0.tar.gz Writing C:\Users\ADMINI~1\AppData\Local\Temp\easy_install-yidy71l0\xdevice-0.0.0\setup.cfg Running xdevice-0.0.0\setup.py -q bdist_egg --dist-dir C:\Users\ADMINI~1\AppData\Local\Temp\easy_install-yidy71l0\xdevice-0.0.0\egg-dist-tmp-_ndu9vfs error: Setup script exited with error: SandboxViolation: mkdir('C:\Users\ADMINI~1\AppData\Local\Temp\easy_install-yidy71l0\xdevice-0.0.0\build', 511) {}

【网络方法】 https://stackoverflow.com/questions/59601673/error-setup-script-exited-with-error-sandboxviolation when i'm try to install python setup.py in a windows command prompt it gives the error like this: command:python setup.py install error: Setup script exited with error: SandboxViolation: mkdir('C:\Users\abc~1\AppData\Local\Temp\easy_install-x6pech6b\python-axolotl-curve25519-0.4.1.post2\build', 511) {} The package setup script has attempted to modify files on your system that are not within the EasyInstall build area, and has been aborted. This package cannot be safely installed by EasyInstall, and may not support alternate installation locations even if you run its setup script by hand. Please inform the package's author and the EasyInstall maintainers to find out if a fix or workaround is available. please help to solve this error,thanks

【实际解决方法】最终按照右侧文件修改,可以解决此问题

XTS配置及问题汇总V1.06279.png

4.3.2. 批量测试步骤如下

cmd控制台切到D:\suites\acts目录下:

  1. 执行:>run.bat

XTS配置及问题汇总V1.06533.png

说明:测试框架已经启动

  1. 执行:list

XTS配置及问题汇总V1.06756.png

说明:USB线缆链接正常,user_config.xml中sn填写的目标设备已被发现

  1. 执行:run acts

XTS配置及问题汇总V1.07014.png

说明:acts中包含的样例正被执行

  1. 执行完成后如图:

    XTS配置及问题汇总V1.07244.png

  2. 执行结果在目录D:\suites\acts\reports\中,目录时间每次执行都会重新生成文件夹:

    XTS配置及问题汇总V1.07497.png

  3. 用浏览器打开summary_report.html 结果如下:

XTS配置及问题汇总V1.07532.png

说明:Time不为零的用例为有效模块,已被执行

4.3.3.单独模块测试步骤如下

单独模块执行命令:run -l ActsAudioManagerJsTest

说明:单独模块测试成功率较高。

5.其他问题

【问题1】全部模块均为 Unavailable 【原因1】hdc.exe 版本不对 【原因2】user_config.xml中参数配置不正确,所以目标设备未发现

【问题2】部分模块为 Unabailable 【原因】模块依赖的外部资源缺失 【例如】单击 ActsAudioManagerJsTest 右侧的operate 眼睛图标,会提示wav音频文件缺少。

XTS配置及问题汇总V1.08017.png

XTS配置及问题汇总V1.08219.png

6.XTS 常用指令便签

6.1.编译

编译命令target_subsystem后面指定自己的部件

  1. multimedia 多媒体模块编译
$cd test\xts\acts  
$./build.sh system_size=standard target_subsystem=multimedia product_name=rk3568
  1. 部分hats模块编译
$cd test\xts\hats  
$./build.sh product_name=rk3568 system_size=standard target_subsystem=hdf/audio:HatsHdfAudioTest  
  1. 全部hats模块编译
$cd  /test/xts/hats/  
$./build.sh product_name=rk3568 system_size=standard target_subsystem=hdf  
  1. 全量编译 test/xts/acts目录下执行编译命令
$./build.sh suite=acts system_size=standard  

6.2.输出目录

$out/release/suites/acts/testcases $out/release/suites/acts(编译用例时会同步编译测试套执行框架)

6.3 hdc 相关操作

  • 查看sn. >hdc list targets -v
  • 查看端口号 port. >hdc discover
  • 进入shell. >hdc shell
  • 查看ip地址. >Ifconfig
  • 退出 shell. >exit
  • 退出python. quit
无用

©著作权归作者所有,转载或内容合作请联系作者

您尚未登录,无法参与评论,登录后可以:
参与开源共建问题交流
认同或收藏高质量问答
获取积分成为开源共建先驱

精彩评论1

ryan

沙发 发表于 2024-1-26 17:11:52
遇到run.bat两个错误. 分别是:
1. 即便pip install setuptools成功, 还是会报这个错误.setuptools 版本69.0.3, python版本3.11.2 , pip :23.3.2
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'easy_install'
"Please install setuptools first!"
2. xdevice找不到. 按你图片给的链接中,下载包已经没有tools的文件夹了,  也就没有 xdevice-0.0.0.tar.gz和xdevice-extension-0.0.0.tar.gz
执行报如下错误
python.exe: No module named xdevice.__main__; 'xdevice' is a package and cannot be directly executed

Copyright   ©2023  OpenHarmony开发者论坛  京ICP备2020036654号-3 |技术支持 Discuz!

返回顶部