Jump to content

Run qtbase auto tests on HarmonyOS devices

From Qt Wiki
Revision as of 17:23, 19 November 2026 by Liang Qi (talk | contribs)

System Setup

macOS(Apple Silicon): DevEco Studio installed at /Applications/DevEco-Studio.app

Windows(x64): generally the steps should be similar, but I haven't tried.

Get signing info for a dummy project

Create an example project with "org.qtproject.autotests" as "bundleName", and sign it with Huawei id with developer permission, then backup build-profile.json5 file.

Checkout source code of latest qtbase dev

$ cd ~/qt
$ git clone git://code.qt.io/qt/qtbase.git
$ cd qtbase

If build with SDK 26.0.0 or 26.0.1 Beta1, apply this patch: https://codereview.qt-project.org/c/qt/qtbase/+/790191/

Host build

$ cd ~/qt
$ mkdir qtbase-build
$ cd qtbase-build
$ ../qtbase/configure -release -developer-build -opensource -confirm-license -nomake examples -nomake tests -verbose
$ cmake --build . --parallel

Target Build

macOS(Apple Silicon) - Setup

$ export DEVECO_SDK_HOME=/Applications/DevEco-Studio.app
$ export QT_HARMONYOS_HVIGOR=/Applications/DevEco-Studio.app/Contents/tools/hvigor/bin/hvigorw
$ export QT_HARMONYOS_SIGNING_CERT_PATH=~/.ohos/config/default_harmonyos-tests-bundle_abcdefxyz=.cer
$ export QT_HARMONYOS_SIGNING_PROFILE=~/.ohos/config/default_harmonyos-tests-bundle_abcdefxyz=.p7b
$ export QT_HARMONYOS_SIGNING_STORE_FILE=~/.ohos/config/default_harmonyos-tests-bundle_abcdefxyz=.p12
$ export QT_HARMONYOS_SIGNING_KEY_ALIAS=debugKey
$ export QT_HARMONYOS_SIGNING_KEY_PASSWORD=ABCDEFXYZ
$ export QT_HARMONYOS_SIGNING_STORE_PASSWORD=ZYXFEDCBA
$ cd ~/qt
$ mkdir qtbase-harmonyos-build
$ cd qtbase-harmonyos-build
$ ../qtbase/configure -developer-build -debug -no-dbus -no-use-gold-linker -no-pch -openssl-runtime -ohos-sdk /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony -qt-host-path ~/qt/qtbase-build -verbose -- -DCMAKE_FIND_ROOT_PATH=~/.local/opt/ohos/additional-packages
$ cmake --build . --parallel

If everything goes well, you will see following on macOS(Apple Silicon)

...
Project location: ~/qt/qtbase-harmonyos-build/harmonyos-tests-bundle
HAP package: ~/qt/qtbase-harmonyos-build/harmonyos-tests-bundle/entry/build/default/outputs/default/entry-default-signed.hap
...

Connect a Huawei MateBook Pro(codename: harden) to the mac(make sure to enable the Developer mode and USB debugging options.)

Check connection

$ /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/toolchains/hdc list targets
3QC0123A00000001

3QC0123A00000001 is the Serial number of your device.

Run a full test

$ cd ~/qt/qtbase-harmonyos-build
$ ctest -j 1 --output-on-failure --no-label-summary

Only run one test

$ cd ~/qt/qtbase-harmonyos-build
$ ctest -R "^tst_qrhi$" --verbose

Happy hacking!

References