]>
Commit | Line | Data |
---|---|---|
a032b68d | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
60f067b4 | 2 | |
60f067b4 | 3 | #include "architecture.h" |
8f232108 | 4 | #include "errno-util.h" |
60f067b4 | 5 | #include "log.h" |
6e866b33 | 6 | #include "tests.h" |
db2df898 MP |
7 | #include "util.h" |
8 | #include "virt.h" | |
60f067b4 JS |
9 | |
10 | int main(int argc, char *argv[]) { | |
8f232108 MB |
11 | Virtualization v; |
12 | Architecture a; | |
52ad194e MB |
13 | const char *p; |
14 | ||
6e866b33 MB |
15 | test_setup_logging(LOG_INFO); |
16 | ||
52ad194e MB |
17 | assert_se(architecture_from_string("") < 0); |
18 | assert_se(architecture_from_string(NULL) < 0); | |
19 | assert_se(architecture_from_string("hoge") < 0); | |
20 | assert_se(architecture_to_string(-1) == NULL); | |
21 | assert_se(architecture_from_string(architecture_to_string(0)) == 0); | |
22 | assert_se(architecture_from_string(architecture_to_string(1)) == 1); | |
60f067b4 | 23 | |
6300502b | 24 | v = detect_virtualization(); |
8f232108 | 25 | if (v < 0 && ERRNO_IS_PRIVILEGE(v)) |
6e866b33 | 26 | return log_tests_skipped("Cannot detect virtualization"); |
60f067b4 JS |
27 | |
28 | assert_se(v >= 0); | |
29 | ||
30 | log_info("virtualization=%s id=%s", | |
6300502b MP |
31 | VIRTUALIZATION_IS_CONTAINER(v) ? "container" : |
32 | VIRTUALIZATION_IS_VM(v) ? "vm" : "n/a", | |
33 | virtualization_to_string(v)); | |
60f067b4 JS |
34 | |
35 | a = uname_architecture(); | |
36 | assert_se(a >= 0); | |
37 | ||
52ad194e MB |
38 | p = architecture_to_string(a); |
39 | assert_se(p); | |
40 | log_info("uname architecture=%s", p); | |
41 | assert_se(architecture_from_string(p) == a); | |
60f067b4 JS |
42 | |
43 | a = native_architecture(); | |
44 | assert_se(a >= 0); | |
45 | ||
52ad194e MB |
46 | p = architecture_to_string(a); |
47 | assert_se(p); | |
48 | log_info("native architecture=%s", p); | |
49 | assert_se(architecture_from_string(p) == a); | |
e842803a MB |
50 | |
51 | log_info("primary library architecture=" LIB_ARCH_TUPLE); | |
52 | ||
60f067b4 JS |
53 | return 0; |
54 | } |