summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/tests.c1
-rw-r--r--src/shared/tests.h21
2 files changed, 22 insertions, 0 deletions
diff --git a/src/shared/tests.c b/src/shared/tests.c
index 195be70b03..41177f821e 100644
--- a/src/shared/tests.c
+++ b/src/shared/tests.c
@@ -114,6 +114,7 @@ bool slow_tests_enabled(void) {
}
void test_setup_logging(int level) {
+ log_set_assert_return_is_critical(true);
log_set_max_level(level);
log_parse_environment();
log_open();
diff --git a/src/shared/tests.h b/src/shared/tests.h
index d76cf2edbe..d5dfb78678 100644
--- a/src/shared/tests.h
+++ b/src/shared/tests.h
@@ -10,6 +10,27 @@
#include "static-destruct.h"
#include "strv.h"
+static inline void log_set_assert_return_is_criticalp(bool *p) {
+ log_set_assert_return_is_critical(*p);
+}
+
+#define _SAVE_ASSERT_RETURN_IS_CRITICAL(b) \
+ _unused_ _cleanup_(log_set_assert_return_is_criticalp) bool b = \
+ log_get_assert_return_is_critical()
+
+#define SAVE_ASSERT_RETURN_IS_CRITICAL \
+ _SAVE_ASSERT_RETURN_IS_CRITICAL(UNIQ_T(saved, UNIQ))
+
+#define ASSERT_RETURN_IS_CRITICAL(b, expr) \
+ ({ \
+ SAVE_ASSERT_RETURN_IS_CRITICAL; \
+ log_set_assert_return_is_critical(b); \
+ expr; \
+ })
+
+#define ASSERT_RETURN_EXPECTED(expr) ASSERT_RETURN_IS_CRITICAL(false, expr)
+#define ASSERT_RETURN_EXPECTED_SE(expr) ASSERT_RETURN_EXPECTED(assert_se(expr));
+
static inline bool manager_errno_skip_test(int r) {
return IN_SET(abs(r),
EPERM,