Automating Qt applications packaged as type-1 AppImages

Last edited on

Synopsis

Qt applications packaged as type-1 (or type-2) AppImages can generally be automated with Squish for Qt.

Usually this only requires to choose a Squish for Qt package for the same Qt version as used by the Qt application, and enabling "Hook into sub-processes launched by the application" in the test suite settings (click on the wrench icon in Test Suites view, select the "AUT" tab at the bottom of the test suite settings editor/view).

However, it may be that the application's AppImage is started through a shell script which overwrites LD_PRELOAD or LD_LIBRARY_PATH, for example (for example stored as "./usr/bin/myapplication.sh" in the AppImage):

#!/bin/sh

script_dir=$(dirname $0)
export LD_LIBRARY_PATH=$script_dir

myapplication $@

If so this will cause hookup failure in Squish, and the "Runner/Server Log" view will contain an error message similar to this:

[...] AUT stderr: ERROR: ld.so: object 'libsquishqtpre.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

This article shows how to solve this by extracting the application from the type-1 AppImage and modifying the shell script.

Step 1 - Check if it is a type-1 AppImage

When executing the following in a shell a type-1 AppImage will start the application and not output any help or usage information:

./myapplication.AppImage --appimage-help

If it is a type-1 AppImage proceed with the following steps.

Step 2 - Enable sub-process hooking

At test suite settings (open via click on wrench icon in the "Test Suites" view) select the "AUT" tab (at the bottom of the test suite settings editor/view) check "Hook into sub-processes launched by the application".

Step 3 - Copy the type-1 AppImage contents to a new folder

In a shell execute the following (adjust paths and file names as required):

mkdir /tmp/myapplication.AppImage.mount
sudo mount -o loop myapplication.AppImage /tmp/myapplication.AppImage.mount
cp -r /tmp/myapplication.AppImage.mount /$HOME/myapplication
sudo umount /tmp/myapplication.AppImage.mount

Step 4 - Modify the shell script

Modify the shell script that starts the application (for example "./usr/bin/myapplication.sh" inside $HOME/myapplication) to append to LD_LIBRARY_PATH:

#!/bin/sh

script_dir=$(dirname $0)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$script_dir

myapplication $@

Step 5 - Register the AUT

Register the AUT binary as "Application" in the "AUT" tab of the test suite settings ($HOME/myapplication/AppRun for this example).

At this point record and replay on the application should work. If this is not the case take a look at the "Runner/Server Log" view to check if there are any obvious problems reported. If you cannot resolve it, please contact Squish technical support, and please provide the newly collected support information (Help > Collect Support Information...) as this point, as well as the modified shell script file.