Commit 0bab2bf2 authored by Simon McVittie's avatar Simon McVittie

Add simple compile/link/execute autopkgtest, based on GLib's

This checks that dynamic linking with either pkg-config or
sdl2-config works correctly. I'd normally also test static linking,
but that doesn't actually work, because libSDL2 depends on
libasound, which hasn't provided a static library in Debian since
2013.
parent 10a830fc
libsdl2 (2.0.8+dfsg1-3.1) UNRELEASED; urgency=medium
* Non-maintainer upload.
* d/tests/build: Add autopkgtest to check that dynamic linking with
either pkg-config or sdl2-config works correctly
-- Simon McVittie <smcv@debian.org> Sun, 30 Sep 2018 15:16:22 +0100
libsdl2 (2.0.8+dfsg1-3) unstable; urgency=medium
[ Hugh McMaster <hugh.mcmaster@outlook.com> ]
......
......@@ -113,6 +113,8 @@ Copyright: 2015, Gianfranco Costamagna <locutusofborg@debian.org>
2002-2007, Josselin Mouette <joss@debian.org>
2001, Christian T. Steigies <cts@debian.org>
2001, Branden Robinson <branden@debian.org>
2012, Canonical Ltd.
2018, Simon McVittie
License: LGPL-2.1+
License: SGI-Free-Software-License-B
......
#!/bin/sh
# autopkgtest check: Build and run a program against SDL, to verify that the
# headers and pkg-config file are installed correctly
#
# Based on glib2.0's debian/tests/build
# (C) 2012 Canonical Ltd.
# (C) 2018 Simon McVittie
# Authors: Martin Pitt, Simon McVittie
set -eux
# Ideally this test could be re-run with mode=static. However, statically
# linking libSDL2 doesn't actually work, because there is no libasound.a
# in libasound-dev (since 1.0.27-3 in 2013).
mode=dynamic
WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR
cat <<EOF > use-sdl.c
#undef NDEBUG
#include <assert.h>
#include <SDL_version.h>
int main(void)
{
SDL_version compiled;
SDL_version linked;
SDL_VERSION(&compiled);
SDL_GetVersion(&linked);
assert(compiled.major == 2);
assert(linked.major == 2);
return 0;
}
EOF
for tool in pkg-config sdl2-config; do
cflags=
pcflags=
scflags=--libs
case "$mode" in
(static)
cflags=-static
pcflags=--static
scflags=--static-libs
;;
esac
case "$tool" in
(pkg-config)
gcc $cflags -o use-${tool}-${mode} use-sdl.c `pkg-config $pcflags --cflags --libs sdl2`
;;
(sdl2-config)
gcc $cflags -o use-${tool}-${mode} use-sdl.c `sdl2-config --cflags $scflags`
;;
(*)
exit 1
;;
esac
echo "build (with $tool, $mode): OK"
[ -x use-${tool}-${mode} ]
./use-${tool}-${mode}
echo "run (with $tool, $mode): OK"
done
Tests: build
Depends: libsdl2-dev, build-essential
Restrictions: allow-stderr
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment