Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / tests / test_syslog.aug
1 module Test_syslog =
2
3         let conf="# $FreeBSD: src/etc/syslog.conf,v 1.30.2.1 2009/08/03 08:13:06 kensmith Exp $
4 #
5
6 daemon.info                                     /var/log/cvsupd.log
7 security.*                                      -/var/log/security
8 *.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err   /var/log/messages
9 uucp,news.crit                                          /var/log/spooler
10 *.emerg                                         *
11 daemon.!info                                    /var/log/foo
12 daemon.<=info                                   /var/log/foo
13 daemon.!<=info                                  /var/log/foo
14 *.*                                             @syslog.far.away
15 *.*                                             @syslog.far.away:123
16 *.*                                             @@syslog.far.away
17 *.*                                             @@syslog.far.away:123
18 *.*                                             @[2001::1]:514
19 *.*                                             foo,bar
20 *.*                                             |\"/usr/bin/soft arg\"
21 !startslip
22 # get that out
23 *.*                                             /var/log/slip.log
24 !pppd,ppp
25
26 *.*                                             /var/log/ppp.log
27 !+startslip
28 *.*                                             /var/log/slip.log
29 !-startslip
30 *.*                                             /var/log/slip.log
31 #!pppd
32 *.*                                             /var/log/ppp.log
33 +foo.example.com
34 daemon.info                                     /var/log/cvsupd.log
35 +foo.example.com,bar.example.com
36 daemon.info                                     /var/log/cvsupd.log
37 #+bar.example.com
38 daemon.info                                     /var/log/cvsupd.log
39 -foo.example.com
40 daemon.info                                     /var/log/cvsupd.log
41 +*
42 daemon.info                                     /var/log/cvsupd.log
43 !*
44 daemon.info                                     /var/log/cvsupd.log
45 *.=debug;\
46         auth,authpriv.none;\
47         news.none;mail.none     -/var/log/debug
48 # !pppd
49 "
50
51         test Syslog.lns get conf =
52           { "#comment" = "$FreeBSD: src/etc/syslog.conf,v 1.30.2.1 2009/08/03 08:13:06 kensmith Exp $" }
53           { }
54           { }
55           { "entry"
56             { "selector" { "facility" = "daemon" } { "level" = "info" } }
57             { "action" { "file" = "/var/log/cvsupd.log" } }
58           }
59           { "entry"
60             { "selector" { "facility" = "security" } { "level" = "*" } }
61             { "action" { "no_sync" } { "file" = "/var/log/security" } }
62           }
63           { "entry"
64             { "selector" { "facility" = "*" } { "level" = "notice" } }
65             { "selector" { "facility" = "authpriv" } { "level" = "none" } }
66             { "selector" { "facility" = "kern" } { "level" = "debug" } }
67             { "selector" { "facility" = "lpr" } { "level" = "info" } }
68             { "selector" { "facility" = "mail" } { "level" = "crit" } }
69             { "selector" { "facility" = "news" } { "level" = "err" } }
70             { "action" { "file" = "/var/log/messages" } }
71           }
72           { "entry"
73             { "selector" { "facility" = "uucp" } { "facility" = "news" } { "level" = "crit" } }
74             { "action" { "file" = "/var/log/spooler" } }
75           }
76           { "entry"
77             { "selector" { "facility" = "*" } { "level" = "emerg" } }
78             { "action" { "user" = "*" } }
79           }
80           { "entry"
81             { "selector" { "facility" = "daemon" } { "comparison" = "!" } { "level" = "info" } }
82             { "action" { "file" = "/var/log/foo" } }
83           }
84           { "entry"
85             { "selector" { "facility" = "daemon" } { "comparison" = "<=" } { "level" = "info" } }
86             { "action" { "file" = "/var/log/foo" } }
87           }
88           { "entry"
89             { "selector" { "facility" = "daemon" } { "comparison" = "!<=" } { "level" = "info" } }
90             { "action" { "file" = "/var/log/foo" } }
91           }
92           { "entry"
93             { "selector" { "facility" = "*" } { "level" = "*" } }
94             { "action" { "protocol" = "@" } { "hostname" = "syslog.far.away" } }
95           }
96           { "entry"
97             { "selector" { "facility" = "*" } { "level" = "*" } }
98             { "action" { "protocol" = "@" } { "hostname" = "syslog.far.away" } { "port" = "123" } }
99           }
100           { "entry"
101             { "selector" { "facility" = "*" } { "level" = "*" } }
102             { "action" { "protocol" = "@@" } { "hostname" = "syslog.far.away" } }
103           }
104           { "entry"
105             { "selector" { "facility" = "*" } { "level" = "*" } }
106             { "action" { "protocol" = "@@" } { "hostname" = "syslog.far.away" } { "port" = "123" } }
107           }
108           { "entry"
109             { "selector" { "facility" = "*" } { "level" = "*" } }
110             { "action" { "protocol" = "@" } { "hostname" = "[2001::1]" } { "port" = "514" } }
111           }
112           { "entry"
113             { "selector" { "facility" = "*" } { "level" = "*" } }
114             { "action" { "user" = "foo" } { "user" = "bar" } }
115           }
116           { "entry"
117             { "selector" { "facility" = "*" } { "level" = "*" } }
118             { "action" { "program" = "\"/usr/bin/soft arg\"" } }
119           }
120           { "program"
121             { "program" = "startslip" }
122             { "#comment" = "get that out" }
123             { "entry"
124               { "selector" { "facility" = "*" } { "level" = "*" } }
125               { "action" { "file" = "/var/log/slip.log" } }
126             }
127           }
128           { "program"
129             { "program" = "pppd" }
130             { "program" = "ppp" }
131             { }
132             { "entry"
133               { "selector" { "facility" = "*" } { "level" = "*" } }
134               { "action" { "file" = "/var/log/ppp.log" } }
135             }
136           }
137           { "program"
138             { "program" = "startslip" }
139             { "entry"
140               { "selector" { "facility" = "*" } { "level" = "*" } }
141               { "action" { "file" = "/var/log/slip.log" } }
142             }
143           }
144           { "program"
145             { "reverse" }
146             { "program" = "startslip" }
147             { "entry"
148               { "selector" { "facility" = "*" } { "level" = "*" } }
149               { "action" { "file" = "/var/log/slip.log" } }
150             }
151           }
152           { "program"
153             { "program" = "pppd" }
154             { "entry"
155               { "selector" { "facility" = "*" } { "level" = "*" } }
156               { "action" { "file" = "/var/log/ppp.log" } }
157             }
158           }
159           { "hostname"
160             { "hostname" = "foo.example.com" }
161             { "entry"
162               { "selector" { "facility" = "daemon" } { "level" = "info" } }
163               { "action" { "file" = "/var/log/cvsupd.log" } }
164             }
165           }
166           { "hostname"
167             { "hostname" = "foo.example.com" }
168             { "hostname" = "bar.example.com" }
169             { "entry"
170               { "selector" { "facility" = "daemon" } { "level" = "info" } }
171               { "action" { "file" = "/var/log/cvsupd.log" } }
172             }
173           }
174           { "hostname"
175             { "hostname" = "bar.example.com" }
176             { "entry"
177               { "selector" { "facility" = "daemon" } { "level" = "info" } }
178               { "action" { "file" = "/var/log/cvsupd.log" } }
179             }
180           }
181           { "hostname"
182             { "reverse" }
183             { "hostname" = "foo.example.com" }
184             { "entry"
185               { "selector" { "facility" = "daemon" } { "level" = "info" } }
186               { "action" { "file" = "/var/log/cvsupd.log" } }
187             }
188           }
189           { "hostname"
190             { "hostname" = "*" }
191             { "entry"
192               { "selector" { "facility" = "daemon" } { "level" = "info" } }
193               { "action" { "file" = "/var/log/cvsupd.log" } }
194             }
195           }
196           { "program"
197             { "program" = "*" }
198             { "entry"
199               { "selector" { "facility" = "daemon" } { "level" = "info" } }
200               { "action" { "file" = "/var/log/cvsupd.log" } } }
201             { "entry"
202               { "selector" { "facility" = "*" } { "comparison" = "=" } { "level" = "debug" } }
203               { "selector" { "facility" = "auth" } { "facility" = "authpriv" } { "level" = "none" } }
204               { "selector" { "facility" = "news" } { "level" = "none" } }
205               { "selector" { "facility" = "mail" } { "level" = "none" } }
206               { "action" { "no_sync" } { "file" = "/var/log/debug" } } }
207       { "#comment" = "!pppd" }
208           }
209
210         (* changing file *)
211         test Syslog.lns put "*.* /var\n" after
212           set "/entry[1]/action/file" "/foo"
213           = "*.* /foo\n"
214
215         (* changing file to discard *)
216         test Syslog.lns put "*.* /var\n" after
217           rm "/entry[1]/action/file" ;
218           set "/entry[1]/action/discard" ""
219           = "*.* ~\n"
220
221         (* removing entry *)
222         test Syslog.lns put "*.* /var\n" after
223           rm "/entry[1]"
224           = ""
225
226         (* changing facility and level *)
227         test Syslog.lns put "*.* /var\n" after
228           set "/entry[1]/selector/facility" "daemon" ;
229           set "/entry[1]/selector/level" "info"
230           = "daemon.info /var\n"
231
232         (* insert a facility *)
233         test Syslog.lns put "daemon.* /var\n" after
234           insa "facility" "/entry/selector/facility" ;
235           set "/entry/selector/facility[2]" "mail"
236           = "daemon,mail.* /var\n"
237
238         (* creating an entry *)
239         test Syslog.lns put "" after
240           set "/entry/selector/facility" "daemon" ;
241           set "/entry/selector/level" "info" ;
242           set "/entry/action/file" "/var"
243           = "daemon.info\t/var\n"
244
245         (* inserting an entry before *)
246         test Syslog.lns put "*.* /var\n" after
247           insb "entry" "/entry" ;
248           set "/entry[1]/selector/facility" "daemon" ;
249           set "/entry[1]/selector/level" "info" ;
250           set "/entry[1]/action/file" "/foo"
251           = "daemon.info /foo\n*.*\t/var\n"
252
253         (* inserting an entry after *)
254         test Syslog.lns put "*.* /var\n" after
255           insa "entry" "/entry" ;
256           set "/entry[2]/selector/facility" "daemon" ;
257           set "/entry[2]/selector/level" "info" ;
258           set "/entry[2]/action/file" "/foo"
259           = "*.* /var\ndaemon.info\t/foo\n"
260
261         (* insert sync on a file *)
262         test Syslog.lns put "*.* /var\n" after
263           insb "no_sync" "/entry/action/file"
264           = "*.* -/var\n"
265
266         (* changing file to remote host *)
267         test Syslog.lns put "*.* /var\n" after
268           rm "/entry/action/file" ;
269           set "/entry/action/protocol"  "@" ;
270           set "/entry/action/hostname" "far.far.away"
271           = "*.* @far.far.away\n"
272
273         (* changing file to remote host *)
274         test Syslog.lns put "*.* /var/lib\n" after
275           rm "/entry/action/file" ;
276           set "/entry/action/protocol"  "@@" ;
277           set "/entry/action/hostname" "far.far.away"
278           = "*.* @@far.far.away\n"
279
280         (* changing file to * *)
281         test Syslog.lns put "*.* /var\n" after
282           rm "/entry/action/file" ;
283           set "/entry/action/user" "*"
284           = "*.* *\n"
285
286         (* changing file to users *)
287         test Syslog.lns put "*.* /var\n" after
288           rm "/entry/action/file" ;
289           set "/entry/action/user[1]" "john" ;
290           set "/entry/action/user[2]" "paul" ;
291           set "/entry/action/user[3]" "george" ;
292           set "/entry/action/user[4]" "ringo"
293           = "*.* john,paul,george,ringo\n"
294
295         (* changing file to program *)
296         test Syslog.lns put "*.* /var\n" after
297           rm "/entry/action/file" ;
298           set "/entry/action/program" "/usr/bin/foo"
299           = "*.* |/usr/bin/foo\n"
300
301         (* inserting a matching program *)
302         test Syslog.lns put "" after
303           insa "program" "/" ;
304           set "/program/program" "foo"
305           = "!foo\n"
306
307         (* inserting an entry to a matching program *)
308         test Syslog.lns put "!foo\n" after
309           set "/program/entry/selector/facility" "*" ;
310           set "/program/entry/selector/level" "*" ;
311           set "/program/entry/action/file" "/foo"
312           = "!foo\n*.*\t/foo\n"
313
314         (* inserting a matching hostname *)
315         test Syslog.lns put "" after
316           insa "hostname" "/" ;
317           set "/hostname/hostname" "foo.foo.away"
318           = "+foo.foo.away\n"
319
320         (* inserting an entry to a matching hostname *)
321         test Syslog.lns put "+foo.foo.away\n" after
322           set "/hostname/entry/selector/facility" "*" ;
323           set "/hostname/entry/selector/level" "*" ;
324           set "/hostname/entry/action/file" "/foo"
325           = "+foo.foo.away\n*.*\t/foo\n"
326
327         (* inserting a reverse matching hostname *)
328         test Syslog.lns put "" after
329           insa "hostname" "/" ;
330           set "/hostname/reverse" "" ;
331           set "/hostname/hostname" "foo.foo.away"
332           = "-foo.foo.away\n"
333
334         (* tokens can contain capital letters *)
335         test Syslog.lns get "LOCAL5.*    -/var/log/foo.log\n" =
336           { "entry"
337             { "selector"
338               { "facility" = "LOCAL5" }
339               { "level" = "*" }
340             }
341             { "action"
342               { "no_sync" }
343               { "file" = "/var/log/foo.log" }
344             }
345           }
346
347     (* test for commented out statements *)
348     test Syslog.lns put "" after
349        set "#comment" "!pppd" = "# !pppd\n"
350
351     (* allow space before comments *)
352     test Syslog.lns get "  \t# space comment\n" =
353       { "#comment" = "space comment" }
354
355     test Syslog.lns get "include /etc/syslog.d\n" =
356       { "include" = "/etc/syslog.d" }