Deleted Added
full compact
legacy_test.sh (210373) legacy_test.sh (220927)
1#!/bin/sh
2
1#!/bin/sh
2
3# $FreeBSD: head/tools/regression/usr.sbin/newsyslog/regress.sh 210373 2010-07-22 11:37:54Z simon $
3# $FreeBSD: head/tools/regression/usr.sbin/newsyslog/regress.sh 220927 2011-04-21 16:40:34Z simon $
4
5COUNT=0
6TMPDIR=`mktemp -d -t regress_newsyslog`
7if [ $? -ne 0 ]; then
8 echo "$0: Can't create temp dir, exiting..."
9 exit 1
10fi
11

--- 53 unchanged lines hidden (view full) ---

65 if [ -r $1 ]
66 then
67 notok
68 else
69 ok
70 fi
71}
72
4
5COUNT=0
6TMPDIR=`mktemp -d -t regress_newsyslog`
7if [ $? -ne 0 ]; then
8 echo "$0: Can't create temp dir, exiting..."
9 exit 1
10fi
11

--- 53 unchanged lines hidden (view full) ---

65 if [ -r $1 ]
66 then
67 notok
68 else
69 ok
70 fi
71}
72
73# Check if a file is there, depending of if it's suposed to or not -
74# basically how many log files we are suposed to keep vs. how many we
75# actually keep.
76ckntfe()
77{
78 curcnt=$1
79 keepcnt=$2
80 f=$3
81
82 if [ $curcnt -le $keepcnt ]
83 then
84 #echo Assuming file there
85 ckfe $f
86 else
87 #echo Assuming file NOT there
88 cknt $f
89 fi
90}
91
92
93
73# A part of a test succeeds
74ok()
75{
76 :
77}
78
79# A part of a test fails
80notok()

--- 134 unchanged lines hidden (view full) ---

215 run_newsyslog ${newsyslog_args} -n >/dev/null
216 ckfe ${LOGFNAME}
217 ckstr "$ofiles" "`ls -lT ${dir}${LOGFNAME}.*${ext} | tr -d '\n'`"
218 end
219
220 tmpdir_clean
221}
222
94# A part of a test succeeds
95ok()
96{
97 :
98}
99
100# A part of a test fails
101notok()

--- 134 unchanged lines hidden (view full) ---

236 run_newsyslog ${newsyslog_args} -n >/dev/null
237 ckfe ${LOGFNAME}
238 ckstr "$ofiles" "`ls -lT ${dir}${LOGFNAME}.*${ext} | tr -d '\n'`"
239 end
240
241 tmpdir_clean
242}
243
244tests_normal_rotate_keepn() {
245 cnt="$1"
246 ext="$2"
247 dir="$3"
248
249 if [ -n "$dir" ]; then
250 newsyslog_args=" -a ${dir}"
251 name_postfix="${ext} archive dir"
252 else
253 newsyslog_args=""
254 name_postfix="${ext}"
255 fi
256
257 tmpdir_create
258
259 begin "create file ${name_postfix}" -newdir
260 run_newsyslog -C
261 ckfe $LOGFNAME
262 cknt ${dir}${LOGFNAME}.0${ext}
263 end
264
265 begin "rotate normal 1 cnt=$cnt ${name_postfix}"
266 run_newsyslog $newsyslog_args
267 ckfe ${LOGFNAME}
268 ckntfe 1 $cnt ${dir}${LOGFNAME}.0${ext}
269 cknt ${dir}${LOGFNAME}.1${ext}
270 end
271
272 begin "rotate normal 2 cnt=$cnt ${name_postfix}"
273 run_newsyslog $newsyslog_args
274 ckfe ${LOGFNAME}
275 ckntfe 1 $cnt ${dir}${LOGFNAME}.0${ext}
276 ckntfe 2 $cnt ${dir}${LOGFNAME}.1${ext}
277 cknt ${dir}${LOGFNAME}.2${ext}
278 end
279
280 begin "rotate normal 3 cnt=$cnt ${name_postfix}"
281 run_newsyslog $newsyslog_args
282 ckfe ${LOGFNAME}
283 ckntfe 1 $cnt ${dir}${LOGFNAME}.0${ext}
284 ckntfe 2 $cnt ${dir}${LOGFNAME}.1${ext}
285 ckntfe 3 $cnt ${dir}${LOGFNAME}.2${ext}
286 cknt ${dir}${LOGFNAME}.3${ext}
287 end
288
289 begin "rotate normal 3 cnt=$cnt ${name_postfix}"
290 run_newsyslog $newsyslog_args
291 ckfe ${LOGFNAME}
292 ckntfe 1 $cnt ${dir}${LOGFNAME}.0${ext}
293 ckntfe 2 $cnt ${dir}${LOGFNAME}.1${ext}
294 ckntfe 3 $cnt ${dir}${LOGFNAME}.2${ext}
295 ckntfe 4 $cnt ${dir}${LOGFNAME}.3${ext}
296 cknt ${dir}${LOGFNAME}.4${ext}
297 end
298
299 # Wait a bit so we can see if the noaction test rotates files
300 sleep 1.1
301
302 begin "noaction ${name_postfix}"
303 osum=`md5 ${dir}${LOGFNAME} | tr -d '\n'`
304 run_newsyslog ${newsyslog_args} -n >/dev/null
305 ckfe ${LOGFNAME}
306 ckstr "$osum" "`md5 ${dir}${LOGFNAME} | tr -d '\n'`"
307 end
308
309 tmpdir_clean
310}
311
223tests_time_rotate() {
224 ext="$1"
225 dir="$2"
226
227 if [ -n "$dir" ]; then
228 newsyslog_args="-t DEFAULT -a ${dir}"
229 name_postfix="${ext} archive dir"
230 else

--- 43 unchanged lines hidden (view full) ---

274 run_newsyslog ${newsyslog_args} -n >/dev/null
275 ckfe ${LOGFNAME}
276 ckstr "$ofiles" "`ls -1 ${dir}${LOGFNAME}.*${ext} | tr -d '\n'`"
277 end
278
279 tmpdir_clean
280}
281
312tests_time_rotate() {
313 ext="$1"
314 dir="$2"
315
316 if [ -n "$dir" ]; then
317 newsyslog_args="-t DEFAULT -a ${dir}"
318 name_postfix="${ext} archive dir"
319 else

--- 43 unchanged lines hidden (view full) ---

363 run_newsyslog ${newsyslog_args} -n >/dev/null
364 ckfe ${LOGFNAME}
365 ckstr "$ofiles" "`ls -1 ${dir}${LOGFNAME}.*${ext} | tr -d '\n'`"
366 end
367
368 tmpdir_clean
369}
370
282echo 1..78
371echo 1..126
283mkdir -p ${TMPDIR}
284cd ${TMPDIR}
285
286LOGFNAME=foo.log
287LOGFPATH=${TMPDIR}/log/${LOGFNAME}
288
372mkdir -p ${TMPDIR}
373cd ${TMPDIR}
374
375LOGFNAME=foo.log
376LOGFPATH=${TMPDIR}/log/${LOGFNAME}
377
378# Normal, no archive dir, keep X files
379echo "$LOGFPATH 640 0 * @T00 NC" > newsyslog.conf
380tests_normal_rotate_keepn 0
289
381
290# XXX for tests_normal_rotate it should be 3 instead of 2 count - but
291# that's currently broken!
382echo "$LOGFPATH 640 1 * @T00 NC" > newsyslog.conf
383tests_normal_rotate_keepn 1
292
384
293# Normal, no archive dir
294echo "$LOGFPATH 640 2 * @T00 NC" > newsyslog.conf
385echo "$LOGFPATH 640 2 * @T00 NC" > newsyslog.conf
295tests_normal_rotate
386tests_normal_rotate_keepn 2
296
387
388echo "$LOGFPATH 640 3 * @T00 NC" > newsyslog.conf
389tests_normal_rotate_keepn 3
390
391# Normal, no archive dir, keep X files, gz
392echo "$LOGFPATH 640 0 * @T00 NCZ" > newsyslog.conf
393tests_normal_rotate_keepn 0 ".gz"
394
395echo "$LOGFPATH 640 1 * @T00 NCZ" > newsyslog.conf
396tests_normal_rotate_keepn 1 ".gz"
397
297echo "$LOGFPATH 640 2 * @T00 NCZ" > newsyslog.conf
398echo "$LOGFPATH 640 2 * @T00 NCZ" > newsyslog.conf
399tests_normal_rotate_keepn 2 ".gz"
400
401echo "$LOGFPATH 640 3 * @T00 NCZ" > newsyslog.conf
402tests_normal_rotate_keepn 3 ".gz"
403
404# Normal, no archive dir
405echo "$LOGFPATH 640 3 * @T00 NC" > newsyslog.conf
406tests_normal_rotate
407
408echo "$LOGFPATH 640 3 * @T00 NCZ" > newsyslog.conf
298tests_normal_rotate ".gz"
299
409tests_normal_rotate ".gz"
410
300echo "$LOGFPATH 640 2 * @T00 NCJ" > newsyslog.conf
411echo "$LOGFPATH 640 3 * @T00 NCJ" > newsyslog.conf
301tests_normal_rotate ".bz2"
302
303# Normal, archive dir
412tests_normal_rotate ".bz2"
413
414# Normal, archive dir
304echo "$LOGFPATH 640 2 * @T00 NC" > newsyslog.conf
415echo "$LOGFPATH 640 3 * @T00 NC" > newsyslog.conf
305tests_normal_rotate "" "${TMPDIR}/alog/"
306
416tests_normal_rotate "" "${TMPDIR}/alog/"
417
307echo "$LOGFPATH 640 2 * @T00 NCZ" > newsyslog.conf
418echo "$LOGFPATH 640 3 * @T00 NCZ" > newsyslog.conf
308tests_normal_rotate ".gz" "${TMPDIR}/alog/"
309
419tests_normal_rotate ".gz" "${TMPDIR}/alog/"
420
310echo "$LOGFPATH 640 2 * @T00 NCJ" > newsyslog.conf
421echo "$LOGFPATH 640 3 * @T00 NCJ" > newsyslog.conf
311tests_normal_rotate ".bz2" "${TMPDIR}/alog/"
312
313# Time based, no archive dir
314echo "$LOGFPATH 640 3 * @T00 NC" > newsyslog.conf
315tests_time_rotate
316
317echo "$LOGFPATH 640 3 * @T00 NCZ" > newsyslog.conf
318tests_time_rotate "gz" ""

--- 15 unchanged lines hidden ---
422tests_normal_rotate ".bz2" "${TMPDIR}/alog/"
423
424# Time based, no archive dir
425echo "$LOGFPATH 640 3 * @T00 NC" > newsyslog.conf
426tests_time_rotate
427
428echo "$LOGFPATH 640 3 * @T00 NCZ" > newsyslog.conf
429tests_time_rotate "gz" ""

--- 15 unchanged lines hidden ---