1

Friday 11th April 2008

Local Packages

Testing GUI Applications in Mock

mock is the standard tool for building Fedora packages these days, and provides a convenient way to build RPMs for older or newer distribution releases than the machines you have available. For instance, all of my machines are running Fedora 8 at the moment but by using mock I can build packages for distributions as old as Red Hat Linux 7.3, and also for CentOS 3,4,5. However, what's not as obvious is that mock can also be used to run applications for these distributions so as to test them in their target environments.

For instance, earlier this week I applied a bunch of patches to my bittorrent package and wanted to make sure that the GUI still worked on Fedora Core 4 (basically checking that I hadn't introduced something that relied on newer versions of dependent packages). I used two machines to do this test, the build server (let's call it buildhost) where I built the package, and the display server (let's call it displayhost) where I wanted to view the GUI window.

The first task is to install the package to be tested (and any necessary infrastructure) into the mock chroot on the build server:

$ mock -r fedora-4-x86_64-core init
$ mock -r fedora-4-x86_64-core --install bittorrent-gui bitmap-fonts dejavu-fonts xorg-x11-fonts-base  xorg-x11-fonts-misc xorg-x11-fonts-Type1

Then set up an X display to view the application. I use Xnest (from the xorg-x11-server-Xnest package) on the display host for this, to set up a clean new display with no authentication aggravation.

$ Xnest -ac :2

Then, back on the build server, I point the DISPLAY variable at my target display and start the application.

$ mock -r fedora-4-x86_64-core shell
mock-chroot> export DISPLAY=displayhost:2
mock-chroot> bittorrent

The application appears on the Xnest display and I can test it to my heart's content.