summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-09-12 13:25:45 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-09-13 12:07:34 +0200
commit08d541ca06c75c8539206c60eba975fb3ecd6460 (patch)
tree59fb44e75054adecadcf80dda43310ad3043b0ec
parent938be08926aa3c05faaca854776f29b9dab72661 (diff)
downloadsystemd-08d541ca06c75c8539206c60eba975fb3ecd6460.tar.gz
test: when skipping tests, always print something
It is quite confusing if the test "fails" without printing anything at all. A typo in an 'if' statement is also fixed.
-rw-r--r--src/libsystemd-network/test-dhcp-server.c9
-rw-r--r--src/test/test-boot-timestamps.c7
-rw-r--r--src/test/test-capability.c17
3 files changed, 21 insertions, 12 deletions
diff --git a/src/libsystemd-network/test-dhcp-server.c b/src/libsystemd-network/test-dhcp-server.c
index 815b11e997..3de25b02c2 100644
--- a/src/libsystemd-network/test-dhcp-server.c
+++ b/src/libsystemd-network/test-dhcp-server.c
@@ -54,9 +54,8 @@ static int test_basic(sd_event *event) {
test_pool(&address_lo, 1, 0);
r = sd_dhcp_server_start(server);
-
if (r == -EPERM)
- return EXIT_TEST_SKIP;
+ return log_info_errno(r, "sd_dhcp_server_start failed: %m");
assert_se(r >= 0);
assert_se(sd_dhcp_server_start(server) == -EBUSY);
@@ -236,8 +235,10 @@ int main(int argc, char *argv[]) {
assert_se(sd_event_new(&e) >= 0);
r = test_basic(e);
- if (r != 0)
- return r;
+ if (r != 0) {
+ log_notice("%s: skipping tests.", program_invocation_short_name);
+ return EXIT_TEST_SKIP;
+ }
test_message_handler();
test_client_id_hash();
diff --git a/src/test/test-boot-timestamps.c b/src/test/test-boot-timestamps.c
index ef39304b9f..e7deee5d5f 100644
--- a/src/test/test-boot-timestamps.c
+++ b/src/test/test-boot-timestamps.c
@@ -91,5 +91,10 @@ int main(int argc, char* argv[]) {
r = test_boot_timestamps();
assert(r >= 0);
- return (p > 0 || q > 0 || r >> 0) ? EXIT_SUCCESS : EXIT_TEST_SKIP;
+ bool any = p > 0 || q > 0 || r > 0;
+ if (!any)
+ log_notice("%s: access to firmware variable not possible, skipping tests.",
+ program_invocation_short_name);
+
+ return any ? EXIT_SUCCESS : EXIT_TEST_SKIP;
}
diff --git a/src/test/test-capability.c b/src/test/test-capability.c
index af6d808b6d..5e2d21bee9 100644
--- a/src/test/test-capability.c
+++ b/src/test/test-capability.c
@@ -91,10 +91,9 @@ static int setup_tests(bool *run_ambient) {
int r;
nobody = getpwnam(NOBODY_USER_NAME);
- if (!nobody) {
- log_error_errno(errno, "Could not find nobody user: %m");
- return -EXIT_TEST_SKIP;
- }
+ if (!nobody)
+ return log_error_errno(errno, "Could not find nobody user: %m");
+
test_uid = nobody->pw_uid;
test_gid = nobody->pw_gid;
@@ -229,12 +228,16 @@ int main(int argc, char *argv[]) {
log_info("have ambient caps: %s", yes_no(ambient_capabilities_supported()));
- if (getuid() != 0)
+ if (getuid() != 0) {
+ log_notice("%s: not root, skipping tests.", program_invocation_short_name);
return EXIT_TEST_SKIP;
+ }
r = setup_tests(&run_ambient);
- if (r < 0)
- return -r;
+ if (r < 0) {
+ log_notice("%s: skipping tests.", program_invocation_short_name);
+ return EXIT_TEST_SKIP;
+ }
show_capabilities();