Automating Qt application in a flatpak package

Last edited on

General

Flatpak packages are meant to introduce security by disabling access of applications to certain parts of the system. Testing application in the sandbox created by flatpak with Squish means you will need to weaken this protection so that Squish can interact with the application.

Setup

For automation of the application we recommend to use a shell script as your AUT, because you will need to modify the environment for the flatpak sandbox.

In order to allow Squish to connect to the hook in the application you must allow the sandbox access to the network as Squish communicates via TCP/IP with the hook. Flatpak has for this the option "--share=network" which you can add to the run command.

You will also need to pass the --env option with LD_LIBRARY_PATH to restore the value which is cleaned by the sandbox on start. This is needed for Squish, because we use the LD_PRELOAD mechanism to load our code early in the application process. The lookup of LD_PRELOAD searches through the directories specified in LD_LIBRARY_PATH.

The complete command can be seen below :

flatpak run --share=network --env=LD_LIBRARY_PATH=$LD_LIBRARY_PATH APP_NAME

the env switch allows you to modify the environment passed to the sandbox. Replace APP_NAME with the identifier of the flatpak package Once these changes are made and the rest of the setup is correct, you will find that Squish is able to connect to the Application like with a regular desktop App when you launch the shell script as your AUT.

This is confirmed working on Ubuntu 24.04 LTS with flatpak 1.14.6