summaryrefslogtreecommitdiffstats
path: root/src/nspawn/test-nspawn-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-04-07 11:51:52 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-04-07 18:17:20 +0200
commitc9394f4f93b9a6baa54f9d1c953035f26dcee253 (patch)
treeb000d8447b8ede88b953edb783677ebff2936d05 /src/nspawn/test-nspawn-util.c
parentREADME: add one more kernel-version line (diff)
downloadsystemd-c9394f4f93b9a6baa54f9d1c953035f26dcee253.tar.xz
systemd-c9394f4f93b9a6baa54f9d1c953035f26dcee253.zip
Move systemd_installation_has_version() to src/nspawn/
This function implements a heuristic that is only used by nspawn. It doesn't belong in basic. I opted for a new file "nspawn-utils.c", because it seems likely that we'll need some other new utilities like that in the future. No functional change.
Diffstat (limited to 'src/nspawn/test-nspawn-util.c')
-rw-r--r--src/nspawn/test-nspawn-util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/nspawn/test-nspawn-util.c b/src/nspawn/test-nspawn-util.c
new file mode 100644
index 0000000000..7d55db8934
--- /dev/null
+++ b/src/nspawn/test-nspawn-util.c
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include "nspawn-util.h"
+#include "string-util.h"
+#include "tests.h"
+
+TEST(systemd_installation_has_version) {
+ static const unsigned versions[] = {0, 231, PROJECT_VERSION, 999};
+ int r;
+
+ for (size_t i = 0; i < ELEMENTSOF(versions); i++) {
+ r = systemd_installation_has_version(saved_argv[1], versions[i]);
+ assert_se(r >= 0);
+ log_info("%s has systemd >= %u: %s",
+ saved_argv[1] ?: "Current installation", versions[i], yes_no(r));
+ }
+}
+
+DEFINE_TEST_MAIN(LOG_DEBUG);