refers to:
https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1710
tree merge:
https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/1005
https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/1009
https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/1076

diff --git a/test/test-logger.c b/test/test-logger.c
index 2e7820c..fde4642 100644
--- a/test/test-logger.c
+++ b/test/test-logger.c
@@ -478,6 +478,7 @@ PWTEST(logger_journal)
 	}
 
 	sd_journal_seek_tail(journal);
+	sd_journal_next(journal);
 
 	spa_logt_info(iface, &topic, "MARK\n");
 	while ((rc = sd_journal_next(journal)) > 0) {
@@ -555,6 +556,7 @@ PWTEST(logger_journal_chain)
 	}
 
 	sd_journal_seek_tail(journal);
+	sd_journal_next(journal);
 
 	spa_logt_info(iface, &topic, "MARK\n");
 	while ((rc = sd_journal_next(journal)) > 0) {
diff --git a/test/test-logger.c b/test/test-logger.c
index fde4642..338cd81 100644
--- a/test/test-logger.c
+++ b/test/test-logger.c
@@ -295,7 +295,7 @@ PWTEST(logger_debug_env_topic_all)
 	struct spa_log *default_logger = pw_log_get();
 	char *oldenv = getenv("PIPEWIRE_DEBUG");
 	char lvlstr[32];
-	char *lvl = SPA_LOG_LEVEL_NONE;
+	char *lvl = "X";
 
 	if (oldenv)
 		oldenv = strdup(oldenv);
@@ -442,6 +442,45 @@ PWTEST(logger_topics)
 	return PWTEST_PASS;
 }
 
+#ifdef HAVE_SYSTEMD
+static enum pwtest_result
+find_in_journal(sd_journal *journal, const char *needle, char *out, size_t out_sz)
+{
+	int rc;
+	int i;
+
+	/* We give ourselves up to a second for our message to appear */
+	for (i = 0; i < 10; i++) {
+		int activity = sd_journal_wait(journal, 100000);
+
+		pwtest_neg_errno_ok(activity);
+		switch (activity) {
+		case SD_JOURNAL_NOP:
+			break;
+		case SD_JOURNAL_INVALIDATE:
+		case SD_JOURNAL_APPEND:
+			while ((rc = sd_journal_next(journal)) > 0) {
+				char buffer[1024] = {0};
+				const char *d;
+				size_t l;
+				int r = sd_journal_get_data(journal, "MESSAGE", (const void **)&d, &l);
+				pwtest_neg_errno_ok(r);
+				spa_scnprintf(buffer, sizeof(buffer), "%.*s", (int) l, d);
+				if (strstr(buffer, needle)) {
+					spa_scnprintf(out, out_sz, "%s", buffer);
+					return PWTEST_PASS;
+				}
+			}
+			pwtest_neg_errno_ok(rc);
+			break;
+		default:
+			break;
+		}
+	}
+	return PWTEST_FAIL;
+}
+#endif
+
 PWTEST(logger_journal)
 {
 	enum pwtest_result result = PWTEST_SKIP;
@@ -450,14 +489,15 @@ PWTEST(logger_journal)
 	void *iface;
 	struct spa_dict_item items[2];
 	struct spa_dict info;
-	bool mark_line_found = false;
 	struct spa_log_topic topic = {
 		.version = 0,
 		.topic = "pwtest journal",
 		.level = SPA_LOG_LEVEL_DEBUG,
 	};
+	char buffer[1024] = {0};
 	sd_journal *journal;
 	int rc;
+	char token[64];
 
 	pw_init(0, NULL);
 
@@ -480,23 +520,12 @@ PWTEST(logger_journal)
 	sd_journal_seek_tail(journal);
 	sd_journal_next(journal);
 
-	spa_logt_info(iface, &topic, "MARK\n");
-	while ((rc = sd_journal_next(journal)) > 0) {
-		char buffer[1024] = {0};
-		const char *d;
-		size_t l;
-		int r = sd_journal_get_data(journal, "MESSAGE", (const void **)&d, &l);
-		pwtest_neg_errno_ok(r);
-		spa_scnprintf(buffer, sizeof(buffer), "%.*s", (int) l, d);
-		if (strstr(buffer, "MARK")) {
-			mark_line_found = true;
-			pwtest_str_contains(buffer, "pwtest journal");
-		}
-	}
-	pwtest_neg_errno_ok(rc);
-	pwtest_bool_true(mark_line_found);
+	spa_scnprintf(token, sizeof(token), "MARK %s:%d", __func__, __LINE__);
+	spa_logt_info(iface, &topic, "%s", token);
 
-	result = PWTEST_PASS;
+	result = find_in_journal(journal, token, buffer, sizeof(buffer));
+	pwtest_int_eq((int)result, PWTEST_PASS);
+	pwtest_str_contains(buffer, "pwtest journal");
 
 cleanup:
 	sd_journal_close(journal);
@@ -526,6 +555,7 @@ PWTEST(logger_journal_chain)
 	};
 	sd_journal *journal;
 	int rc;
+	char token[64];
 
 	pw_init(0, NULL);
 	pwtest_mkstemp(fname);
@@ -558,27 +588,19 @@ PWTEST(logger_journal_chain)
 	sd_journal_seek_tail(journal);
 	sd_journal_next(journal);
 
-	spa_logt_info(iface, &topic, "MARK\n");
-	while ((rc = sd_journal_next(journal)) > 0) {
-		char buffer[1024] = {0};
-		const char *d;
-		size_t l;
-		int r = sd_journal_get_data(journal, "MESSAGE", (const void **)&d, &l);
-		pwtest_neg_errno_ok(r);
-		spa_scnprintf(buffer, sizeof(buffer), "%.*s", (int) l, d);
-		if (strstr(buffer, "MARK")) {
-			mark_line_found = true;
-			pwtest_str_contains(buffer, "pwtest journal");
-		}
-	}
-	pwtest_neg_errno_ok(rc);
-	pwtest_bool_true(mark_line_found);
+	spa_scnprintf(token, sizeof(token), "MARK %s:%d", __func__, __LINE__);
+
+	spa_logt_info(iface, &topic, "%s", token);
+	result = find_in_journal(journal, token, buffer, sizeof(buffer));
+	pwtest_int_eq((int)result, PWTEST_PASS);
+	pwtest_str_contains(buffer, "pwtest journal");
 
 	/* Now check that the line is in the chained file logger too */
+	spa_memzero(buffer, sizeof(buffer));
 	mark_line_found = false;
 	fp = fopen(fname, "r");
 	while (fgets(buffer, sizeof(buffer), fp) != NULL) {
-		if (strstr(buffer, "MARK")) {
+		if (strstr(buffer, token)) {
 			mark_line_found = true;
 			pwtest_ptr_null(strstr(buffer, SPA_ANSI_RESET));
 			pwtest_ptr_null(strstr(buffer, SPA_ANSI_RED));
diff --git a/test/pwtest.c b/test/pwtest.c
index 073014a..24a14f2 100644
--- a/test/pwtest.c
+++ b/test/pwtest.c
@@ -987,6 +987,12 @@ error:
 		}
 	}
 
+	for (size_t i = 0; i < SPA_N_ELEMENTS(t->logs); i++) {
+		char *e = pw_array_add(&t->logs[i], 1);
+		spa_assert_se(e);
+		*e = '\0';
+	}
+
 	close_pipes(read_fds);
 	close_pipes(write_fds);
 
diff --git a/test/test-logger.c b/test/test-logger.c
index 338cd81..a1b0ff0 100644
--- a/test/test-logger.c
+++ b/test/test-logger.c
@@ -24,6 +24,7 @@
 
 #include "pwtest.h"
 
+#include <errno.h>
 #include <fcntl.h>
 #include <unistd.h>
 
@@ -464,6 +465,9 @@ find_in_journal(sd_journal *journal, const char *needle, char *out, size_t out_s
 				const char *d;
 				size_t l;
 				int r = sd_journal_get_data(journal, "MESSAGE", (const void **)&d, &l);
+				if (r == -ENOENT || r == -E2BIG || r == -EBADMSG)
+					continue;
+
 				pwtest_neg_errno_ok(r);
 				spa_scnprintf(buffer, sizeof(buffer), "%.*s", (int) l, d);
 				if (strstr(buffer, needle)) {
