Skip to content
Snippets Groups Projects
Commit 2d744a3d authored by Simon McVittie's avatar Simon McVittie
Browse files

Expand test coverage for accompanying tools

parent f5fd8717
No related branches found
No related tags found
1 merge request!311Build capsule-capture-libs from a bundled copy of libcapsule
......@@ -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
......
#!/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:
......@@ -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:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment