]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: add logger(1) command line options tests
authorSami Kerola <kerolasa@iki.fi>
Sun, 15 Mar 2015 12:54:50 +0000 (12:54 +0000)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Mar 2015 13:08:43 +0000 (14:08 +0100)
[kzak@redhat.com: - use LOGGER_TEST_* env]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 files changed:
tests/expected/logger/input_empty_line [new file with mode: 0644]
tests/expected/logger/input_prio_prefix [new file with mode: 0644]
tests/expected/logger/input_simple [new file with mode: 0644]
tests/expected/logger/options [new file with mode: 0644]
tests/expected/logger/options-input_file_empty_line [new file with mode: 0644]
tests/expected/logger/options-input_file_prio_prefix [new file with mode: 0644]
tests/expected/logger/options-input_file_simple [new file with mode: 0644]
tests/expected/logger/options-input_file_skip_empty [new file with mode: 0644]
tests/expected/logger/options-log_pid [new file with mode: 0644]
tests/expected/logger/options-log_pid_define [new file with mode: 0644]
tests/expected/logger/options-log_pid_long [new file with mode: 0644]
tests/expected/logger/options-log_pid_no_arg [new file with mode: 0644]
tests/expected/logger/options-simple [new file with mode: 0644]
tests/ts/logger/options [new file with mode: 0755]

diff --git a/tests/expected/logger/input_empty_line b/tests/expected/logger/input_empty_line
new file mode 100644 (file)
index 0000000..78578ae
--- /dev/null
@@ -0,0 +1,3 @@
+a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 c1 c2 c3 c4 c5
+
+5{c..1} 4{c..1} 3{c..1} 2{c..1} 1{c..1}
diff --git a/tests/expected/logger/input_prio_prefix b/tests/expected/logger/input_prio_prefix
new file mode 100644 (file)
index 0000000..25a5f54
--- /dev/null
@@ -0,0 +1 @@
+<66> prio_prefix
diff --git a/tests/expected/logger/input_simple b/tests/expected/logger/input_simple
new file mode 100644 (file)
index 0000000..9e5c66d
--- /dev/null
@@ -0,0 +1 @@
+a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 c1 c2 c3 c4 c5
diff --git a/tests/expected/logger/options b/tests/expected/logger/options
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/expected/logger/options-input_file_empty_line b/tests/expected/logger/options-input_file_empty_line
new file mode 100644 (file)
index 0000000..a10fd1c
--- /dev/null
@@ -0,0 +1,3 @@
+<13>Feb 13 23:31:30 test_tag: a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 c1 c2 c3 c4 c5
+<13>Feb 13 23:31:30 test_tag: 
+<13>Feb 13 23:31:30 test_tag: 5{c..1} 4{c..1} 3{c..1} 2{c..1} 1{c..1}
diff --git a/tests/expected/logger/options-input_file_prio_prefix b/tests/expected/logger/options-input_file_prio_prefix
new file mode 100644 (file)
index 0000000..b0f9785
--- /dev/null
@@ -0,0 +1 @@
+<66>Feb 13 23:31:30 test_tag:  prio_prefix
diff --git a/tests/expected/logger/options-input_file_simple b/tests/expected/logger/options-input_file_simple
new file mode 100644 (file)
index 0000000..e8a2ca8
--- /dev/null
@@ -0,0 +1 @@
+<13>Feb 13 23:31:30 test_tag: a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 c1 c2 c3 c4 c5
diff --git a/tests/expected/logger/options-input_file_skip_empty b/tests/expected/logger/options-input_file_skip_empty
new file mode 100644 (file)
index 0000000..cdbe87a
--- /dev/null
@@ -0,0 +1,2 @@
+<13>Feb 13 23:31:30 test_tag: a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 c1 c2 c3 c4 c5
+<13>Feb 13 23:31:30 test_tag: 5{c..1} 4{c..1} 3{c..1} 2{c..1} 1{c..1}
diff --git a/tests/expected/logger/options-log_pid b/tests/expected/logger/options-log_pid
new file mode 100644 (file)
index 0000000..d21ecd4
--- /dev/null
@@ -0,0 +1 @@
+<13>Feb 13 23:31:30 test_tag[98765]: test
diff --git a/tests/expected/logger/options-log_pid_define b/tests/expected/logger/options-log_pid_define
new file mode 100644 (file)
index 0000000..14024b1
--- /dev/null
@@ -0,0 +1 @@
+<13>Feb 13 23:31:30 test_tag[12345]: test
diff --git a/tests/expected/logger/options-log_pid_long b/tests/expected/logger/options-log_pid_long
new file mode 100644 (file)
index 0000000..d21ecd4
--- /dev/null
@@ -0,0 +1 @@
+<13>Feb 13 23:31:30 test_tag[98765]: test
diff --git a/tests/expected/logger/options-log_pid_no_arg b/tests/expected/logger/options-log_pid_no_arg
new file mode 100644 (file)
index 0000000..d21ecd4
--- /dev/null
@@ -0,0 +1 @@
+<13>Feb 13 23:31:30 test_tag[98765]: test
diff --git a/tests/expected/logger/options-simple b/tests/expected/logger/options-simple
new file mode 100644 (file)
index 0000000..1d0c3a0
--- /dev/null
@@ -0,0 +1 @@
+<13>Feb 13 23:31:30 test_tag: test
diff --git a/tests/ts/logger/options b/tests/ts/logger/options
new file mode 100755 (executable)
index 0000000..a040a26
--- /dev/null
@@ -0,0 +1,62 @@
+#!/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="options"
+
+. $TS_TOPDIR/functions.sh
+
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_LOGGER"
+
+# Create --file option input files.
+echo {a..c}{1..5}       > $TS_OUTDIR/input_simple
+echo {a..c}{1..5}       > $TS_OUTDIR/input_empty_line
+echo ""                        >> $TS_OUTDIR/input_empty_line
+echo {5..1}{c..1}      >> $TS_OUTDIR/input_empty_line
+echo "<66>" prio_prefix         > $TS_OUTDIR/input_prio_prefix
+
+# bash 4 might not be available, use go-around hash
+tests_array=(
+       "simple:--stderr test"
+       "log_pid:--stderr -i test"
+       "log_pid_long:--stderr --id test"
+       "log_pid_define:--stderr --id=12345 test"
+       "log_pid_no_arg:-is test"
+       "input_file_simple:--stderr -f $TS_OUTDIR/input_simple"
+       "input_file_empty_line:--stderr -f $TS_OUTDIR/input_empty_line"
+       "input_file_skip_empty:--stderr --file $TS_OUTDIR/input_empty_line -e"
+       "input_file_prio_prefix:--stderr --file $TS_OUTDIR/input_prio_prefix --skip-empty --prio-prefix"
+)
+
+export TZ="GMT"
+export LOGGER_TEST_TIMEOFDAY="1234567890.123456"
+export LOGGER_TEST_HOSTNAME="test-hostname"
+export LOGGER_TEST_GETPID="98765"
+
+for i in "${tests_array[@]}"; do
+       name="${i%%:*}"
+       options="${i##*:}"
+
+       ts_init_subtest "$name"
+       $TS_HELPER_LOGGER -t "test_tag" $options > "$TS_OUTPUT" 2>&1
+       ts_finalize_subtest
+done
+
+ts_finalize