Jump to content

Run qtbase auto tests on OpenHarmony emulator - ohos-qemu

From Qt Wiki

Read https://wiki.qt.io/Run_qtbase_auto_tests_on_HarmonyOS_devices and https://wiki.qt.io/Run_qtbase_auto_tests_on_HarmonyOS_emulator first for system setup and build.

Read https://wiki.qt.io/Ohos-qemu_-_an_OpenHarmony_Emulator_project first for ohos-qemu setup.

I tried on macOS 26.6(MacBook Pro, M3 Max).

The build is a bit mixed.

macOS(Apple Silicon)

  • DevEco Studio 26.0.0.851 installed at /Applications/DevEco-Studio.app
  • Open a project, Device Manager, Create an emulator, MateBook Pro, HarmonyOS 7.0.0(26.0.0)

With Emulator from ohos-qemu, you don't need to setup QT_HARMONYOS_SIGNING_* things.

For the target build, if everything goes well, you will see following:

...
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-unsigned.hap
...

Check connection

After you run the emulator from ohos-qemu, we need to connect it manually,

$ /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/toolchains/hdc list targets
[Empty]
$ /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/toolchains/hdc tconn 127.0.0.1:5555
Connect OK
$ /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/toolchains/hdc list targets
127.0.0.1:5555
$ /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/toolchains/hdc -t 127.0.0.1:5555 shell bm get --udid
udid of current device is :
6F7004D23D437A26667B46CE40A1142A23FBF7E880DBB5DADF65758DB91DD14A

Use hap-sign to sign the package

And a bit extra setup after signing,

$ cd ~/qt/qtbase-harmonyos-build
$ cd harmonyos-tests-bundle/entry/build/default/outputs/default
$ hap-sign sign entry-default-unsigned.hap \
  --acl ohos.permission.READ_PASTEBOARD \
  --bundle-name org.qtproject.autotests \
  --device-id 6F7004D23D437A26667B46CE40A1142A23FBF7E880DBB5DADF65758DB91DD14A \
  --output entry-default-signed.hap
$ mv entry-default-unsigned.hap entry-default-unsigned.hap.bak
$ ln -s entry-default-signed.hap entry-default-unsigned.hap

Run one auto test

$ export QT_HARMONYOS_HDC=/Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/toolchains/hdc
$ cd ~/qt/qtbase-harmonyos-build
$ ctest -R "^tst_qrhi$" --verbose

We haven't finished the support for OpenHarmony 7 yet, there is no need to run all qtbase auto tests in current stage.

Happy hacking!