Add superficial smoke-tests for the library and GIR data
authorSimon McVittie <smcv@debian.org>
Wed, 26 Aug 2020 09:16:11 +0000 (10:16 +0100)
committerSimon McVittie <smcv@debian.org>
Wed, 26 Aug 2020 09:37:28 +0000 (10:37 +0100)
debian/copyright
debian/tests/control [new file with mode: 0644]
debian/tests/gir1.2-babl-0.1 [new file with mode: 0755]
debian/tests/libbabl-dev [new file with mode: 0755]

index 5e73e158da492ca253409104dd6a59ba77b82009..4c39118e4d2a3ff36b63e2e0c0a40a8a9b08c0cd 100644 (file)
@@ -29,7 +29,9 @@ License: GPL-3+ with GGGL exception
 Files: debian/*
 Copyright: 2007, Étienne Bersac <bersace03@laposte.net>
            2012, Matteo F. Vescovi <mfv@debian.org>
-License: LGPL-3+
+           2020 Collabora Ltd.
+           2020 Simon McVittie
+License: LGPL-3+ and Expat
 
 License: Expat
  SPDX-License-Identifier: MIT
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644 (file)
index 0000000..99b1574
--- /dev/null
@@ -0,0 +1,7 @@
+Tests: libbabl-dev
+Depends: build-essential, pkg-config, libbabl-dev
+Restrictions: allow-stderr, superficial
+
+Tests: gir1.2-babl-0.1
+Depends: gir1.2-babl-0.1, python3-gi
+Restrictions: allow-stderr, superficial
diff --git a/debian/tests/gir1.2-babl-0.1 b/debian/tests/gir1.2-babl-0.1
new file mode 100755 (executable)
index 0000000..c4ae698
--- /dev/null
@@ -0,0 +1,14 @@
+#!/usr/bin/python3
+# Copyright 2020 Simon McVittie
+# SPDX-License-Identifier: MIT
+
+import os
+
+import gi
+gi.require_version('Babl', '0.1')
+
+from gi.repository import Babl
+
+if __name__ == '__main__':
+    triple = Babl.get_version()
+    assert tuple(triple) >= (0, 1)
diff --git a/debian/tests/libbabl-dev b/debian/tests/libbabl-dev
new file mode 100755 (executable)
index 0000000..13bb908
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright 2020 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+
+set -eux
+
+if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then
+    CROSS_COMPILE="$DEB_HOST_GNU_TYPE-"
+else
+    CROSS_COMPILE=
+fi
+
+cd "$AUTOPKGTEST_TMP"
+
+cat > trivial.c <<EOF
+#include <babl/babl.h>
+
+#undef NDEBUG
+#include <assert.h>
+
+int main(void)
+{
+    int x, y, z;
+
+    babl_get_version(&x, &y, &z);
+    assert(x >= 0);
+    assert(y >= 0);
+    assert(z >= 0);
+    assert((x * 1000) + y >= 1);
+    return 0;
+}
+EOF
+
+# Deliberately word-splitting pkg-config's output:
+# shellcheck disable=SC2046
+"${CROSS_COMPILE}gcc" -otrivial trivial.c $("${CROSS_COMPILE}pkg-config" --cflags --libs babl)
+./trivial