Package: libfreeaptx
Version: 0.1.1-1
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, and encode and decode tests copying the
examples from the upstream github webpage. The tests are using a .wav
from alsa-utils but it might make sense to include a wav in the package
instead to avoid relying on external packages which might change in the
futur.
We are using that change in Ubuntu now as having tests is a requirement
to promote packages and we plan to preinstall libfreeaptx as part of the
switch to pipewire.
Thanks for considering
diff -Nru libfreeaptx-0.1.1/debian/changelog libfreeaptx-0.1.1/debian/changelog
--- libfreeaptx-0.1.1/debian/changelog 2021-12-17 12:05:02.000000000 +0100
+++ libfreeaptx-0.1.1/debian/changelog 2022-05-20 15:23:06.000000000 +0200
@@ -1,3 +1,10 @@
+libfreeaptx (0.1.1-2) UNRELEASED; urgency=medium
+
+ * debian/tests:
+ - include build, encore and decode autopkgtests
+
+ -- Sebastien Bacher <seb...@ubuntu.com> Fri, 20 May 2022 15:23:06 +0200
+
libfreeaptx (0.1.1-1) unstable; urgency=medium
* Initial release (Closes: #995607)
diff -Nru libfreeaptx-0.1.1/debian/control libfreeaptx-0.1.1/debian/control
--- libfreeaptx-0.1.1/debian/control 2021-12-17 12:05:02.000000000 +0100
+++ libfreeaptx-0.1.1/debian/control 2022-05-20 15:23:06.000000000 +0200
@@ -1,6 +1,7 @@
Source: libfreeaptx
Priority: optional
-Maintainer: Kentaro Hayashi <ken...@xdump.org>
+Maintainer: Ubuntu Developers <ubuntu-devel-disc...@lists.ubuntu.com>
+XSBC-Original-Maintainer: Kentaro Hayashi <ken...@xdump.org>
Build-Depends: debhelper-compat (= 13)
Standards-Version: 4.6.0
Section: libs
diff -Nru libfreeaptx-0.1.1/debian/tests/build libfreeaptx-0.1.1/debian/tests/build
--- libfreeaptx-0.1.1/debian/tests/build 1970-01-01 01:00:00.000000000 +0100
+++ libfreeaptx-0.1.1/debian/tests/build 2022-05-20 14:56:01.000000000 +0200
@@ -0,0 +1,31 @@
+#!/bin/sh
+# autopkgtest check: Build and run a program against libfreeaptx, 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 > libfreeaptx_test.c
+#include "freeaptx.h"
+
+int main(void)
+{
+ struct aptx_context *dec;
+ dec = aptx_init(0);
+ return 0;
+}
+EOF
+
+# deliberately word-splitting pkg-config output:
+# shellcheck disable=SC2046
+"${CROSS_COMPILE}gcc" -o libfreeaptx_test libfreeaptx_test.c \
+$("${CROSS_COMPILE}pkg-config" --cflags --libs libfreeaptx)
+echo "build: OK"
+[ -x libfreeaptx_test ]
+./libfreeaptx_test
+echo "run: OK"
diff -Nru libfreeaptx-0.1.1/debian/tests/control libfreeaptx-0.1.1/debian/tests/control
--- libfreeaptx-0.1.1/debian/tests/control 1970-01-01 01:00:00.000000000 +0100
+++ libfreeaptx-0.1.1/debian/tests/control 2022-05-20 15:22:48.000000000 +0200
@@ -0,0 +1,11 @@
+Tests: build
+Depends: build-essential, pkg-config, libfreeaptx-dev
+Restrictions: allow-stderr superficial
+
+Test-Command: sox /usr/share/sounds/alsa/Noise.wav -t raw -r 44.1k -L -e s -b 24 -c 2 - | freeaptxenc > $AUTOPKGTEST_TMP/sample.aptx; freeaptxdec < $AUTOPKGTEST_TMP/sample.aptx | sox -t raw -r 44.1k -L -e s -b 24 -c 2 - $AUTOPKGTEST_TMP/sample.wav
+Depends: alsa-utils, freeaptx-utils, sox
+Features: test-name=encore_decode
+
+Test-Command: sox /usr/share/sounds/alsa/Noise.wav -t raw -r 44.1k -L -e s -b 24 -c 2 - | freeaptxenc --hd > $AUTOPKGTEST_TMP/sample.aptx; freeaptxdec --hd < $AUTOPKGTEST_TMP/sample.aptx | sox -t raw -r 44.1k -L -e s -b 24 -c 2 - $AUTOPKGTEST_TMP/sample.wav
+Depends: alsa-utils, freeaptx-utils, sox
+Features: test-name=encore_decode_hd