diff --git a/Makefile.am b/Makefile.am index 8811a57cb2314cc2564086c477c2c814c7c6afcb..fdd6a852eacb868eb2b4be4992353dd65668f82f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -195,7 +195,9 @@ LOG_COMPILER = TEST_EXTENSIONS = .pl PL_LOG_DRIVER = $(LOG_DRIVER) PL_LOG_COMPILER = $(PERL) -AM_TESTS_ENVIRONMENT = export CAPSULE_TESTS_UNINSTALLED=1; \ +AM_TESTS_ENVIRONMENT = export CAPSULE_SYMBOLS_TOOL="$(abs_builddir)/capsule-symbols";\ + export CAPSULE_TESTS_UNINSTALLED=1; \ + export CAPSULE_VERSION_TOOL="$(abs_builddir)/capsule-version";\ export G_TEST_SRCDIR="$(abs_srcdir)"; \ export G_TEST_BUILDDIR="$(abs_builddir)";\ export G_DEBUG=gc-friendly; \ @@ -208,7 +210,9 @@ tests_notgl_helper_user_LDADD = tests/lib/libnotgl.la \ test_extra_scripts = tests/manual/gl.pl test_programs = -test_scripts = tests/notgl.pl +test_scripts = tests/notgl.pl \ + tests/symbols.pl \ + tests/version.pl nobase_insttests_PROGRAMS = $(test_programs) \ $(test_extra_programs) nobase_dist_insttests_SCRIPTS = $(test_scripts) \ diff --git a/debian/control b/debian/control index edaa17f67f442f32881556685b884a590bcf2380..c1bf054ce3df18479daed9355385431306546cf2 100644 --- a/debian/control +++ b/debian/control @@ -13,8 +13,10 @@ Build-Depends: gtk-doc-tools, libelf-dev, libipc-run-perl, + libjpeg62-turbo <!nocheck> | libjpeg62 (>= 6b1) <!nocheck>, perl, xsltproc, + zlib1g <!nocheck>, Vcs-Git: https://gitlab.collabora.com/vivek/libcapsule.git Vcs-Browser: https://gitlab.collabora.com/vivek/libcapsule Homepage: https://gitlab.collabora.com/vivek/libcapsule diff --git a/debian/tests/control b/debian/tests/control index 118ec569ea0cbb60db828b4311d207669463130e..7e3978f0506d312283a34462a6462a1c892d8592 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -1,4 +1,4 @@ -Tests: smoke symbols version +Tests: smoke Restrictions: allow-stderr Depends: bubblewrap, @@ -14,7 +14,13 @@ Depends: Tests: gnome-desktop-testing Restrictions: allow-stderr Depends: + bubblewrap, gnome-desktop-testing, + libcapsule-dev, + libcapsule-dev-bin, libcapsule-tests, libipc-run-perl, + libjpeg62 (>= 6b1) | libjpeg62-turbo, perl, + pkg-config, + zlib1g, diff --git a/debian/tests/symbols b/debian/tests/symbols deleted file mode 100755 index 233d7e813e9c59f3be2f3d256c517abbd7dfbcda..0000000000000000000000000000000000000000 --- a/debian/tests/symbols +++ /dev/null @@ -1,73 +0,0 @@ -#!/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/../../tests"; - -use CapsuleTest; - -skip_all_unless_bwrap; - -my $test_tempdir = File::Temp->newdir(); -diag "Working directory: $test_tempdir"; -my $host = "${test_tempdir}/host"; -mkdir($host); - -my $libexecdir = `pkg-config --variable=libexecdir capsule`; -chomp $libexecdir; -my $CAPSULE_SYMBOLS_TOOL = "$libexecdir/capsule-symbols"; - -# We need a well-behaved library with a simple ABI to inspect. Let's use -# libcapsule itself :-) -my $output; -run_ok([qw(bwrap --ro-bind / / --ro-bind /), $host, - qw(--dev-bind /dev /dev), - $CAPSULE_SYMBOLS_TOOL, 'libcapsule.so.0', $host], '>', \$output); -diag_multiline $output; - -like($output, qr{^capsule_init $}m, "capsule_init is an unversioned symbol"); -unlike($output, qr{^(?!capsule)}m, "all of libcapsule's ABI matches /^capsule/"); - -# Try the same thing without a prefix -run_ok([$CAPSULE_SYMBOLS_TOOL, 'libcapsule.so.0', '/'], '>', \$output); -diag_multiline $output; - -like($output, qr{^capsule_init $}m, "capsule_init is an unversioned symbol"); -unlike($output, qr{^(?!capsule)}m, "all of libcapsule's ABI matches /^capsule/"); - -# How about versioned symbols? -run_ok([$CAPSULE_SYMBOLS_TOOL, 'libjpeg.so.62', '/'], '>', \$output); -diag_multiline $output; - -like($output, qr{^jpeg_destroy \@\@LIBJPEG_6\.2$}m, - "jpeg_destroy is a versioned symbol"); -unlike($output, qr{^jpeg_destroy (?!\@\@LIBJPEG_6\.2)}m, - "jpeg_destroy does not appear unversioned"); - -done_testing; - -# vim:set sw=4 sts=4 et: diff --git a/tests/symbols.pl b/tests/symbols.pl new file mode 100755 index 0000000000000000000000000000000000000000..397cb5ed8ad6fab6cbedeba51c48209fadac3911 --- /dev/null +++ b/tests/symbols.pl @@ -0,0 +1,98 @@ +#!/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_bwrap; + +my $test_tempdir = File::Temp->newdir(); +diag "Working directory: $test_tempdir"; +my $host = "${test_tempdir}/host"; +mkdir($host); + +my $CAPSULE_SYMBOLS_TOOL = $ENV{CAPSULE_SYMBOLS_TOOL}; + +unless (defined $CAPSULE_SYMBOLS_TOOL) { + my $libexecdir = `pkg-config --variable=libexecdir capsule`; + chomp $libexecdir; + $CAPSULE_SYMBOLS_TOOL = "$libexecdir/capsule-symbols"; +} + +if (length $ENV{CAPSULE_TESTS_UNINSTALLED}) { + my $path = $ENV{LD_LIBRARY_PATH}; + + if (length $path) { + $path = "$ENV{G_TEST_BUILDDIR}/.libs:$path"; + } + else { + $path = $ENV{G_TEST_BUILDDIR}; + } + + $ENV{LD_LIBRARY_PATH} = $path; + + TODO: { + local $TODO = "capsule-symbols doesn't respect LD_LIBRARY_PATH"; + fail 'Re-enable this later'; + } +} +else { + # We need a well-behaved library with a simple ABI to inspect. Let's use + # libcapsule itself :-) + my $output; + run_ok([qw(bwrap --ro-bind / / --ro-bind /), $host, + qw(--dev-bind /dev /dev), + $CAPSULE_SYMBOLS_TOOL, 'libcapsule.so.0', $host], '>', \$output); + diag_multiline $output; + return unless $output; + + like($output, qr{^capsule_init $}m, "capsule_init is an unversioned symbol"); + unlike($output, qr{^(?!capsule)}m, "all of libcapsule's ABI matches /^capsule/"); + + # Try the same thing without a prefix + run_ok([$CAPSULE_SYMBOLS_TOOL, 'libcapsule.so.0', '/'], '>', \$output); + diag_multiline $output; + + like($output, qr{^capsule_init $}m, "capsule_init is an unversioned symbol"); + unlike($output, qr{^(?!capsule)}m, "all of libcapsule's ABI matches /^capsule/"); +} + +# How about versioned symbols? +my $output; +run_ok([$CAPSULE_SYMBOLS_TOOL, 'libjpeg.so.62', '/'], '>', \$output); +diag_multiline $output; + +like($output, qr{^jpeg_destroy \@\@LIBJPEG_6\.2$}m, + "jpeg_destroy is a versioned symbol"); +unlike($output, qr{^jpeg_destroy (?!\@\@LIBJPEG_6\.2)}m, + "jpeg_destroy does not appear unversioned"); + +done_testing; + +# vim:set sw=4 sts=4 et: diff --git a/debian/tests/version b/tests/version.pl similarity index 83% rename from debian/tests/version rename to tests/version.pl index 57f89c20c80facd1a08b781af1b7d37315a523f0..f0097b81bedc6efd74f4e01a974f9f565ce9a428 100755 --- a/debian/tests/version +++ b/tests/version.pl @@ -26,7 +26,7 @@ use IPC::Run qw(run); use Test::More; use FindBin; -use lib "$FindBin::Bin/../../tests"; +use lib $FindBin::Bin; use CapsuleTest; @@ -37,15 +37,20 @@ diag "Working directory: $test_tempdir"; my $host = "${test_tempdir}/host"; mkdir($host); -my $libexecdir = `pkg-config --variable=libexecdir capsule`; -chomp $libexecdir; -my $CAPSULE_VERSION_TOOL = "$libexecdir/capsule-version"; +my $CAPSULE_VERSION_TOOL = $ENV{CAPSULE_VERSION_TOOL}; + +unless (defined $CAPSULE_VERSION_TOOL) { + my $libexecdir = `pkg-config --variable=libexecdir capsule`; + chomp $libexecdir; + $CAPSULE_VERSION_TOOL = "$libexecdir/capsule-version"; +} my $output; my ($root, $soname, $version, $path); run_ok([qw(bwrap --ro-bind / / --ro-bind /), $host, qw(--dev-bind /dev /dev), $CAPSULE_VERSION_TOOL, 'libz.so.1', $host], '>', \$output); +diag("→ $output"); like($output, qr{^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$}); $output =~ m{^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$}; $root = $1; @@ -61,6 +66,7 @@ ok(-e $path); # Try the same thing without a prefix run_ok([$CAPSULE_VERSION_TOOL, 'libz.so.1', '/'], '>', \$output); +diag("→ $output"); like($output, qr{^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$}); $output =~ m{^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$}; $root = $1; @@ -82,6 +88,7 @@ ok(-e $1); # A different way run_ok([$CAPSULE_VERSION_TOOL, 'libz.so.1', ''], '>', \$output); +diag("→ $output"); like($output, qr{^(\S*)\s+(\S+)\s+(\S+)\s+(\S+)$}); $output =~ m{^(\S*)\s+(\S+)\s+(\S+)\s+(\S+)$}; $root = $1; @@ -94,15 +101,12 @@ TODO: { local $TODO = 'returns 1 for some reason'; like($version, qr{^1\.[0-9]+\.[0-9]+$}); } -TODO: { - local $TODO = "would be nice if this didn't start with //"; - like($path, qr{^(/?(?:usr/)?lib/.*-linux-gnu.*/libz\.so\.\Q$version\E)$}); -} -like($path, qr{^(//?(?:usr/)?lib/.*-linux-gnu.*/libz\.so\.\Q$version\E)$}); +like($path, qr{^(/?(?:usr/)?lib/.*-linux-gnu.*/libz\.so\.\Q$version\E)$}); ok(-e $path); # Another different way run_ok([$CAPSULE_VERSION_TOOL, 'libz.so.1'], '>', \$output); +diag("→ $output"); like($output, qr{^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$}); $output =~ m{^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$}; $root = $1; @@ -116,11 +120,7 @@ TODO: { local $TODO = 'returns 1 for some reason'; like($version, qr{^1\.[0-9]+\.[0-9]+$}); } -TODO: { - local $TODO = "would be nice if this didn't start with //"; - like($path, qr{^(/?(?:usr/)?lib/.*-linux-gnu.*/libz\.so\.\Q$3\E)$}); -} -like($path, qr{^(//?(?:usr/)?lib/.*-linux-gnu.*/libz\.so\.\Q$3\E)$}); +like($path, qr{^(/?(?:usr/)?lib/.*-linux-gnu.*/libz\.so\.\Q$3\E)$}); ok(-e $path); done_testing;