积分1493 / 贡献20

提问16答案被采纳59文章38

[经验分享] 一个带界面的Wukong 原创

深开鸿_王石 显示全部楼层 发表于 2023-12-14 08:52:11

简介

在OpenHarmony仓里有一个稳定性自动化测试工具,叫Wukong。对应的仓位置是https://gitee.com/openharmony/ostest_wukong。这个工具是系统自带的命令行工具,下面先简单介绍下wukong的内容


架构图

image.png

Wukong内子模块职责:

  1. 命令行解析:支持命令行获取参数并解析命令行参数。
  2. 运行环境管理:根据命令行初始化wukong整体运行环境。
  3. 系统接口管理:检查并获取指定的mgr,注册controller和dfx的faultlog的回调函数。
  4. 随机事件生成:通过random函数生成指定种子数的随机序列,生成事件。
  5. 事件注入:根据支持的事件类型向系统注入事件,依赖窗口、多模、安全等子系统。
  6. 异常捕获处理/报告生成:通过DFX子系统获取运行中的异常信息并记录log,生成报告。

Wukong命令

# wukong help
usage: wukong <command> [<arguments>]
These are common wukong command list:
   help                       wukong help information
   -v/--version               wukong version
   exec                       run random test
   special                    run special test
   focus                      run focus test
   appinfo                    show all app information
  • Wukong special是专项测试,具体测试命令如下
    # wukong special -h
    usage: wukong special [<arguments>]
    These are wukong special arguments list:
       -h, --help                 special test help
       -t, --touch[x,y]           touch event
       -c, --count                total count of test
       -i, --interval             interval
       -S, --swap[option]         swap event
                                  option is -s| -e| -b
                                  -s, --start: the start point of swap
                                  -e, --end: the end point of swap
                                  -b, --bilateral: swap go and back
       -k, --spec_insomnia        power on/off event
       -T, --time                 total time of test
       -C, --component            component event
       -p, --screenshot           get screenshot(only in componment input)
       -r, --record               record user operation
       -R, --replay               replay user operation
       -u, --uitest               uitest dumpLayout
  • Wukong exec 随机测试,具体命令如下:
    # wukong exec -h
    usage: wukong exec [<arguments>]
    These are wukong exec arguments list:
       -h, --help                 random test help
       -a, --appswitch            appswitch event percent
       -b, --bundle               the bundle name of allowlist
       -p, --prohibit             the bundle name of blocklist
       -d, --page                 block page list
       -t, --touch                touch event percent
       -c, --count                test count
       -i, --interval             interval
       -s, --seed                 random seed
       -m, --mouse                mouse event percent
       -k, --keyboard             keyboard event percent
       -H, --hardkey              hardkey event percent
       -S, --swap                 swap event percent
       -T, --time                 test time
       -C, --component            component event percent
       -r, --rotate               rotate event percent
       -e, --allow ability        the ability name of allowlist
       -E, --block ability        the ability name of blocklist
       -I, --screenshot           get screenshot(only in random input)
  • Wukong focus 专注测试,具体命令如下:
    # wukong focus -h
    usage: wukong focus [<arguments>]
    These are wukong focus arguments list:
       -h, --help                 random test help
       -a, --appswitch            appswitch event percent
       -b, --bundle               the bundle name of allowlist
       -p, --prohibit             the bundle name of blocklist
       -t, --touch                touch event percent
       -c, --count                test count
       -i, --interval             interval
       -s, --seed                 random seed
       -m, --mouse                mouse event percent
       -k, --keyboard             keyboard event percent
       -H, --hardkey              hardkey event percent
       -S, --swap                 swap event percent
       -T, --time                 test time
       -C, --component            component event percent
       -r, --rotate               rotate event percent
       -n, --numberfocus          the number of inputs to focus on some component one time
       -f, --focustypes           the component type to focus on
  • Wukong appinfo 查询可以测试的app信息,具体如下:
    # wukong appinfo -h
    BundleName:  com.ohos.adminprovisioning
    AbilityName:  com.ohos.adminprovisioning.MainAbility
    BundleName:  com.ohos.callui
    AbilityName:  com.ohos.callui.MainAbility
    BundleName:  com.ohos.camera
    AbilityName:  com.ohos.camera.MainAbility
    BundleName:  com.ohos.contacts
    AbilityName:  com.ohos.contacts.MainAbility
    BundleName:  com.ohos.mms
    AbilityName:  com.ohos.mms.MainAbility
    BundleName:  com.ohos.note
    AbilityName:  MainAbility
    BundleName:  com.ohos.photos
    AbilityName:  com.ohos.photos.MainAbility
    BundleName:  com.ohos.settings
    AbilityName:  com.ohos.settings.MainAbility
    BundleName:  com.ohos.smartperf
    AbilityName:  MainAbility
    BundleName:  com.ohos.updateapp
    AbilityName:  com.ohos.updateapp.MainAbility
    BundleName:  ohos.samples.distributedcalc
    AbilityName:  MainAbility
    BundleName:  ohos.samples.distributedmusicplayer
    AbilityName:  ohos.samples.distributedmusicplayer.MainAbility
    BundleName:  ohos.samples.etsclock
    AbilityName:  MainAbility

问题

  • 控制台命令不太友好,所以利用业余时间写了个带界面的wukong工具

    image.png

    这个是测试界面,可以进行应用随机,系统随机,专项测试和查看测试日志

    image.png

    这是个小工具,可以获取屏幕投屏,能操作板子 目前这个小工具仓地址为:https://gitee.com/wshikh/elec_wukong,在https://gitee.com/wshikh/elec_wukong/tree/master/src/out这个路径下exe安装包可以下载直接使用,若有问题,直接issue。

小结

这个工具刚开发出来,目前有这么几处问题:

  • 只测过usb连接,如果网络连接没有测试过;
  • 压测时间长了,可能会有问题,比如断连啥的就没有实时数据了;
  • 设备控制是通过截屏来的,自己不会刷新,后面需要看看ohos能提供什么接口,不行就得魔改hdc了,哈哈;
无用

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

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

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

返回顶部