Ejemplo n.º 1
0
int main(int argc, char *argv[]) {
        int a, v;

        v = detect_virtualization();
        if (v == -EPERM || v == -EACCES)
                return EXIT_TEST_SKIP;

        assert_se(v >= 0);

        log_info("virtualization=%s id=%s",
                 VIRTUALIZATION_IS_CONTAINER(v) ? "container" :
                 VIRTUALIZATION_IS_VM(v)        ? "vm" : "n/a",
                 virtualization_to_string(v));

        a = uname_architecture();
        assert_se(a >= 0);

        log_info("uname architecture=%s", architecture_to_string(a));

        a = native_architecture();
        assert_se(a >= 0);

        log_info("native architecture=%s", architecture_to_string(a));

        log_info("primary library architecture=" LIB_ARCH_TUPLE);

        return 0;
}
Ejemplo n.º 2
0
int main(int argc, char *argv[]) {
        int a, v;
        const char *p;

        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);

        v = detect_virtualization();
        if (IN_SET(v, -EPERM, -EACCES))
                return EXIT_TEST_SKIP;

        assert_se(v >= 0);

        log_info("virtualization=%s id=%s",
                 VIRTUALIZATION_IS_CONTAINER(v) ? "container" :
                 VIRTUALIZATION_IS_VM(v)        ? "vm" : "n/a",
                 virtualization_to_string(v));

        a = uname_architecture();
        assert_se(a >= 0);

        p = architecture_to_string(a);
        assert_se(p);
        log_info("uname architecture=%s", p);
        assert_se(architecture_from_string(p) == a);

        a = native_architecture();
        assert_se(a >= 0);

        p = architecture_to_string(a);
        assert_se(p);
        log_info("native architecture=%s", p);
        assert_se(architecture_from_string(p) == a);

        log_info("primary library architecture=" LIB_ARCH_TUPLE);

        return 0;
}
Ejemplo n.º 3
0
static int condition_test_architecture(Condition *c) {
        int a, b;

        assert(c);
        assert(c->parameter);
        assert(c->type == CONDITION_ARCHITECTURE);

        a = uname_architecture();
        if (a < 0)
                return a;

        if (streq(c->parameter, "native"))
                b = native_architecture();
        else
                b = architecture_from_string(c->parameter);
        if (b < 0)
                return b;

        return a == b;
}
Ejemplo n.º 4
0
static int condition_test_architecture(Condition *c) {
        int a, b;

        assert(c);
        assert(c->parameter);
        assert(c->type == CONDITION_ARCHITECTURE);

        a = uname_architecture();
        if (a < 0)
                return a;

        if (streq(c->parameter, "native"))
                b = native_architecture();
        else {
                b = architecture_from_string(c->parameter);
                if (b < 0) /* unknown architecture? Then it's definitely not ours */
                        return false;
        }

        return a == b;
}
Ejemplo n.º 5
0
static void test_condition_test_architecture(void) {
        Condition *condition;
        const char *sa;
        int a;

        a = uname_architecture();
        assert_se(a >= 0);

        sa = architecture_to_string(a);
        assert_se(sa);

        condition = condition_new(CONDITION_ARCHITECTURE, sa, false, false);
        assert_se(condition_test(condition));
        condition_free(condition);

        condition = condition_new(CONDITION_ARCHITECTURE, "garbage value", false, false);
        assert_se(condition_test(condition) < 0);
        condition_free(condition);

        condition = condition_new(CONDITION_ARCHITECTURE, sa, false, true);
        assert_se(!condition_test(condition));
        condition_free(condition);
}