Headless testing with FEST

For testing internally the GUI parts of INGENIAS, we use FEST. FEST does not support by itself headless testing,i.e., you need some X server to run your test onto. The following will work only in linux.

To solve this, you need a virtual frame buffer. You need to have installed the following software:

  • Xvfb. It is the virtual frame buffer implementation. It works as if there was a graphic card, but it does show nothing in the screen.
  • X11vnc. It is the session emulation via VNC to enable remote access
  • vncviewer. It is the viewer for you to optionally check everything is going all right. In a pure headless mode, you really don’t use it.
  • fluxbox. It provides desktop functionalities.

Looking at examples like the combination of fluxbox with xvfb or this discussion about how to combine vnc and xvfb. Using these as base, you can have the following the following script, which I call executefb.sh

env DISPLAY=:1 Xvfb :1 -screen 0 1280x1024x24 &
sleep 2
env DISPLAY=:1 fluxbox &
sleep 2
env DISPLAY=:1 x11vnc -display :1 -bg -nopw -listen localhost -xkb&
sleep 2
vncviewer  -viewonly -encodings 'copyrect tight zrle hextile' localhost:5900 &
env DISPLAY=:1 $1
killall -9 vncviewer
killall -9 Xvfb

You can use it to launch things inside like sh executefb.sh firefox. This will launch firefox inside your emulated X11 system. It is quite rough to do a killall, but it was faster for me rather than storing the pids of the corresponding processes.

Be careful because it may harm your system if you run killall and have several running vncviewers around. The script, by default, will kill them.