]>
Commit | Line | Data |
---|---|---|
52ad194e | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
60f067b4 JS |
2 | /*** |
3 | This file is part of systemd. | |
4 | ||
5 | Copyright 2014 Kay Sievers | |
6 | ||
7 | systemd is free software; you can redistribute it and/or modify it | |
8 | under the terms of the GNU Lesser General Public License as published by | |
9 | the Free Software Foundation; either version 2.1 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | systemd is distributed in the hope that it will be useful, but | |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | Lesser General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU Lesser General Public License | |
18 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
19 | ***/ | |
20 | ||
60f067b4 | 21 | #include "architecture.h" |
60f067b4 | 22 | #include "log.h" |
db2df898 MP |
23 | #include "util.h" |
24 | #include "virt.h" | |
60f067b4 JS |
25 | |
26 | int main(int argc, char *argv[]) { | |
f47781d8 | 27 | int a, v; |
52ad194e MB |
28 | const char *p; |
29 | ||
30 | assert_se(architecture_from_string("") < 0); | |
31 | assert_se(architecture_from_string(NULL) < 0); | |
32 | assert_se(architecture_from_string("hoge") < 0); | |
33 | assert_se(architecture_to_string(-1) == NULL); | |
34 | assert_se(architecture_from_string(architecture_to_string(0)) == 0); | |
35 | assert_se(architecture_from_string(architecture_to_string(1)) == 1); | |
60f067b4 | 36 | |
6300502b | 37 | v = detect_virtualization(); |
f5e65279 | 38 | if (IN_SET(v, -EPERM, -EACCES)) |
60f067b4 JS |
39 | return EXIT_TEST_SKIP; |
40 | ||
41 | assert_se(v >= 0); | |
42 | ||
43 | log_info("virtualization=%s id=%s", | |
6300502b MP |
44 | VIRTUALIZATION_IS_CONTAINER(v) ? "container" : |
45 | VIRTUALIZATION_IS_VM(v) ? "vm" : "n/a", | |
46 | virtualization_to_string(v)); | |
60f067b4 JS |
47 | |
48 | a = uname_architecture(); | |
49 | assert_se(a >= 0); | |
50 | ||
52ad194e MB |
51 | p = architecture_to_string(a); |
52 | assert_se(p); | |
53 | log_info("uname architecture=%s", p); | |
54 | assert_se(architecture_from_string(p) == a); | |
60f067b4 JS |
55 | |
56 | a = native_architecture(); | |
57 | assert_se(a >= 0); | |
58 | ||
52ad194e MB |
59 | p = architecture_to_string(a); |
60 | assert_se(p); | |
61 | log_info("native architecture=%s", p); | |
62 | assert_se(architecture_from_string(p) == a); | |
e842803a MB |
63 | |
64 | log_info("primary library architecture=" LIB_ARCH_TUPLE); | |
65 | ||
60f067b4 JS |
66 | return 0; |
67 | } |