[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#893391: libinput: please add an autopkgtest smoke-test for the library



Source: libinput
Version: 1.10.3-1
Severity: wishlist
Tags: patch

Some common failure modes of library packaging (particularly around
dependencies or transitions) result in inability to link dependent
binaries to the library. To catch mistakes before they become
release-critical, it's useful to have an autopkgtest that checks that
the library can work at all, even if it's a library that is awkward or
impossible to test more thoroughly.

I attach a simple autopkgtest that checks that libinput-dev can be
initialized and uninitialized, loosely based on one that I added to dbus.

I included a test for static linking, but libinput-dev doesn't seem to
contain libinput.a, so I've assumed that linking to it statically is
unsupported and left that part of the test commented out.

Note that I don't really know this library, so if I'm using it
incorrectly or in ways that are not what its upstream developers would
recommend, the test might need adjusting. It seems to work locally though.

If libinput_path_create_context() cannot legitimately fail (even in a
chroot or container running as an unprivileged user) then you might
want to make the test abort() if that call fails.

Thanks,
    smcv
>From f850c612b25fe8964ff900447f444698578572cc Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@debian.org>
Date: Sun, 18 Mar 2018 14:24:20 +0000
Subject: [PATCH] Add a simple compile/link/execute smoke-test for libinput-dev

This verifies that it is possible to link to libinput, and would have
detected #893067.

Signed-off-by: Simon McVittie <smcv@debian.org>
---
 debian/tests/build   | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 debian/tests/control |  2 ++
 2 files changed, 62 insertions(+)
 create mode 100755 debian/tests/build
 create mode 100644 debian/tests/control

diff --git a/debian/tests/build b/debian/tests/build
new file mode 100755
index 00000000..bacd15e1
--- /dev/null
+++ b/debian/tests/build
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+exec 2>&1
+set -eux
+
+cd "${AUTOPKGTEST_TMP:-"${ADTTMP}"}"
+
+echo "1..2"
+
+cat > simple.c <<'EOF'
+#include <libinput.h>
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+static int
+my_open (const char *path, int flags, void *user_data)
+{
+  return open (path, flags);
+}
+
+static void
+my_close (int fd, void *user_data)
+{
+  close (fd);
+}
+
+static struct libinput_interface iface = { my_open, my_close };
+
+int
+main (void)
+{
+  struct libinput *ctx;
+
+  ctx = libinput_path_create_context (&iface, NULL);
+
+  if (ctx)
+    libinput_unref (ctx);
+
+  return 0;
+}
+EOF
+
+gcc -o dynamic simple.c $(pkg-config --cflags --libs libinput)
+echo "ok 1 - compile dynamic executable"
+test -x dynamic
+./dynamic
+echo "ok 2 - run dynamic executable"
+
+# This should also be tested if linking statically to libinput is supported
+#gcc -static -o static simple.c $(pkg-config --static --cflags --libs libinput)
+#echo "ok 3 - compile static executable"
+#test -x static
+#./static
+#echo "ok 4 - run static executable"
+
+echo "# everything seems OK"
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 00000000..493aaf0f
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,2 @@
+Tests: build
+Depends: build-essential, libinput-dev
-- 
2.16.2


Reply to: