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

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : #include "alloc-util.h"
       4                 :            : #include "static-destruct.h"
       5                 :            : #include "tests.h"
       6                 :            : 
       7                 :            : static int foo = 0;
       8                 :            : static int bar = 0;
       9                 :            : static int baz = 0;
      10                 :            : static char* memory = NULL;
      11                 :            : 
      12                 :         24 : static void test_destroy(int *b) {
      13                 :         24 :         (*b)++;
      14                 :         24 : }
      15                 :            : 
      16                 :          4 : STATIC_DESTRUCTOR_REGISTER(foo, test_destroy);
      17                 :          4 : STATIC_DESTRUCTOR_REGISTER(bar, test_destroy);
      18                 :          4 : STATIC_DESTRUCTOR_REGISTER(bar, test_destroy);
      19                 :          4 : STATIC_DESTRUCTOR_REGISTER(baz, test_destroy);
      20                 :          4 : STATIC_DESTRUCTOR_REGISTER(baz, test_destroy);
      21                 :          4 : STATIC_DESTRUCTOR_REGISTER(baz, test_destroy);
      22                 :          4 : STATIC_DESTRUCTOR_REGISTER(memory, freep);
      23                 :            : 
      24                 :          4 : int main(int argc, char *argv[]) {
      25                 :          4 :         test_setup_logging(LOG_INFO);
      26                 :            : 
      27         [ -  + ]:          4 :         assert_se(memory = strdup("hallo"));
      28                 :            : 
      29   [ +  -  -  +  :          4 :         assert_se(foo == 0 && bar == 0 && baz == 0);
             +  -  -  + ]
      30                 :          4 :         static_destruct();
      31   [ +  -  -  +  :          4 :         assert_se(foo == 1 && bar == 2 && baz == 3);
             +  -  -  + ]
      32                 :            : 
      33                 :          4 :         return EXIT_SUCCESS;
      34                 :            : }

Generated by: LCOV version 1.14