diff --git a/debian/tests/control b/debian/tests/control index 1e2ace21d563c029e54d91fcf1514e828648205b..6d902f543dd456fbd2d1855e44593bbf50373730 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -3,11 +3,12 @@ Depends: build-essential, libcapsule-dev, -Tests: version +Tests: symbols version Depends: bubblewrap, libcapsule-dev, libcapsule-dev-bin, + libjpeg62 (>= 6b1) | libjpeg62-turbo, zlib1g, Tests: gnome-desktop-testing diff --git a/debian/tests/symbols b/debian/tests/symbols new file mode 100755 index 0000000000000000000000000000000000000000..50cd0b23e1958a0cb8cb8749d56a087cca552b6a --- /dev/null +++ b/debian/tests/symbols @@ -0,0 +1,66 @@ +#!/bin/bash + +# 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/>. + +set -eu -o pipefail + +. "$(dirname "$0")"/../../tests/libtest.sh + +if ! bwrap --ro-bind / / true; then + skip_all "1..0 # SKIP - cannot run bwrap" +fi + +scratch="$(mktemp -d)" +echo "# Working directory: $scratch" +cd "$scratch" +trap 'cd /; rm -fr $scratch' EXIT +host="${scratch}/host" +mkdir "${host}" + +CAPSULE_SYMBOLS="$(pkg-config --variable=libexecdir capsule)/capsule-symbols" + +# We need a well-behaved library with a simple ABI to inspect. Let's use +# libcapsule itself :-) +bwrap --ro-bind / / --ro-bind / "${host}" --dev-bind /dev /dev \ + ${CAPSULE_SYMBOLS} libcapsule.so.0 "${host}" > output +pass "Ran ${CAPSULE_SYMBOLS} libcapsule.so.0 ${host}" + +exec_is 'grep "^capsule_init" output' 0 "capsule_init " \ + "capsule_init is part of libcapsule's ABI" +exec_is 'grep -v "^capsule" output' 1 "" \ + "all of libcapsule's ABI matches /^capsule/" + +# Try the same thing without a prefix +${CAPSULE_SYMBOLS} libcapsule.so.0 / > output +pass "Ran ${CAPSULE_SYMBOLS} libcapsule.so.0 /" + +exec_is 'grep "^capsule_init" output' 0 "capsule_init " \ + "capsule_init is an unversioned symbol" +exec_is 'grep -v "^capsule" output' 1 "" \ + "all of libcapsule's ABI matches /^capsule/" + +# How about versioned symbols? +${CAPSULE_SYMBOLS} libjpeg.so.62 / > output +pass "Ran ${CAPSULE_SYMBOLS} libjpeg.so.62 /" + +exec_is 'grep "^jpeg_destroy " output' 0 'jpeg_destroy @@LIBJPEG_6.2' \ + "jpeg_destroy is a versioned symbol" + +done_testing + +# vim:set sw=4 sts=4 et: diff --git a/debian/tests/version b/debian/tests/version index d696d9db9ae96ef7666028f9ac722da409d10010..892e5b5c58fc436d6fe6a6dccd2fa758896a4cff 100755 --- a/debian/tests/version +++ b/debian/tests/version @@ -44,6 +44,41 @@ like "$4" "${host}/@(usr/lib|lib)/*-linux-gnu*/libz.so.$3" test -e "${4#${host}}" pass "successfully found libz" +# Try the same thing without a prefix +output="$(${CAPSULE_VERSION} libz.so.1 "/")" +set -- $output +is "$1" "/" +is "$2" libz.so.1 +# TODO: This just returns 1? +#like "$3" "1.*.*" +# TODO: Would be nice if this didn't start with // +like "$4" "+(/)@(usr/lib|lib)/*-linux-gnu*/libz.so.$3" +test -e "$4" +pass "successfully found libz" + +# A different way +output="$(${CAPSULE_VERSION} libz.so.1 "")" +set -- $output +is "$1" libz.so.1 +# TODO: This just returns 1? +#like "$2" "1.*.*" +like "$3" "/@(usr/lib|lib)/*-linux-gnu*/libz.so.$2" +test -e "$3" +pass "successfully found libz" + +# Another different way +output="$(${CAPSULE_VERSION} libz.so.1 "/")" +set -- $output +# TODO: This should probably not try to print NULL +#is "$1" "(null)" +is "$2" libz.so.1 +# TODO: This just returns 1? +#like "$3" "1.*.*" +# TODO: Would be nice if this didn't start with // +like "$4" "+(/)@(usr/lib|lib)/*-linux-gnu*/libz.so.$3" +test -e "$4" +pass "successfully found libz" + done_testing # vim:set sw=4 sts=4 et: