LCOV - code coverage report
Current view: top level - test - test-architecture.c (source / functions) Hit Total Coverage
Test: systemd_full.info Lines: 26 27 96.3 %
Date: 2019-08-23 13:36:53 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 21 42 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : #include "architecture.h"
       4                 :            : #include "log.h"
       5                 :            : #include "tests.h"
       6                 :            : #include "util.h"
       7                 :            : #include "virt.h"
       8                 :            : 
       9                 :          4 : int main(int argc, char *argv[]) {
      10                 :            :         int a, v;
      11                 :            :         const char *p;
      12                 :            : 
      13                 :          4 :         test_setup_logging(LOG_INFO);
      14                 :            : 
      15         [ -  + ]:          4 :         assert_se(architecture_from_string("") < 0);
      16         [ -  + ]:          4 :         assert_se(architecture_from_string(NULL) < 0);
      17         [ -  + ]:          4 :         assert_se(architecture_from_string("hoge") < 0);
      18         [ -  + ]:          4 :         assert_se(architecture_to_string(-1) == NULL);
      19         [ -  + ]:          4 :         assert_se(architecture_from_string(architecture_to_string(0)) == 0);
      20         [ -  + ]:          4 :         assert_se(architecture_from_string(architecture_to_string(1)) == 1);
      21                 :            : 
      22                 :          4 :         v = detect_virtualization();
      23   [ -  +  -  + ]:          4 :         if (IN_SET(v, -EPERM, -EACCES))
      24                 :          0 :                 return log_tests_skipped("Cannot detect virtualization");
      25                 :            : 
      26         [ -  + ]:          4 :         assert_se(v >= 0);
      27                 :            : 
      28   [ +  -  +  -  :          4 :         log_info("virtualization=%s id=%s",
                   -  + ]
      29                 :            :                  VIRTUALIZATION_IS_CONTAINER(v) ? "container" :
      30                 :            :                  VIRTUALIZATION_IS_VM(v)        ? "vm" : "n/a",
      31                 :            :                  virtualization_to_string(v));
      32                 :            : 
      33                 :          4 :         a = uname_architecture();
      34         [ -  + ]:          4 :         assert_se(a >= 0);
      35                 :            : 
      36                 :          4 :         p = architecture_to_string(a);
      37         [ -  + ]:          4 :         assert_se(p);
      38         [ +  - ]:          4 :         log_info("uname architecture=%s", p);
      39         [ -  + ]:          4 :         assert_se(architecture_from_string(p) == a);
      40                 :            : 
      41                 :          4 :         a = native_architecture();
      42         [ -  + ]:          4 :         assert_se(a >= 0);
      43                 :            : 
      44                 :          4 :         p = architecture_to_string(a);
      45         [ -  + ]:          4 :         assert_se(p);
      46         [ +  - ]:          4 :         log_info("native architecture=%s", p);
      47         [ -  + ]:          4 :         assert_se(architecture_from_string(p) == a);
      48                 :            : 
      49         [ +  - ]:          4 :         log_info("primary library architecture=" LIB_ARCH_TUPLE);
      50                 :            : 
      51                 :          4 :         return 0;
      52                 :            : }

Generated by: LCOV version 1.14