]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add test that dlopen()'s all our weak library deps once
authorLennart Poettering <lennart@poettering.net>
Mon, 7 Dec 2020 13:15:36 +0000 (14:15 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 9 Dec 2020 12:34:40 +0000 (13:34 +0100)
This test should ensure we notice if distros update shared libraries
that broke so name, and we still use the old soname.

(In contrast to what the commit summary says, this currently doesn#t
cover really all such deps, specifically xkbcommon and PCRE are missing,
since they currently aren't loaded from src/shared/. This is stuff to
fix later)

src/test/meson.build
src/test/test-dlopen-so.c [new file with mode: 0644]

index 9e781f88dcb30b29f8f6897b7c9b73a3a8219777..3afe5d58cbd7dcd6f472432121af64190f0de71b 100644 (file)
@@ -71,6 +71,10 @@ tests += [
           libshared],
          []],
 
+        [['src/test/test-dlopen-so.c'],
+         [libshared],
+         []],
+
         [['src/test/test-job-type.c'],
          [libcore,
           libshared],
diff --git a/src/test/test-dlopen-so.c b/src/test/test-dlopen-so.c
new file mode 100644 (file)
index 0000000..6436dc6
--- /dev/null
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include <dlfcn.h>
+#include <stdlib.h>
+
+#include "cryptsetup-util.h"
+#include "idn-util.h"
+#include "macro.h"
+#include "main-func.h"
+#include "pwquality-util.h"
+#include "qrcode-util.h"
+#include "tests.h"
+
+static int run(int argc, char **argv) {
+        test_setup_logging(LOG_DEBUG);
+
+        /* Try to load each of our weak library dependencies once. This is supposed to help finding cases
+         * where .so versions change and distributions update, but systemd doesn't have the new so names
+         * around yet. */
+
+#if HAVE_LIBIDN2 || HAVE_LIBIDN
+        assert_se(dlopen_idn() >= 0);
+#endif
+
+#if HAVE_LIBCRYPTSETUP
+        assert_se(dlopen_cryptsetup() >= 0);
+#endif
+
+#if HAVE_PWQUALITY
+        assert_se(dlopen_pwquality() >= 0);
+#endif
+
+#if HAVE_QRENCODE
+        assert_se(dlopen_qrencode() >= 0);
+#endif
+
+        return 0;
+}
+
+DEFINE_MAIN_FUNCTION(run);