mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
Merge branch 'ci-test-installed' into 'master'
CI: Test static build on installed glib See merge request GNOME/glib!360
This commit is contained in:
commit
372e81b56c
@ -21,12 +21,27 @@ fedora-x86_64:
|
||||
variables:
|
||||
CFLAGS: "-coverage -ftest-coverage -fprofile-arcs"
|
||||
script:
|
||||
- meson ${MESON_COMMON_OPTIONS} --werror -Dsystemtap=true -Ddtrace=true -Dfam=true _build
|
||||
- meson ${MESON_COMMON_OPTIONS}
|
||||
--werror
|
||||
--default-library=both
|
||||
--prefix=$HOME/glib-installed
|
||||
--libdir=lib
|
||||
-Dsystemtap=true
|
||||
-Ddtrace=true
|
||||
-Dfam=true
|
||||
-Dinstalled_tests=true
|
||||
_build
|
||||
- ninja -C _build
|
||||
- mkdir -p _coverage
|
||||
- lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --initial --output-file "_coverage/${CI_JOB_NAME}-baseline.lcov"
|
||||
- meson test -C _build --timeout-multiplier ${MESON_TEST_TIMEOUT_MULTIPLIER}
|
||||
- lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --output-file "_coverage/${CI_JOB_NAME}.lcov"
|
||||
# FIXME: We should run all installed tests, but do only this one for now
|
||||
# because it cannot run uninstalled. Reconfigure with dtrace disabled
|
||||
# because it breaks static link.
|
||||
- meson configure -Ddtrace=false _build
|
||||
- ninja -C _build install
|
||||
- GLIB_TEST_COMPILATION=1 $HOME/glib-installed/libexec/installed-tests/glib/static-link.py $HOME/glib-installed/lib/pkgconfig
|
||||
artifacts:
|
||||
name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
|
||||
when: always
|
||||
|
@ -376,6 +376,18 @@ if installed_tests_enabled
|
||||
install_subdir('desktop-files', install_dir : installed_tests_execdir)
|
||||
install_subdir('thumbnails', install_dir : installed_tests_execdir)
|
||||
install_subdir('cert-tests', install_dir : installed_tests_execdir)
|
||||
|
||||
cdata = configuration_data()
|
||||
cdata.set('installed_tests_dir', installed_tests_execdir)
|
||||
cdata.set('program', 'static-link.py ' + glib_pkgconfigreldir)
|
||||
configure_file(
|
||||
input: installed_tests_template,
|
||||
output: 'static-link.test',
|
||||
install_dir: installed_tests_metadir,
|
||||
configuration: cdata
|
||||
)
|
||||
install_subdir('static-link', install_dir : installed_tests_execdir)
|
||||
install_data('static-link.py', install_dir : installed_tests_execdir)
|
||||
endif
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
|
51
gio/tests/static-link.py
Executable file
51
gio/tests/static-link.py
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (C) 2018 Collabora Inc.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General
|
||||
# Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Author: Xavier Claessens <xavier.claessens@collabora.com>
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import subprocess
|
||||
|
||||
if not 'GLIB_TEST_COMPILATION' in os.environ:
|
||||
print('''Test disabled because GLIB_TEST_COMPILATION is not set in the env.
|
||||
If you wish to run this test, set GLIB_TEST_COMPILATION=1 in the env,
|
||||
and make sure you have glib build dependencies installed, including
|
||||
meson.''')
|
||||
sys.exit(0)
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print('Usage: {} <gio-2.0.pc dir>'.format(os.path.basename(sys.argv[0])))
|
||||
sys.exit(1)
|
||||
|
||||
test_dir = os.path.dirname(sys.argv[0])
|
||||
|
||||
with tempfile.TemporaryDirectory() as builddir:
|
||||
env = os.environ.copy()
|
||||
env['PKG_CONFIG_PATH'] = sys.argv[1]
|
||||
sourcedir = os.path.join(test_dir, 'static-link')
|
||||
|
||||
# Ensure we can static link and run a test app
|
||||
subprocess.check_call(['meson', sourcedir, builddir], env=env)
|
||||
subprocess.check_call(['ninja', '-C', builddir, 'test'], env=env)
|
||||
# FIXME: This probably only works on Linux
|
||||
out = subprocess.check_output(['ldd', os.path.join(builddir, 'test-static-link')], env=env).decode()
|
||||
if 'libgio' in out:
|
||||
print('test-static-link is dynamically linked on libgio')
|
||||
exit(1)
|
8
gio/tests/static-link/app.c
Normal file
8
gio/tests/static-link/app.c
Normal file
@ -0,0 +1,8 @@
|
||||
#include <gio/gio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
GApplication *app = g_application_new (NULL, 0);
|
||||
g_object_unref (app);
|
||||
return 0;
|
||||
}
|
8
gio/tests/static-link/meson.build
Normal file
8
gio/tests/static-link/meson.build
Normal file
@ -0,0 +1,8 @@
|
||||
project('test-static-link', 'c')
|
||||
|
||||
# This is a dummy project that static links against installed gio.
|
||||
# See gio/tests/static-link.py.
|
||||
app = executable('test-static-link', 'app.c',
|
||||
dependencies : dependency('gio-2.0', static : true)
|
||||
)
|
||||
test('test-static-link', app)
|
Loading…
Reference in New Issue
Block a user