tester revision 636deb6630259136adfafabed91fd84dfcaae63c
33d0a7767d53cb366039fd0ac4f63cf8a9c351b0Tinderbox User# CDDL HEADER START
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User# The contents of this file are subject to the terms of the
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User# Common Development and Distribution License, Version 1.0 only
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User# (the "License"). You may not use this file except in compliance
ca42dcc0686fefd3db202edab80e5adb09d6add5Evan Hunt# with the License.
ca42dcc0686fefd3db202edab80e5adb09d6add5Evan Hunt# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
ca42dcc0686fefd3db202edab80e5adb09d6add5Evan Hunt# See the License for the specific language governing permissions
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# and limitations under the License.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# When distributing Covered Code, include this CDDL HEADER in each
ca42dcc0686fefd3db202edab80e5adb09d6add5Evan Hunt# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# If applicable, add the following below this CDDL HEADER, with the
ca42dcc0686fefd3db202edab80e5adb09d6add5Evan Hunt# fields enclosed by brackets "[]" replaced with your own identifying
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# information: Portions Copyright [yyyy] [name of copyright owner]
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# CDDL HEADER END
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# Use is subject to license terms.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User#ident "%Z%%M% %I% %E% SMI"
ca42dcc0686fefd3db202edab80e5adb09d6add5Evan Hunt# tester - run logadm tests
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# requires a <bindir> argument to say where the various logadm
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# binaries live (conftest, globtest, kwtest, luttest, optstest, and
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# logadm itself).
ca42dcc0686fefd3db202edab80e5adb09d6add5Evan Hunt# to run all the tests:
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# tester [-f] <bindir>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# to run just a few tests, given their names:
ca42dcc0686fefd3db202edab80e5adb09d6add5Evan Hunt# tester [-f] <bindir> globtest1 luttest1
ca42dcc0686fefd3db202edab80e5adb09d6add5Evan Hunt# to setup a test and stop so you can run it by hand:
ca42dcc0686fefd3db202edab80e5adb09d6add5Evan Hunt# tester [-f] -s globtest1 <bindir>
ca42dcc0686fefd3db202edab80e5adb09d6add5Evan Hunt# tester will tell you what tmp directory it created for
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# the test. to run it, cd there and run:
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# to check the results, run:
ca42dcc0686fefd3db202edab80e5adb09d6add5Evan Hunt# sh checktest
ca42dcc0686fefd3db202edab80e5adb09d6add5Evan Hunt# -f means "fast" -- without it, watchmalloc(3MALLOC) is setup for
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# each test and they run a zillion times slower and produce core
ca42dcc0686fefd3db202edab80e5adb09d6add5Evan Hunt# dumps when malloc/free problems are detected.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User# list of tests we run by default
my $msg = shift;
$needrmdir = 1;
$testname = $_;
chdir $mydir;
my $cmd = shift;
$rc >>= 8;
my $coremsg;
$rc &= ~0x80;
my $file = shift;
my $contents = shift;
# common setup step -- create a testfile.conf
my $fname = shift;
apache -C 24 -a '/usr/apache/bin/apachectl graceful' -p 1m -t '/var/apache/old-logs/$basename.%Y-%m' '/var/apache/logs/*{access,error}_log'
# conftest1 -- minimal basic test of the conf.c code
[ -s std.err ] && exit 1
exec /bin/diff sed.out testfile.conf
exec $bindir/conftest testfile.conf >std.out 2>std.err
# conftest2 -- error path through conf.c
exec /bin/diff std.err std.err.expect
$bindir/conftest testfile.conf >std.out 2>std.err || exit 0
# globtest1 -- minimal basic test of the glob.c code
<./dir1/dirA/fileAname4>
<./dir1/dirA/fileAname1>
<./dir1/dirA/fileAname2>
<./dir1/dirA/fileAname3>
<./dir1/dirA/fileAname5>
<./dir1/dirA/fileBname1>
<./dir1/dirA/fileBname2>
<./dir1/dirA/fileBname3>
<./dir1/dirA/fileBname4>
<./dir1/dirA/fileBname5>
oldest <./dir1/dirA/fileAname4>
oldest <./dir1/dirA/fileBname5>
oldest <./dir1/dirA/fileBname4>
oldest <./dir1/dirA/fileBname3>
oldest <./dir1/dirA/fileBname2>
oldest <./dir1/dirA/fileBname1>
oldest <./dir1/dirA/fileAname5>
oldest <./dir1/dirA/fileAname3>
oldest <./dir1/dirA/fileAname2>
oldest <./dir1/dirA/fileAname1>
<./dir1/fileAname1>
<./dir1/fileAname2>
<./dir1/fileAname3>
<./dir1/fileAname4>
<./dir1/fileAname5>
<./dir1/fileBname1>
<./dir1/fileBname2>
<./dir1/fileBname3>
<./dir1/fileBname4>
<./dir1/fileBname5>
oldest <./dir1/fileBname5>
oldest <./dir1/fileBname4>
oldest <./dir1/fileBname3>
oldest <./dir1/fileBname2>
oldest <./dir1/fileBname1>
oldest <./dir1/fileAname5>
oldest <./dir1/fileAname4>
oldest <./dir1/fileAname3>
oldest <./dir1/fileAname2>
oldest <./dir1/fileAname1>
<./dir1/dirA/fileBname2>
<./dir1/dirA/fileBname3>
<./dir1/dirA/fileBname4>
<./dir1/dirA/fileBname5>
oldest <./dir1/dirA/fileBname5>
oldest <./dir1/dirA/fileBname4>
oldest <./dir1/dirA/fileBname3>
oldest <./dir1/dirA/fileBname2>
[ -s std.err ] && exit 1
exec /bin/diff std.out std.out.expect
$testglobs='\'file{A,B,C}name*\' \'file{A,B,C}name\' \'dir1/dirA/file*\' \'dir[13]/[e-z]*\' \'dir?/dir[AC]/fileBname[2-9]\' -r \'file[A-Z]n.*e([0-9]+)$0\'';
# globtest2 -- error path through glob.c
exec /bin/diff std.err std.err.expect
# kwtest1 -- minimal basic test of the kw.c code
$domainname = `/bin/domainname`; chomp $domainname;
expand</var/logs-%Y/moose-$isa$#porklips%d.$n> n -1 hasn 1 result </var/logs-[0-9]+/moose-ISAporklips[0-9]+\.([0-9]+)$0>
expand</var/logs-%Y/moose-$isa$#porklips%d.$n> n 0 hasn 1 result </var/logs-%Y/moose-ISAporklips%d.0>
expand</var/logs-%Y/moose-$isa$#porklips%d.$n> n 1 hasn 1 result </var/logs-%Y/moose-ISAporklips%d.1>
[ -s std.err ] && exit 1
exec /bin/diff sed.out sed.out.expect
$kwtest='kwtest /var/log/syslog \'$file.$n\' \'moose%d.$n\' \'/var/logs-%Y/moose-$isa$#porklips%d.$n\'';
# kwtest2 -- NULL environment variables test of the kw.c code
$domainname = `/bin/domainname`; chomp $domainname;
expand</var/logs-%Y/moose-$isa$#porklips%d.$n> n -1 hasn 1 result </var/logs-[0-9]+/moose-ISAporklips[0-9]+\.([0-9]+)$0>
expand</var/logs-%Y/moose-$isa$#porklips%d.$n> n 0 hasn 1 result </var/logs-%Y/moose-ISAporklips%d.0>
expand</var/logs-%Y/moose-$isa$#porklips%d.$n> n 1 hasn 1 result </var/logs-%Y/moose-ISAporklips%d.1>
[ -s std.err ] && exit 1
exec /bin/diff sed.out sed.out.expect
$kwtest='kwtest /var/log/syslog \'$file.$n\' \'moose%d.$n\' \'/var/logs-%Y/moose-$isa$#porklips%d.$n\'';
# luttest1 -- minimal basic test of the lut.c code
[ -s std.err ] && exit 1
exec /bin/diff std.out std.out.expect
# optstest1 -- minimal basic test of the opts.c code
[ -s std.err ] && exit 1
exec /bin/diff std.out std.out.expect
# optstest2 -- error path through opts.c code
[ -s std.out ] && exit 1
exec /bin/diff std.err std.err.expect
apache -C 24 -a '/usr/apache/bin/apachectl graceful' -p 1m -t '/var/apache/old-logs/$basename.%Y-%m' '/var/apache/logs/*{access,error}_log'
[ -s std.err ] && exit 1
exec /bin/diff std.out std.out.expect
exec $bindir/logadm -f testfile.conf -V >std.out 2>std.err
[ -s std.err ] && exit 1
exec /bin/diff std.out std.out.expect
[ -s std.err ] && exit 1
exec /bin/diff diff.out diff.out.expect
[ -s std.err ] && exit 1
exec /bin/diff diff.out diff.out.expect
exec $bindir/logadm -f testfile.conf -w moose -C 20 -a moose_after_cmd -g pig -m 664 -o cow -p never /moose/file >std.out 2>std.err
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
# logadm3 -- minimal basic test of logadm pre/post-commands
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -f pre.out ] || exit 1
[ -f post.out ] || exit 1
exec $bindir/logadm -f /dev/null -p now logfile -C2 -b 'echo pre-command-stuff > pre.out' -a 'echo post-command-stuff > post.out' >std.out 2>std.err
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
exec /bin/diff cmd.out cmd.out.expect
exec $bindir/logadm -f /dev/null -p now logfile -C1 -R 'echo just rotated: `/bin/cat \$file` >>cmd.out' -E 'echo just expired: `/bin/cat \$file` >>cmd.out' >std.out 2>std.err
[ -s std.err ] || exit 1
[ -s std.out ] && exit 1
exec /bin/diff std.err std.err.expect
exec $bindir/logadm -f /dev/null -p now logfile -m 411 -o _nonexistentuser_ -g _nonexistentgroup_ >std.out 2>std.err
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -s std.err2 ] && exit 1
[ -s std.out2 ] && exit 1
[ -s std.err3 ] && exit 1
[ -s std.out3 ] && exit 1
[ -s std.err4 ] && exit 1
[ -s std.out4 ] && exit 1
[ -f dir2/messages.0 ] || exit 1
[ -f dir2/messages.1 ] || exit 1
[ -f dir2/messages.2 ] || exit 1
[ -f dir2/messages.3 ] || exit 1
[ -f dir2/messages.4 ] && exit 1
exec /bin/diff sed.out logadm.conf.orig
$bindir/logadm -f logadm.conf >std.out 2>std.err || exit 1
$bindir/logadm -f logadm.conf >std.out3 2>std.err3 || exit 1
exec $bindir/logadm -f logadm.conf dir2/messages -p now -a 'echo second kill -HUP `cat /etc/syslog.pid` >> cmd.out' >std.out4 2>std.err4
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -f dir1/syslog.2.gz ] || exit 1
[ -f dir1/syslog.3.gz ] || exit 1
[ -f dir1/syslog.4.gz ] || exit 1
[ -f dir1/syslog.5.gz ] || exit 1
[ -f dir1/syslog.6.gz ] || exit 1
[ -f dir1/syslog.7.gz ] || exit 1
[ -f dir1/syslog.8.gz ] && exit 1
$now = time;
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -f dir2/messages.0 ] || exit 1
[ -f dir2/messages.1 ] || exit 1
[ -f dir2/messages.2 ] || exit 1
[ -f dir2/messages.3 ] || exit 1
[ -f dir2/messages.4 ] && exit 1
exec $bindir/logadm -f logadm.conf >std.out 2>std.err
$now = time;
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -f dir2/messages.0 ] || exit 1
[ -f dir2/messages.1 ] || exit 1
[ -f dir2/messages.2 ] || exit 1
[ -f dir2/messages.3 ] || exit 1
[ -f dir2/messages.4 ] && exit 1
exec $bindir/logadm -f logadm.conf >std.out 2>std.err
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ "xinitially dir1/syslogXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" = "x`/bin/cat dir1/syslog.0`" ] || exit 1
[ -f dir2/messages.0 ] || exit 1
[ -f dir2/messages.1 ] || exit 1
[ -f dir2/messages.2 ] || exit 1
[ -f dir2/messages.3 ] || exit 1
[ -f dir2/messages.4 ] && exit 1
exec $bindir/logadm -f logadm.conf >std.out 2>std.err
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -f dir2/messages.0 ] || exit 1
[ -f dir2/messages.1 ] || exit 1
[ -f dir2/messages.2 ] || exit 1
[ -f dir2/messages.3 ] && exit 1
[ -f dir2/messages.4 ] && exit 1
exec $bindir/logadm -f logadm.conf >std.out 2>std.err
[ -s std.out ] && exit 1
exec /bin/diff std.err std.err.expect
[ -s std.out ] && exit 1
[ -s std.err ] && exit 1
$gid = $);
$gid =~ s/ .*//;
# loading logadm.conf
# logadm.conf unchanged
[ -s std.err ] && exit 1
[ -f std.out ] || exit 1
[ -f dir2/messages.0 ] || exit 1
[ -f dir2/messages.1 ] || exit 1
[ -f dir2/messages.2 ] || exit 1
[ -f dir2/messages.3 ] || exit 1
[ -f dir2/messages.4 ] && exit 1
exec /bin/diff grep.out grep.out.expect
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -f logfile ] || exit 1
[ -f logfile.0 ] || exit 1
[ -f logfile.1 ] || exit 1
[ -f logfile.2 ] || exit 1
[ -f logfile.3 ] && exit 1
[ -f logfile.4 ] || exit 1
[ -f logfile.5 ] && exit 1
[ -f logfile.6 ] || exit 1
[ -f logfile.7 ] && exit 1
[ -f logfile.8 ] || exit 1
[ -f logfile.9 ] && exit 1
[ -f logfile.10 ] && exit 1
[ -s std.out ] && exit 1
exec /bin/diff std.err std.err.expect
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -f logfile ] || exit 1
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
exec $bindir/logadm -f logadm.conf >std.out 2>std.err
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -s logfile ] && exit 1
[ -f logfile.$d ] || exit 1