Skip to content
Snippets Groups Projects
init-project.pl 7.79 KiB
#!/usr/bin/perl

# Copyright © 2017 Collabora Ltd
#
# This file is part of libcapsule.
#
# libcapsule 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.
#
# libcapsule 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 libcapsule.  If not, see <http://www.gnu.org/licenses/>.

use autodie;
use warnings;
use strict;

use File::Temp qw();
use IPC::Run qw(run);
use Test::More;

use FindBin;
use lib $FindBin::Bin;

use CapsuleTest;

skip_all_unless_nm;

my $test_tempdir = File::Temp->newdir();
diag "Working directory: $test_tempdir";
chdir $test_tempdir;

my ($output, $ignored, $error);

my @libcapsule_environment;
if (length $ENV{CAPSULE_TESTS_UNINSTALLED}) {
    # Make sure the shim can load the just-built libcapsule
    push @libcapsule_environment, "LD_LIBRARY_PATH=$ENV{G_TEST_BUILDDIR}/.libs";
}
delete $ENV{MAKEFLAGS};

my @configure_arguments = ();

if (length $ENV{CAPSULE_TESTS_GNU_BUILD}) {
    push @configure_arguments, '--build', $ENV{CAPSULE_TESTS_GNU_BUILD};
}

if (length $ENV{CAPSULE_TESTS_GNU_HOST}) {
    push @configure_arguments, '--host', $ENV{CAPSULE_TESTS_GNU_HOST};
}

run_ok([$CAPSULE_INIT_PROJECT_TOOL,
        '--search-tree=/',
        '--runtime-tree=/run/host',
        'libz.so.1/1.2.3',
        'libjpeg.so.62']);
run_ok([
        'sh', '-euc', 'cd "$1"; shift; ./configure "$@"',
        'sh', "$test_tempdir/libz-proxy",
        @configure_arguments,
        '--with-search-tree=/',
        '--with-runtime-tree=/host',
    ], '>&2');
run_ok(['make', '-C', "$test_tempdir/libz-proxy", 'V=1'], '>&2');