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 1 : int main(int argc, char *argv[]) { 10 : int a, v; 11 : const char *p; 12 : 13 1 : test_setup_logging(LOG_INFO); 14 : 15 1 : assert_se(architecture_from_string("") < 0); 16 1 : assert_se(architecture_from_string(NULL) < 0); 17 1 : assert_se(architecture_from_string("hoge") < 0); 18 1 : assert_se(architecture_to_string(-1) == NULL); 19 1 : assert_se(architecture_from_string(architecture_to_string(0)) == 0); 20 1 : assert_se(architecture_from_string(architecture_to_string(1)) == 1); 21 : 22 1 : v = detect_virtualization(); 23 1 : if (IN_SET(v, -EPERM, -EACCES)) 24 0 : return log_tests_skipped("Cannot detect virtualization"); 25 : 26 1 : assert_se(v >= 0); 27 : 28 1 : 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 1 : a = uname_architecture(); 34 1 : assert_se(a >= 0); 35 : 36 1 : p = architecture_to_string(a); 37 1 : assert_se(p); 38 1 : log_info("uname architecture=%s", p); 39 1 : assert_se(architecture_from_string(p) == a); 40 : 41 1 : a = native_architecture(); 42 1 : assert_se(a >= 0); 43 : 44 1 : p = architecture_to_string(a); 45 1 : assert_se(p); 46 1 : log_info("native architecture=%s", p); 47 1 : assert_se(architecture_from_string(p) == a); 48 : 49 1 : log_info("primary library architecture=" LIB_ARCH_TUPLE); 50 : 51 1 : return 0; 52 : }