summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2022-04-21 18:33:34 +0100
committerSimon McVittie <smcv@collabora.com>2022-04-21 19:51:53 +0100
commit4d5b1fcf0257f508f4b5e48b099f259b7bb9c908 (patch)
tree7748a739d6bce5851a169f402a5d3c77f3429f27 /tests
parent96ba9f4d8d747889a10e1a84594922e25fde495c (diff)
downloadlibglnx-4d5b1fcf0257f508f4b5e48b099f259b7bb9c908.tar.gz
tests: Verify libglnx can work as a subproject
What isn't tested usually doesn't work, and the only way to use libglnx is as a subproject, so test it like that. Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/use-as-subproject/.gitignore5
-rw-r--r--tests/use-as-subproject/README8
-rw-r--r--tests/use-as-subproject/config.h6
-rw-r--r--tests/use-as-subproject/dummy-config.h.in6
-rw-r--r--tests/use-as-subproject/meson.build25
-rw-r--r--tests/use-as-subproject/use-libglnx.c16
-rw-r--r--tests/use-as-subproject/use-testlib.c17
7 files changed, 83 insertions, 0 deletions
diff --git a/tests/use-as-subproject/.gitignore b/tests/use-as-subproject/.gitignore
new file mode 100644
index 0000000..ec6149f
--- /dev/null
+++ b/tests/use-as-subproject/.gitignore
@@ -0,0 +1,5 @@
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: LGPL-2.0-or-later
+
+/_build/
+/subprojects/
diff --git a/tests/use-as-subproject/README b/tests/use-as-subproject/README
new file mode 100644
index 0000000..cc43a09
--- /dev/null
+++ b/tests/use-as-subproject/README
@@ -0,0 +1,8 @@
+This is a simple example of a project that uses libglnx as a subproject.
+The intention is that if this project can successfully build and use libglnx
+as a subproject, then so could Flatpak.
+
+<!--
+Copyright 2022 Collabora Ltd.
+SPDX-License-Identifier: LGPL-2.0-or-later
+-->
diff --git a/tests/use-as-subproject/config.h b/tests/use-as-subproject/config.h
new file mode 100644
index 0000000..dffc647
--- /dev/null
+++ b/tests/use-as-subproject/config.h
@@ -0,0 +1,6 @@
+/*
+ * Copyright 2022 Collabora Ltd.
+ * SPDX-License-Identifier: LGPL-2.0-or-later
+ */
+
+#error Should not use superproject config.h to compile libglnx
diff --git a/tests/use-as-subproject/dummy-config.h.in b/tests/use-as-subproject/dummy-config.h.in
new file mode 100644
index 0000000..bffb52a
--- /dev/null
+++ b/tests/use-as-subproject/dummy-config.h.in
@@ -0,0 +1,6 @@
+/*
+ * Copyright 2022 Collabora Ltd.
+ * SPDX-License-Identifier: LGPL-2.0-or-later
+ */
+
+#error Should not use superproject generated config.h to compile libglnx
diff --git a/tests/use-as-subproject/meson.build b/tests/use-as-subproject/meson.build
new file mode 100644
index 0000000..65ba37b
--- /dev/null
+++ b/tests/use-as-subproject/meson.build
@@ -0,0 +1,25 @@
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: LGPL-2.0-or-later
+
+project(
+ 'use-libglnx-as-subproject',
+ 'c',
+ version : '0',
+ meson_version : '>=0.49.0',
+)
+add_project_arguments('-D_GNU_SOURCE', language : 'c')
+
+configure_file(
+ copy : true,
+ input : 'dummy-config.h.in',
+ output : 'config.h',
+)
+
+glib_dep = dependency('glib-2.0')
+
+libglnx = subproject('libglnx')
+libglnx_dep = libglnx.get_variable('libglnx_dep')
+libglnx_testlib_dep = libglnx.get_variable('libglnx_testlib_dep')
+
+executable('use-libglnx', 'use-libglnx.c', dependencies : [libglnx_dep, glib_dep])
+executable('use-testlib', 'use-testlib.c', dependencies : [libglnx_testlib_dep, glib_dep])
diff --git a/tests/use-as-subproject/use-libglnx.c b/tests/use-as-subproject/use-libglnx.c
new file mode 100644
index 0000000..0e14db0
--- /dev/null
+++ b/tests/use-as-subproject/use-libglnx.c
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2022 Collabora Ltd.
+ * SPDX-License-Identifier: LGPL-2.0-or-later
+ */
+
+#include <libglnx.h>
+
+int
+main (void)
+{
+ GError *error = NULL;
+
+ glnx_throw (&error, "whatever");
+ g_clear_error (&error);
+ return 0;
+}
diff --git a/tests/use-as-subproject/use-testlib.c b/tests/use-as-subproject/use-testlib.c
new file mode 100644
index 0000000..9a955b4
--- /dev/null
+++ b/tests/use-as-subproject/use-testlib.c
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2022 Collabora Ltd.
+ * SPDX-License-Identifier: LGPL-2.0-or-later
+ */
+
+#include <libglnx.h>
+#include <libglnx-testlib.h>
+
+int
+main (void)
+{
+ _GLNX_TEST_DECLARE_ERROR (local_error, error);
+
+ glnx_throw (error, "Whatever");
+ g_clear_error (&local_error);
+ return 0;
+}