diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-08-01 14:25:14 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-09-16 18:08:00 +0200 |
commit | da33cba0f8cf3d4c23c11218485d8d4f339fc45b (patch) | |
tree | 2fc0ffac6982965f38a7c957dab7979c3f4617c2 /src/test/test-unit-file.c | |
parent | util-lib: move some functions from basic/cgroup-util to shared/cgroup-setup (diff) | |
download | systemd-da33cba0f8cf3d4c23c11218485d8d4f339fc45b.tar.xz systemd-da33cba0f8cf3d4c23c11218485d8d4f339fc45b.zip |
util-lib: move runlevel_to_target() to shared/unit-file
It if of course related to /proc/cmdline parsing, but is higher-level
functionality built on top of it. It should be in shared/ because it
is something to be used by pid1 and related utilities, not something for
level-level libraries.
Diffstat (limited to '')
-rw-r--r-- | src/test/test-unit-file.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c index 8bc5bf6038..f0186b078f 100644 --- a/src/test/test-unit-file.c +++ b/src/test/test-unit-file.c @@ -2,6 +2,7 @@ #include "path-lookup.h" #include "set.h" +#include "special.h" #include "strv.h" #include "tests.h" #include "unit-file.h" @@ -75,11 +76,30 @@ static void test_unit_file_build_name_map(char **ids) { } } +static void test_runlevel_to_target(void) { + log_info("/* %s */", __func__); + + in_initrd_force(false); + assert_se(streq_ptr(runlevel_to_target(NULL), NULL)); + assert_se(streq_ptr(runlevel_to_target("unknown-runlevel"), NULL)); + assert_se(streq_ptr(runlevel_to_target("rd.unknown-runlevel"), NULL)); + assert_se(streq_ptr(runlevel_to_target("3"), SPECIAL_MULTI_USER_TARGET)); + assert_se(streq_ptr(runlevel_to_target("rd.rescue"), NULL)); + + in_initrd_force(true); + assert_se(streq_ptr(runlevel_to_target(NULL), NULL)); + assert_se(streq_ptr(runlevel_to_target("unknown-runlevel"), NULL)); + assert_se(streq_ptr(runlevel_to_target("rd.unknown-runlevel"), NULL)); + assert_se(streq_ptr(runlevel_to_target("3"), NULL)); + assert_se(streq_ptr(runlevel_to_target("rd.rescue"), SPECIAL_RESCUE_TARGET)); +} + int main(int argc, char **argv) { test_setup_logging(LOG_DEBUG); test_unit_validate_alias_symlink_and_warn(); test_unit_file_build_name_map(strv_skip(argv, 1)); + test_runlevel_to_target(); return 0; } |