summaryrefslogtreecommitdiffstats
path: root/tests/ts/logger
diff options
context:
space:
mode:
authorSami Kerola2015-03-15 13:46:30 +0100
committerSami Kerola2015-03-17 00:25:10 +0100
commitb3d4c9862c1c12c1f1e5db5e72fe010b192ca106 (patch)
treec8c3aa923f12c14626c3b727e48b62ab202dfa07 /tests/ts/logger
parenttests: add logger(1) message format tests (diff)
downloadkernel-qcow2-util-linux-b3d4c9862c1c12c1f1e5db5e72fe010b192ca106.tar.gz
kernel-qcow2-util-linux-b3d4c9862c1c12c1f1e5db5e72fe010b192ca106.tar.xz
kernel-qcow2-util-linux-b3d4c9862c1c12c1f1e5db5e72fe010b192ca106.zip
tests: add logger(1) error condition tests
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'tests/ts/logger')
-rwxr-xr-xtests/ts/logger/errors65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/ts/logger/errors b/tests/ts/logger/errors
new file mode 100755
index 000000000..369ceb6e2
--- /dev/null
+++ b/tests/ts/logger/errors
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2015 Sami Kerola <kerolasa@iki.fi>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="errors"
+
+. $TS_TOPDIR/functions.sh
+
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_LOGGER"
+
+export TZ="GMT"
+export LOGGER_TEST_TIMEOFDAY="1234567890.123456"
+export LOGGER_TEST_HOSTNAME="test-hostname"
+export LOGGER_TEST_GETPID="98765"
+
+ts_init_subtest "kern_priority"
+$TS_HELPER_LOGGER --no-act -s -t "prio" -p kern.emerg "message" > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "kern_priority_numeric"
+$TS_HELPER_LOGGER --no-act -s -t "prio" -p 0 "message" > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "invalid_prio"
+$TS_HELPER_LOGGER --no-act -s -t "prio" -p 8 "message" > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+# should truncate
+ts_init_subtest "rfc5424_exceed_size"
+$TS_HELPER_LOGGER --no-act -s -t "rfc5424_exceed_size" --rfc5424 --size 3 "abcd" > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "id_with_space"
+$TS_HELPER_LOGGER --no-act -s -t "id_with_space" --id="A B" "message" > "$TS_OUTPUT" 2>&1
+$TS_HELPER_LOGGER --no-act -s -t "rfc5424_id_with_space" --rfc5424 --id="A B" "message" >> "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+# should not fail
+ts_init_subtest "tag_with_space"
+$TS_HELPER_LOGGER --no-act -s -t "A B" "tag_with_space" > "$TS_OUTPUT" 2>&1
+$TS_HELPER_LOGGER --no-act -s -t "A B" --rfc5424 "tag_with_space_rfc5424" >> "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "rfc5424_msgid_with_space"
+$TS_HELPER_LOGGER --no-act -s -t "rfc5424_msgid_with_space" --rfc5424 --msgid="A B" "message" > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_finalize