gparted/.gitlab-ci.yml
Mike Fleetwood 8db9a83b39 Run test program under xvfb-run to satisfy need for an X11 display (!49)
Running test_ext2 in GitLab Continuous Integration environment fails like
this:
    (test_ext2:6338): Gtk-WARNING **: 09:06:17.576: cannot open display:
    Running main() from test_ext2.cc

Obviously the GitLab CI environment doesn't have an X11 display, but
unfortunately this test case code requires one.
Utils::execute_command() calls Gtk::Main::run() so requires a Gtk::Main
object constructing and therefore an X11 display, even though this
program never displays anything graphical.  The call chain is:
    main()                       test_ext2.cc
      Gtk::Main::Main()          gtkmm/gtk/src/main.ccg
        Gtk::Main::init()        [1]
          gtk_init()             gtk/gtk/gtkmain.c [2]
which exits with a non-zero exit status when the DISPLAY environment
variable is unset.

Looked at deriving from Gtk::Main class and writing a replacement init()
method which calls gtk_init_check() instead of gtk_init() but
Gtk::Main::instance_ is a private member so not accessible in a derived
class.

Tried using Glib::MainLoop instead of Gtk::Main, but that doesn't
initialise everything that Gtk::Main(), so the program crashes.

Therefore use xvfb-run [3][4] to run this test program against a virtual
X11 display when a real display isn't available.  Coded execution of
xvfb-run into this test program so that it can simply be executed on the
command line like the other test programs, without having to remember to
run "xvfb-run ./test_ext2 ...".

[1] Gtk::Main::init()
    https://gitlab.gnome.org/GNOME/gtkmm/blob/3.10.1/gtk/src/main.ccg#L287
[2] gtk_init()
    https://gitlab.gnome.org/GNOME/gtk/blob/3.10.9/gtk/gtkmain.c#L1000
[3] how to run gtk app on linux without an x server
    https://superuser.com/questions/624918/how-to-run-gtk-app-on-linux-without-an-x-server
[4] Using GTK without DISPLAY
    https://stackoverflow.com/questions/11694278/using-gtk-without-display

Closes !49 - Add file system interface tests
2019-11-09 17:18:34 +00:00

67 lines
2 KiB
YAML

stages:
- build
- test
.centos_image_template: &centos_image_definition
# Use official CentOS image https://hub.docker.com/_/centos/.
image: centos:centos7
before_script:
- yum update -y
- yum install -y which gnome-common yelp-tools glib2-devel intltool
gcc-c++ libuuid-devel parted-devel gtkmm30-devel make
polkit file
# Extra packages only needed during the test stage.
- yum install -y e2fsprogs xorg-x11-server-Xvfb
- cat /etc/os-release
.ubuntu_image_template: &ubuntu_image_definition
# Use official Ubuntu image https://hub.docker.com/_/ubuntu/.
image: ubuntu:latest
before_script:
- apt-get update
- apt-get install -y gnome-common yelp-tools libglib2.0-dev-bin
uuid-dev libparted-dev libgtkmm-3.0-dev make
policykit-1
# Extra packages only needed during the test stage.
- apt-get install -y e2fsprogs xvfb
- cat /etc/os-release
.build_stage_template: &build_stage_definition
stage: build
script:
- ./autogen.sh
- nproc=`grep -c '^processor' /proc/cpuinfo` || nproc=1
- echo nproc=$nproc
- make -j $nproc
- make install
.test_stage_template: &test_stage_definition
stage: test
script:
- ./autogen.sh
- nproc=`grep -c '^processor' /proc/cpuinfo` || nproc=1
- echo nproc=$nproc
- make -j $nproc
# Exclude specific unit test which fails without /dev/disk in Docker images.
- export GTEST_FILTER='-BlockSpecialTest.NamedBlockSpecialObjectBySymlinkMatches'
- make check
- make distcheck
# Check GParted can be built and installed on CentOS and Ubuntu.
centos_build:
<<: *centos_image_definition
<<: *build_stage_definition
ubuntu_build:
<<: *ubuntu_image_definition
<<: *build_stage_definition
# Check GParted unit tests and distcheck pass on CentOS and Ubuntu.
centos_test:
<<: *centos_image_definition
<<: *test_stage_definition
ubuntu_test:
<<: *ubuntu_image_definition
<<: *test_stage_definition