• 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 "GLIB_TEST_COMPILATION" not in os.environ:
27    print(
28        """Test disabled because GLIB_TEST_COMPILATION is not set in the env.
29If you wish to run this test, set GLIB_TEST_COMPILATION=1 in the env,
30and make sure you have glib build dependencies installed, including
31meson."""
32    )
33    sys.exit(77)
34
35if len(sys.argv) != 2:
36    print("Usage: {} <gio-2.0.pc dir>".format(os.path.basename(sys.argv[0])))
37    sys.exit(1)
38
39test_dir = os.path.dirname(sys.argv[0])
40
41with tempfile.TemporaryDirectory() as builddir:
42    env = os.environ.copy()
43    env["PKG_CONFIG_PATH"] = sys.argv[1]
44    sourcedir = os.path.join(test_dir, "static-link")
45
46    # Ensure we can static link and run a test app
47    subprocess.check_call(["meson", sourcedir, builddir], env=env)
48    subprocess.check_call(["ninja", "-C", builddir, "test"], env=env)
49    # FIXME: This probably only works on Linux
50    out = subprocess.check_output(
51        ["ldd", os.path.join(builddir, "test-static-link")], env=env
52    ).decode()
53    if "libgio" in out:
54        print("test-static-link is dynamically linked on libgio")
55        exit(1)
56