]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-architecture.c
Merge pull request #8575 from keszybz/non-absolute-paths
[thirdparty/systemd.git] / src / test / test-architecture.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 /***
3 This file is part of systemd.
4
5 Copyright 2014 Kay Sievers
6 ***/
7
8 #include "architecture.h"
9 #include "log.h"
10 #include "util.h"
11 #include "virt.h"
12
13 int main(int argc, char *argv[]) {
14 int a, v;
15 const char *p;
16
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);
23
24 v = detect_virtualization();
25 if (IN_SET(v, -EPERM, -EACCES))
26 return EXIT_TEST_SKIP;
27
28 assert_se(v >= 0);
29
30 log_info("virtualization=%s id=%s",
31 VIRTUALIZATION_IS_CONTAINER(v) ? "container" :
32 VIRTUALIZATION_IS_VM(v) ? "vm" : "n/a",
33 virtualization_to_string(v));
34
35 a = uname_architecture();
36 assert_se(a >= 0);
37
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);
42
43 a = native_architecture();
44 assert_se(a >= 0);
45
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);
50
51 log_info("primary library architecture=" LIB_ARCH_TUPLE);
52
53 return 0;
54 }