• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3
4# Copyright (C) 2018 Collabora Inc.
5#
6# This library is free software; you can redistribute it and/or
7# modify it under the terms of the GNU Lesser General Public
8# License as published by the Free Software Foundation; either
9# version 2.1 of the License, or (at your option) any later version.
10#
11# This library is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14# Lesser General Public License for more details.
15#
16# You should have received a copy of the GNU Lesser General
17# Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
18#
19# Author: Xavier Claessens <xavier.claessens@collabora.com>
20
21import os
22import sys
23import tempfile
24import subprocess
25
26if not 'GLIB_TEST_COMPILATION' in os.environ:
27  print('''Test disabled because GLIB_TEST_COMPILATION is not set in the env.
28If you wish to run this test, set GLIB_TEST_COMPILATION=1 in the env,
29and make sure you have glib build dependencies installed, including
30meson.''')
31  sys.exit(0)
32
33if len(sys.argv) != 2:
34  print('Usage: {} <gio-2.0.pc dir>'.format(os.path.basename(sys.argv[0])))
35  sys.exit(1)
36
37test_dir = os.path.dirname(sys.argv[0])
38
39with tempfile.TemporaryDirectory() as builddir:
40  env = os.environ.copy()
41  env['PKG_CONFIG_PATH'] = sys.argv[1]
42  sourcedir = os.path.join(test_dir, 'static-link')
43
44  # Ensure we can static link and run a test app
45  subprocess.check_call(['meson', sourcedir, builddir], env=env)
46  subprocess.check_call(['ninja', '-C', builddir, 'test'], env=env)
47  # FIXME: This probably only works on Linux
48  out = subprocess.check_output(['ldd', os.path.join(builddir, 'test-static-link')], env=env).decode()
49  if 'libgio' in out:
50    print('test-static-link is dynamically linked on libgio')
51    exit(1)
52