diff options
author | Karel Zak | 2015-03-17 10:01:35 +0100 |
---|---|---|
committer | Karel Zak | 2015-03-17 10:01:35 +0100 |
commit | bd0673f95a3e528507b24a435ea62de4e7267f24 (patch) | |
tree | 86d16adec7c1cfff61a6b576d27b2ed5c594db5c | |
parent | tests: remove warning from test output (diff) | |
parent | libblkid: fix compiler warnings (diff) | |
download | kernel-qcow2-util-linux-bd0673f95a3e528507b24a435ea62de4e7267f24.tar.gz kernel-qcow2-util-linux-bd0673f95a3e528507b24a435ea62de4e7267f24.tar.xz kernel-qcow2-util-linux-bd0673f95a3e528507b24a435ea62de4e7267f24.zip |
Merge branch 'tests_logger' of https://github.com/kerolasa/lelux-utiliteetit
21 files changed, 333 insertions, 5 deletions
diff --git a/libblkid/src/superblocks/bcache.c b/libblkid/src/superblocks/bcache.c index 4fb16bde2..ba9cf3270 100644 --- a/libblkid/src/superblocks/bcache.c +++ b/libblkid/src/superblocks/bcache.c @@ -117,7 +117,7 @@ static int probe_bcache (blkid_probe pr, const struct blkid_idmag *mag) return BLKID_PROBE_NONE; return BLKID_PROBE_OK; -}; +} const struct blkid_idinfo bcache_idinfo = { diff --git a/libblkid/src/superblocks/minix.c b/libblkid/src/superblocks/minix.c index 9ea49fee8..d6d45bd9b 100644 --- a/libblkid/src/superblocks/minix.c +++ b/libblkid/src/superblocks/minix.c @@ -21,6 +21,7 @@ static int get_minix_version(const unsigned char *data, int *other_endian) struct minix_super_block *sb = (struct minix_super_block *) data; struct minix3_super_block *sb3 = (struct minix3_super_block *) data; int version = 0; + char *endian; *other_endian = 0; @@ -60,13 +61,13 @@ static int get_minix_version(const unsigned char *data, int *other_endian) if (!version) return -1; - DBG(LOWPROBE, ul_debug("minix version %d detected [%s]", version, #if defined(WORDS_BIGENDIAN) - *other_endian ? "LE" : "BE" + endian = *other_endian ? "LE" : "BE"; #else - *other_endian ? "BE" : "LE" + endian = *other_endian ? "BE" : "LE"; #endif - )); + DBG(LOWPROBE, ul_debug("minix version %d detected [%s]", version, + endian)); return version; } diff --git a/tests/expected/logger/errors b/tests/expected/logger/errors new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/expected/logger/errors diff --git a/tests/expected/logger/errors-id_with_space b/tests/expected/logger/errors-id_with_space new file mode 100644 index 000000000..081efaccd --- /dev/null +++ b/tests/expected/logger/errors-id_with_space @@ -0,0 +1,2 @@ +test_logger: failed to parse id: 'A B' +test_logger: failed to parse id: 'A B' diff --git a/tests/expected/logger/errors-invalid_prio b/tests/expected/logger/errors-invalid_prio new file mode 100644 index 000000000..cf79cf388 --- /dev/null +++ b/tests/expected/logger/errors-invalid_prio @@ -0,0 +1 @@ +test_logger: unknown priority name: 8 diff --git a/tests/expected/logger/errors-kern_priority b/tests/expected/logger/errors-kern_priority new file mode 100644 index 000000000..6656db089 --- /dev/null +++ b/tests/expected/logger/errors-kern_priority @@ -0,0 +1 @@ +<8>Feb 13 23:31:30 prio: message diff --git a/tests/expected/logger/errors-kern_priority_numeric b/tests/expected/logger/errors-kern_priority_numeric new file mode 100644 index 000000000..6656db089 --- /dev/null +++ b/tests/expected/logger/errors-kern_priority_numeric @@ -0,0 +1 @@ +<8>Feb 13 23:31:30 prio: message diff --git a/tests/expected/logger/errors-rfc5424_exceed_size b/tests/expected/logger/errors-rfc5424_exceed_size new file mode 100644 index 000000000..91f69b62a --- /dev/null +++ b/tests/expected/logger/errors-rfc5424_exceed_size @@ -0,0 +1 @@ +<13>1 2009-02-13T23:31:30.123456+00:00 test-hostname rfc5424_exceed_size - - [timeQuality tzKnown="1" isSynced="0"] abc diff --git a/tests/expected/logger/errors-rfc5424_msgid_with_space b/tests/expected/logger/errors-rfc5424_msgid_with_space new file mode 100644 index 000000000..273bc9b65 --- /dev/null +++ b/tests/expected/logger/errors-rfc5424_msgid_with_space @@ -0,0 +1 @@ +test_logger: --msgid cannot contain space diff --git a/tests/expected/logger/errors-tag_with_space b/tests/expected/logger/errors-tag_with_space new file mode 100644 index 000000000..9821d82c0 --- /dev/null +++ b/tests/expected/logger/errors-tag_with_space @@ -0,0 +1,2 @@ +<13>Feb 13 23:31:30 A B: tag_with_space +<13>1 2009-02-13T23:31:30.123456+00:00 test-hostname A B - - [timeQuality tzKnown="1" isSynced="0"] tag_with_space_rfc5424 diff --git a/tests/expected/logger/formats b/tests/expected/logger/formats new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/expected/logger/formats diff --git a/tests/expected/logger/formats-priorities b/tests/expected/logger/formats-priorities new file mode 100644 index 000000000..32d136f46 --- /dev/null +++ b/tests/expected/logger/formats-priorities @@ -0,0 +1,152 @@ +<32>Feb 13 23:31:30 prio: auth.emerg +<33>Feb 13 23:31:30 prio: auth.alert +<34>Feb 13 23:31:30 prio: auth.crit +<35>Feb 13 23:31:30 prio: auth.err +<36>Feb 13 23:31:30 prio: auth.warning +<37>Feb 13 23:31:30 prio: auth.notice +<38>Feb 13 23:31:30 prio: auth.info +<39>Feb 13 23:31:30 prio: auth.debug +<80>Feb 13 23:31:30 prio: authpriv.emerg +<81>Feb 13 23:31:30 prio: authpriv.alert +<82>Feb 13 23:31:30 prio: authpriv.crit +<83>Feb 13 23:31:30 prio: authpriv.err +<84>Feb 13 23:31:30 prio: authpriv.warning +<85>Feb 13 23:31:30 prio: authpriv.notice +<86>Feb 13 23:31:30 prio: authpriv.info +<87>Feb 13 23:31:30 prio: authpriv.debug +<72>Feb 13 23:31:30 prio: cron.emerg +<73>Feb 13 23:31:30 prio: cron.alert +<74>Feb 13 23:31:30 prio: cron.crit +<75>Feb 13 23:31:30 prio: cron.err +<76>Feb 13 23:31:30 prio: cron.warning +<77>Feb 13 23:31:30 prio: cron.notice +<78>Feb 13 23:31:30 prio: cron.info +<79>Feb 13 23:31:30 prio: cron.debug +<24>Feb 13 23:31:30 prio: daemon.emerg +<25>Feb 13 23:31:30 prio: daemon.alert +<26>Feb 13 23:31:30 prio: daemon.crit +<27>Feb 13 23:31:30 prio: daemon.err +<28>Feb 13 23:31:30 prio: daemon.warning +<29>Feb 13 23:31:30 prio: daemon.notice +<30>Feb 13 23:31:30 prio: daemon.info +<31>Feb 13 23:31:30 prio: daemon.debug +<88>Feb 13 23:31:30 prio: ftp.emerg +<89>Feb 13 23:31:30 prio: ftp.alert +<90>Feb 13 23:31:30 prio: ftp.crit +<91>Feb 13 23:31:30 prio: ftp.err +<92>Feb 13 23:31:30 prio: ftp.warning +<93>Feb 13 23:31:30 prio: ftp.notice +<94>Feb 13 23:31:30 prio: ftp.info +<95>Feb 13 23:31:30 prio: ftp.debug +<48>Feb 13 23:31:30 prio: lpr.emerg +<49>Feb 13 23:31:30 prio: lpr.alert +<50>Feb 13 23:31:30 prio: lpr.crit +<51>Feb 13 23:31:30 prio: lpr.err +<52>Feb 13 23:31:30 prio: lpr.warning +<53>Feb 13 23:31:30 prio: lpr.notice +<54>Feb 13 23:31:30 prio: lpr.info +<55>Feb 13 23:31:30 prio: lpr.debug +<16>Feb 13 23:31:30 prio: mail.emerg +<17>Feb 13 23:31:30 prio: mail.alert +<18>Feb 13 23:31:30 prio: mail.crit +<19>Feb 13 23:31:30 prio: mail.err +<20>Feb 13 23:31:30 prio: mail.warning +<21>Feb 13 23:31:30 prio: mail.notice +<22>Feb 13 23:31:30 prio: mail.info +<23>Feb 13 23:31:30 prio: mail.debug +<56>Feb 13 23:31:30 prio: news.emerg +<57>Feb 13 23:31:30 prio: news.alert +<58>Feb 13 23:31:30 prio: news.crit +<59>Feb 13 23:31:30 prio: news.err +<60>Feb 13 23:31:30 prio: news.warning +<61>Feb 13 23:31:30 prio: news.notice +<62>Feb 13 23:31:30 prio: news.info +<63>Feb 13 23:31:30 prio: news.debug +<40>Feb 13 23:31:30 prio: syslog.emerg +<41>Feb 13 23:31:30 prio: syslog.alert +<42>Feb 13 23:31:30 prio: syslog.crit +<43>Feb 13 23:31:30 prio: syslog.err +<44>Feb 13 23:31:30 prio: syslog.warning +<45>Feb 13 23:31:30 prio: syslog.notice +<46>Feb 13 23:31:30 prio: syslog.info +<47>Feb 13 23:31:30 prio: syslog.debug +<8>Feb 13 23:31:30 prio: user.emerg +<9>Feb 13 23:31:30 prio: user.alert +<10>Feb 13 23:31:30 prio: user.crit +<11>Feb 13 23:31:30 prio: user.err +<12>Feb 13 23:31:30 prio: user.warning +<13>Feb 13 23:31:30 prio: user.notice +<14>Feb 13 23:31:30 prio: user.info +<15>Feb 13 23:31:30 prio: user.debug +<64>Feb 13 23:31:30 prio: uucp.emerg +<65>Feb 13 23:31:30 prio: uucp.alert +<66>Feb 13 23:31:30 prio: uucp.crit +<67>Feb 13 23:31:30 prio: uucp.err +<68>Feb 13 23:31:30 prio: uucp.warning +<69>Feb 13 23:31:30 prio: uucp.notice +<70>Feb 13 23:31:30 prio: uucp.info +<71>Feb 13 23:31:30 prio: uucp.debug +<128>Feb 13 23:31:30 prio: local0.emerg +<129>Feb 13 23:31:30 prio: local0.alert +<130>Feb 13 23:31:30 prio: local0.crit +<131>Feb 13 23:31:30 prio: local0.err +<132>Feb 13 23:31:30 prio: local0.warning +<133>Feb 13 23:31:30 prio: local0.notice +<134>Feb 13 23:31:30 prio: local0.info +<135>Feb 13 23:31:30 prio: local0.debug +<136>Feb 13 23:31:30 prio: local1.emerg +<137>Feb 13 23:31:30 prio: local1.alert +<138>Feb 13 23:31:30 prio: local1.crit +<139>Feb 13 23:31:30 prio: local1.err +<140>Feb 13 23:31:30 prio: local1.warning +<141>Feb 13 23:31:30 prio: local1.notice +<142>Feb 13 23:31:30 prio: local1.info +<143>Feb 13 23:31:30 prio: local1.debug +<144>Feb 13 23:31:30 prio: local2.emerg +<145>Feb 13 23:31:30 prio: local2.alert +<146>Feb 13 23:31:30 prio: local2.crit +<147>Feb 13 23:31:30 prio: local2.err +<148>Feb 13 23:31:30 prio: local2.warning +<149>Feb 13 23:31:30 prio: local2.notice +<150>Feb 13 23:31:30 prio: local2.info +<151>Feb 13 23:31:30 prio: local2.debug +<152>Feb 13 23:31:30 prio: local3.emerg +<153>Feb 13 23:31:30 prio: local3.alert +<154>Feb 13 23:31:30 prio: local3.crit +<155>Feb 13 23:31:30 prio: local3.err +<156>Feb 13 23:31:30 prio: local3.warning +<157>Feb 13 23:31:30 prio: local3.notice +<158>Feb 13 23:31:30 prio: local3.info +<159>Feb 13 23:31:30 prio: local3.debug +<160>Feb 13 23:31:30 prio: local4.emerg +<161>Feb 13 23:31:30 prio: local4.alert +<162>Feb 13 23:31:30 prio: local4.crit +<163>Feb 13 23:31:30 prio: local4.err +<164>Feb 13 23:31:30 prio: local4.warning +<165>Feb 13 23:31:30 prio: local4.notice +<166>Feb 13 23:31:30 prio: local4.info +<167>Feb 13 23:31:30 prio: local4.debug +<168>Feb 13 23:31:30 prio: local5.emerg +<169>Feb 13 23:31:30 prio: local5.alert +<170>Feb 13 23:31:30 prio: local5.crit +<171>Feb 13 23:31:30 prio: local5.err +<172>Feb 13 23:31:30 prio: local5.warning +<173>Feb 13 23:31:30 prio: local5.notice +<174>Feb 13 23:31:30 prio: local5.info +<175>Feb 13 23:31:30 prio: local5.debug +<176>Feb 13 23:31:30 prio: local6.emerg +<177>Feb 13 23:31:30 prio: local6.alert +<178>Feb 13 23:31:30 prio: local6.crit +<179>Feb 13 23:31:30 prio: local6.err +<180>Feb 13 23:31:30 prio: local6.warning +<181>Feb 13 23:31:30 prio: local6.notice +<182>Feb 13 23:31:30 prio: local6.info +<183>Feb 13 23:31:30 prio: local6.debug +<184>Feb 13 23:31:30 prio: local7.emerg +<185>Feb 13 23:31:30 prio: local7.alert +<186>Feb 13 23:31:30 prio: local7.crit +<187>Feb 13 23:31:30 prio: local7.err +<188>Feb 13 23:31:30 prio: local7.warning +<189>Feb 13 23:31:30 prio: local7.notice +<190>Feb 13 23:31:30 prio: local7.info +<191>Feb 13 23:31:30 prio: local7.debug diff --git a/tests/expected/logger/formats-rfc3164 b/tests/expected/logger/formats-rfc3164 new file mode 100644 index 000000000..03534609d --- /dev/null +++ b/tests/expected/logger/formats-rfc3164 @@ -0,0 +1 @@ +<13>Feb 13 23:31:30 test-hostname rfc3164: message diff --git a/tests/expected/logger/formats-rfc5424_msgid b/tests/expected/logger/formats-rfc5424_msgid new file mode 100644 index 000000000..fee0e430d --- /dev/null +++ b/tests/expected/logger/formats-rfc5424_msgid @@ -0,0 +1 @@ +<13>1 2009-02-13T23:31:30.123456+00:00 test-hostname rfc5424 - MSGID [timeQuality tzKnown="1" isSynced="0"] message diff --git a/tests/expected/logger/formats-rfc5424_nohost b/tests/expected/logger/formats-rfc5424_nohost new file mode 100644 index 000000000..30af1115e --- /dev/null +++ b/tests/expected/logger/formats-rfc5424_nohost @@ -0,0 +1 @@ +<13>1 2009-02-13T23:31:30.123456+00:00 - rfc5424 - - [timeQuality tzKnown="1" isSynced="0"] message diff --git a/tests/expected/logger/formats-rfc5424_notime b/tests/expected/logger/formats-rfc5424_notime new file mode 100644 index 000000000..4572dfad4 --- /dev/null +++ b/tests/expected/logger/formats-rfc5424_notime @@ -0,0 +1 @@ +<13>1 - test-hostname rfc5424 - - - message diff --git a/tests/expected/logger/formats-rfc5424_simple b/tests/expected/logger/formats-rfc5424_simple new file mode 100644 index 000000000..8ac4038cf --- /dev/null +++ b/tests/expected/logger/formats-rfc5424_simple @@ -0,0 +1 @@ +<13>1 2009-02-13T23:31:30.123456+00:00 test-hostname rfc5424 - - [timeQuality tzKnown="1" isSynced="0"] message diff --git a/tests/expected/logger/journald b/tests/expected/logger/journald new file mode 100644 index 000000000..d4b1549e7 --- /dev/null +++ b/tests/expected/logger/journald @@ -0,0 +1,3 @@ +MESSAGE_ID=b8f74e14bc714bfc8040a5106dc9376a +MESSAGE=a b c 1 2 3 + 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 diff --git a/tests/ts/logger/formats b/tests/ts/logger/formats new file mode 100755 index 000000000..4d11c1d9b --- /dev/null +++ b/tests/ts/logger/formats @@ -0,0 +1,58 @@ +#!/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="formats" + +. $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 "rfc3164" +$TS_HELPER_LOGGER -s --no-act -t "rfc3164" --rfc3164 "message" > "$TS_OUTPUT" 2>&1 +ts_finalize_subtest + +ts_init_subtest "rfc5424_simple" +$TS_HELPER_LOGGER -s --no-act -t "rfc5424" --rfc5424 "message" > "$TS_OUTPUT" 2>&1 +ts_finalize_subtest +ts_init_subtest "rfc5424_notime" +$TS_HELPER_LOGGER -s --no-act -t "rfc5424" --rfc5424=notime "message" > "$TS_OUTPUT" 2>&1 +ts_finalize_subtest +ts_init_subtest "rfc5424_nohost" +$TS_HELPER_LOGGER -s --no-act -t "rfc5424" --rfc5424=nohost "message" > "$TS_OUTPUT" 2>&1 +ts_finalize_subtest +ts_init_subtest "rfc5424_msgid" +$TS_HELPER_LOGGER -s --no-act -t "rfc5424" --rfc5424 --msgid "MSGID" "message" > "$TS_OUTPUT" 2>&1 +ts_finalize_subtest + +ts_init_subtest "priorities" +for facility in auth authpriv cron daemon ftp lpr mail news syslog user uucp local{0..7}; do + for level in emerg alert crit err warning notice info debug; do + $TS_HELPER_LOGGER -s --no-act -t "prio" -p "$facility.$level" "$facility.$level" >> "$TS_OUTPUT" 2>&1 + done +done +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/logger/journald b/tests/ts/logger/journald new file mode 100755 index 000000000..155aeae84 --- /dev/null +++ b/tests/ts/logger/journald @@ -0,0 +1,35 @@ +#!/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="journald" + +. $TS_TOPDIR/functions.sh + +ts_init "$*" + +ts_check_test_command "$TS_HELPER_LOGGER" + +if ! $TS_HELPER_LOGGER --help | grep -q journald; then + TS_KNOWN_FAIL="yes" +fi + +printf "%s\n%s\n%s\n" MESSAGE_ID=b8f74e14bc714bfc8040a5106dc9376a MESSAGE="a b c 1 2 3" | +$TS_HELPER_LOGGER --no-act --journald --stderr > "$TS_OUTPUT" 2>&1 + +ts_finalize |