diff options
author | 2016-10-04 22:12:47 +0000 | |
---|---|---|
committer | 2016-10-04 22:12:47 +0000 | |
commit | 7c3ab69d99e57e09e7e1bbce4600b972cd47e684 (patch) | |
tree | 26041266ba7748ab7cac29ed4ba032e1799b6a9a | |
parent | When doing global remote logging and archiving, it is inconvenient (diff) | |
download | wireguard-openbsd-7c3ab69d99e57e09e7e1bbce4600b972cd47e684.tar.xz wireguard-openbsd-7c3ab69d99e57e09e7e1bbce4600b972cd47e684.zip |
Add test for syslogd(8) -Z ISO timestamp format.
-rw-r--r-- | regress/usr.sbin/syslogd/args-zulu.pl | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/regress/usr.sbin/syslogd/args-zulu.pl b/regress/usr.sbin/syslogd/args-zulu.pl new file mode 100644 index 00000000000..869b3b988a4 --- /dev/null +++ b/regress/usr.sbin/syslogd/args-zulu.pl @@ -0,0 +1,79 @@ +# The client writes message with different timestamps to /dev/log. +# The syslogd runs with -Z to translate them to iso time. +# The syslogd writes it into a file and through a pipe and to tty. +# The syslogd passes it via UDP to the loghost. +# The server receives the message on its UDP socket. +# Find the message in client, file, pipe, console, user, syslogd, server log. +# Check for the correct time conversion in file and server log. + +use strict; +use warnings; +use Sys::Hostname; + +(my $host = hostname()) =~ s/\..*//; + +# 2016-09-28T15:38:09Z +my $iso = qr/20\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ/; +my $bsd = qr/\w\w\w [ \d]\d \d\d:\d\d:\d\d/; + +our %args = ( + client => { + connect => { domain => AF_UNIX }, + func => sub { + my $self = shift; + write_message($self, "no time"); + write_message($self, "Oct 11 22:14:15 bsd time"); + write_message($self, "1985-04-12T23:20:50Z iso time"); + write_message($self, "1985-04-12T23:20:50.52Z iso frac"); + write_message($self, "1985-04-12T19:20:50.52-04:00 iso offset"); + write_message($self, "2003-10-11T22:14:15.003Z iso milisec"); + write_message($self, "2003-08-24T05:14:15.000003-07:00 iso full"); + write_message($self, "2003-08-24T05:14:15.000000003-07:00 invalid"); + write_message($self, "- nil time"); + write_message($self, "2003-08-24T05:14:15.000003-07:00space"); + write_message($self, "2003-08-24T05:14:15.-07:00 nofrac"); + write_message($self, "2003-08-24T05:14:15.1234567-07:00 longfrac"); + write_message($self, "1985-04-12T23:20:50X zulu"); + write_log($self); + }, + }, + syslogd => { + options => ["-Z"], + }, + server => { + loggrep => { + qr/>$iso no time$/ => 1, + qr/>$iso bsd time$/ => 1, + qr/>1985-04-12T23:20:50Z iso time$/ => 1, + qr/>1985-04-12T23:20:50.52Z iso frac$/ => 1, + qr/>1985-04-12T19:20:50.52-04:00 iso offset$/ => 1, + qr/>2003-10-11T22:14:15.003Z iso milisec$/ => 1, + qr/>2003-08-24T05:14:15.000003-07:00 iso full$/ => 1, + qr/>$iso 2003-08-24T05:14:15.000000003-07:00 invalid$/ => 1, + qr/>$iso nil time$/ => 1, + qr/>$iso 2003-08-24T05:14:15.000003-07:00space$/ => 1, + qr/>$iso 2003-08-24T05:14:15.-07:00 nofrac$/ => 1, + qr/>$iso 2003-08-24T05:14:15.1234567-07:00 longfrac$/ => 1, + qr/>$iso 1985-04-12T23:20:50X zulu$/ => 1, + }, + }, + file => { + loggrep => { + qr/^$iso $host no time$/ => 1, + qr/^$iso $host bsd time$/ => 1, + qr/^1985-04-12T23:20:50Z $host iso time$/ => 1, + qr/^1985-04-12T23:20:50.52Z $host iso frac$/ => 1, + qr/^1985-04-12T19:20:50.52-04:00 $host iso offset$/ => 1, + qr/^2003-10-11T22:14:15.003Z $host iso milisec$/ => 1, + qr/^2003-08-24T05:14:15.000003-07:00 $host iso full$/ => 1, + qr/^$iso $host 2003-08-24T05:14:15.000000003-07:00 invalid$/ => 1, + qr/^$iso $host nil time$/ => 1, + qr/^$iso $host 2003-08-24T05:14:15.000003-07:00space$/ => 1, + qr/^$iso $host 2003-08-24T05:14:15.-07:00 nofrac$/ => 1, + qr/^$iso $host 2003-08-24T05:14:15.1234567-07:00 longfrac$/ => 1, + qr/^$iso $host 1985-04-12T23:20:50X zulu$/ => 1, + }, + }, +); + +1; |