diff --git a/debian/tests/control b/debian/tests/control index 2b70beb5c046e2cc81b0af7b534a3dee64eaddb5..1e2ace21d563c029e54d91fcf1514e828648205b 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -3,6 +3,13 @@ Depends: build-essential, libcapsule-dev, +Tests: version +Depends: + bubblewrap, + libcapsule-dev, + libcapsule-dev-bin, + zlib1g, + Tests: gnome-desktop-testing Depends: gnome-desktop-testing, diff --git a/debian/tests/version b/debian/tests/version new file mode 100755 index 0000000000000000000000000000000000000000..42c00016ba5a9a8d58ae46c9218ba0110009830f --- /dev/null +++ b/debian/tests/version @@ -0,0 +1,55 @@ +#!/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 + +if ! [ -d /mnt ]; then + skip_all "1..0 # SKIP - this test needs /mnt" +fi + +scratch="$(mktemp -d)" +echo "# Working directory: $scratch" +cd "$scratch" +trap 'cd /; rm -fr $scratch' EXIT +# Work around what appears to be a recent regression? +#host="${scratch}/host" +#mkdir "${host}" +host=/mnt + +CAPSULE_VERSION="$(pkg-config --variable=libexecdir capsule)/capsule-version" + +output="$(bwrap --ro-bind / / --ro-bind / "${host}" --dev-bind /dev /dev \ + ${CAPSULE_VERSION} libz.so.1 "${host}")" +set -- $output +is "$1" "${host}" +is "$2" libz.so.1 +like "$3" "1.*.*" +like "$4" "${host}/@(usr/lib|lib)/*-linux-gnu*/libz.so.$3" +test -e "${4#${host}}" +pass "successfully found libz" + +done_testing + +# vim:set sw=4 sts=4 et: diff --git a/tests/libtest.sh b/tests/libtest.sh index f81601c5d3894a9dde7d8d5592a4565e28e1f453..938f96afa0be6a0c86565e094140c68a3e70378c 100644 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -71,6 +71,20 @@ is () { fi } +like () { + local got="$1" + local expected="$2" + shift 2 + + if [[ $got == $expected ]]; then + pass "$* ($got matches $expected)" + else + echo "# Got: $got" + echo "# Expected extglob: $expected" + fail "$* ($got does not match $expected)" + fi +} + isnt () { local got="$1" local unexpected="$2"