LCOV - code coverage report
Current view: top level - test - test-emergency-action.c (source / functions) Hit Total Coverage
Test: systemd_full.info Lines: 38 38 100.0 %
Date: 2019-08-23 13:36:53 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 32 64 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : #include "emergency-action.h"
       4                 :            : #include "tests.h"
       5                 :            : 
       6                 :          4 : static void test_parse_emergency_action(void) {
       7                 :            :         EmergencyAction x;
       8                 :            : 
       9         [ +  - ]:          4 :         log_info("/* %s */", __func__);
      10                 :            : 
      11         [ -  + ]:          4 :         assert_se(parse_emergency_action("none", false, &x) == 0);
      12         [ -  + ]:          4 :         assert_se(x == EMERGENCY_ACTION_NONE);
      13         [ -  + ]:          4 :         assert_se(parse_emergency_action("reboot", false, &x) == -EOPNOTSUPP);
      14         [ -  + ]:          4 :         assert_se(parse_emergency_action("reboot-force", false, &x) == -EOPNOTSUPP);
      15         [ -  + ]:          4 :         assert_se(parse_emergency_action("reboot-immediate", false, &x) == -EOPNOTSUPP);
      16         [ -  + ]:          4 :         assert_se(parse_emergency_action("poweroff", false, &x) == -EOPNOTSUPP);
      17         [ -  + ]:          4 :         assert_se(parse_emergency_action("poweroff-force", false, &x) == -EOPNOTSUPP);
      18         [ -  + ]:          4 :         assert_se(parse_emergency_action("poweroff-immediate", false, &x) == -EOPNOTSUPP);
      19         [ -  + ]:          4 :         assert_se(x == EMERGENCY_ACTION_NONE);
      20         [ -  + ]:          4 :         assert_se(parse_emergency_action("exit", false, &x) == 0);
      21         [ -  + ]:          4 :         assert_se(x == EMERGENCY_ACTION_EXIT);
      22         [ -  + ]:          4 :         assert_se(parse_emergency_action("exit-force", false, &x) == 0);
      23         [ -  + ]:          4 :         assert_se(x == EMERGENCY_ACTION_EXIT_FORCE);
      24         [ -  + ]:          4 :         assert_se(parse_emergency_action("exit-forcee", false, &x) == -EINVAL);
      25                 :            : 
      26         [ -  + ]:          4 :         assert_se(parse_emergency_action("none", true, &x) == 0);
      27         [ -  + ]:          4 :         assert_se(x == EMERGENCY_ACTION_NONE);
      28         [ -  + ]:          4 :         assert_se(parse_emergency_action("reboot", true, &x) == 0);
      29         [ -  + ]:          4 :         assert_se(x == EMERGENCY_ACTION_REBOOT);
      30         [ -  + ]:          4 :         assert_se(parse_emergency_action("reboot-force", true, &x) == 0);
      31         [ -  + ]:          4 :         assert_se(x == EMERGENCY_ACTION_REBOOT_FORCE);
      32         [ -  + ]:          4 :         assert_se(parse_emergency_action("reboot-immediate", true, &x) == 0);
      33         [ -  + ]:          4 :         assert_se(x == EMERGENCY_ACTION_REBOOT_IMMEDIATE);
      34         [ -  + ]:          4 :         assert_se(parse_emergency_action("poweroff", true, &x) == 0);
      35         [ -  + ]:          4 :         assert_se(x == EMERGENCY_ACTION_POWEROFF);
      36         [ -  + ]:          4 :         assert_se(parse_emergency_action("poweroff-force", true, &x) == 0);
      37         [ -  + ]:          4 :         assert_se(x == EMERGENCY_ACTION_POWEROFF_FORCE);
      38         [ -  + ]:          4 :         assert_se(parse_emergency_action("poweroff-immediate", true, &x) == 0);
      39         [ -  + ]:          4 :         assert_se(parse_emergency_action("exit", true, &x) == 0);
      40         [ -  + ]:          4 :         assert_se(parse_emergency_action("exit-force", true, &x) == 0);
      41         [ -  + ]:          4 :         assert_se(parse_emergency_action("exit-forcee", true, &x) == -EINVAL);
      42         [ -  + ]:          4 :         assert_se(x == EMERGENCY_ACTION_EXIT_FORCE);
      43                 :          4 : }
      44                 :            : 
      45                 :          4 : int main(int argc, char **argv) {
      46                 :          4 :         test_setup_logging(LOG_INFO);
      47                 :            : 
      48                 :          4 :         test_parse_emergency_action();
      49                 :            : 
      50                 :          4 :         return EXIT_SUCCESS;
      51                 :            : }

Generated by: LCOV version 1.14