util-linux add dmesg caller_id Issue: 2666 patch 2 of 4
PATCH 1/1 util-linux add dmesg caller_id Issue: 2666 patch 2 of 4
Submission to Project: util-linux
Open Incident: #2637 at github.com/util-linux/util-linux/issues/2637
Component: util-linux/sys-utils
Files: tests/ts/dmesg syslog interface caller-id files, tests
and related expected files
Testing on Fedora 39 with Linux-6.6.6 Kernel and CONFIG_PRINTK_CALLER config option set.
Patch tested and generated with the latest util-linux code pulled. Retro-fitted to merge on top of the patch for Issue: #2609
For Issue #2609 Thomas and Zak pointed out the we need tests to verify that the dmesg command works correctly and to allow us to compare the results from PRINTK_CALLER id field tests provided by #2609 with the standard (syslog interface) dmesg tests.
Currently, dmesg only has standard syslog interface tests even though dmesg -S the syslog interface supports the caller_id field. There are no syslog caller-id tests.
We would like syslog caller-id tests both to validate that the dmesg code works correctly with the caller-id field being present and also to compare against the addition of dmesg kmsg caller_id support added by Issue #2609.
These tests are for the dmesg syslog interface with caller-id follow the existing test structure for dmesg tests. The existing dmesg -F interface is used to input our test files.
Until Thomas added a dmesg kmsg interface for json format testing there were no dmesg tests except the tests for the generic dmesg syslog tests. So we're naming the syslog caller-id tests to follow the test naming convention that Thomas introduced.
For caller_id tests we prefix the test name with cid- abbreviating the caller_id name to keep the names short. There is no unqiue indentifier for syslog tests, so syslog tests are currently:
colors, console-levels, decode, delta, facilities, indentation, limit, json
The cid versions of these test files are just prefixed with cid- The patch for Issue: #2609 has the files:
cid-input and cid-json and the expected file for cide-json
Additional new dmesg tests are found with Issue #2663 which add standard dmesg kmsg interface tests providing equivalent tests to the existing dmesg syslog interface tests.
Also, Issue #2609 introduces dmesg kmsg interface caller-id tests equivalent to the dmesg syslog interface with caller-id tests introduced here along with the necessary dmesg kmsg interface caller-id support needed to accomodate the PRINTK_CALLER id field.
Just for reference, on a Linux system with the CONFIG_PRINTK_CALLER configuration option set the output from dmesg -S looks like:
[ 520.899558] [ T3919] hub 3-3:1.0: USB hub found
on a system where the PRINTK_CALLER configuration option is not set the output looks like:
[ 520.899558] hub 3-3:1.0: USB hub found
the additional field specifies either a Thread Id or CPU id depending on the context of the task or thread at the time the printk that added the message to the kernel ring buffer was executed.
--- tests/expected/dmesg/cid-colors | 106 ++++++++++ tests/expected/dmesg/cid-console-levels | 253 ++++++++++++++++++++++++ tests/expected/dmesg/cid-decode | 106 ++++++++++ tests/expected/dmesg/cid-delta | 106 ++++++++++ tests/expected/dmesg/cid-facilities | 104 ++++++++++ tests/expected/dmesg/cid-indentation | 35 ++++ tests/expected/dmesg/cid-limit | 4 + tests/ts/dmesg/cid-colors | 29 +++ tests/ts/dmesg/cid-console-levels | 36 ++++ tests/ts/dmesg/cid-decode | 28 +++ tests/ts/dmesg/cid-delta | 27 +++ tests/ts/dmesg/cid-facilities | 30 +++ tests/ts/dmesg/cid-indentation | 40 ++++ tests/ts/dmesg/cid-limit | 29 +++ tests/ts/dmesg/cid-newlines | 5 + 15 files changed, 938 insertions(+) create mode 100644 tests/expected/dmesg/cid-colors create mode 100644 tests/expected/dmesg/cid-console-levels create mode 100644 tests/expected/dmesg/cid-decode create mode 100644 tests/expected/dmesg/cid-delta create mode 100644 tests/expected/dmesg/cid-facilities create mode 100644 tests/expected/dmesg/cid-indentation create mode 100644 tests/expected/dmesg/cid-limit create mode 100755 tests/ts/dmesg/cid-colors create mode 100755 tests/ts/dmesg/cid-console-levels create mode 100755 tests/ts/dmesg/cid-decode create mode 100755 tests/ts/dmesg/cid-delta create mode 100755 tests/ts/dmesg/cid-facilities create mode 100755 tests/ts/dmesg/cid-indentation create mode 100755 tests/ts/dmesg/cid-limit create mode 100644 tests/ts/dmesg/cid-newlines
tests/expected/dmesg/cid-colors new file +106 -0
@@ -0,0 +1,106 @@ +kern :emerg : [32m[ 0.000000] [0m[ T0] example[0] +kern :alert : [32m[ 1.000000] [0m[ T1] [7m[31mexample[1][0m +kern :crit : [32m[ 8.000000] [0m[ T2] [1m[31mexample[2][0m +kern :err : [32m[ 27.000000] [0m[ T3] [31mexample[3][0m +kern :warn : [32m[ 64.000000] [0m[ T4] [1mexample[4][0m +kern :notice: [32m[ 125.000000] [0m[ T5] example[5] +kern :info : [32m[ 216.000000] [0m[ T6] example[6] +kern :debug : [32m[ 343.000000] [0m[ T7] example[7] +user :emerg : [32m[ 512.000000] [0m[ T8] example[8] +user :alert : [32m[ 729.000000] [0m[ T9] [7m[31mexample[9][0m +user :crit : [32m[ 1000.000000] [0m[ T10] [1m[31mexample[10][0m +user :err : [32m[ 1331.000000] [0m[ T11] [31mexample[11][0m +user :warn : [32m[ 1728.000000] [0m[ T12] [1mexample[12][0m +user :notice: [32m[ 2197.000000] [0m[ T13] example[13] +user :info : [32m[ 2744.000000] [0m[ T14] example[14] +user :debug : [32m[ 3375.000000] [0m[ T15] example[15] +mail :emerg : [32m[ 4096.000000] [0m[ T16] example[16] +mail :alert : [32m[ 4913.000000] [0m[ T17] [7m[31mexample[17][0m +mail :crit : [32m[ 5832.000000] [0m[ T18] [1m[31mexample[18][0m +mail :err : [32m[ 6859.000000] [0m[ T19] [31mexample[19][0m +mail :warn : [32m[ 8000.000000] [0m[ T20] [1mexample[20][0m +mail :notice: [32m[ 9261.000000] [0m[ T21] example[21] +mail :info : [32m[10648.000000] [0m[ T22] example[22] +mail :debug : [32m[12167.000000] [0m[ T23] example[23] +daemon:emerg : [32m[13824.000000] [0m[ T24] example[24] +daemon:alert : [32m[15625.000000] [0m[ T25] [7m[31mexample[25][0m +daemon:crit : [32m[17576.000000] [0m[ T26] [1m[31mexample[26][0m +daemon:err : [32m[19683.000000] [0m[ T27] [31mexample[27][0m +daemon:warn : [32m[21952.000000] [0m[ T28] [1mexample[28][0m +daemon:notice: [32m[24389.000000] [0m[ T29] example[29] +daemon:info : [32m[27000.000000] [0m[ T10] example[30] +daemon:debug : [32m[29791.000000] [0m[ T31] example[31] +auth :emerg : [32m[32768.000000] [0m[ T32] example[32] +auth :alert : [32m[35937.000000] [0m[ T33] [7m[31mexample[33][0m +auth :crit : [32m[39304.000000] [0m[ T34] [1m[31mexample[34][0m +auth :err : [32m[42875.000000] [0m[ T35] [31mexample[35][0m +auth :warn : [32m[46656.000000] [0m[ T36] [1mexample[36][0m +auth :notice: [32m[50653.000000] [0m[ T37] example[37] +auth :info : [32m[54872.000000] [0m[ T38] example[38] +auth :debug : [32m[59319.000000] [0m[ T39] example[39] +syslog:emerg : [32m[64000.000000] [0m[ T40] example[40] +syslog:alert : [32m[68921.000000] [0m[ T41] [7m[31mexample[41][0m +syslog:crit : [32m[74088.000000] [0m[ T42] [1m[31mexample[42][0m +syslog:err : [32m[79507.000000] [0m[ T43] [31mexample[43][0m +syslog:warn : [32m[85184.000000] [0m[ T44] [1mexample[44][0m +syslog:notice: [32m[91125.000000] [0m[ T45] example[45] +syslog:info : [32m[97336.000000] [0m[ T46] example[46] +syslog:debug : [32m[103823.000000] [0m[ T47] example[47] +lpr :emerg : [32m[110592.000000] [0m[ T48] example[48] +lpr :alert : [32m[117649.000000] [0m[ T49] [7m[31mexample[49][0m +lpr :crit : [32m[125000.000000] [0m[ T50] [1m[31mexample[50][0m +lpr :err : [32m[132651.000000] [0m[ T51] [31mexample[51][0m +lpr :warn : [32m[140608.000000] [0m[ T52] [1mexample[52][0m +lpr :notice: [32m[148877.000000] [0m[ T53] example[53] +lpr :info : [32m[157464.000000] [0m[ T54] example[54] +lpr :debug : [32m[166375.000000] [0m[ T55] example[55] +news :emerg : [32m[175616.000000] [0m[ T56] example[56] +news :alert : [32m[185193.000000] [0m[ T57] [7m[31mexample[57][0m +news :crit : [32m[195112.000000] [0m[ T58] [1m[31mexample[58][0m +news :err : [32m[205379.000000] [0m[ T59] [31mexample[59][0m +news :warn : [32m[216000.000000] [0m[ T60] [1mexample[60][0m +news :notice: [32m[226981.000000] [0m[ T61] example[61] +news :info : [32m[238328.000000] [0m[ T62] example[62] +news :debug : [32m[250047.000000] [0m[ T63] example[63] +uucp :emerg : [32m[262144.000000] [0m[ T64] example[64] +uucp :alert : [32m[274625.000000] [0m[ T65] [7m[31mexample[65][0m +uucp :crit : [32m[287496.000000] [0m[ T66] [1m[31mexample[66][0m +uucp :err : [32m[300763.000000] [0m[ T67] [31mexample[67][0m +uucp :warn : [32m[314432.000000] [0m[ T68] [1mexample[68][0m +uucp :notice: [32m[328509.000000] [0m[ T69] example[69] +uucp :info : [32m[343000.000000] [0m[ T70] example[70] +uucp :debug : [32m[357911.000000] [0m[ T71] example[71] +cron :emerg : [32m[373248.000000] [0m[ T72] example[72] +cron :alert : [32m[389017.000000] [0m[ T73] [7m[31mexample[73][0m +cron :crit : [32m[405224.000000] [0m[ T74] [1m[31mexample[74][0m +cron :err : [32m[421875.000000] [0m[ T75] [31mexample[75][0m +cron :warn : [32m[438976.000000] [0m[ T76] [1mexample[76][0m +cron :notice: [32m[456533.000000] [0m[ T77] example[77] +cron :info : [32m[474552.000000] [0m[ T78] example[78] +cron :debug : [32m[493039.000000] [0m[ T79] example[79] +authpriv:emerg : [32m[512000.000000] [0m[ T80] example[80] +authpriv:alert : [32m[531441.000000] [0m[ T81] [7m[31mexample[81][0m +authpriv:crit : [32m[551368.000000] [0m[ T82] [1m[31mexample[82][0m +authpriv:err : [32m[571787.000000] [0m[ T83] [31mexample[83][0m +authpriv:warn : [32m[592704.000000] [0m[ T84] [1mexample[84][0m +authpriv:notice: [32m[614125.000000] [0m[ T85] example[85] +authpriv:info : [32m[636056.000000] [0m[ T86] example[86] +authpriv:debug : [32m[658503.000000] [0m[ T87] example[87] +ftp :emerg : [32m[681472.000000] [0m[ T88] example[88] +ftp :alert : [32m[704969.000000] [0m[ T89] [7m[31mexample[89][0m +ftp :crit : [32m[729000.000000] [0m[ T90] [1m[31mexample[90][0m +ftp :err : [32m[753571.000000] [0m[ T91] [31mexample[91][0m +ftp :warn : [32m[778688.000000] [0m[ T92] [1mexample[92][0m +ftp :notice: [32m[804357.000000] [0m[ T93] example[93] +ftp :info : [32m[830584.000000] [0m[ T94] example[94] +ftp :debug : [32m[857375.000000] [0m[ T95] example[95] +res0 :emerg : [32m[884736.000000] [0m[ T96] example[96] +res0 :alert : [32m[912673.000000] [0m[ T97] [7m[31mexample[97][0m +res0 :crit : [32m[941192.000000] [0m[ T98] [1m[31mexample[98][0m +res0 :err : [32m[970299.000000] [0m[ T99] [31mexample[99][0m +res0 :warn : [32m[1000000.000000] [0m[ T100] [1mexample[100][0m +res0 :notice: [32m[1030301.000000] [0m[ T101] example[101] +res0 :info : [32m[1061208.000000] [0m[ T102] example[102] +res0 :debug : [32m[1092727.000000] [0m[ T103] example[103] +res1 :emerg : [32m[1124864.000000] [0m[ T104] example[104] +local2:info : [32m[4557523.000000] [0m[ T105] example[105]
tests/expected/dmesg/cid-console-levels new file +253 -0
253 lines not on this page · raw message
tests/expected/dmesg/cid-decode new file +106 -0
106 lines not on this page · raw message
tests/expected/dmesg/cid-delta new file +106 -0
106 lines not on this page · raw message
tests/expected/dmesg/cid-facilities new file +104 -0
104 lines not on this page · raw message
tests/expected/dmesg/cid-indentation new file +35 -0
@@ -0,0 +1,35 @@ +[ 1.000000] [ T1] new + line +[ 2.000000] [ T2] two + new + lines +user :crit : [ 1.000000] [ T1] new + line +mail :warn : [ 2.000000] [ T2] two + new + lines +[< 0.000000>] [ T1] new + line +[< 1.000000>] [ T2] two + new + lines +[ T1] new + line +[ T2] two + new + lines +[Feb13 23:31] [ T1] new + line +[ +1.000000] [ T2] two + new + lines +[Fri Feb 13 23:31:31 2009] [ T1] new + line +[Fri Feb 13 23:31:32 2009] [ T2] two + new + lines +2009-02-13T23:31:31,123456+00:00 [ T1] new + line +2009-02-13T23:31:32,123456+00:00 [ T2] two + new + lines
tests/expected/dmesg/cid-limit new file +4 -0
@@ -0,0 +1,4 @@ +[ 1.000000] [ T1] example[1] +[ 8.000000] [ T2] example[2] +[ 27.000000] [ T3] example[3] +[ 64.000000] [ T4] example[4]
tests/ts/dmesg/cid-colors new file +29 -0
@@ -0,0 +1,29 @@ +#!/bin/bash + +# 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="cid-colors" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_DMESG" +ts_inhibit_custom_colorscheme + +export TZ="GMT" +export DMESG_TEST_BOOTIME="1234567890.123456" + +$TS_HELPER_DMESG --color=always -F $TS_SELF/cid-input -x >> $TS_OUTPUT 2>/dev/null + +ts_finalize
tests/ts/dmesg/cid-console-levels new file +36 -0
@@ -0,0 +1,36 @@ +#!/bin/bash + +# 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="cid-levels" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_DMESG" + +export TZ="GMT" +export DMESG_TEST_BOOTIME="1234567890.123456" + +for I in {-1..8}; do + $TS_HELPER_DMESG -F $TS_SELF/cid-input -l $I >> $TS_OUTPUT 2>/dev/null +done + +$TS_HELPER_DMESG -F $TS_SELF/cid-input -l err+ >> $TS_OUTPUT 2>/dev/null +$TS_HELPER_DMESG -F $TS_SELF/cid-input -l emerg+ >> $TS_OUTPUT 2>/dev/null +$TS_HELPER_DMESG -F $TS_SELF/cid-input -l +err >> $TS_OUTPUT 2>/dev/null +$TS_HELPER_DMESG -F $TS_SELF/cid-input -l +debug >> $TS_OUTPUT 2>/dev/null +$TS_HELPER_DMESG -F $TS_SELF/cid-input -l + 2>> $TS_OUTPUT >/dev/null + +ts_finalize
tests/ts/dmesg/cid-decode new file +28 -0
@@ -0,0 +1,28 @@ +#!/bin/bash + +# 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="cid-decode" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_DMESG" + +export TZ="GMT" +export DMESG_TEST_BOOTIME="1234567890.123456" + +$TS_HELPER_DMESG -x -F $TS_SELF/cid-input >> $TS_OUTPUT 2>/dev/null + +ts_finalize
tests/ts/dmesg/cid-delta new file +27 -0
@@ -0,0 +1,27 @@ +#!/bin/bash + +# 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="cid-delta" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_DMESG" + +export TZ="GMT" +export DMESG_TEST_BOOTIME="1234567890.123456" +$TS_HELPER_DMESG -d -F $TS_SELF/cid-input >> $TS_OUTPUT 2>/dev/null + +ts_finalize
tests/ts/dmesg/cid-facilities new file +30 -0
@@ -0,0 +1,30 @@ +#!/bin/bash + +# 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="cid-facilities" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_DMESG" + +export TZ="GMT" +export DMESG_TEST_BOOTIME="1234567890.123456" + +for I in {-1..12}; do + $TS_HELPER_DMESG -F $TS_SELF/cid-input -f $I >> $TS_OUTPUT 2>/dev/null +done + +ts_finalize
tests/ts/dmesg/cid-indentation new file +40 -0
@@ -0,0 +1,40 @@ +#!/bin/bash + +# 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="cid-indentation" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_DMESG" + +export TZ="GMT" +export DMESG_TEST_BOOTIME="1234567890.123456" + +$TS_HELPER_DMESG -F $TS_SELF/cid-newlines >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_DMESG -F $TS_SELF/cid-newlines -x >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_DMESG --time-format=delta --file $TS_SELF/cid-newlines >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_DMESG --time-format=notime --file $TS_SELF/cid-newlines >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_DMESG --time-format=reltime --file $TS_SELF/cid-newlines >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_DMESG --time-format=ctime --file $TS_SELF/cid-newlines >> $TS_OUTPUT 2>> $TS_ERRLOG + +$TS_HELPER_DMESG --time-format=iso --file $TS_SELF/cid-newlines >> $TS_OUTPUT 2>> $TS_ERRLOG + +ts_finalize
tests/ts/dmesg/cid-limit new file +29 -0
@@ -0,0 +1,29 @@ +#!/bin/bash + +# 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="cid-limit" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_DMESG" + +export TZ="GMT" +export DMESG_TEST_BOOTIME="1234567890.123456" + +$TS_HELPER_DMESG --since @1234567890.124 --until @1234567991 \ + -F $TS_SELF/cid-input >> $TS_OUTPUT 2> $TS_ERRLOG + +ts_finalize
tests/ts/dmesg/cid-newlines new file +5 -0
@@ -0,0 +1,5 @@ +<10>[ 1.000000] [ T1] new +line +<20>[ 2.000000] [ T2] two +new +lines
Signature · 1 line
2.43.0