Package: libsdl2-net-dev
Version: 2.0.1+dfsg1-4
Severity: wishlist
Tags: patch

While backporting libsdl2-net to a Debian derivative I added the
attached autopkgtest. It doesn't have much coverage, but it does
demonstrate that the -dev package doesn't have missing dependencies
and that the library doesn't immediately crash. I've found that smoke
tests of this sort are surprisingly effective for detecting regressions.

    smcv
>From f2e1f1efe72de88a8d9189d42ae7f99e14aec24b Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@collabora.com>
Date: Tue, 24 Sep 2019 12:58:57 +0100
Subject: [PATCH] d/tests: Add basic autopkgtest smoke-test to prove the
 library works

This builds the example program showinterfaces, and runs it. It doesn't
provide much coverage, but does at least demonstrate that the -dev
package is working correctly, without missing dependencies.

Signed-off-by: Simon McVittie <s...@collabora.com>
---
 debian/tests/control         |  6 ++++++
 debian/tests/libsdl2-net-dev | 22 ++++++++++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 100644 debian/tests/control
 create mode 100755 debian/tests/libsdl2-net-dev

diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..f2d2968
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,6 @@
+Tests: libsdl2-net-dev
+Restrictions: allow-stderr, superficial
+Depends:
+ libsdl2-net-dev,
+ xauth,
+ xvfb,
diff --git a/debian/tests/libsdl2-net-dev b/debian/tests/libsdl2-net-dev
new file mode 100755
index 0000000..432684c
--- /dev/null
+++ b/debian/tests/libsdl2-net-dev
@@ -0,0 +1,22 @@
+#!/bin/sh
+# Copyright 2019 Collabora Ltd.
+# SPDX-License-Identifier: Zlib
+# (see "zlib/libpng" in debian/copyright)
+
+set -eux
+
+if [ -n "${AUTOPKGTEST_ARTIFACTS-}" ]; then
+	WORKDIR="$AUTOPKGTEST_ARTIFACTS"
+else
+	WORKDIR="$(mktemp -d)"
+	trap 'cd /; rm -fr "$WORKDIR"' 0 INT QUIT ABRT PIPE TERM
+fi
+
+cp showinterfaces.c "$WORKDIR"
+
+cd "$WORKDIR"
+
+# Deliberately word-splitting pkg-config's output:
+# shellcheck disable=SC2046
+gcc -oshowinterfaces showinterfaces.c $(pkg-config --cflags --libs SDL2_net)
+xvfb-run -a ./showinterfaces
-- 
2.23.0

Reply via email to