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 let conf = "# see man logrotate for details
18 # rotate log files weekly
21 # keep 4 weeks worth of backlogs
24 # create new (empty) log files after rotating old ones
27 # uncomment this if you want your log files compressed
30 tabooext + .old .orig .ignore
32 # packages drop log rotation information into this directory
33 include /etc/logrotate.d
35 # no packages own wtmp, or btmp -- we'll rotate them here
45 /var/log/btmp /var/log/btmp* {
47 # ftpd doesn't handle SIGHUP properly
53 # ftpd doesn't handle SIGHUP properly
61 /var/log/apache2/*.log {
71 if [ -f /var/run/apache2.pid ]; then
72 /etc/init.d/apache2 restart > /dev/null
76 /var/log/mailman/digest {
86 [ -f '/var/run/mailman/mailman.pid' ] && /usr/lib/mailman/bin/mailmanctl -q reopen || exit 0
99 chmod 644 /var/log/ntp
104 test Logrotate.lns get conf =
105 { "#comment" = "see man logrotate for details" }
106 { "#comment" = "rotate log files weekly" }
107 { "schedule" = "weekly" }
109 { "#comment" = "keep 4 weeks worth of backlogs" }
112 { "#comment" = "create new (empty) log files after rotating old ones" }
115 { "#comment" = "uncomment this if you want your log files compressed" }
116 { "#comment" = "compress" }
118 { "tabooext" = "+" { ".old" } { ".orig" } { ".ignore" } }
120 { "#comment" = "packages drop log rotation information into this directory" }
121 { "include" = "/etc/logrotate.d" }
123 { "#comment" = "no packages own wtmp, or btmp -- we'll rotate them here" }
125 { "file" = "/var/log/wtmp" }
126 { "file" = "/var/log/wtmp2" }
127 { "missingok" = "missingok" }
128 { "schedule" = "monthly" }
132 { "group" = "utmp" } }
136 { "file" = "/var/log/btmp" }
137 { "file" = "/var/log/btmp*" }
138 { "missingok" = "missingok" }
139 { "#comment" = "ftpd doesn't handle SIGHUP properly" }
140 { "schedule" = "monthly" }
144 { "group" = "utmp" } }
147 { "file" = "/var/log/vsftpd.log" }
148 { "#comment" = "ftpd doesn't handle SIGHUP properly" }
149 { "compress" = "nocompress" }
150 { "missingok" = "missingok" }
151 { "ifempty" = "notifempty" }
153 { "schedule" = "weekly" } }
156 { "file" = "/var/log/apache2/*.log" }
157 { "schedule" = "weekly" }
158 { "missingok" = "missingok" }
160 { "compress" = "compress" }
161 { "delaycompress" = "delaycompress" }
162 { "ifempty" = "notifempty" }
166 { "group" = "adm" } }
167 { "sharedscripts" = "sharedscripts" }
168 { "prerotate" = " if [ -f /var/run/apache2.pid ]; then
169 /etc/init.d/apache2 restart > /dev/null
172 { "file" = "/var/log/mailman/digest" }
175 { "group" = "list" } }
176 { "schedule" = "monthly" }
177 { "missingok" = "missingok" }
181 { "group" = "list" } }
183 { "compress" = "compress" }
184 { "delaycompress" = "delaycompress" }
185 { "sharedscripts" = "sharedscripts" }
186 { "postrotate" = " [ -f '/var/run/mailman/mailman.pid' ] && /usr/lib/mailman/bin/mailmanctl -q reopen || exit 0" } }
188 { "file" = "/var/log/ntp" }
189 { "compress" = "compress" }
190 { "dateext" = "dateext" }
193 { "size" = "+2048k" }
194 { "ifempty" = "notifempty" }
195 { "missingok" = "missingok" }
196 { "copytruncate" = "copytruncate" }
197 { "postrotate" = " chmod 644 /var/log/ntp" } }
199 test Logrotate.lns get "/var/log/file {\n dateext\n}\n" =
201 { "file" = "/var/log/file" }
202 { "dateext" = "dateext" } }
204 (* Make sure 'minsize 1M' works *)
205 test Logrotate.lns get "/avr/log/wtmp {\n minsize 1M\n}\n" =
207 { "file" = "/avr/log/wtmp" }
208 { "minsize" = "1M" } }
210 (* '=' is a legal separator, file names can be indented *)
211 test Logrotate.lns get " \t /file {\n size=5M\n}\n" =
216 (* Can leave owner/group off a create statement *)
217 test Logrotate.lns get "/file {
222 { "mode" = "600" } } }
224 test Logrotate.lns put "/file {\n create 600\n}\n" after
225 set "/rule/create/owner" "user"
226 = "/file {\n create 600 user\n}\n"
228 (* The newline at the end of a script is optional *)
229 test Logrotate.lns put "/file {\n size=5M\n}\n" after
230 set "/rule/prerotate" "\tfoobar"
238 test Logrotate.lns put "/file {\n size=5M\n}\n" after
239 set "/rule/prerotate" "\tfoobar\n"
247 (* Bug #101: whitespace at the end of the line *)
248 test Logrotate.lns get "/file {\n missingok \t\n}\n" =
251 { "missingok" = "missingok" } }
253 (* Bug #104: file names can be separated by newlines *)
254 let conf2 = "/var/log/mail.info
261 test Logrotate.lns get conf2 =
263 { "file" = "/var/log/mail.info" }
264 { "file" = "/var/log/mail.warn" }
265 { "file" = "/var/log/mail.err" }
266 { "schedule" = "weekly" } }
268 (* Issue #217: support for dateformat *)
269 let dateformat = "dateformat -%Y%m%d\n"
271 test Logrotate.lns get dateformat =
272 { "dateformat" = "-%Y%m%d" }
274 (* Issue #123: no space before '{' *)
275 test Logrotate.lns get "/file{\n missingok \t\n}\n" =
278 { "missingok" = "missingok" } }
280 (* RHBZ#1213292: maxsize 30k *)
281 test Logrotate.lns get "/var/log/yum.log {\n maxsize 30k\n}\n" =
283 { "file" = "/var/log/yum.log" }
284 { "maxsize" = "30k" } }