From: Yu Watanabe Date: Mon, 4 Mar 2019 06:28:32 +0000 (+0900) Subject: test: add tests for log_syntax() X-Git-Tag: v242-rc1~212^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F11882%2Fhead;p=thirdparty%2Fsystemd.git test: add tests for log_syntax() --- diff --git a/src/test/test-log.c b/src/test/test-log.c index 1e010c08fb8..18ef56ac391 100644 --- a/src/test/test-log.c +++ b/src/test/test-log.c @@ -59,15 +59,22 @@ static void test_long_lines(void) { "asdfasdf %s asdfasdfa", "foobar"); } +static void test_log_syntax(void) { + assert_se(log_syntax("unit", LOG_ERR, "filename", 10, EINVAL, "EINVAL: %s: %m", "hogehoge") == -EINVAL); + assert_se(log_syntax("unit", LOG_ERR, "filename", 10, -ENOENT, "ENOENT: %s: %m", "hogehoge") == -ENOENT); + assert_se(log_syntax("unit", LOG_ERR, "filename", 10, SYNTHETIC_ERRNO(ENOTTY), "ENOTTY: %s: %m", "hogehoge") == -ENOTTY); +} + int main(int argc, char* argv[]) { int target; - for (target = 0; target < _LOG_TARGET_MAX; target++) { + for (target = 0; target < _LOG_TARGET_MAX; target++) { log_set_target(target); log_open(); test_log_struct(); test_long_lines(); + test_log_syntax(); } assert_se(log_info_errno(SYNTHETIC_ERRNO(EUCLEAN), "foo") == -EUCLEAN);