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