test: log when skipping tests in more cases

Follow-up for the previous commit.
This commit is contained in:
Yu Watanabe 2018-09-12 21:52:31 +09:00 committed by Zbigniew Jędrzejewski-Szmek
parent 08d541ca06
commit 964bc0ad60
15 changed files with 50 additions and 19 deletions

View File

@ -173,6 +173,7 @@ int main(int argc, char *argv[]) {
}
return 0;
#else
log_info("No compression feature is enabled, skipping tests.");
return EXIT_TEST_SKIP;
#endif
}

View File

@ -305,6 +305,7 @@ int main(int argc, char *argv[]) {
return 0;
#else
log_info("/* XZ and LZ4 tests skipped */");
return EXIT_TEST_SKIP;
#endif
}

View File

@ -277,8 +277,10 @@ int main(int argc, char *argv[]) {
log_set_max_level(LOG_DEBUG);
/* journal_file_open requires a valid machine id */
if (access("/etc/machine-id", F_OK) != 0)
if (access("/etc/machine-id", F_OK) != 0) {
log_info("/etc/machine-id not found, skipping tests.");
return EXIT_TEST_SKIP;
}
arg_keep = argc > 1;

View File

@ -67,8 +67,10 @@ int main(int argc, char *argv[]) {
dual_timestamp previous_ts = DUAL_TIMESTAMP_NULL;
/* journal_file_open requires a valid machine id */
if (access("/etc/machine-id", F_OK) != 0)
if (access("/etc/machine-id", F_OK) != 0) {
log_info("/etc/machine-id not found, skipping tests.");
return EXIT_TEST_SKIP;
}
log_set_max_level(LOG_DEBUG);

View File

@ -61,8 +61,10 @@ int main(int argc, char *argv[]) {
uint64_t p;
/* journal_file_open requires a valid machine id */
if (access("/etc/machine-id", F_OK) != 0)
if (access("/etc/machine-id", F_OK) != 0) {
log_info("/etc/machine-id not found, skipping tests.");
return EXIT_TEST_SKIP;
}
log_set_max_level(LOG_DEBUG);

View File

@ -239,8 +239,10 @@ int main(int argc, char *argv[]) {
arg_keep = argc > 1;
/* journal_file_open requires a valid machine id */
if (access("/etc/machine-id", F_OK) != 0)
if (access("/etc/machine-id", F_OK) != 0) {
log_info("/etc/machine-id not found, skipping tests.");
return EXIT_TEST_SKIP;
}
test_non_empty();
test_empty();

View File

@ -121,8 +121,10 @@ static void test_marshal(void) {
int r;
r = sd_bus_open_user(&bus);
if (r < 0)
if (r < 0) {
log_info("Failed to connect to bus, skipping tests.");
exit(EXIT_TEST_SKIP);
}
bus->message_version = 2; /* dirty hack to enable gvariant */

View File

@ -121,8 +121,10 @@ int main(int argc, char *argv[]) {
uint64_t u64;
r = sd_bus_default_user(&bus);
if (r < 0)
if (r < 0) {
log_info("Failed to connect to bus, skipping tests.");
return EXIT_TEST_SKIP;
}
r = sd_bus_message_new_method_call(bus, &m, "foobar.waldo", "/", "foobar.waldo", "Piep");
assert_se(r >= 0);

View File

@ -78,8 +78,10 @@ int main(int argc, char *argv[]) {
int r;
r = sd_bus_open_user(&bus);
if (r < 0)
if (r < 0) {
log_info("Failed to connect to bus, skipping tests.");
return EXIT_TEST_SKIP;
}
assert_se(match_add(slots, &root, "arg2='wal\\'do',sender='foo',type='signal',interface='bar.x',", 1) >= 0);
assert_se(match_add(slots, &root, "arg2='wal\\'do2',sender='foo',type='signal',interface='bar.x',", 2) >= 0);

View File

@ -231,8 +231,10 @@ int main(void) {
assert_se(manager_new(&manager) >= 0);
r = test_load_config(manager);
if (r == -EPERM)
if (r == -EPERM) {
log_info_errno(r, "Skipping tests: %m");
return EXIT_TEST_SKIP;
}
assert_se(sd_device_new_from_syspath(&loopback, "/sys/class/net/lo") >= 0);
assert_se(loopback);

View File

@ -17,8 +17,10 @@ int main(int argc, char *argv[]) {
assert_se(architecture_from_string(architecture_to_string(1)) == 1);
v = detect_virtualization();
if (IN_SET(v, -EPERM, -EACCES))
if (IN_SET(v, -EPERM, -EACCES)) {
log_info_errno(v, "Skipping tests: %m");
return EXIT_TEST_SKIP;
}
assert_se(v >= 0);

View File

@ -110,9 +110,10 @@ int main(int argc, char *argv[]) {
unit_dump(u, stdout, NULL);
r = bpf_firewall_compile(u);
if (IN_SET(r, -ENOTTY, -ENOSYS, -EPERM ))
/* Kernel doesn't support the necessary bpf bits, or masked out via seccomp? */
if (IN_SET(r, -ENOTTY, -ENOSYS, -EPERM)) {
log_info_errno(r, "Kernel doesn't support the necessary bpf bits, or masked out via seccomp? Skipping tests: %m");
return EXIT_TEST_SKIP;
}
assert_se(r >= 0);
assert(u->ip_bpf_ingress);

View File

@ -12,7 +12,8 @@ int main(int argc, char *argv[]) {
r = get_user_creds(&name, &uid, NULL, NULL, NULL, 0);
if (r < 0) {
log_full_errno(r == -ESRCH ? LOG_NOTICE : LOG_ERR,
r, "Failed to resolve \"%s\": %m", name);
r, "Failed to resolve \"%s\"%s: %m", name,
r == -ESRCH ? ", skipping tests" : "");
return r == -ESRCH ? EXIT_TEST_SKIP : EXIT_FAILURE;
}

View File

@ -46,11 +46,21 @@ static int test_tunnel_configure(sd_netlink *rtnl) {
/* skip test if module cannot be loaded */
r = load_module("ipip");
if (r < 0)
if (r < 0) {
log_info_errno(r, "Skipping tests: failed to load module 'ipip': %m");
return EXIT_TEST_SKIP;
}
if (getuid() != 0)
r = load_module("sit");
if (r < 0) {
log_info_errno(r, "Skipping tests: failed to load module 'sit': %m");
return EXIT_TEST_SKIP;
}
if (getuid() != 0) {
log_info("Skipping tests: not root");
return EXIT_TEST_SKIP;
}
/* IPIP tunnel */
assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0) >= 0);
@ -76,10 +86,6 @@ static int test_tunnel_configure(sd_netlink *rtnl) {
assert_se((m = sd_netlink_message_unref(m)) == NULL);
r = load_module("sit");
if (r < 0)
return EXIT_TEST_SKIP;
/* sit */
assert_se(sd_rtnl_message_new_link(rtnl, &n, RTM_NEWLINK, 0) >= 0);
assert_se(n);

View File

@ -16,11 +16,14 @@ int main(int argc, char *argv[]) {
uint8_t *p;
#if HAVE_VALGRIND_VALGRIND_H
if (RUNNING_ON_VALGRIND)
if (RUNNING_ON_VALGRIND) {
puts("This test cannot run on valgrind, skipping tests.");
return EXIT_TEST_SKIP;
}
#endif
#ifdef __SANITIZE_ADDRESS__
puts("Address sanitization is enabled, skipping tests.");
return EXIT_TEST_SKIP;
#endif
sigbus_install();