summaryrefslogtreecommitdiff
path: root/regress/usr.sbin/syslogd/args-zulu.pl
blob: af6817b86a5db31b06cb20c5dfef7c21979c8fb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# 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 Socket;
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\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;