2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2014-02-21 02:06:04 +01:00
|
|
|
|
|
|
|
#include "architecture.h"
|
|
|
|
#include "log.h"
|
2018-09-13 13:34:12 +02:00
|
|
|
#include "tests.h"
|
2015-11-16 22:09:36 +01:00
|
|
|
#include "util.h"
|
|
|
|
#include "virt.h"
|
2014-02-21 02:06:04 +01:00
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
2014-11-06 00:49:44 +01:00
|
|
|
int a, v;
|
2017-11-28 10:14:55 +01:00
|
|
|
const char *p;
|
|
|
|
|
2018-09-13 14:31:13 +02:00
|
|
|
test_setup_logging(LOG_INFO);
|
|
|
|
|
2017-11-28 10:14:55 +01:00
|
|
|
assert_se(architecture_from_string("") < 0);
|
|
|
|
assert_se(architecture_from_string(NULL) < 0);
|
|
|
|
assert_se(architecture_from_string("hoge") < 0);
|
|
|
|
assert_se(architecture_to_string(-1) == NULL);
|
|
|
|
assert_se(architecture_from_string(architecture_to_string(0)) == 0);
|
|
|
|
assert_se(architecture_from_string(architecture_to_string(1)) == 1);
|
2014-02-21 02:06:04 +01:00
|
|
|
|
2015-09-07 13:42:47 +02:00
|
|
|
v = detect_virtualization();
|
2018-09-13 13:34:12 +02:00
|
|
|
if (IN_SET(v, -EPERM, -EACCES))
|
|
|
|
return log_tests_skipped("Cannot detect virtualization");
|
2014-02-21 02:06:04 +01:00
|
|
|
|
|
|
|
assert_se(v >= 0);
|
|
|
|
|
|
|
|
log_info("virtualization=%s id=%s",
|
2015-09-07 13:42:47 +02:00
|
|
|
VIRTUALIZATION_IS_CONTAINER(v) ? "container" :
|
|
|
|
VIRTUALIZATION_IS_VM(v) ? "vm" : "n/a",
|
|
|
|
virtualization_to_string(v));
|
2014-02-21 02:06:04 +01:00
|
|
|
|
|
|
|
a = uname_architecture();
|
|
|
|
assert_se(a >= 0);
|
|
|
|
|
2017-11-28 10:14:55 +01:00
|
|
|
p = architecture_to_string(a);
|
|
|
|
assert_se(p);
|
|
|
|
log_info("uname architecture=%s", p);
|
|
|
|
assert_se(architecture_from_string(p) == a);
|
2014-02-21 02:06:04 +01:00
|
|
|
|
|
|
|
a = native_architecture();
|
|
|
|
assert_se(a >= 0);
|
|
|
|
|
2017-11-28 10:14:55 +01:00
|
|
|
p = architecture_to_string(a);
|
|
|
|
assert_se(p);
|
|
|
|
log_info("native architecture=%s", p);
|
|
|
|
assert_se(architecture_from_string(p) == a);
|
2014-07-03 15:50:57 +02:00
|
|
|
|
|
|
|
log_info("primary library architecture=" LIB_ARCH_TUPLE);
|
|
|
|
|
2014-02-21 02:06:04 +01:00
|
|
|
return 0;
|
|
|
|
}
|