tester revision 636deb6630259136adfafabed91fd84dfcaae63c
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
#
#
# tester - run logadm tests
#
# requires a <bindir> argument to say where the various logadm
# binaries live (conftest, globtest, kwtest, luttest, optstest, and
# logadm itself).
#
# to run all the tests:
# tester [-f] <bindir>
#
# to run just a few tests, given their names:
# tester [-f] <bindir> globtest1 luttest1
#
# to setup a test and stop so you can run it by hand:
# tester [-f] -s globtest1 <bindir>
#
# tester will tell you what tmp directory it created for
# the test. to run it, cd there and run:
# sh runtest
# to check the results, run:
# sh checktest
#
# -f means "fast" -- without it, watchmalloc(3MALLOC) is setup for
# each test and they run a zillion times slower and produce core
#
${ENV} = "/bin";
umask 002;
# list of tests we run by default
@tests = (
"conftest1",
"conftest2",
"globtest1",
"globtest2",
"kwtest1",
"kwtest2",
"luttest1",
"optstest1",
"optstest2",
"logadmV1",
"logadmV2",
"logadmr",
"logadmw",
"logadm1",
"logadm1c",
"logadm2",
"logadm3",
"logadm4",
"logadm5",
"logadm6",
"logadm7",
"logadm8",
"logadm9",
"logadm9d",
"logadm10",
"logadm11",
"logadm12",
"logadm13",
"logadm14",
"logadm15",
"logadm16",
"logadm17",
"logadm18",
"logadm19",
);
$usage_summary = '[-s test-name] [-d dir] bindir [test-name...]';
$usage_getopts = 'fd:s:';
%usage = (
d=>'use dir for tests rather than creating one in /tmp',
s=>'setup only, do not run test');
# spew usage message, plus any given message, and exit
sub usage {
my $msg = shift;
}
}
exit 1;
}
#
# basic argument processing
#
$myname = $0;
$myname =~ s/.*\///; # just show last component in error mesages
print "Fast mode\n" if $opt_f;
$mydir=`pwd`;
if (!-d $dir) {
$needrmdir = 1;
}
# common commands in runtest by tests
if ($watchmalloc) {
"MALLOC_DEBUG=RW export MALLOC_DEBUG";
} else {
}
$| = 1; # a.k.a. setbuf(stdout, NULL)
if ($opt_s) {
#
# just setup the test, explain how to use it, and exit
#
print "and run the command:\n";
print " sh runtest\n";
print "to check the results, run the command:\n";
print " sh checktest\n";
exit 0;
} else {
#
# run all the tests
#
$testname = $_;
eval "&$_";
if ($@) {
print " SETUP FAILURE\n";
exit 1;
}
eval "runner('runtest')";
if ($@) {
print " RUNTEST FAILURE\n";
exit 1;
}
eval "runner('checktest')";
if ($@) {
print " CHECKTEST FAILURE\n";
exit 1;
}
print "pass\n";
# sanity...
}
}
# if we were the ones who created $dir, remove it
if ($needrmdir) {
chdir $mydir;
}
exit 0;
#
# run a shell script and check for failure
#
# the shell scripts generated by this program always "exec" the binary
# under test so checking here are for exit code, signals, and core dump
#
sub runner {
my $cmd = shift;
return; # cmd completed normally
$rc >>= 8;
} else {
my $coremsg;
$rc &= ~0x80;
}
}
#
# set_file(filename [, contents]) -- create a file, optionally with contents
#
sub set_file {
my $file = shift;
my $contents = shift;
}
#############
#############
############# THE TESTS START AFTER HERE...
#############
#############
# common setup step -- create a testfile.conf
sub set_testconffile {
my $fname = shift;
#
#
# Default settings for system log file management.
# The -w option to logadm(1M) is the preferred way to write to this file,
# but if you do edit it by hand, use "logadm -V" to check it for errors.
#
# The format of lines in this file is:
# <logname> <options>
# For each logname listed here, the default options to logadm
# are given. Options given on the logadm command line override
# the defaults contained in this file.
#
# logadm typically runs early every morning via an entry in
# root's crontab (see crontab(1)).
#
#
# The entry below is used by turnacct(1M)
#
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'
/var/apache/logs/access_log -P 'Thu Nov 1 08:27:56 2001'
/var/apache/logs/suexec_log -P 'Thu Nov 1 08:27:56 2001'
/var/apache/logs/mod_jserv.log -P 'Thu Nov 1 08:27:56 2001'
}
###########################################################################
#
# conftest1 -- minimal basic test of the conf.c code
#
###########################################################################
sub conftest1 {
[ -s std.err ] && exit 1
exec /bin/diff sed.out testfile.conf
# test "conftest1"
exec $bindir/conftest testfile.conf >std.out 2>std.err
}
###########################################################################
#
# conftest2 -- error path through conf.c
#
###########################################################################
sub conftest2 {
EOF
exec /bin/diff std.err std.err.expect
EOF
# test "conftest2"
$envsetup
$bindir/conftest testfile.conf >std.out 2>std.err || exit 0
exit 1
EOF
}
###########################################################################
#
# globtest1 -- minimal basic test of the glob.c code
#
###########################################################################
sub globtest1 {
sleep 2; # ensure above name is odler than below name
# supply some varying sizes to produce different total size values
sleep 2; # ensure above file is oldest in dirA
<file{A,B,C}name*>:
<./fileAname12>
<./fileAname1>
<./fileAname3>
<./fileAname5>
<./fileAname7>
<./fileAname9>
<./fileAname11>
<./fileBname12>
<./fileBname0>
<./fileBname2>
<./fileBname4>
<./fileBname6>
<./fileBname8>
<./fileBname10>
total size: 0
oldest <./fileBname12>
oldest <./fileBname8>
oldest <./fileBname6>
oldest <./fileBname4>
oldest <./fileBname2>
oldest <./fileBname10>
oldest <./fileBname0>
oldest <./fileAname9>
oldest <./fileAname7>
oldest <./fileAname5>
oldest <./fileAname3>
oldest <./fileAname12>
oldest <./fileAname11>
oldest <./fileAname1>
<file{A,B,C}name>:
<fileAname>
<fileBname>
<fileCname>
total size: 0
oldest <fileCname>
oldest <fileBname>
oldest <fileAname>
<./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>
total size: 30
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>
<dir[13]/[e-z]*>:
<./dir1/fileAname1>
<./dir1/fileAname2>
<./dir1/fileAname3>
<./dir1/fileAname4>
<./dir1/fileAname5>
<./dir1/fileBname1>
<./dir1/fileBname2>
<./dir1/fileBname3>
<./dir1/fileBname4>
<./dir1/fileBname5>
total size: 0
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>
<dir?/dir[AC]/fileBname[2-9]>:
<./dir1/dirA/fileBname2>
<./dir1/dirA/fileBname3>
<./dir1/dirA/fileBname4>
<./dir1/dirA/fileBname5>
total size: 14
oldest <./dir1/dirA/fileBname5>
oldest <./dir1/dirA/fileBname4>
oldest <./dir1/dirA/fileBname3>
oldest <./dir1/dirA/fileBname2>
<file[A-Z]n.*e([0-9]+)$0>:
<./fileBname12>
<./fileAname12>
<./fileAname1>
<./fileAname3>
<./fileAname5>
<./fileAname7>
<./fileAname9>
<./fileAname11>
<./fileBname0>
<./fileBname2>
<./fileBname4>
<./fileBname6>
<./fileBname8>
<./fileBname10>
total size: 0
oldest <./fileBname12>
oldest <./fileAname12>
oldest <./fileAname11>
oldest <./fileBname10>
oldest <./fileAname9>
oldest <./fileBname8>
oldest <./fileAname7>
oldest <./fileBname6>
oldest <./fileAname5>
oldest <./fileBname4>
oldest <./fileAname3>
oldest <./fileBname2>
oldest <./fileAname1>
oldest <./fileBname0>
EOF
[ -s std.err ] && exit 1
exec /bin/diff std.out std.out.expect
EOF
$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\'';
# test "globtest1"
$envsetup
EOF
}
###########################################################################
#
# globtest2 -- error path through glob.c
#
###########################################################################
sub globtest2 {
globtest: Error: Missing }
EOF
exec /bin/diff std.err std.err.expect
EOF
# test "globtest2"
$envsetup
exit 1
EOF
}
###########################################################################
#
# kwtest1 -- minimal basic test of the kw.c code
#
###########################################################################
sub kwtest1 {
$domainname = `/bin/domainname`; chomp $domainname;
expand<moose%d.$n> n -1 hasn 1 result <moose[0-9]+\.([0-9]+)$0>
expand<moose%d.$n> n 0 hasn 1 result <moose%d.0>
expand<moose%d.$n> n 1 hasn 1 result <moose%d.1>
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>
EOF
$utcenv = "TZ=UTC export TZ";
chomp $secondblob;
basename syslog
domain $domainname
home $dir
isa $isa
logname $ENV{LOGNAME}
machine $machine
nfile
nodename $nodename
platform $platform
release $release
user $ENV{USER}
$secondblob
EOF
[ -s std.err ] && exit 1
exec /bin/diff sed.out sed.out.expect
EOF
$kwtest='kwtest /var/log/syslog \'$file.$n\' \'moose%d.$n\' \'/var/logs-%Y/moose-$isa$#porklips%d.$n\'';
# test "kwtest1"
$envsetup
$utcenv
EOF
}
###########################################################################
#
# kwtest2 -- NULL environment variables test of the kw.c code
#
###########################################################################
sub kwtest2 {
$domainname = `/bin/domainname`; chomp $domainname;
expand<moose%d.$n> n -1 hasn 1 result <moose[0-9]+\.([0-9]+)$0>
expand<moose%d.$n> n 0 hasn 1 result <moose%d.0>
expand<moose%d.$n> n 1 hasn 1 result <moose%d.1>
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>
EOF
chomp $secondblob;
basename syslog
domain $domainname
home
isa $isa
logname
machine $machine
nfile
nodename $nodename
platform $platform
release $release
user
$secondblob
EOF
[ -s std.err ] && exit 1
exec /bin/diff sed.out sed.out.expect
EOF
$kwtest='kwtest /var/log/syslog \'$file.$n\' \'moose%d.$n\' \'/var/logs-%Y/moose-$isa$#porklips%d.$n\'';
# test "kwtest2"
$envsetup
LOGNAME=
export LOGNAME
HOME=
export HOME
USER=
export USER
EOF
}
###########################################################################
#
# luttest1 -- minimal basic test of the lut.c code
#
###########################################################################
sub luttest1 {
lut contains:
<fix> <NULL> (<NULL>)
<one> <two> (<two>)
<seven> <eight> (<eight>)
<six> <NULL> (<NULL>)
<three> <four> (<four>)
dup lut contains:
<fix> <NULL> (<NULL>)
<one> <two> (<two>)
<seven> <eight> (<eight>)
<six> <NULL> (<NULL>)
<three> <four> (<four>)
EOF
[ -s std.err ] && exit 1
exec /bin/diff std.out std.out.expect
EOF
# test "luttest1"
$envsetup
EOF
}
###########################################################################
#
# optstest1 -- minimal basic test of the opts.c code
#
###########################################################################
sub optstest1 {
options: $options
EOF
[ -s std.err ] && exit 1
exec /bin/diff std.out std.out.expect
EOF
# test "optstest1"
$envsetup
EOF
}
###########################################################################
#
# optstest2 -- error path through opts.c code
#
###########################################################################
sub optstest2 {
optstest: Error: Option 'b' requires an argument
optstest: Error: opts parsing failed
EOF
[ -s std.out ] && exit 1
exec /bin/diff std.err std.err.expect
EOF
# test "optstest2"
$envsetup
exit 1
EOF
}
###########################################################################
#
# logadmV1 -- test of "logadm -V"
#
###########################################################################
sub logadmV1 {
set_testconffile;
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'
EOF
[ -s std.err ] && exit 1
exec /bin/diff std.out std.out.expect
EOF
# test "logadmV1"
$envsetup
exec $bindir/logadm -f testfile.conf -V >std.out 2>std.err
EOF
}
###########################################################################
#
# logadmV2 -- test of "logadm -V <entry>"
#
###########################################################################
sub logadmV2 {
set_testconffile;
EOF
[ -s std.err ] && exit 1
exec /bin/diff std.out std.out.expect
EOF
# test "logadmV2"
$envsetup
EOF
}
###########################################################################
#
# logadmr -- test of "logadm -r <entry>"
#
###########################################################################
sub logadmr {
set_testconffile;
17a18
21a23
EOF
[ -s std.err ] && exit 1
exec /bin/diff diff.out diff.out.expect
EOF
# test "logadmr"
$envsetup
EOF
}
###########################################################################
#
# logadmw -- test of "logadm -w <entry>"
#
###########################################################################
sub logadmw {
set_testconffile;
31d30
EOF
[ -s std.err ] && exit 1
exec /bin/diff diff.out diff.out.expect
EOF
# test "logadmw"
$envsetup
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
EOF
}
###########################################################################
#
# logadm1 -- minimal basic test of logadm rotation
#
###########################################################################
sub logadm1 {
my ($stdev, $stino, $stmode, $stnlink, $stuid, $stgid, $strdev,
$stsize, $statime, $stmtime, $stctime, $stblksize, $stblocks) =
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -s logfile ] && exit 1
[ -f logfile.0 ] || exit 1
[ -f logfile.1 ] || exit 1
exit 0
EOF
# test "logadm1"
$envsetup
EOF
}
###########################################################################
#
# logadm1c -- same as logadm1 but with -c option
#
###########################################################################
sub logadm1c {
my ($stdev, $stino, $stmode, $stnlink, $stuid, $stgid, $strdev,
$stsize, $statime, $stmtime, $stctime, $stblksize, $stblocks) =
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -s logfile ] && exit 1
[ -f logfile.0 ] || exit 1
[ -f logfile.1 ] || exit 1
exit 0
EOF
# test "logadm1c"
$envsetup
EOF
}
###########################################################################
#
# logadm2 -- minimal basic test of logadm expiration
#
###########################################################################
sub logadm2 {
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -s logfile ] && exit 1
[ -f logfile.0 ] || exit 1
[ -f logfile.1 ] || exit 1
[ -f logfile.2 ] && exit 1
exit 0
EOF
# test "logadm2"
$envsetup
EOF
}
###########################################################################
#
# logadm3 -- minimal basic test of logadm pre/post-commands
#
###########################################################################
sub logadm3 {
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -s logfile ] && exit 1
[ -f logfile.0 ] || exit 1
[ -f logfile.1 ] || exit 1
[ -f logfile.2 ] && exit 1
[ -f pre.out ] || exit 1
[ -f post.out ] || exit 1
exit 0
EOF
# test "logadm3"
$envsetup
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
EOF
}
###########################################################################
#
# logadm4 -- test of -t template
#
###########################################################################
sub logadm4 {
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -s logfile ] && exit 1
TZ=UTC export TZ
[ -f logfile.$d ] || exit 1
exit 0
EOF
# test "logadm4"
$envsetup
EOF
}
###########################################################################
#
# logadm5 -- test of -R cmd and -E cmd
#
###########################################################################
sub logadm5 {
just rotated: initially logfile
just expired: initially logfile.0
EOF
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -s logfile ] && exit 1
[ -f logfile.0 ] || exit 1
[ -f logfile.1 ] || exit 1
exec /bin/diff cmd.out cmd.out.expect
EOF
# test "logadm5"
$envsetup
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
EOF
}
###########################################################################
#
# logadm6 -- test of -m, -o, -g
#
###########################################################################
sub logadm6 {
chown: unknown group id _nonexistentgroup_
EOF
[ -s std.err ] || exit 1
[ -s std.out ] && exit 1
[ -s logfile ] && exit 1
[ -f logfile.0 ] || exit 1
exec /bin/diff std.err std.err.expect
EOF
# test "logadm6"
$envsetup
exec $bindir/logadm -f /dev/null -p now logfile -m 411 -o _nonexistentuser_ -g _nonexistentgroup_ >std.out 2>std.err
EOF
}
###########################################################################
#
# logadm7 -- test running through a conffile
#
###########################################################################
sub logadm7 {
#
#
# this comment # has at least another #-sign in it #...
#
# Default settings for system log file management.
# The -w option to logadm(1M) is the preferred way to write to this file,
# but if you do edit it by hand, use "logadm -V" to check it for errors.
# but if you do edit it by hand, use "logadm -V" to check it for errors.
#
# The format of lines in this file is:
# <logname> <options>
# For each logname listed here, the default options to logadm
# are given. Options given on the logadm command line override
# the defaults contained in this file.
#
# logadm typically runs early every morning via an entry in
#
dir1/syslog -C 8 -a 'echo kill -HUP `cat /etc/syslog.pid` >> cmd.out'
dir2/messages -C 4 -a 'echo kill -HUP `cat /etc/syslog.pid` >> cmd.out'
#
# The entry below is used by turnacct(1M)
#
[ -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
# first logadm call will rotate both syslog and messages
# second one won't because size is zero
# third one won't because of -P timestamps stored in conffile
# fourth one will do messages because of -p now on command line
# test "logadm7"
$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
}
###########################################################################
#
# logadm8 -- test of -z
#
###########################################################################
sub logadm8 {
[ -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
exit 0
# test "logadm8"
}
###########################################################################
#
# logadm9 -- test of age check
#
###########################################################################
sub logadm9 {
$now = time;
# a week minus 30 seconds ago...
# technically not a full week, but the heuristic used by logadm
# should think this is "close enough" to a full week
# a week minus six hours ago...
# now: $nowstr is $now
# $closetoweek is $closetoweeksecs
# $lessthanweek is $lessthanweeksecs
[ -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
exit 0
# test "logadm9"
exec $bindir/logadm -f logadm.conf >std.out 2>std.err
}
###########################################################################
#
# logadm9d -- test of age check like logadm9, but age is a couple days
#
###########################################################################
sub logadm9d {
$now = time;
# a day minus 30 seconds ago...
# a day minus six hours ago...
# now: $nowstr is $now
# $closetoday is $closetodaysecs
# $lessthanday is $lessthandaysecs
[ -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
exit 0
# test "logadm9d"
exec $bindir/logadm -f logadm.conf >std.out 2>std.err
}
###########################################################################
#
# logadm10 -- test of size-based rotation check
#
###########################################################################
sub logadm10 {
[ -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
exit 0
# test "logadm10"
exec $bindir/logadm -f logadm.conf >std.out 2>std.err
}
###########################################################################
#
# logadm11 -- test of size-based expiration check
#
###########################################################################
sub logadm11 {
[ -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
exit 0
# test "logadm11"
exec $bindir/logadm -f logadm.conf >std.out 2>std.err
}
###########################################################################
#
# logadm12 -- ENOENT error path
#
###########################################################################
sub logadm12 {
[ -s std.out ] && exit 1
exec /bin/diff std.err std.err.expect
# test "logadm12"
}
###########################################################################
#
# logadm13 -- ENOENT error path with -N flag
#
###########################################################################
sub logadm13 {
[ -s std.out ] && exit 1
[ -s std.err ] && exit 1
exit 0
# test "logadm13"
}
###########################################################################
#
# logadm14 -- test of -n and -v flags
#
###########################################################################
sub logadm14 {
#
#
# Default settings for system log file management.
# The -w option to logadm(1M) is the preferred way to write to this file,
# but if you do edit it by hand, use "logadm -V" to check it for errors.
# but if you do edit it by hand, use "logadm -V" to check it for errors.
#
# The format of lines in this file is:
# <logname> <options>
# For each logname listed here, the default options to logadm
# are given. Options given on the logadm command line override
# the defaults contained in this file.
#
# logadm typically runs early every morning via an entry in
# root's crontab (see crontab(1)).
#
dir1/syslog -C 8 -a 'echo kill -HUP `cat /etc/syslog.pid` >> cmd.out'
dir2/messages -C 4 -a 'echo kill -HUP `cat /etc/syslog.pid` >> cmd.out'
#
# The entry below is used by turnacct(1M)
#
$gid = $);
$gid =~ s/ .*//;
# loading logadm.conf
# using default rotate rules: -s1b -p1w
# using default template: $file.$n
# using default rotate rules: -s1b -p1w
# using default template: $file.$n
mv -f dir2/messages.3 dir2/messages.4 # rotate log file
mv -f dir2/messages.2 dir2/messages.3 # rotate log file
mv -f dir2/messages.1 dir2/messages.2 # rotate log file
mv -f dir2/messages.0 dir2/messages.1 # rotate log file
mv -f dir2/messages dir2/messages.0 # rotate log file
# using default template: $file.$n
# 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
# test "logadm14"
}
###########################################################################
#
# logadm15 -- test of -T
#
###########################################################################
sub logadm15 {
[ -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
exit 0
# test "logadm15"
}
###########################################################################
#
# logadm16 -- test of -h
#
###########################################################################
sub logadm16 {
-r remove logname entry from conffile
-V ensure conffile entries exist, correct
-v print info about actions happening
-w entryname write entry to config file
Options which control when a logfile is rotated:
(default is: -s1b -p1w if no -s or -p)
-p period only rotate if period passed since last rotate
-P timestamp used to store rotation date in conffile
-s size only rotate if given size or greater
Options which control how a logfile is rotated:
-a cmd execute cmd after taking actions
-b cmd execute cmd before taking actions
-c copy & truncate logfile, don't rename
[ -s std.out ] && exit 1
exec /bin/diff std.err std.err.expect
# test "logadm16"
}
###########################################################################
#
# logadm17 -- test that mkdir -p happens as necessary
#
###########################################################################
sub logadm17 {
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -f logfile ] || exit 1
exit 0
# test "logadm17"
}
###########################################################################
#
# logadm18 -- test of -M option
#
###########################################################################
sub logadm18 {
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
exit 0
# test "logadm18"
exec $bindir/logadm -f logadm.conf >std.out 2>std.err
}
#############################################################################
#
# logadm19 -- test of -l
#
#############################################################################
sub logadm19 {
[ -s std.err ] && exit 1
[ -s std.out ] && exit 1
[ -s logfile ] && exit 1
[ -f logfile.$d ] || exit 1
exit 0
# test "logadm4"
}