2020-09-14 08:03:26 +00:00
|
|
|
From 4c38dcdc8d8f22dddc521faedad6a4f45fa81d63 Mon Sep 17 00:00:00 2001
|
2020-09-14 07:19:02 +00:00
|
|
|
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
|
|
Date: Mon, 14 Sep 2020 08:56:28 +0200
|
2020-09-14 08:03:26 +00:00
|
|
|
Subject: [PATCH 2/4] test-path: more debugging information
|
2020-09-14 07:19:02 +00:00
|
|
|
MIME-Version: 1.0
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
|
|
|
|
Just to make it easier to grok what happens when test-path fails.
|
|
|
|
Change printf→log_info so that output is interleaved and not split in two
|
|
|
|
independent parts in log files.
|
|
|
|
---
|
|
|
|
src/test/test-path.c | 31 ++++++++++++++++++-------------
|
|
|
|
1 file changed, 18 insertions(+), 13 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/src/test/test-path.c b/src/test/test-path.c
|
2020-09-14 08:03:26 +00:00
|
|
|
index 63b709c8da..84dcf5e37d 100644
|
2020-09-14 07:19:02 +00:00
|
|
|
--- a/src/test/test-path.c
|
|
|
|
+++ b/src/test/test-path.c
|
|
|
|
@@ -1,7 +1,6 @@
|
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
-#include <stdio.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2020-09-14 08:03:26 +00:00
|
|
|
@@ -78,32 +77,38 @@ static Service *service_for_path(Manager *m, Path *path, const char *service_nam
|
2020-09-14 07:19:02 +00:00
|
|
|
return SERVICE(service_unit);
|
|
|
|
}
|
|
|
|
|
|
|
|
-static void check_states(Manager *m, Path *path, Service *service, PathState path_state, ServiceState service_state) {
|
|
|
|
+static void _check_states(unsigned line,
|
|
|
|
+ Manager *m, Path *path, Service *service, PathState path_state, ServiceState service_state) {
|
|
|
|
assert_se(m);
|
|
|
|
assert_se(service);
|
|
|
|
|
2020-09-14 07:19:52 +00:00
|
|
|
usec_t end = now(CLOCK_MONOTONIC) + 2 * USEC_PER_SEC;
|
2020-09-14 07:19:02 +00:00
|
|
|
|
|
|
|
- while (path->result != PATH_SUCCESS || service->result != SERVICE_SUCCESS ||
|
|
|
|
- path->state != path_state || service->state != service_state) {
|
|
|
|
+ while (path->state != path_state || service->state != service_state ||
|
|
|
|
+ path->result != PATH_SUCCESS || service->result != SERVICE_SUCCESS) {
|
|
|
|
|
|
|
|
assert_se(sd_event_run(m->event, 100 * USEC_PER_MSEC) >= 0);
|
|
|
|
|
|
|
|
- printf("%s: state = %s; result = %s \n",
|
|
|
|
- UNIT(path)->id,
|
|
|
|
- path_state_to_string(path->state),
|
|
|
|
- path_result_to_string(path->result));
|
|
|
|
- printf("%s: state = %s; result = %s \n",
|
|
|
|
- UNIT(service)->id,
|
|
|
|
- service_state_to_string(service->state),
|
|
|
|
- service_result_to_string(service->result));
|
|
|
|
+ usec_t n = now(CLOCK_MONOTONIC);
|
|
|
|
+ log_info("line %d: %s: state = %s; result = %s (left: %" PRIi64 ")",
|
|
|
|
+ line,
|
|
|
|
+ UNIT(path)->id,
|
|
|
|
+ path_state_to_string(path->state),
|
|
|
|
+ path_result_to_string(path->result),
|
|
|
|
+ end - n);
|
|
|
|
+ log_info("line %d: %s: state = %s; result = %s",
|
|
|
|
+ line,
|
|
|
|
+ UNIT(service)->id,
|
|
|
|
+ service_state_to_string(service->state),
|
|
|
|
+ service_result_to_string(service->result));
|
|
|
|
|
|
|
|
- if (now(CLOCK_MONOTONIC) >= end) {
|
|
|
|
+ if (n >= end) {
|
|
|
|
log_error("Test timeout when testing %s", UNIT(path)->id);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+#define check_states(...) _check_states(__LINE__, __VA_ARGS__)
|
|
|
|
|
|
|
|
static void test_path_exists(Manager *m) {
|
|
|
|
const char *test_path = "/tmp/test-path_exists";
|