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