C

配置和使用QBSP测试平台

基于Squish的QBSP测试平台可以帮助您验证QBSP是否真正工作,以及应用程序是否可以从Qt Creator部署到目标设备。

要下载QBSP测试平台包,请访问Qt合作伙伴门户。如果是首次操作,请登录或注册为Qt用户,然后下载QBSP测试平台包。该包的标题为tqtc-qbsp-testbench-ddmmyy.7z。确保您有Squish许可证。

解压缩包。然后运行setup_install.py脚本,安装所需的Qt和Qt Creator版本,并将镜像刷写到您的硬件设备。

如果您在Linux中将设备连接类型选择为USB,请确保USB已按设置USB访问嵌入式设备中的说明进行配置。如果选择以太网,则会要求数据被测试的设备的IP地址。如果您还不知道它,请留空该字段,以后再添加地址。

在Windows上,您需要以管理员身份运行该脚本。为此,搜索"cmd",在命令提示符上右键单击并选择以管理员身份运行。然后执行脚本,例如如下所示

C:\Users\<username>\workdir\tqtc-qbsp-testbench>python3 setup_install.py ..\..\Downloads\meta-b2qt-embedded-qbsp-x86_64-mingw32-stm32mp15-disco-6.7.2.qbsp
~$ cd tqtc-qbsp-testbench/
~/tqtc-qbsp-testbench $ ./setup_install.py /home/<username>/workdir/testbenchimages/meta-b2qt-embedded-qbsp-x86_64-stm32mp15-disco-6.7.2.qbsp
Configuration settings will be written into /home/<username>/testbench.config file where settings can be later edited.
Please input setting values matching your setup.
; Absolute path of directory, where Qt will be installed
qt installation_location: /home/<username>/workdir/testbench/qt
; Absolute path of Qt installer binary file (leave empty to attempt automatic Qt installer download)
qt installer_location:
; Qt credentials, which will be used with Qt installer
qt <username>: [email protected]
qt password:
; Qt version which QBSP file is based on
QBSP image_qt_version: 6.7.2
; The name of the hardware which is supported by the QBSP under test
device hardware_name: stm32mp15-disco
; connection_type can be ethernet or usb
device connection_type: ethernet
device ethernet_address: 192.168.1.113
User configuration read from /home/<username>/testbench.config
Attempting to download Qt installer
--2023-03-01 15:41:29--  https://download.qt.io/official_releases/online_installers/qt-unified-linux-x64-online.run
Resolving download.qt.io (download.qt.io)... 77.86.162.2
Connecting to download.qt.io (download.qt.io)|77.86.162.2|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://www.nic.funet.fi/pub/mirrors/download.qt-project.org/archive/online_installers/4.5/qt-unified-linux-x64-4.5.1-online.run [following]
--2023-03-01 15:41:29--  https://www.nic.funet.fi/pub/mirrors/download.qt-project.org/archive/online_installers/4.5/qt-unified-linux-x64-4.5.1-online.run
Resolving www.nic.funet.fi (www.nic.funet.fi)... 193.166.3.3, 2001:708:10:8::3
Connecting to www.nic.funet.fi (www.nic.funet.fi)|193.166.3.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
.
.
.
[12618] Installation finished!
[12621] Headless installation: skip wizard page item addition:  "LaunchQtCreatorCheckBoxForm"
[12621] Components installed successfully.
Installation complete. Install dir: '/home/<username>/workdir/testbench/qt' found

Please update image from /home/<username>/workdir/testbench/qt/6.7.2/Boot2Qt/stm32mp15-disco/images
to your stm32mp15-disco hardware and run suite_qbsp_testbench with Squish.
/home/<username>/workdir/testbench/qt/Tools/b2qt/b2qt-flashing-wizard tool installed.
Please use it to write the installed image to memory card.

Please use a Squish version that is based on the same Qt version as the installed Qt Creator:
Qt Creator 12.0.2 based on Qt 6.6.0

安装完成后,安装程序将启动Qt Creator的Boot to Qt刷写向导,您可以使用它将设备镜像写入SD卡。如果该设备上已经有镜像,请跳过此步骤。

安装程序输出中的一个重要细节是"基于Qt 6.6.0"。在安装Squish时,您需要此信息。

注意:在Windows上,安装程序将启动一个弹出窗口,您可以在其中看到Qt版本。当您关闭该窗口时,安装将继续。

如果脚本没有打印出Qt Creator版本,您也可以手动检查

$ <qt installation path>/Tools/QtCreator/bin/qtcreator -version 2> >(grep "based on")
Qt Creator 12.0.2 based on Qt 6.6.0

或者,您也可以启动Qt Creator,选择帮助 > 关于Qt Creator来验证版本信息。

在继续之前,您可以根据需要检查和编辑从用户主目录创建的testbench.config。在Linux中位于~/testbench.config,在Windows上的位置是C:\Users\[<username>]\testbench.config

$ cat ~/testbench.config
[qt]
; Absolute path of directory, where Qt will be installed
installation_location = /home/<username>/workdir/testbench/qt
; Absolute path of Qt installer binary file (leave empty to attempt automatic Qt installer download)
installer_location =
; Qt credentials, which will be used with Qt installer
username = [your Qt account username]
password = [your Qt account password]

[QBSP]
; Qt version which QBSP file is based on
image_qt_version = 6.7.2

[device]
; The name of the hardware which is supported by the QBSP under test
hardware_name = stm32mp15-disco
; connection_type can be ethernet or usb
connection_type = ethernet
ethernet_address = [ip address of your device under testing]

警告: testbench.config 中使用绝对路径,因为像 ~/workdir/testbench/qt 这样的路径在此情况下将无法工作。

安装 Squish

要成功运行测试,确保满足以下两个前提条件

  • 安装的 Squish 版本需要为安装的 Qt Creator 中使用的 Qt 版本编译(在这个例子中是 Qt 6.4)。
  • Qt Creator 版本(或者更具体地说,它的 GUI)需要与 Squish 测试套件设计的 Qt Creator 版本相匹配:setup_install.py 尝试为你确定并安装正确的 Qt Creator 版本。

Squish 安装包可在 Qt 客户门户 获取。在这个示例安装中,你需要与 Qt 6.4 兼容的最新版本,因此下载、赋予执行权限,并安装 squish-7.2.1-qt64x-linux64.run

~/Downloads$ chmod +x squish-7.2.1-qt64x-linux64.run
~/Downloads$ ./squish-7.2.1-qt64x-linux64.run

注意: 对于 Windows,请选择 Squish 的 Microsoft Visual C++ 版本,即 squish-7.2.1-qt64x-win64-msvc142.exe

  1. 许可证 视图中,选择 本地许可证

  2. 在可用的组件中,您只需要 Squish 工具 来从命令行执行 Squish 测试套件。但是,为了调查可能的测试失败情况,以及存储和查看测试结果,我们建议还安装 Squish IDE。全安装时请准备至少 1GB 的硬盘空间。

  3. 脚本语言 视图中,接受 Python 版本 3.10。

  4. 安装文件夹 视图中,选择安装目录并继续安装。

执行 Squish 测试套件

在 Linux 上,按照以下方式启动 squish 服务器

~$ ./squish-for-qt-7.2.1/bin/squishserver &

使用 squishrunner 命令运行 Squish 测试套件

~$ ./squish-for-qt-7.2.1/bin/squishrunner --testsuite tqtc-qbsp-testbench/suite_qbsp_testbench/
2022-10-04T15:54:11 START Start 'suite_testsuite' Test 'suite_testsuite' started
2022-10-04T15:54:11 START_TEST_CASE Start 'tst_install' Test 'tst_install' started (tst_install)
...
2022-10-04T15:05:17 END End 'suite_testsuite' End of test 'suite_testsuite'
*******************************************************
Summary:
Number of Test Cases: 15
Number of Tests: 30
Number of Errors: 0
Number of Fatals: 0
Number of Fails: 0
Number of Passes: 30
Number of Expected Fails: 0
Number of Unexpected Passes: 0
Number of Warnings: 0
*******************************************************

在 Windows 上,为 squish 服务器打开一个新的命令提示符窗口

C:\Users\<username>\Squish for Qt 7.2.1\bin>squishserver.exe
15:29:19:834 Info: Starting server of Squish version 7.2.1.
15:29:19:849 Info: Listening on 0.0.0.0:4322
15:29:19:849 Info: Listening on ws://127.0.0.1:63535?pQoRUcLoosOUVMcCZR0c
15:29:19:849 Info: Announcing server presence via SSDP

使用 squishrunner 命令运行 Squish 测试套件

C:\Users\<username>\Squish for Qt 7.2.1\bin>squishrunner.exe --testsuite ..\..\workdir\tqtc-qbsp-testbench\suite_qbsp_testbench

注意: --reportgen html,[绝对路径到报告目录] 添加到命令行将生成一个 HTML 报告,在问题情况下可能提供更多有帮助的详细信息。将文件夹存档是一种与他人共享结果的好方法。

您还可以从 Squish IDE 运行 Squish 测试套件

~/workdir/squish-for-qt-7.2.1 $ ./squishide

在完整 Squish 测试套件执行完毕后,您还可以从 Squish IDE 运行单个测试用例。

在特定 Qt 许可证下可用。
了解更多。