1 module Test_logrotate =
3 test Logrotate.body get "\n{\n monthly\n}" =
4 { "schedule" = "monthly" }
6 test Logrotate.rule get "/var/log/foo\n{\n monthly\n}\n" =
8 { "file" = "/var/log/foo" }
9 { "schedule" = "monthly" } }
11 test Logrotate.rule get "/var/log/foo /var/log/bar\n{\n monthly\n}\n" =
13 { "file" = "/var/log/foo" }
14 { "file" = "/var/log/bar" }
15 { "schedule" = "monthly" } }
17 test Logrotate.rule get "\"/var/log/foo\"\n{\n monthly\n}\n" =
19 { "file" = "/var/log/foo" }
20 { "schedule" = "monthly" } }
22 let conf = "# see man logrotate for details
23 # rotate log files weekly
26 # keep 4 weeks worth of backlogs
29 # create new (empty) log files after rotating old ones
32 # uncomment this if you want your log files compressed
35 tabooext + .old .orig .ignore
37 # packages drop log rotation information into this directory
38 include /etc/logrotate.d
40 # no packages own wtmp, or btmp -- we'll rotate them here
50 /var/log/btmp /var/log/btmp* {
52 # ftpd doesn't handle SIGHUP properly
58 # ftpd doesn't handle SIGHUP properly
66 /var/log/apache2/*.log {
76 if [ -f /var/run/apache2.pid ]; then
77 /etc/init.d/apache2 restart > /dev/null
81 /var/log/mailman/digest {
91 [ -f '/var/run/mailman/mailman.pid' ] && /usr/lib/mailman/bin/mailmanctl -q reopen || exit 0
104 chmod 644 /var/log/ntp
109 test Logrotate.lns get conf =
110 { "#comment" = "see man logrotate for details" }
111 { "#comment" = "rotate log files weekly" }
112 { "schedule" = "weekly" }
114 { "#comment" = "keep 4 weeks worth of backlogs" }
117 { "#comment" = "create new (empty) log files after rotating old ones" }
120 { "#comment" = "uncomment this if you want your log files compressed" }
121 { "#comment" = "compress" }
123 { "tabooext" = "+" { ".old" } { ".orig" } { ".ignore" } }
125 { "#comment" = "packages drop log rotation information into this directory" }
126 { "include" = "/etc/logrotate.d" }
128 { "#comment" = "no packages own wtmp, or btmp -- we'll rotate them here" }
130 { "file" = "/var/log/wtmp" }
131 { "file" = "/var/log/wtmp2" }
132 { "missingok" = "missingok" }
133 { "schedule" = "monthly" }
137 { "group" = "utmp" } }
141 { "file" = "/var/log/btmp" }
142 { "file" = "/var/log/btmp*" }
143 { "missingok" = "missingok" }
144 { "#comment" = "ftpd doesn't handle SIGHUP properly" }
145 { "schedule" = "monthly" }
149 { "group" = "utmp" } }
152 { "file" = "/var/log/vsftpd.log" }
153 { "#comment" = "ftpd doesn't handle SIGHUP properly" }
154 { "compress" = "nocompress" }
155 { "missingok" = "missingok" }
156 { "ifempty" = "notifempty" }
158 { "schedule" = "weekly" } }
161 { "file" = "/var/log/apache2/*.log" }
162 { "schedule" = "weekly" }
163 { "missingok" = "missingok" }
165 { "compress" = "compress" }
166 { "delaycompress" = "delaycompress" }
167 { "ifempty" = "notifempty" }
171 { "group" = "adm" } }
172 { "sharedscripts" = "sharedscripts" }
173 { "prerotate" = " if [ -f /var/run/apache2.pid ]; then
174 /etc/init.d/apache2 restart > /dev/null
177 { "file" = "/var/log/mailman/digest" }
180 { "group" = "list" } }
181 { "schedule" = "monthly" }
182 { "missingok" = "missingok" }
186 { "group" = "list" } }
188 { "compress" = "compress" }
189 { "delaycompress" = "delaycompress" }
190 { "sharedscripts" = "sharedscripts" }
191 { "postrotate" = " [ -f '/var/run/mailman/mailman.pid' ] && /usr/lib/mailman/bin/mailmanctl -q reopen || exit 0" } }
193 { "file" = "/var/log/ntp" }
194 { "compress" = "compress" }
195 { "dateext" = "dateext" }
198 { "size" = "+2048k" }
199 { "ifempty" = "notifempty" }
200 { "missingok" = "missingok" }
201 { "copytruncate" = "copytruncate" }
202 { "postrotate" = " chmod 644 /var/log/ntp" } }
204 test Logrotate.lns get "/var/log/file {\n dateext\n}\n" =
206 { "file" = "/var/log/file" }
207 { "dateext" = "dateext" } }
209 (* Make sure 'minsize 1M' works *)
210 test Logrotate.lns get "/avr/log/wtmp {\n minsize 1M\n}\n" =
212 { "file" = "/avr/log/wtmp" }
213 { "minsize" = "1M" } }
215 (* '=' is a legal separator, file names can be indented *)
216 test Logrotate.lns get " \t /file {\n size=5M\n}\n" =
221 (* Can leave owner/group off a create statement *)
222 test Logrotate.lns get "/file {
227 { "mode" = "600" } } }
229 test Logrotate.lns put "/file {\n create 600\n}\n" after
230 set "/rule/create/owner" "user"
231 = "/file {\n create 600 user\n}\n"
233 (* The newline at the end of a script is optional *)
234 test Logrotate.lns put "/file {\n size=5M\n}\n" after
235 set "/rule/prerotate" "\tfoobar"
243 test Logrotate.lns put "/file {\n size=5M\n}\n" after
244 set "/rule/prerotate" "\tfoobar\n"
252 (* Bug #101: whitespace at the end of the line *)
253 test Logrotate.lns get "/file {\n missingok \t\n}\n" =
256 { "missingok" = "missingok" } }
258 (* Bug #104: file names can be separated by newlines *)
259 let conf2 = "/var/log/mail.info
266 test Logrotate.lns get conf2 =
268 { "file" = "/var/log/mail.info" }
269 { "file" = "/var/log/mail.warn" }
270 { "file" = "/var/log/mail.err" }
271 { "schedule" = "weekly" } }
273 (* Issue #217: support for dateformat *)
274 let dateformat = "dateformat -%Y%m%d\n"
276 test Logrotate.lns get dateformat =
277 { "dateformat" = "-%Y%m%d" }
279 (* Issue #123: no space before '{' *)
280 test Logrotate.lns get "/file{\n missingok \t\n}\n" =
283 { "missingok" = "missingok" } }
285 (* RHBZ#1213292: maxsize 30k *)
286 test Logrotate.lns get "/var/log/yum.log {\n maxsize 30k\n}\n" =
288 { "file" = "/var/log/yum.log" }
289 { "maxsize" = "30k" } }