diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-10-17 21:29:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-17 21:29:10 +0200 |
commit | a42984dbc7fce567acf33270e39e11fef81abc0c (patch) | |
tree | b6a4b529b00d2e4ff5dcfd01bab894da2c1a20a6 /src/test | |
parent | 33eb44fe4a8d7971b5614bc4c2d90f8d91cce66c (diff) | |
parent | c7adcb1af9946d0672c16bb4bb7eedf39b3d1fcb (diff) | |
download | systemd-a42984dbc7fce567acf33270e39e11fef81abc0c.tar.gz systemd-a42984dbc7fce567acf33270e39e11fef81abc0c.tar.bz2 systemd-a42984dbc7fce567acf33270e39e11fef81abc0c.zip |
Merge pull request #10428 from keszybz/failure-actions
Implement manager status changes using SuccessAction=
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/meson.build | 5 | ||||
-rw-r--r-- | src/test/test-emergency-action.c | 51 |
2 files changed, 56 insertions, 0 deletions
diff --git a/src/test/meson.build b/src/test/meson.build index 2e003f1fd2..a1770213a8 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -63,6 +63,11 @@ tests += [ libmount, libblkid]], + [['src/test/test-emergency-action.c'], + [libcore, + libshared], + []], + [['src/test/test-job-type.c'], [libcore, libshared], diff --git a/src/test/test-emergency-action.c b/src/test/test-emergency-action.c new file mode 100644 index 0000000000..8ce28ed9f5 --- /dev/null +++ b/src/test/test-emergency-action.c @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ + +#include "emergency-action.h" +#include "tests.h" + +static void test_parse_emergency_action(void) { + EmergencyAction x; + + log_info("/* %s */", __func__); + + assert_se(parse_emergency_action("none", false, &x) == 0); + assert_se(x == EMERGENCY_ACTION_NONE); + assert_se(parse_emergency_action("reboot", false, &x) == -EOPNOTSUPP); + assert_se(parse_emergency_action("reboot-force", false, &x) == -EOPNOTSUPP); + assert_se(parse_emergency_action("reboot-immediate", false, &x) == -EOPNOTSUPP); + assert_se(parse_emergency_action("poweroff", false, &x) == -EOPNOTSUPP); + assert_se(parse_emergency_action("poweroff-force", false, &x) == -EOPNOTSUPP); + assert_se(parse_emergency_action("poweroff-immediate", false, &x) == -EOPNOTSUPP); + assert_se(x == EMERGENCY_ACTION_NONE); + assert_se(parse_emergency_action("exit", false, &x) == 0); + assert_se(x == EMERGENCY_ACTION_EXIT); + assert_se(parse_emergency_action("exit-force", false, &x) == 0); + assert_se(x == EMERGENCY_ACTION_EXIT_FORCE); + assert_se(parse_emergency_action("exit-forcee", false, &x) == -EINVAL); + + assert_se(parse_emergency_action("none", true, &x) == 0); + assert_se(x == EMERGENCY_ACTION_NONE); + assert_se(parse_emergency_action("reboot", true, &x) == 0); + assert_se(x == EMERGENCY_ACTION_REBOOT); + assert_se(parse_emergency_action("reboot-force", true, &x) == 0); + assert_se(x == EMERGENCY_ACTION_REBOOT_FORCE); + assert_se(parse_emergency_action("reboot-immediate", true, &x) == 0); + assert_se(x == EMERGENCY_ACTION_REBOOT_IMMEDIATE); + assert_se(parse_emergency_action("poweroff", true, &x) == 0); + assert_se(x == EMERGENCY_ACTION_POWEROFF); + assert_se(parse_emergency_action("poweroff-force", true, &x) == 0); + assert_se(x == EMERGENCY_ACTION_POWEROFF_FORCE); + assert_se(parse_emergency_action("poweroff-immediate", true, &x) == 0); + assert_se(parse_emergency_action("exit", true, &x) == 0); + assert_se(parse_emergency_action("exit-force", true, &x) == 0); + assert_se(parse_emergency_action("exit-forcee", true, &x) == -EINVAL); + assert_se(x == EMERGENCY_ACTION_EXIT_FORCE); +} + +int main(int argc, char **argv) { + test_setup_logging(LOG_INFO); + + test_parse_emergency_action(); + + return EXIT_SUCCESS; +} |