tests/dmesg: add time-format option test & fixtures.

This commit is contained in:
Fuad Ismail 2024-11-24 22:56:45 +07:00
parent f271489a9f
commit 1cc260d414
8 changed files with 46 additions and 0 deletions

@ -30,3 +30,19 @@ fn test_kmsg_json() {
.no_stderr()
.stdout_is_templated_fixture("test_kmsg_json.expected", &[("\r\n", "\n")]);
}
#[test]
fn test_kmsg_time_format() {
let time_formats = ["delta", "reltime", "ctime", "notime", "iso", "raw"];
for format in time_formats {
let time_format_arg = format!("--time-format={format}");
let expected_output = format!("test_kmsg_time_format_{format}.expected");
new_ucmd!()
.arg("--kmsg-file")
.arg("kmsg.input.1")
.arg(time_format_arg)
.succeeds()
.no_stderr()
.stdout_is_fixture(expected_output);
}
}

BIN
tests/fixtures/dmesg/kmsg.input.1 vendored Normal file

Binary file not shown.

@ -0,0 +1,5 @@
[Mon Nov 18 19:34:12 2024] LOG_EMERG LOG_AUTH
[Mon Nov 18 19:34:13 2024] LOG_EMERG LOG_AUTHPRIV
[Mon Nov 18 19:34:13 2024] LOG_EMERG LOG_CRON
[Mon Nov 18 19:34:13 2024] LOG_EMERG LOG_DAEMON
[Mon Nov 18 19:35:00 2024] LOG_EMERG LOG_FTP

@ -0,0 +1,5 @@
[< 0.000000>] LOG_EMERG LOG_AUTH
[< 0.000000>] LOG_EMERG LOG_AUTHPRIV
[< -0.166667>] LOG_EMERG LOG_CRON
[< 0.666667>] LOG_EMERG LOG_DAEMON
[< 47.000000>] LOG_EMERG LOG_FTP

@ -0,0 +1,5 @@
2024-11-18T19:34:12,866807+07:00 LOG_EMERG LOG_AUTH
2024-11-18T19:34:13,366807+07:00 LOG_EMERG LOG_AUTHPRIV
2024-11-18T19:34:13,200140+07:00 LOG_EMERG LOG_CRON
2024-11-18T19:34:13,866807+07:00 LOG_EMERG LOG_DAEMON
2024-11-18T19:35:00,866807+07:00 LOG_EMERG LOG_FTP

@ -0,0 +1,5 @@
LOG_EMERG LOG_AUTH
LOG_EMERG LOG_AUTHPRIV
LOG_EMERG LOG_CRON
LOG_EMERG LOG_DAEMON
LOG_EMERG LOG_FTP

@ -0,0 +1,5 @@
[ 0.000000] LOG_EMERG LOG_AUTH
[ 0.500000] LOG_EMERG LOG_AUTHPRIV
[ 0.333333] LOG_EMERG LOG_CRON
[ 1.000000] LOG_EMERG LOG_DAEMON
[ 48.000000] LOG_EMERG LOG_FTP

@ -0,0 +1,5 @@
[Nov18 19:34] LOG_EMERG LOG_AUTH
[ +0.000000] LOG_EMERG LOG_AUTHPRIV
[ -0.166667] LOG_EMERG LOG_CRON
[ +0.666667] LOG_EMERG LOG_DAEMON
[Nov18 19:35] LOG_EMERG LOG_FTP