Package: libldac
Version: 2.0.2.3+git20200429+ed310a0-4

It would be nicer if the package had autopkgtests testing. The attached patch is adding a trivial build test on the model of the ones used for most GNOME libraries, it ensure that a simple case builds and that the dev isn't missing any depends. We are using that change in Ubuntu now as having tests is a requirement for supported packages and libldac is a pipewrire depends.

Thanks for considering

diff -Nru libldac-2.0.2.3+git20200429+ed310a0/debian/changelog libldac-2.0.2.3+git20200429+ed310a0/debian/changelog
--- libldac-2.0.2.3+git20200429+ed310a0/debian/changelog	2020-07-16 19:03:09.000000000 +0200
+++ libldac-2.0.2.3+git20200429+ed310a0/debian/changelog	2022-05-19 15:50:16.000000000 +0200
@@ -1,3 +1,9 @@
+libldac (2.0.2.3+git20200429+ed310a0-5) unstable; urgency=medium
+
+  * debian/tests: add a basic build autopkgtest for the library
+
+ -- Sebastien Bacher <seb...@debian.org>  Thu, 19 May 2022 15:50:16 +0200
+
 libldac (2.0.2.3+git20200429+ed310a0-4) unstable; urgency=medium
 
   * Rebuild with no source changes.
diff -Nru libldac-2.0.2.3+git20200429+ed310a0/debian/tests/build libldac-2.0.2.3+git20200429+ed310a0/debian/tests/build
--- libldac-2.0.2.3+git20200429+ed310a0/debian/tests/build	1970-01-01 01:00:00.000000000 +0100
+++ libldac-2.0.2.3+git20200429+ed310a0/debian/tests/build	2022-05-19 15:45:50.000000000 +0200
@@ -0,0 +1,35 @@
+#!/bin/sh
+# autopkgtest check: Build and run a program against libldac, to verify that
+# the headers and pkg-config file are installed correctly
+
+set -e
+
+if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then
+    CROSS_COMPILE="$DEB_HOST_GNU_TYPE-"
+else
+    CROSS_COMPILE=
+fi
+
+cat <<EOF > libldac_test.c
+#include <assert.h>
+#include <ldacBT.h>
+#include <stddef.h>
+
+int main(void)
+{
+	HANDLE_LDAC_BT ldac;
+
+	assert(ldacBT_get_handle());
+
+	return 0;
+}
+EOF
+
+# deliberately word-splitting pkg-config output:
+# shellcheck disable=SC2046
+"${CROSS_COMPILE}gcc" -o libldac_test libldac_test.c \
+$("${CROSS_COMPILE}pkg-config" --cflags --libs ldacBT-enc)
+echo "build: OK"
+[ -x libldac_test ]
+./libldac_test
+echo "run: OK"
diff -Nru libldac-2.0.2.3+git20200429+ed310a0/debian/tests/control libldac-2.0.2.3+git20200429+ed310a0/debian/tests/control
--- libldac-2.0.2.3+git20200429+ed310a0/debian/tests/control	1970-01-01 01:00:00.000000000 +0100
+++ libldac-2.0.2.3+git20200429+ed310a0/debian/tests/control	2022-05-19 15:41:13.000000000 +0200
@@ -0,0 +1,3 @@
+Tests: build
+Depends: build-essential, pkg-config, libldacbt-enc-dev
+Restrictions: allow-stderr superficial

Reply via email to