summaryrefslogtreecommitdiffstats
path: root/src/test/test-log.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
commit78e9bb837c258ac0ec7712b3d612cc2f407e731e (patch)
treef515d16b6efd858a9aeb5b0ef5d6f90bf288283d /src/test/test-log.c
parentAdding debian version 255.5-1. (diff)
downloadsystemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.tar.xz
systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.zip
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/test-log.c')
-rw-r--r--src/test/test-log.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/test-log.c b/src/test/test-log.c
index b5ba67b..97eb5e0 100644
--- a/src/test/test-log.c
+++ b/src/test/test-log.c
@@ -22,6 +22,26 @@ assert_cc(!IS_SYNTHETIC_ERRNO(0));
#define X100(x) X10(X10(x))
#define X1000(x) X100(X10(x))
+static int fail_with_EINVAL(void) {
+ assert_return(false, -EINVAL);
+ return 0;
+}
+
+static void test_assert_return_is_critical(void) {
+ SAVE_ASSERT_RETURN_IS_CRITICAL;
+
+ log_set_assert_return_is_critical(false);
+ assert_se(fail_with_EINVAL() == -EINVAL);
+
+ log_set_assert_return_is_critical(true);
+ ASSERT_RETURN_IS_CRITICAL(false, assert_se(fail_with_EINVAL() == -EINVAL));
+ assert_se(log_get_assert_return_is_critical() == true);
+ ASSERT_RETURN_EXPECTED(assert_se(fail_with_EINVAL() == -EINVAL));
+ assert_se(log_get_assert_return_is_critical() == true);
+ ASSERT_RETURN_EXPECTED_SE(fail_with_EINVAL() == -EINVAL);
+ assert_se(log_get_assert_return_is_critical() == true);
+}
+
static void test_file(void) {
log_info("__FILE__: %s", __FILE__);
log_info("RELATIVE_SOURCE_PATH: %s", RELATIVE_SOURCE_PATH);
@@ -207,6 +227,7 @@ static void test_log_prefix(void) {
int main(int argc, char* argv[]) {
test_setup_logging(LOG_DEBUG);
+ test_assert_return_is_critical();
test_file();
assert_se(log_info_errno(SYNTHETIC_ERRNO(EUCLEAN), "foo") == -EUCLEAN);