Using Squish on headless systems

Last edited on

Introduction

Unix:

Squish can be used on "headless" Unix systems with virtual display software such as Xvfb.

Without an X server launching the AUT typically yields an error, for example (when starting your application through Squish):

[...] AUT stderr (5202390009): MyAUT: cannot connect to X server.

Windows:

We are not aware of any virtual display software for Microsoft Windows, thus the only solution is to use a virtual computer with VMware, VirtualBox and similar technologies. (Also see Automation on Windows .)

Enable headless usage (without physical display connected)

The Problem

On physical computers, modern operating systems (Linux, macOS, Windows) may refuse to launch properly, unless a physical display is connected (and sometimes: also turned on).

And if they do launch, they may still not open a regular desktop session.

And if they do open a regular desktop session, the session may not have a display area.

All of the above may result in GUI applications not being able to launch properly.

Solutions

  1. Leave a physical display connected to the computer. If required, even turned on. If required, disable power saving/automatically turning it off.

  2. Use the desired setup in virtual a computer instead. (This works because its "display" is virtual.)

  3. Use a (display) "dummy plug", which is plugged into the graphics card port instead of a physical display, and which pretends to be a display. These can be obtained in many places. Common terms for these are:

    • Dummy plug
    • Dummy HDMI plug
    • Dummy DisplayPort plug
    • EDID emulator
    • Virtual display adapter

Using Squish on headless Unix systems

Here are the required steps for using Squish on headless Unix systems (probably scheduled via cron or other scheduling tools).

Note the use of the two helper shell scripts mentioned below.

Step #1 - Copy/Install Shell Helper Scripts

These two shell helper scripts must be copied to the computer where the AUT (Application Under Test) should be executing.

They start and stop the virtual display, a DBUS session and a window manager for us:

Shell Helper Script Requirements:

Step #2 - Start the virtual display

path/to/startxvfb.sh 8
In a shell

(Replace "path/to" according to your setup.)

Step #3 - Start squishserver on/with that virtual display

DISPLAY=:8 squish_dir/bin/squishserver --verbose &
In a shell

Alternative, more explicit:

export DISPLAY=:8
squish_dir/bin/squishserver --verbose &
In a shell

(Replace "squish_dir" according to your setup.)

(The display number "8" is just an example. Any valid and unused display number can be used. Keep in mind that display number 0 may be used now or later for an interactive login session, and thus should be avoided.)

Step #4 - Execute the test suite

squish_dir/bin/squishrunner --testsuite suite_mine
In a shell

(Replace "squish_dir" according to your setup.)

Step #5 - Stop squishserver

squish_dir/bin/squishserver --stop
In a shell

(Replace "squish_dir" according to your setup.)

Step #6 - Stop the virtual display

path/to/stopxvfb.sh 8
In a shell

(Replace "path/to" according to your setup.)