1*0Sstevel@tonic-gate#!/usr/bin/perl -w 2*0Sstevel@tonic-gate# 3*0Sstevel@tonic-gate# CDDL HEADER START 4*0Sstevel@tonic-gate# 5*0Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*0Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only 7*0Sstevel@tonic-gate# (the "License"). You may not use this file except in compliance 8*0Sstevel@tonic-gate# with the License. 9*0Sstevel@tonic-gate# 10*0Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11*0Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 12*0Sstevel@tonic-gate# See the License for the specific language governing permissions 13*0Sstevel@tonic-gate# and limitations under the License. 14*0Sstevel@tonic-gate# 15*0Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 16*0Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17*0Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 18*0Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 19*0Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 20*0Sstevel@tonic-gate# 21*0Sstevel@tonic-gate# CDDL HEADER END 22*0Sstevel@tonic-gate# 23*0Sstevel@tonic-gate# 24*0Sstevel@tonic-gate# Copyright 2004 Sun Microsystems, Inc. All rights reserved. 25*0Sstevel@tonic-gate# Use is subject to license terms. 26*0Sstevel@tonic-gate# 27*0Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate# 29*0Sstevel@tonic-gate# 30*0Sstevel@tonic-gate# tester - run logadm tests 31*0Sstevel@tonic-gate# 32*0Sstevel@tonic-gate# requires a <bindir> argument to say where the various logadm 33*0Sstevel@tonic-gate# binaries live (conftest, globtest, kwtest, luttest, optstest, and 34*0Sstevel@tonic-gate# logadm itself). 35*0Sstevel@tonic-gate# 36*0Sstevel@tonic-gate# to run all the tests: 37*0Sstevel@tonic-gate# tester [-f] <bindir> 38*0Sstevel@tonic-gate# 39*0Sstevel@tonic-gate# to run just a few tests, given their names: 40*0Sstevel@tonic-gate# tester [-f] <bindir> globtest1 luttest1 41*0Sstevel@tonic-gate# 42*0Sstevel@tonic-gate# to setup a test and stop so you can run it by hand: 43*0Sstevel@tonic-gate# tester [-f] -s globtest1 <bindir> 44*0Sstevel@tonic-gate# 45*0Sstevel@tonic-gate# tester will tell you what tmp directory it created for 46*0Sstevel@tonic-gate# the test. to run it, cd there and run: 47*0Sstevel@tonic-gate# sh runtest 48*0Sstevel@tonic-gate# to check the results, run: 49*0Sstevel@tonic-gate# sh checktest 50*0Sstevel@tonic-gate# 51*0Sstevel@tonic-gate# -f means "fast" -- without it, watchmalloc(3MALLOC) is setup for 52*0Sstevel@tonic-gate# each test and they run a zillion times slower and produce core 53*0Sstevel@tonic-gate# dumps when malloc/free problems are detected. 54*0Sstevel@tonic-gate# 55*0Sstevel@tonic-gate$watchmalloc=1; # default is to use watchmalloc 56*0Sstevel@tonic-gate${ENV} = "/bin"; 57*0Sstevel@tonic-gateumask 002; 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate# list of tests we run by default 60*0Sstevel@tonic-gate@tests = ( 61*0Sstevel@tonic-gate "conftest1", 62*0Sstevel@tonic-gate "conftest2", 63*0Sstevel@tonic-gate "globtest1", 64*0Sstevel@tonic-gate "globtest2", 65*0Sstevel@tonic-gate "kwtest1", 66*0Sstevel@tonic-gate "kwtest2", 67*0Sstevel@tonic-gate "luttest1", 68*0Sstevel@tonic-gate "optstest1", 69*0Sstevel@tonic-gate "optstest2", 70*0Sstevel@tonic-gate "logadmV1", 71*0Sstevel@tonic-gate "logadmV2", 72*0Sstevel@tonic-gate "logadmr", 73*0Sstevel@tonic-gate "logadmw", 74*0Sstevel@tonic-gate "logadm1", 75*0Sstevel@tonic-gate "logadm1c", 76*0Sstevel@tonic-gate "logadm2", 77*0Sstevel@tonic-gate "logadm3", 78*0Sstevel@tonic-gate "logadm4", 79*0Sstevel@tonic-gate "logadm5", 80*0Sstevel@tonic-gate "logadm6", 81*0Sstevel@tonic-gate "logadm7", 82*0Sstevel@tonic-gate "logadm8", 83*0Sstevel@tonic-gate "logadm9", 84*0Sstevel@tonic-gate "logadm9d", 85*0Sstevel@tonic-gate "logadm10", 86*0Sstevel@tonic-gate "logadm11", 87*0Sstevel@tonic-gate "logadm12", 88*0Sstevel@tonic-gate "logadm13", 89*0Sstevel@tonic-gate "logadm14", 90*0Sstevel@tonic-gate "logadm15", 91*0Sstevel@tonic-gate "logadm16", 92*0Sstevel@tonic-gate "logadm17", 93*0Sstevel@tonic-gate "logadm18", 94*0Sstevel@tonic-gate); 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gateuse Getopt::Std; 97*0Sstevel@tonic-gateuse File::Find; 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate$usage_summary = '[-s test-name] [-d dir] bindir [test-name...]'; 100*0Sstevel@tonic-gate$usage_getopts = 'fd:s:'; 101*0Sstevel@tonic-gate%usage = ( 102*0Sstevel@tonic-gate d=>'use dir for tests rather than creating one in /tmp', 103*0Sstevel@tonic-gate s=>'setup only, do not run test'); 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate# spew usage message, plus any given message, and exit 106*0Sstevel@tonic-gatesub usage { 107*0Sstevel@tonic-gate my $msg = shift; 108*0Sstevel@tonic-gate 109*0Sstevel@tonic-gate if ($msg) { 110*0Sstevel@tonic-gate chomp $msg; 111*0Sstevel@tonic-gate warn "$0: $msg\n" if $msg; 112*0Sstevel@tonic-gate } 113*0Sstevel@tonic-gate warn "Usage: $0 $usage_summary\n"; 114*0Sstevel@tonic-gate foreach (sort keys %usage) { 115*0Sstevel@tonic-gate warn " -$_ $usage{$_}\n"; 116*0Sstevel@tonic-gate } 117*0Sstevel@tonic-gate exit 1; 118*0Sstevel@tonic-gate} 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate# 121*0Sstevel@tonic-gate# basic argument processing 122*0Sstevel@tonic-gate# 123*0Sstevel@tonic-gate$myname = $0; 124*0Sstevel@tonic-gate$myname =~ s/.*\///; # just show last component in error mesages 125*0Sstevel@tonic-gategetopts($usage_getopts) or usage; 126*0Sstevel@tonic-gate$bindir = shift or usage; 127*0Sstevel@tonic-gateusage("$bindir does not exist") unless -d $bindir; 128*0Sstevel@tonic-gateusage("cannot list more than one test with -s option") if $opt_s && @ARGV; 129*0Sstevel@tonic-gate@tests = @ARGV if @ARGV; 130*0Sstevel@tonic-gateprint "Fast mode\n" if $opt_f; 131*0Sstevel@tonic-gate$watchmalloc = 0 if $opt_f; 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate$mydir=`pwd`; 134*0Sstevel@tonic-gatechomp $mydir; 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate$dir = $opt_d; 137*0Sstevel@tonic-gate$dir = "/tmp/logadmtest$$" unless $dir = $opt_d; 138*0Sstevel@tonic-gate 139*0Sstevel@tonic-gateif (!-d $dir) { 140*0Sstevel@tonic-gate mkdir $dir, 0777 or die "$myname: mkdir $dir: $!\n"; 141*0Sstevel@tonic-gate $needrmdir = 1; 142*0Sstevel@tonic-gate} 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gatechdir $dir or die "$myname: $dir: $!\n"; 145*0Sstevel@tonic-gate 146*0Sstevel@tonic-gate# common commands in runtest by tests 147*0Sstevel@tonic-gateif ($watchmalloc) { 148*0Sstevel@tonic-gate $envsetup = 149*0Sstevel@tonic-gate "HOME=$dir export HOME; " . 150*0Sstevel@tonic-gate "LD_PRELOAD=watchmalloc.so.1 export LD_PRELOAD; " . 151*0Sstevel@tonic-gate "MALLOC_DEBUG=RW export MALLOC_DEBUG"; 152*0Sstevel@tonic-gate} else { 153*0Sstevel@tonic-gate $envsetup = "HOME=$dir export HOME; "; 154*0Sstevel@tonic-gate} 155*0Sstevel@tonic-gate 156*0Sstevel@tonic-gate$| = 1; # a.k.a. setbuf(stdout, NULL) 157*0Sstevel@tonic-gate 158*0Sstevel@tonic-gateif ($opt_s) { 159*0Sstevel@tonic-gate # 160*0Sstevel@tonic-gate # just setup the test, explain how to use it, and exit 161*0Sstevel@tonic-gate # 162*0Sstevel@tonic-gate $testname = $opt_s; 163*0Sstevel@tonic-gate eval "&$opt_s"; 164*0Sstevel@tonic-gate die "$myname: ERROR: $@" if $@; 165*0Sstevel@tonic-gate print "$myname: $testname setup complete, to run, cd to:\n"; 166*0Sstevel@tonic-gate print " $dir\n"; 167*0Sstevel@tonic-gate print "and run the command:\n"; 168*0Sstevel@tonic-gate print " sh runtest\n"; 169*0Sstevel@tonic-gate print "to check the results, run the command:\n"; 170*0Sstevel@tonic-gate print " sh checktest\n"; 171*0Sstevel@tonic-gate exit 0; 172*0Sstevel@tonic-gate} else { 173*0Sstevel@tonic-gate # 174*0Sstevel@tonic-gate # run all the tests 175*0Sstevel@tonic-gate # 176*0Sstevel@tonic-gate foreach (@tests) { 177*0Sstevel@tonic-gate $testname = $_; 178*0Sstevel@tonic-gate print "Running $testname..."; 179*0Sstevel@tonic-gate eval "&$_"; 180*0Sstevel@tonic-gate if ($@) { 181*0Sstevel@tonic-gate print " SETUP FAILURE\n"; 182*0Sstevel@tonic-gate print STDERR "$myname: ERROR: $@"; 183*0Sstevel@tonic-gate exit 1; 184*0Sstevel@tonic-gate } 185*0Sstevel@tonic-gate eval "runner('runtest')"; 186*0Sstevel@tonic-gate if ($@) { 187*0Sstevel@tonic-gate print " RUNTEST FAILURE\n"; 188*0Sstevel@tonic-gate print STDERR "$myname: ERROR: $@"; 189*0Sstevel@tonic-gate print STDERR "results captured in directory $dir\n"; 190*0Sstevel@tonic-gate print STDERR " or use: $myname -s $testname $bindir\n"; 191*0Sstevel@tonic-gate print STDERR " to do a fresh setup of this test.\n"; 192*0Sstevel@tonic-gate exit 1; 193*0Sstevel@tonic-gate } 194*0Sstevel@tonic-gate eval "runner('checktest')"; 195*0Sstevel@tonic-gate if ($@) { 196*0Sstevel@tonic-gate print " CHECKTEST FAILURE\n"; 197*0Sstevel@tonic-gate print STDERR "$myname: ERROR: $@"; 198*0Sstevel@tonic-gate print STDERR "results captured in directory $dir\n"; 199*0Sstevel@tonic-gate print STDERR " or use: $myname -s $testname $bindir\n"; 200*0Sstevel@tonic-gate print STDERR " to do a fresh setup of this test.\n"; 201*0Sstevel@tonic-gate exit 1; 202*0Sstevel@tonic-gate } 203*0Sstevel@tonic-gate print "pass\n"; 204*0Sstevel@tonic-gate # sanity... 205*0Sstevel@tonic-gate die "unexpected dir $dir" unless $dir =~ m,/.+/,; 206*0Sstevel@tonic-gate system("/bin/rm -rf $dir/*"); 207*0Sstevel@tonic-gate } 208*0Sstevel@tonic-gate} 209*0Sstevel@tonic-gate 210*0Sstevel@tonic-gate# if we were the ones who created $dir, remove it 211*0Sstevel@tonic-gateif ($needrmdir) { 212*0Sstevel@tonic-gate chdir $mydir; 213*0Sstevel@tonic-gate rmdir $dir || die "$myname: rmdir $dir: $!\n"; 214*0Sstevel@tonic-gate} 215*0Sstevel@tonic-gate 216*0Sstevel@tonic-gateexit 0; 217*0Sstevel@tonic-gate 218*0Sstevel@tonic-gate# 219*0Sstevel@tonic-gate# run a shell script and check for failure 220*0Sstevel@tonic-gate# 221*0Sstevel@tonic-gate# the shell scripts generated by this program always "exec" the binary 222*0Sstevel@tonic-gate# under test so checking here are for exit code, signals, and core dump 223*0Sstevel@tonic-gate# is actually checking the program under test and not /bin/sh 224*0Sstevel@tonic-gate# 225*0Sstevel@tonic-gatesub runner { 226*0Sstevel@tonic-gate my $cmd = shift; 227*0Sstevel@tonic-gate my $fullcmd = "/bin/sh $cmd"; 228*0Sstevel@tonic-gate my $rc = 0xffff & system("$fullcmd"); 229*0Sstevel@tonic-gate 230*0Sstevel@tonic-gate if ($rc == 0) { 231*0Sstevel@tonic-gate return; # cmd completed normally 232*0Sstevel@tonic-gate } elsif ($rc == 0xff00) { 233*0Sstevel@tonic-gate die "command \"$cmd\" failed: $!\n"; 234*0Sstevel@tonic-gate } elsif (($rc & 0xff) == 0) { 235*0Sstevel@tonic-gate $rc >>= 8; 236*0Sstevel@tonic-gate die "command \"$cmd\" exit $rc\n"; 237*0Sstevel@tonic-gate } else { 238*0Sstevel@tonic-gate my $coremsg; 239*0Sstevel@tonic-gate $coremsg = " (core dumped)" if ($rc & 0x80); 240*0Sstevel@tonic-gate $rc &= ~0x80; 241*0Sstevel@tonic-gate die "command \"$cmd\" signal $rc$coremsg\n" ; 242*0Sstevel@tonic-gate } 243*0Sstevel@tonic-gate} 244*0Sstevel@tonic-gate 245*0Sstevel@tonic-gate# 246*0Sstevel@tonic-gate# set_file(filename [, contents]) -- create a file, optionally with contents 247*0Sstevel@tonic-gate# 248*0Sstevel@tonic-gatesub set_file { 249*0Sstevel@tonic-gate my $file = shift; 250*0Sstevel@tonic-gate my $contents = shift; 251*0Sstevel@tonic-gate 252*0Sstevel@tonic-gate open SF, ">$file" or die "create \"$file\": $!\n"; 253*0Sstevel@tonic-gate print SF $contents if defined($contents); 254*0Sstevel@tonic-gate close SF; 255*0Sstevel@tonic-gate} 256*0Sstevel@tonic-gate 257*0Sstevel@tonic-gate############# 258*0Sstevel@tonic-gate############# 259*0Sstevel@tonic-gate############# THE TESTS START AFTER HERE... 260*0Sstevel@tonic-gate############# 261*0Sstevel@tonic-gate############# 262*0Sstevel@tonic-gate 263*0Sstevel@tonic-gate# common setup step -- create a testfile.conf 264*0Sstevel@tonic-gatesub set_testconffile { 265*0Sstevel@tonic-gate my $fname = shift; 266*0Sstevel@tonic-gate $fname = 'testfile.conf' unless defined($fname); 267*0Sstevel@tonic-gate 268*0Sstevel@tonic-gate set_file($fname, <<'EOF'); 269*0Sstevel@tonic-gate# 270*0Sstevel@tonic-gate# logadm.conf 271*0Sstevel@tonic-gate# 272*0Sstevel@tonic-gate# Default settings for system log file management. 273*0Sstevel@tonic-gate# The -w option to logadm(1M) is the preferred way to write to this file, 274*0Sstevel@tonic-gate# but if you do edit it by hand, use "logadm -V" to check it for errors. 275*0Sstevel@tonic-gate# 276*0Sstevel@tonic-gate# The format of lines in this file is: 277*0Sstevel@tonic-gate# <logname> <options> 278*0Sstevel@tonic-gate# For each logname listed here, the default options to logadm 279*0Sstevel@tonic-gate# are given. Options given on the logadm command line override 280*0Sstevel@tonic-gate# the defaults contained in this file. 281*0Sstevel@tonic-gate# 282*0Sstevel@tonic-gate# logadm typically runs early every morning via an entry in 283*0Sstevel@tonic-gate# root's crontab (see crontab(1)). 284*0Sstevel@tonic-gate# 285*0Sstevel@tonic-gate/var/adm/messages -C 4 -P 'Thu Nov 1 16:56:42 2001' -a 'kill -HUP `cat /var/run/syslog.pid`' 286*0Sstevel@tonic-gate/var/cron/log -s 512k -t /var/cron/olog 287*0Sstevel@tonic-gate/var/lp/logs/lpsched -C 2 -N -t '$file.$N' 288*0Sstevel@tonic-gate# 289*0Sstevel@tonic-gate# The entry below is used by turnacct(1M) 290*0Sstevel@tonic-gate# 291*0Sstevel@tonic-gate/var/adm/pacct -C 0 -a '/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -p never 292*0Sstevel@tonic-gateapache -C 24 -a '/usr/apache/bin/apachectl graceful' -p 1m -t '/var/apache/old-logs/$basename.%Y-%m' '/var/apache/logs/*{access,error}_log' 293*0Sstevel@tonic-gate/var/log/syslog -C 8 -P 'Thu Nov 1 09:16:38 2001' -a 'kill -HUP `cat /var/run/syslog.pid`' 294*0Sstevel@tonic-gate/var/apache/logs/access_log -P 'Thu Nov 1 08:27:56 2001' 295*0Sstevel@tonic-gate/var/apache/logs/error_log -P 'Thu Nov 1 08:27:56 2001' 296*0Sstevel@tonic-gate/var/apache/logs/suexec_log -P 'Thu Nov 1 08:27:56 2001' 297*0Sstevel@tonic-gate/var/apache/logs/mod_jserv.log -P 'Thu Nov 1 08:27:56 2001' 298*0Sstevel@tonic-gate/var/apache/logs/jserv.log -P 'Thu Nov 1 08:27:56 2001' 299*0Sstevel@tonic-gateEOF 300*0Sstevel@tonic-gate} 301*0Sstevel@tonic-gate 302*0Sstevel@tonic-gate 303*0Sstevel@tonic-gate########################################################################### 304*0Sstevel@tonic-gate# 305*0Sstevel@tonic-gate# conftest1 -- minimal basic test of the conf.c code 306*0Sstevel@tonic-gate# 307*0Sstevel@tonic-gate########################################################################### 308*0Sstevel@tonic-gatesub conftest1 { 309*0Sstevel@tonic-gate set_testconffile; 310*0Sstevel@tonic-gate 311*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 312*0Sstevel@tonic-gate[ -s std.err ] && exit 1 313*0Sstevel@tonic-gate/bin/sed '/^conffile <testfile.conf>:$/d' <std.out >sed.out 314*0Sstevel@tonic-gateexec /bin/diff sed.out testfile.conf 315*0Sstevel@tonic-gateEOF 316*0Sstevel@tonic-gate 317*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 318*0Sstevel@tonic-gate# test "conftest1" 319*0Sstevel@tonic-gate$envsetup 320*0Sstevel@tonic-gateexec $bindir/conftest testfile.conf >std.out 2>std.err 321*0Sstevel@tonic-gateEOF 322*0Sstevel@tonic-gate} 323*0Sstevel@tonic-gate 324*0Sstevel@tonic-gate########################################################################### 325*0Sstevel@tonic-gate# 326*0Sstevel@tonic-gate# conftest2 -- error path through conf.c 327*0Sstevel@tonic-gate# 328*0Sstevel@tonic-gate########################################################################### 329*0Sstevel@tonic-gatesub conftest2 { 330*0Sstevel@tonic-gate set_file('testfile.conf', 'line fragment'); 331*0Sstevel@tonic-gate 332*0Sstevel@tonic-gate set_file('std.err.expect', <<'EOF'); 333*0Sstevel@tonic-gateconftest: Warning: config file doesn't end with newline, last line ignored. 334*0Sstevel@tonic-gateEOF 335*0Sstevel@tonic-gate 336*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 337*0Sstevel@tonic-gateexec /bin/diff std.err std.err.expect 338*0Sstevel@tonic-gateEOF 339*0Sstevel@tonic-gate 340*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 341*0Sstevel@tonic-gate# test "conftest2" 342*0Sstevel@tonic-gate$envsetup 343*0Sstevel@tonic-gate$bindir/conftest testfile.conf >std.out 2>std.err || exit 0 344*0Sstevel@tonic-gateexit 1 345*0Sstevel@tonic-gateEOF 346*0Sstevel@tonic-gate} 347*0Sstevel@tonic-gate 348*0Sstevel@tonic-gate########################################################################### 349*0Sstevel@tonic-gate# 350*0Sstevel@tonic-gate# globtest1 -- minimal basic test of the glob.c code 351*0Sstevel@tonic-gate# 352*0Sstevel@tonic-gate########################################################################### 353*0Sstevel@tonic-gatesub globtest1 { 354*0Sstevel@tonic-gate set_file('fileBname12'); 355*0Sstevel@tonic-gate sleep 2; # ensure above name is odler than below name 356*0Sstevel@tonic-gate set_file('fileAname12'); 357*0Sstevel@tonic-gate set_file('fileAname1'); 358*0Sstevel@tonic-gate set_file('fileAname3'); 359*0Sstevel@tonic-gate set_file('fileAname5'); 360*0Sstevel@tonic-gate set_file('fileAname7'); 361*0Sstevel@tonic-gate set_file('fileAname9'); 362*0Sstevel@tonic-gate set_file('fileAname11'); 363*0Sstevel@tonic-gate set_file('fileBname0'); 364*0Sstevel@tonic-gate set_file('fileBname2'); 365*0Sstevel@tonic-gate set_file('fileBname4'); 366*0Sstevel@tonic-gate set_file('fileBname6'); 367*0Sstevel@tonic-gate set_file('fileBname8'); 368*0Sstevel@tonic-gate set_file('fileBname10'); 369*0Sstevel@tonic-gate mkdir 'dir1', 0777 or die "mkdir dir1: $!\n"; 370*0Sstevel@tonic-gate mkdir 'dir2', 0777 or die "mkdir dir2: $!\n"; 371*0Sstevel@tonic-gate mkdir 'dir3', 0777 or die "mkdir dir3: $!\n"; 372*0Sstevel@tonic-gate mkdir 'dir1/dirA', 0777 or die "mkdir dir1/dirA: $!\n"; 373*0Sstevel@tonic-gate mkdir 'dir1/dirB', 0777 or die "mkdir dir1/dirB: $!\n"; 374*0Sstevel@tonic-gate mkdir 'dir1/dirC', 0777 or die "mkdir dir1/dirC: $!\n"; 375*0Sstevel@tonic-gate mkdir 'dir2/dirA', 0777 or die "mkdir dir2/dirA: $!\n"; 376*0Sstevel@tonic-gate mkdir 'dir2/dirB', 0777 or die "mkdir dir2/dirB: $!\n"; 377*0Sstevel@tonic-gate mkdir 'dir2/dirC', 0777 or die "mkdir dir2/dirC: $!\n"; 378*0Sstevel@tonic-gate set_file('dir1/fileAname1'); 379*0Sstevel@tonic-gate set_file('dir1/fileAname2'); 380*0Sstevel@tonic-gate set_file('dir1/fileAname3'); 381*0Sstevel@tonic-gate set_file('dir1/fileAname4'); 382*0Sstevel@tonic-gate set_file('dir1/fileAname5'); 383*0Sstevel@tonic-gate set_file('dir1/fileBname1'); 384*0Sstevel@tonic-gate set_file('dir1/fileBname2'); 385*0Sstevel@tonic-gate set_file('dir1/fileBname3'); 386*0Sstevel@tonic-gate set_file('dir1/fileBname4'); 387*0Sstevel@tonic-gate set_file('dir1/fileBname5'); 388*0Sstevel@tonic-gate # supply some varying sizes to produce different total size values 389*0Sstevel@tonic-gate set_file('dir1/dirA/fileAname4', '4444'); 390*0Sstevel@tonic-gate sleep 2; # ensure above file is oldest in dirA 391*0Sstevel@tonic-gate set_file('dir1/dirA/fileAname1', '1'); 392*0Sstevel@tonic-gate set_file('dir1/dirA/fileAname2', '22'); 393*0Sstevel@tonic-gate set_file('dir1/dirA/fileAname3', '333'); 394*0Sstevel@tonic-gate set_file('dir1/dirA/fileAname5', '55555'); 395*0Sstevel@tonic-gate set_file('dir1/dirA/fileBname1', '1'); 396*0Sstevel@tonic-gate set_file('dir1/dirA/fileBname2', '22'); 397*0Sstevel@tonic-gate set_file('dir1/dirA/fileBname3', '333'); 398*0Sstevel@tonic-gate set_file('dir1/dirA/fileBname4', '4444'); 399*0Sstevel@tonic-gate set_file('dir1/dirA/fileBname5', '55555'); 400*0Sstevel@tonic-gate set_file('dir1/dirB/fileAname1', '1'); 401*0Sstevel@tonic-gate set_file('dir1/dirB/fileAname2', '22'); 402*0Sstevel@tonic-gate set_file('dir1/dirB/fileAname3', '333'); 403*0Sstevel@tonic-gate set_file('dir1/dirB/fileAname4', '4444'); 404*0Sstevel@tonic-gate set_file('dir1/dirB/fileAname5', '55555'); 405*0Sstevel@tonic-gate set_file('dir1/dirB/fileBname1', '1'); 406*0Sstevel@tonic-gate set_file('dir1/dirB/fileBname2', '22'); 407*0Sstevel@tonic-gate set_file('dir1/dirB/fileBname3', '333'); 408*0Sstevel@tonic-gate set_file('dir1/dirB/fileBname4', '4444'); 409*0Sstevel@tonic-gate set_file('dir1/dirB/fileBname5', '55555'); 410*0Sstevel@tonic-gate set_file('dir1/dirC/fileAname10', '12345678901'); 411*0Sstevel@tonic-gate set_file('dir1/dirC/fileAname20', '123456789022'); 412*0Sstevel@tonic-gate set_file('dir1/dirC/fileAname30', '1234567890333'); 413*0Sstevel@tonic-gate set_file('dir1/dirC/fileAname40', '12345678904444'); 414*0Sstevel@tonic-gate set_file('dir1/dirC/fileAname50', '123456789055555'); 415*0Sstevel@tonic-gate set_file('dir1/dirC/fileBname10', '12345678901'); 416*0Sstevel@tonic-gate set_file('dir1/dirC/fileBname20', '123456789022'); 417*0Sstevel@tonic-gate set_file('dir1/dirC/fileBname30', '1234567890333'); 418*0Sstevel@tonic-gate set_file('dir1/dirC/fileBname40', '12345678904444'); 419*0Sstevel@tonic-gate set_file('dir1/dirC/fileBname50', '123456789055555'); 420*0Sstevel@tonic-gate 421*0Sstevel@tonic-gate set_file('std.out.expect', <<'EOF'); 422*0Sstevel@tonic-gate<file{A,B,C}name*>: 423*0Sstevel@tonic-gate <./fileAname12> 424*0Sstevel@tonic-gate <./fileAname1> 425*0Sstevel@tonic-gate <./fileAname3> 426*0Sstevel@tonic-gate <./fileAname5> 427*0Sstevel@tonic-gate <./fileAname7> 428*0Sstevel@tonic-gate <./fileAname9> 429*0Sstevel@tonic-gate <./fileAname11> 430*0Sstevel@tonic-gate <./fileBname12> 431*0Sstevel@tonic-gate <./fileBname0> 432*0Sstevel@tonic-gate <./fileBname2> 433*0Sstevel@tonic-gate <./fileBname4> 434*0Sstevel@tonic-gate <./fileBname6> 435*0Sstevel@tonic-gate <./fileBname8> 436*0Sstevel@tonic-gate <./fileBname10> 437*0Sstevel@tonic-gatetotal size: 0 438*0Sstevel@tonic-gate oldest <./fileBname12> 439*0Sstevel@tonic-gate oldest <./fileBname8> 440*0Sstevel@tonic-gate oldest <./fileBname6> 441*0Sstevel@tonic-gate oldest <./fileBname4> 442*0Sstevel@tonic-gate oldest <./fileBname2> 443*0Sstevel@tonic-gate oldest <./fileBname10> 444*0Sstevel@tonic-gate oldest <./fileBname0> 445*0Sstevel@tonic-gate oldest <./fileAname9> 446*0Sstevel@tonic-gate oldest <./fileAname7> 447*0Sstevel@tonic-gate oldest <./fileAname5> 448*0Sstevel@tonic-gate oldest <./fileAname3> 449*0Sstevel@tonic-gate oldest <./fileAname12> 450*0Sstevel@tonic-gate oldest <./fileAname11> 451*0Sstevel@tonic-gate oldest <./fileAname1> 452*0Sstevel@tonic-gate<file{A,B,C}name>: 453*0Sstevel@tonic-gate <fileAname> 454*0Sstevel@tonic-gate <fileBname> 455*0Sstevel@tonic-gate <fileCname> 456*0Sstevel@tonic-gatetotal size: 0 457*0Sstevel@tonic-gate oldest <fileCname> 458*0Sstevel@tonic-gate oldest <fileBname> 459*0Sstevel@tonic-gate oldest <fileAname> 460*0Sstevel@tonic-gate<dir1/dirA/file*>: 461*0Sstevel@tonic-gate <./dir1/dirA/fileAname4> 462*0Sstevel@tonic-gate <./dir1/dirA/fileAname1> 463*0Sstevel@tonic-gate <./dir1/dirA/fileAname2> 464*0Sstevel@tonic-gate <./dir1/dirA/fileAname3> 465*0Sstevel@tonic-gate <./dir1/dirA/fileAname5> 466*0Sstevel@tonic-gate <./dir1/dirA/fileBname1> 467*0Sstevel@tonic-gate <./dir1/dirA/fileBname2> 468*0Sstevel@tonic-gate <./dir1/dirA/fileBname3> 469*0Sstevel@tonic-gate <./dir1/dirA/fileBname4> 470*0Sstevel@tonic-gate <./dir1/dirA/fileBname5> 471*0Sstevel@tonic-gatetotal size: 30 472*0Sstevel@tonic-gate oldest <./dir1/dirA/fileAname4> 473*0Sstevel@tonic-gate oldest <./dir1/dirA/fileBname5> 474*0Sstevel@tonic-gate oldest <./dir1/dirA/fileBname4> 475*0Sstevel@tonic-gate oldest <./dir1/dirA/fileBname3> 476*0Sstevel@tonic-gate oldest <./dir1/dirA/fileBname2> 477*0Sstevel@tonic-gate oldest <./dir1/dirA/fileBname1> 478*0Sstevel@tonic-gate oldest <./dir1/dirA/fileAname5> 479*0Sstevel@tonic-gate oldest <./dir1/dirA/fileAname3> 480*0Sstevel@tonic-gate oldest <./dir1/dirA/fileAname2> 481*0Sstevel@tonic-gate oldest <./dir1/dirA/fileAname1> 482*0Sstevel@tonic-gate<dir[13]/[e-z]*>: 483*0Sstevel@tonic-gate <./dir1/fileAname1> 484*0Sstevel@tonic-gate <./dir1/fileAname2> 485*0Sstevel@tonic-gate <./dir1/fileAname3> 486*0Sstevel@tonic-gate <./dir1/fileAname4> 487*0Sstevel@tonic-gate <./dir1/fileAname5> 488*0Sstevel@tonic-gate <./dir1/fileBname1> 489*0Sstevel@tonic-gate <./dir1/fileBname2> 490*0Sstevel@tonic-gate <./dir1/fileBname3> 491*0Sstevel@tonic-gate <./dir1/fileBname4> 492*0Sstevel@tonic-gate <./dir1/fileBname5> 493*0Sstevel@tonic-gatetotal size: 0 494*0Sstevel@tonic-gate oldest <./dir1/fileBname5> 495*0Sstevel@tonic-gate oldest <./dir1/fileBname4> 496*0Sstevel@tonic-gate oldest <./dir1/fileBname3> 497*0Sstevel@tonic-gate oldest <./dir1/fileBname2> 498*0Sstevel@tonic-gate oldest <./dir1/fileBname1> 499*0Sstevel@tonic-gate oldest <./dir1/fileAname5> 500*0Sstevel@tonic-gate oldest <./dir1/fileAname4> 501*0Sstevel@tonic-gate oldest <./dir1/fileAname3> 502*0Sstevel@tonic-gate oldest <./dir1/fileAname2> 503*0Sstevel@tonic-gate oldest <./dir1/fileAname1> 504*0Sstevel@tonic-gate<dir?/dir[AC]/fileBname[2-9]>: 505*0Sstevel@tonic-gate <./dir1/dirA/fileBname2> 506*0Sstevel@tonic-gate <./dir1/dirA/fileBname3> 507*0Sstevel@tonic-gate <./dir1/dirA/fileBname4> 508*0Sstevel@tonic-gate <./dir1/dirA/fileBname5> 509*0Sstevel@tonic-gatetotal size: 14 510*0Sstevel@tonic-gate oldest <./dir1/dirA/fileBname5> 511*0Sstevel@tonic-gate oldest <./dir1/dirA/fileBname4> 512*0Sstevel@tonic-gate oldest <./dir1/dirA/fileBname3> 513*0Sstevel@tonic-gate oldest <./dir1/dirA/fileBname2> 514*0Sstevel@tonic-gate<file[A-Z]n.*e([0-9]+)$0>: 515*0Sstevel@tonic-gate <./fileBname12> 516*0Sstevel@tonic-gate <./fileAname12> 517*0Sstevel@tonic-gate <./fileAname1> 518*0Sstevel@tonic-gate <./fileAname3> 519*0Sstevel@tonic-gate <./fileAname5> 520*0Sstevel@tonic-gate <./fileAname7> 521*0Sstevel@tonic-gate <./fileAname9> 522*0Sstevel@tonic-gate <./fileAname11> 523*0Sstevel@tonic-gate <./fileBname0> 524*0Sstevel@tonic-gate <./fileBname2> 525*0Sstevel@tonic-gate <./fileBname4> 526*0Sstevel@tonic-gate <./fileBname6> 527*0Sstevel@tonic-gate <./fileBname8> 528*0Sstevel@tonic-gate <./fileBname10> 529*0Sstevel@tonic-gatetotal size: 0 530*0Sstevel@tonic-gate oldest <./fileBname12> 531*0Sstevel@tonic-gate oldest <./fileAname12> 532*0Sstevel@tonic-gate oldest <./fileAname11> 533*0Sstevel@tonic-gate oldest <./fileBname10> 534*0Sstevel@tonic-gate oldest <./fileAname9> 535*0Sstevel@tonic-gate oldest <./fileBname8> 536*0Sstevel@tonic-gate oldest <./fileAname7> 537*0Sstevel@tonic-gate oldest <./fileBname6> 538*0Sstevel@tonic-gate oldest <./fileAname5> 539*0Sstevel@tonic-gate oldest <./fileBname4> 540*0Sstevel@tonic-gate oldest <./fileAname3> 541*0Sstevel@tonic-gate oldest <./fileBname2> 542*0Sstevel@tonic-gate oldest <./fileAname1> 543*0Sstevel@tonic-gate oldest <./fileBname0> 544*0Sstevel@tonic-gateEOF 545*0Sstevel@tonic-gate 546*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 547*0Sstevel@tonic-gate[ -s std.err ] && exit 1 548*0Sstevel@tonic-gateexec /bin/diff std.out std.out.expect 549*0Sstevel@tonic-gateEOF 550*0Sstevel@tonic-gate 551*0Sstevel@tonic-gate $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\''; 552*0Sstevel@tonic-gate 553*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 554*0Sstevel@tonic-gate# test "globtest1" 555*0Sstevel@tonic-gate$envsetup 556*0Sstevel@tonic-gateexec $bindir/globtest $testglobs >std.out 2>std.err 557*0Sstevel@tonic-gateEOF 558*0Sstevel@tonic-gate} 559*0Sstevel@tonic-gate 560*0Sstevel@tonic-gate########################################################################### 561*0Sstevel@tonic-gate# 562*0Sstevel@tonic-gate# globtest2 -- error path through glob.c 563*0Sstevel@tonic-gate# 564*0Sstevel@tonic-gate########################################################################### 565*0Sstevel@tonic-gatesub globtest2 { 566*0Sstevel@tonic-gate set_file('std.err.expect', <<'EOF'); 567*0Sstevel@tonic-gateglobtest: Error: Missing } 568*0Sstevel@tonic-gateEOF 569*0Sstevel@tonic-gate 570*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 571*0Sstevel@tonic-gateexec /bin/diff std.err std.err.expect 572*0Sstevel@tonic-gateEOF 573*0Sstevel@tonic-gate 574*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 575*0Sstevel@tonic-gate# test "globtest2" 576*0Sstevel@tonic-gate$envsetup 577*0Sstevel@tonic-gate$bindir/globtest 'hello{there' >std.out 2>std.err || exit 0 578*0Sstevel@tonic-gateexit 1 579*0Sstevel@tonic-gateEOF 580*0Sstevel@tonic-gate} 581*0Sstevel@tonic-gate 582*0Sstevel@tonic-gate########################################################################### 583*0Sstevel@tonic-gate# 584*0Sstevel@tonic-gate# kwtest1 -- minimal basic test of the kw.c code 585*0Sstevel@tonic-gate# 586*0Sstevel@tonic-gate########################################################################### 587*0Sstevel@tonic-gatesub kwtest1 { 588*0Sstevel@tonic-gate $domainname = `/bin/domainname`; chomp $domainname; 589*0Sstevel@tonic-gate $isa = `/bin/uname -p`; chomp $isa; 590*0Sstevel@tonic-gate $platform = `/bin/uname -i`; chomp $platform; 591*0Sstevel@tonic-gate $nodename = `/bin/uname -n`; chomp $nodename; 592*0Sstevel@tonic-gate $machine = `/bin/uname -m`; chomp $machine; 593*0Sstevel@tonic-gate $release = `/bin/uname -r`; chomp $release; 594*0Sstevel@tonic-gate$secondblob=<<'EOF'; 595*0Sstevel@tonic-gateexpand<$file.$n> n -1 hasn 1 result </var/log/syslog\.([0-9]+)$0> 596*0Sstevel@tonic-gateexpand<$file.$n> n 0 hasn 1 result </var/log/syslog.0> 597*0Sstevel@tonic-gateexpand<$file.$n> n 1 hasn 1 result </var/log/syslog.1> 598*0Sstevel@tonic-gateexpand<moose%d.$n> n -1 hasn 1 result <moose[0-9]+\.([0-9]+)$0> 599*0Sstevel@tonic-gateexpand<moose%d.$n> n 0 hasn 1 result <moose%d.0> 600*0Sstevel@tonic-gateexpand<moose%d.$n> n 1 hasn 1 result <moose%d.1> 601*0Sstevel@tonic-gateexpand</var/logs-%Y/moose-$isa$#porklips%d.$n> n -1 hasn 1 result </var/logs-[0-9]+/moose-ISAporklips[0-9]+\.([0-9]+)$0> 602*0Sstevel@tonic-gateexpand</var/logs-%Y/moose-$isa$#porklips%d.$n> n 0 hasn 1 result </var/logs-%Y/moose-ISAporklips%d.0> 603*0Sstevel@tonic-gateexpand</var/logs-%Y/moose-$isa$#porklips%d.$n> n 1 hasn 1 result </var/logs-%Y/moose-ISAporklips%d.1> 604*0Sstevel@tonic-gateEOF 605*0Sstevel@tonic-gate $percentd = `/bin/env TZ=UTC /bin/date +%d`; chomp $percentd; 606*0Sstevel@tonic-gate $percentY = `/bin/env TZ=UTC /bin/date +%Y`; chomp $percentY; 607*0Sstevel@tonic-gate $secondblob =~ s/%d/$percentd/mg; 608*0Sstevel@tonic-gate $secondblob =~ s/%Y/$percentY/mg; 609*0Sstevel@tonic-gate $secondblob =~ s/ISA/$isa/mg; 610*0Sstevel@tonic-gate chomp $secondblob; 611*0Sstevel@tonic-gate set_file('sed.out.expect', <<"EOF"); 612*0Sstevel@tonic-gate basename syslog 613*0Sstevel@tonic-gate dirname /var/log 614*0Sstevel@tonic-gate domain $domainname 615*0Sstevel@tonic-gate file /var/log/syslog 616*0Sstevel@tonic-gate home $dir 617*0Sstevel@tonic-gate isa $isa 618*0Sstevel@tonic-gate logname $ENV{LOGNAME} 619*0Sstevel@tonic-gate machine $machine 620*0Sstevel@tonic-gate nfile 621*0Sstevel@tonic-gate nodename $nodename 622*0Sstevel@tonic-gate platform $platform 623*0Sstevel@tonic-gate release $release 624*0Sstevel@tonic-gate user $ENV{USER} 625*0Sstevel@tonic-gate$secondblob 626*0Sstevel@tonic-gateEOF 627*0Sstevel@tonic-gate 628*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 629*0Sstevel@tonic-gate[ -s std.err ] && exit 1 630*0Sstevel@tonic-gate/bin/sed -e '/^ *secs [0-9][0-9]*$/d'\ 631*0Sstevel@tonic-gate -e "s/%d/`/bin/env TZ=UTC /bin/date +%d`/g"\ 632*0Sstevel@tonic-gate -e "s/%Y/`/bin/env TZ=UTC /bin/date +%Y`/g"\ 633*0Sstevel@tonic-gate <std.out >sed.out 634*0Sstevel@tonic-gateexec /bin/diff sed.out sed.out.expect 635*0Sstevel@tonic-gateEOF 636*0Sstevel@tonic-gate 637*0Sstevel@tonic-gate $kwtest='kwtest /var/log/syslog \'$file.$n\' \'moose%d.$n\' \'/var/logs-%Y/moose-$isa$#porklips%d.$n\''; 638*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 639*0Sstevel@tonic-gate# test "kwtest1" 640*0Sstevel@tonic-gate$envsetup 641*0Sstevel@tonic-gateexec $bindir/$kwtest >std.out 2>std.err 642*0Sstevel@tonic-gateEOF 643*0Sstevel@tonic-gate} 644*0Sstevel@tonic-gate 645*0Sstevel@tonic-gate########################################################################### 646*0Sstevel@tonic-gate# 647*0Sstevel@tonic-gate# kwtest2 -- NULL environment variables test of the kw.c code 648*0Sstevel@tonic-gate# 649*0Sstevel@tonic-gate########################################################################### 650*0Sstevel@tonic-gatesub kwtest2 { 651*0Sstevel@tonic-gate $domainname = `/bin/domainname`; chomp $domainname; 652*0Sstevel@tonic-gate $isa = `/bin/uname -p`; chomp $isa; 653*0Sstevel@tonic-gate $platform = `/bin/uname -i`; chomp $platform; 654*0Sstevel@tonic-gate $nodename = `/bin/uname -n`; chomp $nodename; 655*0Sstevel@tonic-gate $machine = `/bin/uname -m`; chomp $machine; 656*0Sstevel@tonic-gate $release = `/bin/uname -r`; chomp $release; 657*0Sstevel@tonic-gate$secondblob=<<'EOF'; 658*0Sstevel@tonic-gateexpand<$file.$n> n -1 hasn 1 result </var/log/syslog\.([0-9]+)$0> 659*0Sstevel@tonic-gateexpand<$file.$n> n 0 hasn 1 result </var/log/syslog.0> 660*0Sstevel@tonic-gateexpand<$file.$n> n 1 hasn 1 result </var/log/syslog.1> 661*0Sstevel@tonic-gateexpand<moose%d.$n> n -1 hasn 1 result <moose[0-9]+\.([0-9]+)$0> 662*0Sstevel@tonic-gateexpand<moose%d.$n> n 0 hasn 1 result <moose%d.0> 663*0Sstevel@tonic-gateexpand<moose%d.$n> n 1 hasn 1 result <moose%d.1> 664*0Sstevel@tonic-gateexpand</var/logs-%Y/moose-$isa$#porklips%d.$n> n -1 hasn 1 result </var/logs-[0-9]+/moose-ISAporklips[0-9]+\.([0-9]+)$0> 665*0Sstevel@tonic-gateexpand</var/logs-%Y/moose-$isa$#porklips%d.$n> n 0 hasn 1 result </var/logs-%Y/moose-ISAporklips%d.0> 666*0Sstevel@tonic-gateexpand</var/logs-%Y/moose-$isa$#porklips%d.$n> n 1 hasn 1 result </var/logs-%Y/moose-ISAporklips%d.1> 667*0Sstevel@tonic-gateEOF 668*0Sstevel@tonic-gate $percentd = `/bin/env TZ=UTC /bin/date +%d`; chomp $percentd; 669*0Sstevel@tonic-gate $percentY = `/bin/env TZ=UTC /bin/date +%Y`; chomp $percentY; 670*0Sstevel@tonic-gate $secondblob =~ s/%d/$percentd/mg; 671*0Sstevel@tonic-gate $secondblob =~ s/%Y/$percentY/mg; 672*0Sstevel@tonic-gate $secondblob =~ s/ISA/$isa/mg; 673*0Sstevel@tonic-gate chomp $secondblob; 674*0Sstevel@tonic-gate set_file('sed.out.expect', <<"EOF"); 675*0Sstevel@tonic-gate basename syslog 676*0Sstevel@tonic-gate dirname /var/log 677*0Sstevel@tonic-gate domain $domainname 678*0Sstevel@tonic-gate file /var/log/syslog 679*0Sstevel@tonic-gate home 680*0Sstevel@tonic-gate isa $isa 681*0Sstevel@tonic-gate logname 682*0Sstevel@tonic-gate machine $machine 683*0Sstevel@tonic-gate nfile 684*0Sstevel@tonic-gate nodename $nodename 685*0Sstevel@tonic-gate platform $platform 686*0Sstevel@tonic-gate release $release 687*0Sstevel@tonic-gate user 688*0Sstevel@tonic-gate$secondblob 689*0Sstevel@tonic-gateEOF 690*0Sstevel@tonic-gate 691*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 692*0Sstevel@tonic-gate[ -s std.err ] && exit 1 693*0Sstevel@tonic-gate/bin/sed -e '/^ *secs [0-9][0-9]*$/d'\ 694*0Sstevel@tonic-gate -e "s/%d/`/bin/env TZ=UTC /bin/date +%d`/g"\ 695*0Sstevel@tonic-gate -e "s/%Y/`/bin/env TZ=UTC /bin/date +%Y`/g"\ 696*0Sstevel@tonic-gate <std.out >sed.out 697*0Sstevel@tonic-gateexec /bin/diff sed.out sed.out.expect 698*0Sstevel@tonic-gateEOF 699*0Sstevel@tonic-gate 700*0Sstevel@tonic-gate $kwtest='kwtest /var/log/syslog \'$file.$n\' \'moose%d.$n\' \'/var/logs-%Y/moose-$isa$#porklips%d.$n\''; 701*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 702*0Sstevel@tonic-gate# test "kwtest2" 703*0Sstevel@tonic-gate$envsetup 704*0Sstevel@tonic-gateLOGNAME= 705*0Sstevel@tonic-gateexport LOGNAME 706*0Sstevel@tonic-gateHOME= 707*0Sstevel@tonic-gateexport HOME 708*0Sstevel@tonic-gateUSER= 709*0Sstevel@tonic-gateexport USER 710*0Sstevel@tonic-gateexec $bindir/$kwtest >std.out 2>std.err 711*0Sstevel@tonic-gateEOF 712*0Sstevel@tonic-gate} 713*0Sstevel@tonic-gate 714*0Sstevel@tonic-gate########################################################################### 715*0Sstevel@tonic-gate# 716*0Sstevel@tonic-gate# luttest1 -- minimal basic test of the lut.c code 717*0Sstevel@tonic-gate# 718*0Sstevel@tonic-gate########################################################################### 719*0Sstevel@tonic-gatesub luttest1 { 720*0Sstevel@tonic-gate set_file('std.out.expect', <<'EOF'); 721*0Sstevel@tonic-gatelut contains: 722*0Sstevel@tonic-gate<fix> <NULL> (<NULL>) 723*0Sstevel@tonic-gate<one> <two> (<two>) 724*0Sstevel@tonic-gate<seven> <eight> (<eight>) 725*0Sstevel@tonic-gate<six> <NULL> (<NULL>) 726*0Sstevel@tonic-gate<three> <four> (<four>) 727*0Sstevel@tonic-gatedup lut contains: 728*0Sstevel@tonic-gate<fix> <NULL> (<NULL>) 729*0Sstevel@tonic-gate<one> <two> (<two>) 730*0Sstevel@tonic-gate<seven> <eight> (<eight>) 731*0Sstevel@tonic-gate<six> <NULL> (<NULL>) 732*0Sstevel@tonic-gate<three> <four> (<four>) 733*0Sstevel@tonic-gateEOF 734*0Sstevel@tonic-gate 735*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 736*0Sstevel@tonic-gate[ -s std.err ] && exit 1 737*0Sstevel@tonic-gateexec /bin/diff std.out std.out.expect 738*0Sstevel@tonic-gateEOF 739*0Sstevel@tonic-gate 740*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 741*0Sstevel@tonic-gate# test "luttest1" 742*0Sstevel@tonic-gate$envsetup 743*0Sstevel@tonic-gateexec $bindir/luttest one=two three=four fix six seven=eight >std.out 2>std.err 744*0Sstevel@tonic-gateEOF 745*0Sstevel@tonic-gate} 746*0Sstevel@tonic-gate 747*0Sstevel@tonic-gate########################################################################### 748*0Sstevel@tonic-gate# 749*0Sstevel@tonic-gate# optstest1 -- minimal basic test of the opts.c code 750*0Sstevel@tonic-gate# 751*0Sstevel@tonic-gate########################################################################### 752*0Sstevel@tonic-gatesub optstest1 { 753*0Sstevel@tonic-gate $options="-a -b moose -c 1h -d 'Fri Nov 2 13:19:55 2001' -e 1k -f 2 one two three"; 754*0Sstevel@tonic-gate set_file('std.out.expect', <<"EOF"); 755*0Sstevel@tonic-gateoptions: $options 756*0Sstevel@tonic-gateEOF 757*0Sstevel@tonic-gate 758*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 759*0Sstevel@tonic-gate[ -s std.err ] && exit 1 760*0Sstevel@tonic-gateexec /bin/diff std.out std.out.expect 761*0Sstevel@tonic-gateEOF 762*0Sstevel@tonic-gate 763*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 764*0Sstevel@tonic-gate# test "optstest1" 765*0Sstevel@tonic-gate$envsetup 766*0Sstevel@tonic-gateexec $bindir/optstest $options >std.out 2>std.err 767*0Sstevel@tonic-gateEOF 768*0Sstevel@tonic-gate} 769*0Sstevel@tonic-gate 770*0Sstevel@tonic-gate########################################################################### 771*0Sstevel@tonic-gate# 772*0Sstevel@tonic-gate# optstest2 -- error path through opts.c code 773*0Sstevel@tonic-gate# 774*0Sstevel@tonic-gate########################################################################### 775*0Sstevel@tonic-gatesub optstest2 { 776*0Sstevel@tonic-gate $options="-a -b -c 1h -d 'Fri Nov 2 13:19:55 2001' -e 1k -f 2 one two three"; 777*0Sstevel@tonic-gate set_file('std.err.expect', <<'EOF'); 778*0Sstevel@tonic-gateoptstest: Error: Option 'b' requires an argument 779*0Sstevel@tonic-gateoptstest: Error: opts parsing failed 780*0Sstevel@tonic-gateEOF 781*0Sstevel@tonic-gate 782*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 783*0Sstevel@tonic-gate[ -s std.out ] && exit 1 784*0Sstevel@tonic-gateexec /bin/diff std.err std.err.expect 785*0Sstevel@tonic-gateEOF 786*0Sstevel@tonic-gate 787*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 788*0Sstevel@tonic-gate# test "optstest2" 789*0Sstevel@tonic-gate$envsetup 790*0Sstevel@tonic-gate$bindir/optstest $options >std.out 2>std.err || exit 0 791*0Sstevel@tonic-gateexit 1 792*0Sstevel@tonic-gateEOF 793*0Sstevel@tonic-gate} 794*0Sstevel@tonic-gate 795*0Sstevel@tonic-gate########################################################################### 796*0Sstevel@tonic-gate# 797*0Sstevel@tonic-gate# logadmV1 -- test of "logadm -V" 798*0Sstevel@tonic-gate# 799*0Sstevel@tonic-gate########################################################################### 800*0Sstevel@tonic-gatesub logadmV1 { 801*0Sstevel@tonic-gate set_testconffile; 802*0Sstevel@tonic-gate 803*0Sstevel@tonic-gate set_file('std.out.expect', <<'EOF'); 804*0Sstevel@tonic-gate/var/adm/messages -C 4 -P 'Thu Nov 1 16:56:42 2001' -a 'kill -HUP `cat /var/run/syslog.pid`' 805*0Sstevel@tonic-gate/var/cron/log -s 512k -t /var/cron/olog 806*0Sstevel@tonic-gate/var/lp/logs/lpsched -C 2 -N -t '$file.$N' 807*0Sstevel@tonic-gate/var/adm/pacct -C 0 -a '/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -p never 808*0Sstevel@tonic-gateapache -C 24 -a '/usr/apache/bin/apachectl graceful' -p 1m -t '/var/apache/old-logs/$basename.%Y-%m' '/var/apache/logs/*{access,error}_log' 809*0Sstevel@tonic-gate/var/log/syslog -C 8 -P 'Thu Nov 1 09:16:38 2001' -a 'kill -HUP `cat /var/run/syslog.pid`' 810*0Sstevel@tonic-gate/var/apache/logs/access_log -P 'Thu Nov 1 08:27:56 2001' 811*0Sstevel@tonic-gate/var/apache/logs/error_log -P 'Thu Nov 1 08:27:56 2001' 812*0Sstevel@tonic-gate/var/apache/logs/suexec_log -P 'Thu Nov 1 08:27:56 2001' 813*0Sstevel@tonic-gate/var/apache/logs/mod_jserv.log -P 'Thu Nov 1 08:27:56 2001' 814*0Sstevel@tonic-gate/var/apache/logs/jserv.log -P 'Thu Nov 1 08:27:56 2001' 815*0Sstevel@tonic-gateEOF 816*0Sstevel@tonic-gate 817*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 818*0Sstevel@tonic-gate[ -s std.err ] && exit 1 819*0Sstevel@tonic-gateexec /bin/diff std.out std.out.expect 820*0Sstevel@tonic-gateEOF 821*0Sstevel@tonic-gate 822*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 823*0Sstevel@tonic-gate# test "logadmV1" 824*0Sstevel@tonic-gate$envsetup 825*0Sstevel@tonic-gateexec $bindir/logadm -f testfile.conf -V >std.out 2>std.err 826*0Sstevel@tonic-gateEOF 827*0Sstevel@tonic-gate} 828*0Sstevel@tonic-gate 829*0Sstevel@tonic-gate########################################################################### 830*0Sstevel@tonic-gate# 831*0Sstevel@tonic-gate# logadmV2 -- test of "logadm -V <entry>" 832*0Sstevel@tonic-gate# 833*0Sstevel@tonic-gate########################################################################### 834*0Sstevel@tonic-gatesub logadmV2 { 835*0Sstevel@tonic-gate set_testconffile; 836*0Sstevel@tonic-gate 837*0Sstevel@tonic-gate set_file('std.out.expect', <<'EOF'); 838*0Sstevel@tonic-gate/var/cron/log -s 512k -t /var/cron/olog 839*0Sstevel@tonic-gate/var/adm/pacct -C 0 -a '/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -p never 840*0Sstevel@tonic-gateEOF 841*0Sstevel@tonic-gate 842*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 843*0Sstevel@tonic-gate[ -s std.err ] && exit 1 844*0Sstevel@tonic-gateexec /bin/diff std.out std.out.expect 845*0Sstevel@tonic-gateEOF 846*0Sstevel@tonic-gate 847*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 848*0Sstevel@tonic-gate# test "logadmV2" 849*0Sstevel@tonic-gate$envsetup 850*0Sstevel@tonic-gateexec $bindir/logadm -f testfile.conf -V /var/cron/log /var/adm/pacct >std.out 2>std.err 851*0Sstevel@tonic-gateEOF 852*0Sstevel@tonic-gate} 853*0Sstevel@tonic-gate 854*0Sstevel@tonic-gate########################################################################### 855*0Sstevel@tonic-gate# 856*0Sstevel@tonic-gate# logadmr -- test of "logadm -r <entry>" 857*0Sstevel@tonic-gate# 858*0Sstevel@tonic-gate########################################################################### 859*0Sstevel@tonic-gatesub logadmr { 860*0Sstevel@tonic-gate set_testconffile; 861*0Sstevel@tonic-gate set_testconffile('testfile.conf.orig'); 862*0Sstevel@tonic-gate 863*0Sstevel@tonic-gate set_file('diff.out.expect', <<'EOF'); 864*0Sstevel@tonic-gate17a18 865*0Sstevel@tonic-gate> /var/cron/log -s 512k -t /var/cron/olog 866*0Sstevel@tonic-gate21a23 867*0Sstevel@tonic-gate> /var/adm/pacct -C 0 -a '/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -p never 868*0Sstevel@tonic-gateEOF 869*0Sstevel@tonic-gate 870*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 871*0Sstevel@tonic-gate[ -s std.err ] && exit 1 872*0Sstevel@tonic-gate/bin/diff testfile.conf testfile.conf.orig > diff.out 873*0Sstevel@tonic-gateexec /bin/diff diff.out diff.out.expect 874*0Sstevel@tonic-gateEOF 875*0Sstevel@tonic-gate 876*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 877*0Sstevel@tonic-gate# test "logadmr" 878*0Sstevel@tonic-gate$envsetup 879*0Sstevel@tonic-gateexec $bindir/logadm -f testfile.conf -r /var/cron/log /var/adm/pacct >std.out 2>std.err 880*0Sstevel@tonic-gateEOF 881*0Sstevel@tonic-gate} 882*0Sstevel@tonic-gate 883*0Sstevel@tonic-gate########################################################################### 884*0Sstevel@tonic-gate# 885*0Sstevel@tonic-gate# logadmw -- test of "logadm -w <entry>" 886*0Sstevel@tonic-gate# 887*0Sstevel@tonic-gate########################################################################### 888*0Sstevel@tonic-gatesub logadmw { 889*0Sstevel@tonic-gate set_testconffile; 890*0Sstevel@tonic-gate set_testconffile('testfile.conf.orig'); 891*0Sstevel@tonic-gate 892*0Sstevel@tonic-gate set_file('diff.out.expect', <<'EOF'); 893*0Sstevel@tonic-gate31d30 894*0Sstevel@tonic-gate< moose -C 20 -a moose_after_cmd -g pig -m 664 -o cow -p never /moose/file 895*0Sstevel@tonic-gateEOF 896*0Sstevel@tonic-gate 897*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 898*0Sstevel@tonic-gate[ -s std.err ] && exit 1 899*0Sstevel@tonic-gate/bin/diff testfile.conf testfile.conf.orig > diff.out 900*0Sstevel@tonic-gateexec /bin/diff diff.out diff.out.expect 901*0Sstevel@tonic-gateEOF 902*0Sstevel@tonic-gate 903*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 904*0Sstevel@tonic-gate# test "logadmw" 905*0Sstevel@tonic-gate$envsetup 906*0Sstevel@tonic-gateexec $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 907*0Sstevel@tonic-gateEOF 908*0Sstevel@tonic-gate} 909*0Sstevel@tonic-gate 910*0Sstevel@tonic-gate########################################################################### 911*0Sstevel@tonic-gate# 912*0Sstevel@tonic-gate# logadm1 -- minimal basic test of logadm rotation 913*0Sstevel@tonic-gate# 914*0Sstevel@tonic-gate########################################################################### 915*0Sstevel@tonic-gatesub logadm1 { 916*0Sstevel@tonic-gate set_file('logfile', 'initially logfile'); 917*0Sstevel@tonic-gate set_file('logfile.0', 'initially logfile.0'); 918*0Sstevel@tonic-gate my ($stdev, $stino, $stmode, $stnlink, $stuid, $stgid, $strdev, 919*0Sstevel@tonic-gate $stsize, $statime, $stmtime, $stctime, $stblksize, $stblocks) = 920*0Sstevel@tonic-gate lstat 'logfile' or die "lstat logfile: $!\n"; 921*0Sstevel@tonic-gate 922*0Sstevel@tonic-gate set_file('checktest', <<"EOF"); 923*0Sstevel@tonic-gate[ -s std.err ] && exit 1 924*0Sstevel@tonic-gate[ -s std.out ] && exit 1 925*0Sstevel@tonic-gate[ -s logfile ] && exit 1 926*0Sstevel@tonic-gate[ -f logfile.0 ] || exit 1 927*0Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat logfile.0`" ] || exit 1 928*0Sstevel@tonic-gate[ "`/bin/ls -i logfile.0 | /bin/awk '{ print \$1; }'`" = "$stino" ] || exit 1 929*0Sstevel@tonic-gate[ -f logfile.1 ] || exit 1 930*0Sstevel@tonic-gate[ "xinitially logfile.0" = "x`/bin/cat logfile.1`" ] || exit 1 931*0Sstevel@tonic-gateexit 0 932*0Sstevel@tonic-gateEOF 933*0Sstevel@tonic-gate 934*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 935*0Sstevel@tonic-gate# test "logadm1" 936*0Sstevel@tonic-gate$envsetup 937*0Sstevel@tonic-gateexec $bindir/logadm -f /dev/null -p now logfile >std.out 2>std.err 938*0Sstevel@tonic-gateEOF 939*0Sstevel@tonic-gate} 940*0Sstevel@tonic-gate 941*0Sstevel@tonic-gate########################################################################### 942*0Sstevel@tonic-gate# 943*0Sstevel@tonic-gate# logadm1c -- same as logadm1 but with -c option 944*0Sstevel@tonic-gate# 945*0Sstevel@tonic-gate########################################################################### 946*0Sstevel@tonic-gatesub logadm1c { 947*0Sstevel@tonic-gate set_file('logfile', 'initially logfile'); 948*0Sstevel@tonic-gate set_file('logfile.0', 'initially logfile.0'); 949*0Sstevel@tonic-gate my ($stdev, $stino, $stmode, $stnlink, $stuid, $stgid, $strdev, 950*0Sstevel@tonic-gate $stsize, $statime, $stmtime, $stctime, $stblksize, $stblocks) = 951*0Sstevel@tonic-gate lstat 'logfile' or die "lstat logfile: $!\n"; 952*0Sstevel@tonic-gate 953*0Sstevel@tonic-gate set_file('checktest', <<"EOF"); 954*0Sstevel@tonic-gate[ -s std.err ] && exit 1 955*0Sstevel@tonic-gate[ -s std.out ] && exit 1 956*0Sstevel@tonic-gate[ -s logfile ] && exit 1 957*0Sstevel@tonic-gate[ -f logfile.0 ] || exit 1 958*0Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat logfile.0`" ] || exit 1 959*0Sstevel@tonic-gate[ "`/bin/ls -i logfile.0 | /bin/awk '{ print \$1; }'`" = "$stino" ] && exit 1 960*0Sstevel@tonic-gate[ -f logfile.1 ] || exit 1 961*0Sstevel@tonic-gate[ "xinitially logfile.0" = "x`/bin/cat logfile.1`" ] || exit 1 962*0Sstevel@tonic-gateexit 0 963*0Sstevel@tonic-gateEOF 964*0Sstevel@tonic-gate 965*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 966*0Sstevel@tonic-gate# test "logadm1c" 967*0Sstevel@tonic-gate$envsetup 968*0Sstevel@tonic-gateexec $bindir/logadm -f /dev/null -p now -c logfile >std.out 2>std.err 969*0Sstevel@tonic-gateEOF 970*0Sstevel@tonic-gate} 971*0Sstevel@tonic-gate 972*0Sstevel@tonic-gate########################################################################### 973*0Sstevel@tonic-gate# 974*0Sstevel@tonic-gate# logadm2 -- minimal basic test of logadm expiration 975*0Sstevel@tonic-gate# 976*0Sstevel@tonic-gate########################################################################### 977*0Sstevel@tonic-gatesub logadm2 { 978*0Sstevel@tonic-gate set_file('logfile', 'initially logfile'); 979*0Sstevel@tonic-gate set_file('logfile.0', 'initially logfile.0'); 980*0Sstevel@tonic-gate set_file('logfile.1', 'initially logfile.1'); 981*0Sstevel@tonic-gate 982*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 983*0Sstevel@tonic-gate[ -s std.err ] && exit 1 984*0Sstevel@tonic-gate[ -s std.out ] && exit 1 985*0Sstevel@tonic-gate[ -s logfile ] && exit 1 986*0Sstevel@tonic-gate[ -f logfile.0 ] || exit 1 987*0Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat logfile.0`" ] || exit 1 988*0Sstevel@tonic-gate[ -f logfile.1 ] || exit 1 989*0Sstevel@tonic-gate[ "xinitially logfile.0" = "x`/bin/cat logfile.1`" ] || exit 1 990*0Sstevel@tonic-gate[ -f logfile.2 ] && exit 1 991*0Sstevel@tonic-gateexit 0 992*0Sstevel@tonic-gateEOF 993*0Sstevel@tonic-gate 994*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 995*0Sstevel@tonic-gate# test "logadm2" 996*0Sstevel@tonic-gate$envsetup 997*0Sstevel@tonic-gateexec $bindir/logadm -f /dev/null -p now logfile -C2 >std.out 2>std.err 998*0Sstevel@tonic-gateEOF 999*0Sstevel@tonic-gate} 1000*0Sstevel@tonic-gate 1001*0Sstevel@tonic-gate########################################################################### 1002*0Sstevel@tonic-gate# 1003*0Sstevel@tonic-gate# logadm3 -- minimal basic test of logadm pre/post-commands 1004*0Sstevel@tonic-gate# 1005*0Sstevel@tonic-gate########################################################################### 1006*0Sstevel@tonic-gatesub logadm3 { 1007*0Sstevel@tonic-gate set_file('logfile', 'initially logfile'); 1008*0Sstevel@tonic-gate set_file('logfile.0', 'initially logfile.0'); 1009*0Sstevel@tonic-gate set_file('logfile.1', 'initially logfile.1'); 1010*0Sstevel@tonic-gate 1011*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1012*0Sstevel@tonic-gate[ -s std.err ] && exit 1 1013*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1014*0Sstevel@tonic-gate[ -s logfile ] && exit 1 1015*0Sstevel@tonic-gate[ -f logfile.0 ] || exit 1 1016*0Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat logfile.0`" ] || exit 1 1017*0Sstevel@tonic-gate[ -f logfile.1 ] || exit 1 1018*0Sstevel@tonic-gate[ "xinitially logfile.0" = "x`/bin/cat logfile.1`" ] || exit 1 1019*0Sstevel@tonic-gate[ -f logfile.2 ] && exit 1 1020*0Sstevel@tonic-gate[ -f pre.out ] || exit 1 1021*0Sstevel@tonic-gate[ "xpre-command-stuff" = "x`/bin/cat pre.out`" ] || exit 1 1022*0Sstevel@tonic-gate[ -f post.out ] || exit 1 1023*0Sstevel@tonic-gate[ "xpost-command-stuff" = "x`/bin/cat post.out`" ] || exit 1 1024*0Sstevel@tonic-gateexit 0 1025*0Sstevel@tonic-gateEOF 1026*0Sstevel@tonic-gate 1027*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1028*0Sstevel@tonic-gate# test "logadm3" 1029*0Sstevel@tonic-gate$envsetup 1030*0Sstevel@tonic-gateexec $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 1031*0Sstevel@tonic-gateEOF 1032*0Sstevel@tonic-gate} 1033*0Sstevel@tonic-gate 1034*0Sstevel@tonic-gate########################################################################### 1035*0Sstevel@tonic-gate# 1036*0Sstevel@tonic-gate# logadm4 -- test of -t template 1037*0Sstevel@tonic-gate# 1038*0Sstevel@tonic-gate########################################################################### 1039*0Sstevel@tonic-gatesub logadm4 { 1040*0Sstevel@tonic-gate set_file('logfile', 'initially logfile'); 1041*0Sstevel@tonic-gate 1042*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1043*0Sstevel@tonic-gate[ -s std.err ] && exit 1 1044*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1045*0Sstevel@tonic-gate[ -s logfile ] && exit 1 1046*0Sstevel@tonic-gateTZ=UTC export TZ 1047*0Sstevel@tonic-gated=`/bin/date +%d` 1048*0Sstevel@tonic-gate[ -f logfile.$d ] || exit 1 1049*0Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat logfile.$d`" ] || exit 1 1050*0Sstevel@tonic-gateexit 0 1051*0Sstevel@tonic-gateEOF 1052*0Sstevel@tonic-gate 1053*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1054*0Sstevel@tonic-gate# test "logadm4" 1055*0Sstevel@tonic-gate$envsetup 1056*0Sstevel@tonic-gateexec $bindir/logadm -f /dev/null -p now logfile -t '\$file.\%d' >std.out 2>std.err 1057*0Sstevel@tonic-gateEOF 1058*0Sstevel@tonic-gate} 1059*0Sstevel@tonic-gate 1060*0Sstevel@tonic-gate########################################################################### 1061*0Sstevel@tonic-gate# 1062*0Sstevel@tonic-gate# logadm5 -- test of -R cmd and -E cmd 1063*0Sstevel@tonic-gate# 1064*0Sstevel@tonic-gate########################################################################### 1065*0Sstevel@tonic-gatesub logadm5 { 1066*0Sstevel@tonic-gate set_file('logfile', 'initially logfile'); 1067*0Sstevel@tonic-gate set_file('logfile.0', 'initially logfile.0'); 1068*0Sstevel@tonic-gate 1069*0Sstevel@tonic-gate set_file('cmd.out.expect', <<'EOF'); 1070*0Sstevel@tonic-gatejust rotated: initially logfile 1071*0Sstevel@tonic-gatejust expired: initially logfile.0 1072*0Sstevel@tonic-gateEOF 1073*0Sstevel@tonic-gate 1074*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1075*0Sstevel@tonic-gate[ -s std.err ] && exit 1 1076*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1077*0Sstevel@tonic-gate[ -s logfile ] && exit 1 1078*0Sstevel@tonic-gate[ -f logfile.0 ] || exit 1 1079*0Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat logfile.0`" ] || exit 1 1080*0Sstevel@tonic-gate[ -f logfile.1 ] || exit 1 1081*0Sstevel@tonic-gate[ "xinitially logfile.0" = "x`/bin/cat logfile.1`" ] || exit 1 1082*0Sstevel@tonic-gateexec /bin/diff cmd.out cmd.out.expect 1083*0Sstevel@tonic-gateEOF 1084*0Sstevel@tonic-gate 1085*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1086*0Sstevel@tonic-gate# test "logadm5" 1087*0Sstevel@tonic-gate$envsetup 1088*0Sstevel@tonic-gateexec $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 1089*0Sstevel@tonic-gateEOF 1090*0Sstevel@tonic-gate} 1091*0Sstevel@tonic-gate 1092*0Sstevel@tonic-gate########################################################################### 1093*0Sstevel@tonic-gate# 1094*0Sstevel@tonic-gate# logadm6 -- test of -m, -o, -g 1095*0Sstevel@tonic-gate# 1096*0Sstevel@tonic-gate########################################################################### 1097*0Sstevel@tonic-gatesub logadm6 { 1098*0Sstevel@tonic-gate set_file('logfile', 'initially logfile'); 1099*0Sstevel@tonic-gate 1100*0Sstevel@tonic-gate set_file('std.err.expect', <<'EOF'); 1101*0Sstevel@tonic-gatelogadm: Warning: command failed: /bin/chown _nonexistentuser_:_nonexistentgroup_ logfile 1102*0Sstevel@tonic-gatechown: unknown group id _nonexistentgroup_ 1103*0Sstevel@tonic-gateEOF 1104*0Sstevel@tonic-gate 1105*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1106*0Sstevel@tonic-gate[ -s std.err ] || exit 1 1107*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1108*0Sstevel@tonic-gate[ -s logfile ] && exit 1 1109*0Sstevel@tonic-gate[ -f logfile.0 ] || exit 1 1110*0Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat logfile.0`" ] || exit 1 1111*0Sstevel@tonic-gate[ "`/bin/ls -l logfile | /bin/awk '{ print $1; }'`" = "-r----x--x" ] || exit 1 1112*0Sstevel@tonic-gateexec /bin/diff std.err std.err.expect 1113*0Sstevel@tonic-gateEOF 1114*0Sstevel@tonic-gate 1115*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1116*0Sstevel@tonic-gate# test "logadm6" 1117*0Sstevel@tonic-gate$envsetup 1118*0Sstevel@tonic-gateexec $bindir/logadm -f /dev/null -p now logfile -m 411 -o _nonexistentuser_ -g _nonexistentgroup_ >std.out 2>std.err 1119*0Sstevel@tonic-gateEOF 1120*0Sstevel@tonic-gate} 1121*0Sstevel@tonic-gate 1122*0Sstevel@tonic-gate########################################################################### 1123*0Sstevel@tonic-gate# 1124*0Sstevel@tonic-gate# logadm7 -- test running through a conffile 1125*0Sstevel@tonic-gate# 1126*0Sstevel@tonic-gate########################################################################### 1127*0Sstevel@tonic-gatesub logadm7 { 1128*0Sstevel@tonic-gate mkdir 'dir1', 0777 or die "mkdir dir1: $!\n"; 1129*0Sstevel@tonic-gate set_file('dir1/syslog', 'initially dir1/syslog'); 1130*0Sstevel@tonic-gate set_file('dir1/syslog.0', 'initially dir1/syslog.0'); 1131*0Sstevel@tonic-gate set_file('dir1/syslog.1', 'initially dir1/syslog.1'); 1132*0Sstevel@tonic-gate set_file('dir1/syslog.2', 'initially dir1/syslog.2'); 1133*0Sstevel@tonic-gate set_file('dir1/syslog.3', 'initially dir1/syslog.3'); 1134*0Sstevel@tonic-gate set_file('dir1/syslog.4', 'initially dir1/syslog.4'); 1135*0Sstevel@tonic-gate set_file('dir1/syslog.5', 'initially dir1/syslog.5'); 1136*0Sstevel@tonic-gate set_file('dir1/syslog.6', 'initially dir1/syslog.6'); 1137*0Sstevel@tonic-gate set_file('dir1/syslog.7', 'initially dir1/syslog.7'); 1138*0Sstevel@tonic-gate mkdir 'dir2', 0777 or die "mkdir dir2: $!\n"; 1139*0Sstevel@tonic-gate set_file('dir2/messages', 'initially dir2/messages'); 1140*0Sstevel@tonic-gate set_file('dir2/messages.0', 'initially dir2/messages.0'); 1141*0Sstevel@tonic-gate set_file('dir2/messages.1', 'initially dir2/messages.1'); 1142*0Sstevel@tonic-gate set_file('dir2/messages.2', 'initially dir2/messages.2'); 1143*0Sstevel@tonic-gate set_file('dir2/messages.3', 'initially dir2/messages.3'); 1144*0Sstevel@tonic-gate 1145*0Sstevel@tonic-gate set_file('logadm.conf', <<'EOF'); 1146*0Sstevel@tonic-gate# 1147*0Sstevel@tonic-gate# logadm.conf 1148*0Sstevel@tonic-gate# 1149*0Sstevel@tonic-gate# this comment # has at least another #-sign in it #... 1150*0Sstevel@tonic-gate# 1151*0Sstevel@tonic-gate# Default settings for system log file management. 1152*0Sstevel@tonic-gate# The -w option to logadm(1M) is the preferred way to write to this file, 1153*0Sstevel@tonic-gate# but if you do edit it by hand, use "logadm -V" to check it for errors. 1154*0Sstevel@tonic-gate# but if you do edit it by hand, use "logadm -V" to check it for errors. 1155*0Sstevel@tonic-gate# 1156*0Sstevel@tonic-gate# The format of lines in this file is: 1157*0Sstevel@tonic-gate# <logname> <options> 1158*0Sstevel@tonic-gate# For each logname listed here, the default options to logadm 1159*0Sstevel@tonic-gate# are given. Options given on the logadm command line override 1160*0Sstevel@tonic-gate# the defaults contained in this file. 1161*0Sstevel@tonic-gate# 1162*0Sstevel@tonic-gate# logadm typically runs early every morning via an entry in 1163*0Sstevel@tonic-gate# root's crontab (see crontab(1)). 1164*0Sstevel@tonic-gate# 1165*0Sstevel@tonic-gatedir1/syslog -C 8 -a 'echo kill -HUP `cat /etc/syslog.pid` >> cmd.out' 1166*0Sstevel@tonic-gatedir2/messages -C 4 -a 'echo kill -HUP `cat /etc/syslog.pid` >> cmd.out' 1167*0Sstevel@tonic-gate# 1168*0Sstevel@tonic-gate# The entry below is used by turnacct(1M) 1169*0Sstevel@tonic-gate# 1170*0Sstevel@tonic-gate/var/adm/pacct -C 0 -a '/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -p never 1171*0Sstevel@tonic-gateEOF 1172*0Sstevel@tonic-gate 1173*0Sstevel@tonic-gate system("/bin/cp logadm.conf logadm.conf.orig"); 1174*0Sstevel@tonic-gate 1175*0Sstevel@tonic-gate $pid=`cat /etc/syslog.pid`; 1176*0Sstevel@tonic-gate chomp $pid; 1177*0Sstevel@tonic-gate set_file('cmd.out.expect', <<"EOF"); 1178*0Sstevel@tonic-gatekill -HUP $pid 1179*0Sstevel@tonic-gatesecond kill -HUP $pid 1180*0Sstevel@tonic-gateEOF 1181*0Sstevel@tonic-gate 1182*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1183*0Sstevel@tonic-gate[ -s std.err ] && exit 1 1184*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1185*0Sstevel@tonic-gate[ -s std.err2 ] && exit 1 1186*0Sstevel@tonic-gate[ -s std.out2 ] && exit 1 1187*0Sstevel@tonic-gate[ -s std.err3 ] && exit 1 1188*0Sstevel@tonic-gate[ -s std.out3 ] && exit 1 1189*0Sstevel@tonic-gate[ -s std.err4 ] && exit 1 1190*0Sstevel@tonic-gate[ -s std.out4 ] && exit 1 1191*0Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1 1192*0Sstevel@tonic-gate[ "xsomething" = "x`/bin/cat dir1/syslog`" ] || exit 1 1193*0Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1 1194*0Sstevel@tonic-gate[ "xinitially dir1/syslog" = "x`/bin/cat dir1/syslog.0`" ] || exit 1 1195*0Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1 1196*0Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.1`" ] || exit 1 1197*0Sstevel@tonic-gate[ -f dir1/syslog.2 ] || exit 1 1198*0Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/cat dir1/syslog.2`" ] || exit 1 1199*0Sstevel@tonic-gate[ -f dir1/syslog.3 ] || exit 1 1200*0Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/cat dir1/syslog.3`" ] || exit 1 1201*0Sstevel@tonic-gate[ -f dir1/syslog.4 ] || exit 1 1202*0Sstevel@tonic-gate[ "xinitially dir1/syslog.3" = "x`/bin/cat dir1/syslog.4`" ] || exit 1 1203*0Sstevel@tonic-gate[ -f dir1/syslog.5 ] || exit 1 1204*0Sstevel@tonic-gate[ "xinitially dir1/syslog.4" = "x`/bin/cat dir1/syslog.5`" ] || exit 1 1205*0Sstevel@tonic-gate[ -f dir1/syslog.6 ] || exit 1 1206*0Sstevel@tonic-gate[ "xinitially dir1/syslog.5" = "x`/bin/cat dir1/syslog.6`" ] || exit 1 1207*0Sstevel@tonic-gate[ -f dir1/syslog.7 ] || exit 1 1208*0Sstevel@tonic-gate[ "xinitially dir1/syslog.6" = "x`/bin/cat dir1/syslog.7`" ] || exit 1 1209*0Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1 1210*0Sstevel@tonic-gate 1211*0Sstevel@tonic-gate[ -s dir2/messages ] && exit 1 1212*0Sstevel@tonic-gate[ -f dir2/messages.0 ] || exit 1 1213*0Sstevel@tonic-gate[ "xsomething" = "x`/bin/cat dir2/messages.0`" ] || exit 1 1214*0Sstevel@tonic-gate[ -f dir2/messages.1 ] || exit 1 1215*0Sstevel@tonic-gate[ "xinitially dir2/messages" = "x`/bin/cat dir2/messages.1`" ] || exit 1 1216*0Sstevel@tonic-gate[ -f dir2/messages.2 ] || exit 1 1217*0Sstevel@tonic-gate[ "xinitially dir2/messages.0" = "x`/bin/cat dir2/messages.2`" ] || exit 1 1218*0Sstevel@tonic-gate[ -f dir2/messages.3 ] || exit 1 1219*0Sstevel@tonic-gate[ "xinitially dir2/messages.1" = "x`/bin/cat dir2/messages.3`" ] || exit 1 1220*0Sstevel@tonic-gate[ -f dir2/messages.4 ] && exit 1 1221*0Sstevel@tonic-gate/bin/sed "s/-P '[^']*' *//" < logadm.conf > sed.out 1222*0Sstevel@tonic-gateexec /bin/diff sed.out logadm.conf.orig 1223*0Sstevel@tonic-gateEOF 1224*0Sstevel@tonic-gate 1225*0Sstevel@tonic-gate # first logadm call will rotate both syslog and messages 1226*0Sstevel@tonic-gate # second one won't because size is zero 1227*0Sstevel@tonic-gate # third one won't because of -P timestamps stored in conffile 1228*0Sstevel@tonic-gate # fourth one will do messages because of -p now on command line 1229*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1230*0Sstevel@tonic-gate# test "logadm7" 1231*0Sstevel@tonic-gate$envsetup 1232*0Sstevel@tonic-gate$bindir/logadm -f logadm.conf >std.out 2>std.err || exit 1 1233*0Sstevel@tonic-gate$bindir/logadm -f logadm.conf dir1/syslog dir2/messages >std.out2 2>std.err2 || exit 1 1234*0Sstevel@tonic-gateecho something > dir1/syslog 1235*0Sstevel@tonic-gateecho something > dir2/messages 1236*0Sstevel@tonic-gate$bindir/logadm -f logadm.conf >std.out3 2>std.err3 || exit 1 1237*0Sstevel@tonic-gateexec $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 1238*0Sstevel@tonic-gateEOF 1239*0Sstevel@tonic-gate} 1240*0Sstevel@tonic-gate 1241*0Sstevel@tonic-gate########################################################################### 1242*0Sstevel@tonic-gate# 1243*0Sstevel@tonic-gate# logadm8 -- test of -z 1244*0Sstevel@tonic-gate# 1245*0Sstevel@tonic-gate########################################################################### 1246*0Sstevel@tonic-gatesub logadm8 { 1247*0Sstevel@tonic-gate mkdir 'dir1', 0777 or die "mkdir dir1: $!\n"; 1248*0Sstevel@tonic-gate set_file('dir1/syslog', 'initially dir1/syslog'); 1249*0Sstevel@tonic-gate set_file('dir1/syslog.0', 'initially dir1/syslog.0'); 1250*0Sstevel@tonic-gate set_file('dir1/syslog.1', 'initially dir1/syslog.1'); 1251*0Sstevel@tonic-gate set_file('dir1/syslog.2', 'initially dir1/syslog.2'); 1252*0Sstevel@tonic-gate system("/bin/gzip dir1/syslog.2"); 1253*0Sstevel@tonic-gate die "gzip dir1/syslog.2 didn't work\n" unless -f 'dir1/syslog.2.gz'; 1254*0Sstevel@tonic-gate set_file('dir1/syslog.3', 'initially dir1/syslog.3'); 1255*0Sstevel@tonic-gate system("/bin/gzip dir1/syslog.3"); 1256*0Sstevel@tonic-gate die "gzip dir1/syslog.3 didn't work\n" unless -f 'dir1/syslog.3.gz'; 1257*0Sstevel@tonic-gate set_file('dir1/syslog.4', 'initially dir1/syslog.4'); 1258*0Sstevel@tonic-gate system("/bin/gzip dir1/syslog.4"); 1259*0Sstevel@tonic-gate die "gzip dir1/syslog.4 didn't work\n" unless -f 'dir1/syslog.4.gz'; 1260*0Sstevel@tonic-gate set_file('dir1/syslog.5', 'initially dir1/syslog.5'); 1261*0Sstevel@tonic-gate system("/bin/gzip dir1/syslog.5"); 1262*0Sstevel@tonic-gate die "gzip dir1/syslog.5 didn't work\n" unless -f 'dir1/syslog.5.gz'; 1263*0Sstevel@tonic-gate set_file('dir1/syslog.6', 'initially dir1/syslog.6'); 1264*0Sstevel@tonic-gate system("/bin/gzip dir1/syslog.6"); 1265*0Sstevel@tonic-gate die "gzip dir1/syslog.6 didn't work\n" unless -f 'dir1/syslog.6.gz'; 1266*0Sstevel@tonic-gate set_file('dir1/syslog.7', 'initially dir1/syslog.7'); 1267*0Sstevel@tonic-gate system("/bin/gzip dir1/syslog.7"); 1268*0Sstevel@tonic-gate die "gzip dir1/syslog.7 didn't work\n" unless -f 'dir1/syslog.7.gz'; 1269*0Sstevel@tonic-gate 1270*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1271*0Sstevel@tonic-gate[ -s std.err ] && exit 1 1272*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1273*0Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1 1274*0Sstevel@tonic-gate[ -s dir1/syslog ] && exit 1 1275*0Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1 1276*0Sstevel@tonic-gate[ "xinitially dir1/syslog" = "x`/bin/cat dir1/syslog.0`" ] || exit 1 1277*0Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1 1278*0Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.1`" ] || exit 1 1279*0Sstevel@tonic-gate[ -f dir1/syslog.2.gz ] || exit 1 1280*0Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/gzcat dir1/syslog.2.gz`" ] || exit 1 1281*0Sstevel@tonic-gate[ -f dir1/syslog.3.gz ] || exit 1 1282*0Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/gzcat dir1/syslog.3.gz`" ] || exit 1 1283*0Sstevel@tonic-gate[ -f dir1/syslog.4.gz ] || exit 1 1284*0Sstevel@tonic-gate[ "xinitially dir1/syslog.3" = "x`/bin/gzcat dir1/syslog.4.gz`" ] || exit 1 1285*0Sstevel@tonic-gate[ -f dir1/syslog.5.gz ] || exit 1 1286*0Sstevel@tonic-gate[ "xinitially dir1/syslog.4" = "x`/bin/gzcat dir1/syslog.5.gz`" ] || exit 1 1287*0Sstevel@tonic-gate[ -f dir1/syslog.6.gz ] || exit 1 1288*0Sstevel@tonic-gate[ "xinitially dir1/syslog.5" = "x`/bin/gzcat dir1/syslog.6.gz`" ] || exit 1 1289*0Sstevel@tonic-gate[ -f dir1/syslog.7.gz ] || exit 1 1290*0Sstevel@tonic-gate[ "xinitially dir1/syslog.6" = "x`/bin/gzcat dir1/syslog.7.gz`" ] || exit 1 1291*0Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1 1292*0Sstevel@tonic-gate[ -f dir1/syslog.8.gz ] && exit 1 1293*0Sstevel@tonic-gateexit 0 1294*0Sstevel@tonic-gateEOF 1295*0Sstevel@tonic-gate 1296*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1297*0Sstevel@tonic-gate# test "logadm8" 1298*0Sstevel@tonic-gate$envsetup 1299*0Sstevel@tonic-gateexec $bindir/logadm -f /dev/null dir1/syslog -z 2 -C 8 >std.out 2>std.err 1300*0Sstevel@tonic-gateEOF 1301*0Sstevel@tonic-gate} 1302*0Sstevel@tonic-gate 1303*0Sstevel@tonic-gate########################################################################### 1304*0Sstevel@tonic-gate# 1305*0Sstevel@tonic-gate# logadm9 -- test of age check 1306*0Sstevel@tonic-gate# 1307*0Sstevel@tonic-gate########################################################################### 1308*0Sstevel@tonic-gatesub logadm9 { 1309*0Sstevel@tonic-gate mkdir 'dir1', 0777 or die "mkdir dir1: $!\n"; 1310*0Sstevel@tonic-gate set_file('dir1/syslog', 'initially dir1/syslog'); 1311*0Sstevel@tonic-gate set_file('dir1/syslog.0', 'initially dir1/syslog.0'); 1312*0Sstevel@tonic-gate set_file('dir1/syslog.1', 'initially dir1/syslog.1'); 1313*0Sstevel@tonic-gate set_file('dir1/syslog.2', 'initially dir1/syslog.2'); 1314*0Sstevel@tonic-gate set_file('dir1/syslog.3', 'initially dir1/syslog.3'); 1315*0Sstevel@tonic-gate set_file('dir1/syslog.4', 'initially dir1/syslog.4'); 1316*0Sstevel@tonic-gate set_file('dir1/syslog.5', 'initially dir1/syslog.5'); 1317*0Sstevel@tonic-gate set_file('dir1/syslog.6', 'initially dir1/syslog.6'); 1318*0Sstevel@tonic-gate set_file('dir1/syslog.7', 'initially dir1/syslog.7'); 1319*0Sstevel@tonic-gate mkdir 'dir2', 0777 or die "mkdir dir2: $!\n"; 1320*0Sstevel@tonic-gate set_file('dir2/messages', 'initially dir2/messages'); 1321*0Sstevel@tonic-gate set_file('dir2/messages.0', 'initially dir2/messages.0'); 1322*0Sstevel@tonic-gate set_file('dir2/messages.1', 'initially dir2/messages.1'); 1323*0Sstevel@tonic-gate set_file('dir2/messages.2', 'initially dir2/messages.2'); 1324*0Sstevel@tonic-gate set_file('dir2/messages.3', 'initially dir2/messages.3'); 1325*0Sstevel@tonic-gate 1326*0Sstevel@tonic-gate $now = time; 1327*0Sstevel@tonic-gate $nowstr = gmtime($now); 1328*0Sstevel@tonic-gate # a week minus 30 seconds ago... 1329*0Sstevel@tonic-gate # technically not a full week, but the heuristic used by logadm 1330*0Sstevel@tonic-gate # should think this is "close enough" to a full week 1331*0Sstevel@tonic-gate $closetoweeksecs = $now - (60 * 60 * 24 * 7 - 30); 1332*0Sstevel@tonic-gate $closetoweek = gmtime($closetoweeksecs); 1333*0Sstevel@tonic-gate # a week minus six hours ago... 1334*0Sstevel@tonic-gate $lessthanweeksecs = $now - (60 * 60 * 24 * 7 - 60 * 60 * 6); 1335*0Sstevel@tonic-gate $lessthanweek = gmtime($lessthanweeksecs); 1336*0Sstevel@tonic-gate 1337*0Sstevel@tonic-gate set_file('logadm.conf', <<"EOF"); 1338*0Sstevel@tonic-gate# now: $nowstr is $now 1339*0Sstevel@tonic-gate# $closetoweek is $closetoweeksecs 1340*0Sstevel@tonic-gatedir1/syslog -C 8 -P '$closetoweek' 1341*0Sstevel@tonic-gate# $lessthanweek is $lessthanweeksecs 1342*0Sstevel@tonic-gatedir2/messages -C 4 -P '$lessthanweek' 1343*0Sstevel@tonic-gateEOF 1344*0Sstevel@tonic-gate 1345*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1346*0Sstevel@tonic-gate[ -s std.err ] && exit 1 1347*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1348*0Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1 1349*0Sstevel@tonic-gate[ -s dir1/syslog ] && exit 1 1350*0Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1 1351*0Sstevel@tonic-gate[ "xinitially dir1/syslog" = "x`/bin/cat dir1/syslog.0`" ] || exit 1 1352*0Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1 1353*0Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.1`" ] || exit 1 1354*0Sstevel@tonic-gate[ -f dir1/syslog.2 ] || exit 1 1355*0Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/cat dir1/syslog.2`" ] || exit 1 1356*0Sstevel@tonic-gate[ -f dir1/syslog.3 ] || exit 1 1357*0Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/cat dir1/syslog.3`" ] || exit 1 1358*0Sstevel@tonic-gate[ -f dir1/syslog.4 ] || exit 1 1359*0Sstevel@tonic-gate[ "xinitially dir1/syslog.3" = "x`/bin/cat dir1/syslog.4`" ] || exit 1 1360*0Sstevel@tonic-gate[ -f dir1/syslog.5 ] || exit 1 1361*0Sstevel@tonic-gate[ "xinitially dir1/syslog.4" = "x`/bin/cat dir1/syslog.5`" ] || exit 1 1362*0Sstevel@tonic-gate[ -f dir1/syslog.6 ] || exit 1 1363*0Sstevel@tonic-gate[ "xinitially dir1/syslog.5" = "x`/bin/cat dir1/syslog.6`" ] || exit 1 1364*0Sstevel@tonic-gate[ -f dir1/syslog.7 ] || exit 1 1365*0Sstevel@tonic-gate[ "xinitially dir1/syslog.6" = "x`/bin/cat dir1/syslog.7`" ] || exit 1 1366*0Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1 1367*0Sstevel@tonic-gate 1368*0Sstevel@tonic-gate[ -f dir2/messages ] || exit 1 1369*0Sstevel@tonic-gate[ "xinitially dir2/messages" = "x`/bin/cat dir2/messages`" ] || exit 1 1370*0Sstevel@tonic-gate[ -f dir2/messages.0 ] || exit 1 1371*0Sstevel@tonic-gate[ "xinitially dir2/messages.0" = "x`/bin/cat dir2/messages.0`" ] || exit 1 1372*0Sstevel@tonic-gate[ -f dir2/messages.1 ] || exit 1 1373*0Sstevel@tonic-gate[ "xinitially dir2/messages.1" = "x`/bin/cat dir2/messages.1`" ] || exit 1 1374*0Sstevel@tonic-gate[ -f dir2/messages.2 ] || exit 1 1375*0Sstevel@tonic-gate[ "xinitially dir2/messages.2" = "x`/bin/cat dir2/messages.2`" ] || exit 1 1376*0Sstevel@tonic-gate[ -f dir2/messages.3 ] || exit 1 1377*0Sstevel@tonic-gate[ "xinitially dir2/messages.3" = "x`/bin/cat dir2/messages.3`" ] || exit 1 1378*0Sstevel@tonic-gate[ -f dir2/messages.4 ] && exit 1 1379*0Sstevel@tonic-gateexit 0 1380*0Sstevel@tonic-gateEOF 1381*0Sstevel@tonic-gate 1382*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1383*0Sstevel@tonic-gate# test "logadm9" 1384*0Sstevel@tonic-gate$envsetup 1385*0Sstevel@tonic-gateexec $bindir/logadm -f logadm.conf >std.out 2>std.err 1386*0Sstevel@tonic-gateEOF 1387*0Sstevel@tonic-gate} 1388*0Sstevel@tonic-gate 1389*0Sstevel@tonic-gate########################################################################### 1390*0Sstevel@tonic-gate# 1391*0Sstevel@tonic-gate# logadm9d -- test of age check like logadm9, but age is a couple days 1392*0Sstevel@tonic-gate# 1393*0Sstevel@tonic-gate########################################################################### 1394*0Sstevel@tonic-gatesub logadm9d { 1395*0Sstevel@tonic-gate mkdir 'dir1', 0777 or die "mkdir dir1: $!\n"; 1396*0Sstevel@tonic-gate set_file('dir1/syslog', 'initially dir1/syslog'); 1397*0Sstevel@tonic-gate set_file('dir1/syslog.0', 'initially dir1/syslog.0'); 1398*0Sstevel@tonic-gate set_file('dir1/syslog.1', 'initially dir1/syslog.1'); 1399*0Sstevel@tonic-gate set_file('dir1/syslog.2', 'initially dir1/syslog.2'); 1400*0Sstevel@tonic-gate set_file('dir1/syslog.3', 'initially dir1/syslog.3'); 1401*0Sstevel@tonic-gate set_file('dir1/syslog.4', 'initially dir1/syslog.4'); 1402*0Sstevel@tonic-gate set_file('dir1/syslog.5', 'initially dir1/syslog.5'); 1403*0Sstevel@tonic-gate set_file('dir1/syslog.6', 'initially dir1/syslog.6'); 1404*0Sstevel@tonic-gate set_file('dir1/syslog.7', 'initially dir1/syslog.7'); 1405*0Sstevel@tonic-gate mkdir 'dir2', 0777 or die "mkdir dir2: $!\n"; 1406*0Sstevel@tonic-gate set_file('dir2/messages', 'initially dir2/messages'); 1407*0Sstevel@tonic-gate set_file('dir2/messages.0', 'initially dir2/messages.0'); 1408*0Sstevel@tonic-gate set_file('dir2/messages.1', 'initially dir2/messages.1'); 1409*0Sstevel@tonic-gate set_file('dir2/messages.2', 'initially dir2/messages.2'); 1410*0Sstevel@tonic-gate set_file('dir2/messages.3', 'initially dir2/messages.3'); 1411*0Sstevel@tonic-gate 1412*0Sstevel@tonic-gate $now = time; 1413*0Sstevel@tonic-gate $nowstr = gmtime($now); 1414*0Sstevel@tonic-gate # a day minus 30 seconds ago... 1415*0Sstevel@tonic-gate $closetodaysecs = $now - (60 * 60 * 24 - 30); 1416*0Sstevel@tonic-gate $closetoday = gmtime($closetodaysecs); 1417*0Sstevel@tonic-gate # a day minus six hours ago... 1418*0Sstevel@tonic-gate $lessthandaysecs = $now - (60 * 60 * 24 - 60 * 60 * 6); 1419*0Sstevel@tonic-gate $lessthanday = gmtime($lessthandaysecs); 1420*0Sstevel@tonic-gate 1421*0Sstevel@tonic-gate set_file('logadm.conf', <<"EOF"); 1422*0Sstevel@tonic-gate# now: $nowstr is $now 1423*0Sstevel@tonic-gate# $closetoday is $closetodaysecs 1424*0Sstevel@tonic-gatedir1/syslog -p 1d -C 8 -P '$closetoday' 1425*0Sstevel@tonic-gate# $lessthanday is $lessthandaysecs 1426*0Sstevel@tonic-gatedir2/messages -p 1d -C 4 -P '$lessthanday' 1427*0Sstevel@tonic-gateEOF 1428*0Sstevel@tonic-gate 1429*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1430*0Sstevel@tonic-gate[ -s std.err ] && exit 1 1431*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1432*0Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1 1433*0Sstevel@tonic-gate[ -s dir1/syslog ] && exit 1 1434*0Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1 1435*0Sstevel@tonic-gate[ "xinitially dir1/syslog" = "x`/bin/cat dir1/syslog.0`" ] || exit 1 1436*0Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1 1437*0Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.1`" ] || exit 1 1438*0Sstevel@tonic-gate[ -f dir1/syslog.2 ] || exit 1 1439*0Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/cat dir1/syslog.2`" ] || exit 1 1440*0Sstevel@tonic-gate[ -f dir1/syslog.3 ] || exit 1 1441*0Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/cat dir1/syslog.3`" ] || exit 1 1442*0Sstevel@tonic-gate[ -f dir1/syslog.4 ] || exit 1 1443*0Sstevel@tonic-gate[ "xinitially dir1/syslog.3" = "x`/bin/cat dir1/syslog.4`" ] || exit 1 1444*0Sstevel@tonic-gate[ -f dir1/syslog.5 ] || exit 1 1445*0Sstevel@tonic-gate[ "xinitially dir1/syslog.4" = "x`/bin/cat dir1/syslog.5`" ] || exit 1 1446*0Sstevel@tonic-gate[ -f dir1/syslog.6 ] || exit 1 1447*0Sstevel@tonic-gate[ "xinitially dir1/syslog.5" = "x`/bin/cat dir1/syslog.6`" ] || exit 1 1448*0Sstevel@tonic-gate[ -f dir1/syslog.7 ] || exit 1 1449*0Sstevel@tonic-gate[ "xinitially dir1/syslog.6" = "x`/bin/cat dir1/syslog.7`" ] || exit 1 1450*0Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1 1451*0Sstevel@tonic-gate 1452*0Sstevel@tonic-gate[ -f dir2/messages ] || exit 1 1453*0Sstevel@tonic-gate[ "xinitially dir2/messages" = "x`/bin/cat dir2/messages`" ] || exit 1 1454*0Sstevel@tonic-gate[ -f dir2/messages.0 ] || exit 1 1455*0Sstevel@tonic-gate[ "xinitially dir2/messages.0" = "x`/bin/cat dir2/messages.0`" ] || exit 1 1456*0Sstevel@tonic-gate[ -f dir2/messages.1 ] || exit 1 1457*0Sstevel@tonic-gate[ "xinitially dir2/messages.1" = "x`/bin/cat dir2/messages.1`" ] || exit 1 1458*0Sstevel@tonic-gate[ -f dir2/messages.2 ] || exit 1 1459*0Sstevel@tonic-gate[ "xinitially dir2/messages.2" = "x`/bin/cat dir2/messages.2`" ] || exit 1 1460*0Sstevel@tonic-gate[ -f dir2/messages.3 ] || exit 1 1461*0Sstevel@tonic-gate[ "xinitially dir2/messages.3" = "x`/bin/cat dir2/messages.3`" ] || exit 1 1462*0Sstevel@tonic-gate[ -f dir2/messages.4 ] && exit 1 1463*0Sstevel@tonic-gateexit 0 1464*0Sstevel@tonic-gateEOF 1465*0Sstevel@tonic-gate 1466*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1467*0Sstevel@tonic-gate# test "logadm9d" 1468*0Sstevel@tonic-gate$envsetup 1469*0Sstevel@tonic-gateexec $bindir/logadm -f logadm.conf >std.out 2>std.err 1470*0Sstevel@tonic-gateEOF 1471*0Sstevel@tonic-gate} 1472*0Sstevel@tonic-gate 1473*0Sstevel@tonic-gate########################################################################### 1474*0Sstevel@tonic-gate# 1475*0Sstevel@tonic-gate# logadm10 -- test of size-based rotation check 1476*0Sstevel@tonic-gate# 1477*0Sstevel@tonic-gate########################################################################### 1478*0Sstevel@tonic-gatesub logadm10 { 1479*0Sstevel@tonic-gate mkdir 'dir1', 0777 or die "mkdir dir1: $!\n"; 1480*0Sstevel@tonic-gate set_file('dir1/syslog', 'initially dir1/syslogXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); 1481*0Sstevel@tonic-gate set_file('dir1/syslog.0', 'initially dir1/syslog.0'); 1482*0Sstevel@tonic-gate set_file('dir1/syslog.1', 'initially dir1/syslog.1'); 1483*0Sstevel@tonic-gate set_file('dir1/syslog.2', 'initially dir1/syslog.2'); 1484*0Sstevel@tonic-gate set_file('dir1/syslog.3', 'initially dir1/syslog.3'); 1485*0Sstevel@tonic-gate set_file('dir1/syslog.4', 'initially dir1/syslog.4'); 1486*0Sstevel@tonic-gate set_file('dir1/syslog.5', 'initially dir1/syslog.5'); 1487*0Sstevel@tonic-gate set_file('dir1/syslog.6', 'initially dir1/syslog.6'); 1488*0Sstevel@tonic-gate set_file('dir1/syslog.7', 'initially dir1/syslog.7'); 1489*0Sstevel@tonic-gate mkdir 'dir2', 0777 or die "mkdir dir2: $!\n"; 1490*0Sstevel@tonic-gate set_file('dir2/messages', 'initially dir2/messages'); 1491*0Sstevel@tonic-gate set_file('dir2/messages.0', 'initially dir2/messages.0'); 1492*0Sstevel@tonic-gate set_file('dir2/messages.1', 'initially dir2/messages.1'); 1493*0Sstevel@tonic-gate set_file('dir2/messages.2', 'initially dir2/messages.2'); 1494*0Sstevel@tonic-gate set_file('dir2/messages.3', 'initially dir2/messages.3'); 1495*0Sstevel@tonic-gate 1496*0Sstevel@tonic-gate set_file('logadm.conf', <<"EOF"); 1497*0Sstevel@tonic-gatedir1/syslog -C 8 -s 30b 1498*0Sstevel@tonic-gatedir2/messages -C 4 -s 30b 1499*0Sstevel@tonic-gateEOF 1500*0Sstevel@tonic-gate 1501*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1502*0Sstevel@tonic-gate[ -s std.err ] && exit 1 1503*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1504*0Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1 1505*0Sstevel@tonic-gate[ -s dir1/syslog ] && exit 1 1506*0Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1 1507*0Sstevel@tonic-gate[ "xinitially dir1/syslogXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" = "x`/bin/cat dir1/syslog.0`" ] || exit 1 1508*0Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1 1509*0Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.1`" ] || exit 1 1510*0Sstevel@tonic-gate[ -f dir1/syslog.2 ] || exit 1 1511*0Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/cat dir1/syslog.2`" ] || exit 1 1512*0Sstevel@tonic-gate[ -f dir1/syslog.3 ] || exit 1 1513*0Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/cat dir1/syslog.3`" ] || exit 1 1514*0Sstevel@tonic-gate[ -f dir1/syslog.4 ] || exit 1 1515*0Sstevel@tonic-gate[ "xinitially dir1/syslog.3" = "x`/bin/cat dir1/syslog.4`" ] || exit 1 1516*0Sstevel@tonic-gate[ -f dir1/syslog.5 ] || exit 1 1517*0Sstevel@tonic-gate[ "xinitially dir1/syslog.4" = "x`/bin/cat dir1/syslog.5`" ] || exit 1 1518*0Sstevel@tonic-gate[ -f dir1/syslog.6 ] || exit 1 1519*0Sstevel@tonic-gate[ "xinitially dir1/syslog.5" = "x`/bin/cat dir1/syslog.6`" ] || exit 1 1520*0Sstevel@tonic-gate[ -f dir1/syslog.7 ] || exit 1 1521*0Sstevel@tonic-gate[ "xinitially dir1/syslog.6" = "x`/bin/cat dir1/syslog.7`" ] || exit 1 1522*0Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1 1523*0Sstevel@tonic-gate 1524*0Sstevel@tonic-gate[ -f dir2/messages ] || exit 1 1525*0Sstevel@tonic-gate[ "xinitially dir2/messages" = "x`/bin/cat dir2/messages`" ] || exit 1 1526*0Sstevel@tonic-gate[ -f dir2/messages.0 ] || exit 1 1527*0Sstevel@tonic-gate[ "xinitially dir2/messages.0" = "x`/bin/cat dir2/messages.0`" ] || exit 1 1528*0Sstevel@tonic-gate[ -f dir2/messages.1 ] || exit 1 1529*0Sstevel@tonic-gate[ "xinitially dir2/messages.1" = "x`/bin/cat dir2/messages.1`" ] || exit 1 1530*0Sstevel@tonic-gate[ -f dir2/messages.2 ] || exit 1 1531*0Sstevel@tonic-gate[ "xinitially dir2/messages.2" = "x`/bin/cat dir2/messages.2`" ] || exit 1 1532*0Sstevel@tonic-gate[ -f dir2/messages.3 ] || exit 1 1533*0Sstevel@tonic-gate[ "xinitially dir2/messages.3" = "x`/bin/cat dir2/messages.3`" ] || exit 1 1534*0Sstevel@tonic-gate[ -f dir2/messages.4 ] && exit 1 1535*0Sstevel@tonic-gateexit 0 1536*0Sstevel@tonic-gateEOF 1537*0Sstevel@tonic-gate 1538*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1539*0Sstevel@tonic-gate# test "logadm10" 1540*0Sstevel@tonic-gate$envsetup 1541*0Sstevel@tonic-gateexec $bindir/logadm -f logadm.conf >std.out 2>std.err 1542*0Sstevel@tonic-gateEOF 1543*0Sstevel@tonic-gate} 1544*0Sstevel@tonic-gate 1545*0Sstevel@tonic-gate########################################################################### 1546*0Sstevel@tonic-gate# 1547*0Sstevel@tonic-gate# logadm11 -- test of size-based expiration check 1548*0Sstevel@tonic-gate# 1549*0Sstevel@tonic-gate########################################################################### 1550*0Sstevel@tonic-gatesub logadm11 { 1551*0Sstevel@tonic-gate mkdir 'dir1', 0777 or die "mkdir dir1: $!\n"; 1552*0Sstevel@tonic-gate set_file('dir1/syslog', 'initially dir1/syslog'); 1553*0Sstevel@tonic-gate set_file('dir1/syslog.0', 'initially dir1/syslog.0'); 1554*0Sstevel@tonic-gate set_file('dir1/syslog.1', 'initially dir1/syslog.1'); 1555*0Sstevel@tonic-gate set_file('dir1/syslog.2', 'initially dir1/syslog.2'); 1556*0Sstevel@tonic-gate set_file('dir1/syslog.3', 'initially dir1/syslog.3'); 1557*0Sstevel@tonic-gate set_file('dir1/syslog.4', 'initially dir1/syslog.4'); 1558*0Sstevel@tonic-gate set_file('dir1/syslog.5', 'initially dir1/syslog.5'); 1559*0Sstevel@tonic-gate set_file('dir1/syslog.6', 'initially dir1/syslog.6'); 1560*0Sstevel@tonic-gate set_file('dir1/syslog.7', 'initially dir1/syslog.7'); 1561*0Sstevel@tonic-gate mkdir 'dir2', 0777 or die "mkdir dir2: $!\n"; 1562*0Sstevel@tonic-gate set_file('dir2/messages', 'initially dir2/messages'); 1563*0Sstevel@tonic-gate set_file('dir2/messages.0', 'initially dir2/messages.0'); 1564*0Sstevel@tonic-gate set_file('dir2/messages.1', 'initially dir2/messages.1'); 1565*0Sstevel@tonic-gate set_file('dir2/messages.2', 'initially dir2/messages.2'); 1566*0Sstevel@tonic-gate set_file('dir2/messages.3', 'initially dir2/messages.3'); 1567*0Sstevel@tonic-gate 1568*0Sstevel@tonic-gate set_file('logadm.conf', <<"EOF"); 1569*0Sstevel@tonic-gatedir1/syslog -C 8 -s 30b -S 75b 1570*0Sstevel@tonic-gatedir2/messages -C 4 -s 30b -S 75b 1571*0Sstevel@tonic-gateEOF 1572*0Sstevel@tonic-gate 1573*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1574*0Sstevel@tonic-gate[ -s std.err ] && exit 1 1575*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1576*0Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1 1577*0Sstevel@tonic-gate[ "xinitially dir1/syslog" = "x`/bin/cat dir1/syslog`" ] || exit 1 1578*0Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1 1579*0Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.0`" ] || exit 1 1580*0Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1 1581*0Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/cat dir1/syslog.1`" ] || exit 1 1582*0Sstevel@tonic-gate[ -f dir1/syslog.2 ] || exit 1 1583*0Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/cat dir1/syslog.2`" ] || exit 1 1584*0Sstevel@tonic-gate[ -f dir1/syslog.3 ] && exit 1 1585*0Sstevel@tonic-gate[ -f dir1/syslog.4 ] && exit 1 1586*0Sstevel@tonic-gate[ -f dir1/syslog.5 ] && exit 1 1587*0Sstevel@tonic-gate[ -f dir1/syslog.6 ] && exit 1 1588*0Sstevel@tonic-gate[ -f dir1/syslog.7 ] && exit 1 1589*0Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1 1590*0Sstevel@tonic-gate 1591*0Sstevel@tonic-gate[ -f dir2/messages ] || exit 1 1592*0Sstevel@tonic-gate[ "xinitially dir2/messages" = "x`/bin/cat dir2/messages`" ] || exit 1 1593*0Sstevel@tonic-gate[ -f dir2/messages.0 ] || exit 1 1594*0Sstevel@tonic-gate[ "xinitially dir2/messages.0" = "x`/bin/cat dir2/messages.0`" ] || exit 1 1595*0Sstevel@tonic-gate[ -f dir2/messages.1 ] || exit 1 1596*0Sstevel@tonic-gate[ "xinitially dir2/messages.1" = "x`/bin/cat dir2/messages.1`" ] || exit 1 1597*0Sstevel@tonic-gate[ -f dir2/messages.2 ] || exit 1 1598*0Sstevel@tonic-gate[ "xinitially dir2/messages.2" = "x`/bin/cat dir2/messages.2`" ] || exit 1 1599*0Sstevel@tonic-gate[ -f dir2/messages.3 ] && exit 1 1600*0Sstevel@tonic-gate[ -f dir2/messages.4 ] && exit 1 1601*0Sstevel@tonic-gateexit 0 1602*0Sstevel@tonic-gateEOF 1603*0Sstevel@tonic-gate 1604*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1605*0Sstevel@tonic-gate# test "logadm11" 1606*0Sstevel@tonic-gate$envsetup 1607*0Sstevel@tonic-gateexec $bindir/logadm -f logadm.conf >std.out 2>std.err 1608*0Sstevel@tonic-gateEOF 1609*0Sstevel@tonic-gate} 1610*0Sstevel@tonic-gate 1611*0Sstevel@tonic-gate########################################################################### 1612*0Sstevel@tonic-gate# 1613*0Sstevel@tonic-gate# logadm12 -- ENOENT error path 1614*0Sstevel@tonic-gate# 1615*0Sstevel@tonic-gate########################################################################### 1616*0Sstevel@tonic-gatesub logadm12 { 1617*0Sstevel@tonic-gate set_file('std.err.expect', <<'EOF'); 1618*0Sstevel@tonic-gatelogadm: Warning: logfile: No such file or directory 1619*0Sstevel@tonic-gateEOF 1620*0Sstevel@tonic-gate 1621*0Sstevel@tonic-gate set_file('checktest', <<"EOF"); 1622*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1623*0Sstevel@tonic-gateexec /bin/diff std.err std.err.expect 1624*0Sstevel@tonic-gateEOF 1625*0Sstevel@tonic-gate 1626*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1627*0Sstevel@tonic-gate# test "logadm12" 1628*0Sstevel@tonic-gate$envsetup 1629*0Sstevel@tonic-gateexec $bindir/logadm -f /dev/null logfile >std.out 2>std.err 1630*0Sstevel@tonic-gateEOF 1631*0Sstevel@tonic-gate} 1632*0Sstevel@tonic-gate 1633*0Sstevel@tonic-gate########################################################################### 1634*0Sstevel@tonic-gate# 1635*0Sstevel@tonic-gate# logadm13 -- ENOENT error path with -N flag 1636*0Sstevel@tonic-gate# 1637*0Sstevel@tonic-gate########################################################################### 1638*0Sstevel@tonic-gatesub logadm13 { 1639*0Sstevel@tonic-gate set_file('checktest', <<"EOF"); 1640*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1641*0Sstevel@tonic-gate[ -s std.err ] && exit 1 1642*0Sstevel@tonic-gateexit 0 1643*0Sstevel@tonic-gateEOF 1644*0Sstevel@tonic-gate 1645*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1646*0Sstevel@tonic-gate# test "logadm13" 1647*0Sstevel@tonic-gate$envsetup 1648*0Sstevel@tonic-gateexec $bindir/logadm -N -f /dev/null logfile >std.out 2>std.err 1649*0Sstevel@tonic-gateEOF 1650*0Sstevel@tonic-gate} 1651*0Sstevel@tonic-gate 1652*0Sstevel@tonic-gate########################################################################### 1653*0Sstevel@tonic-gate# 1654*0Sstevel@tonic-gate# logadm14 -- test of -n and -v flags 1655*0Sstevel@tonic-gate# 1656*0Sstevel@tonic-gate########################################################################### 1657*0Sstevel@tonic-gatesub logadm14 { 1658*0Sstevel@tonic-gate mkdir 'dir1', 0777 or die "mkdir dir1: $!\n"; 1659*0Sstevel@tonic-gate set_file('dir1/syslog', 'initially dir1/syslog'); 1660*0Sstevel@tonic-gate set_file('dir1/syslog.0', 'initially dir1/syslog.0'); 1661*0Sstevel@tonic-gate set_file('dir1/syslog.1', 'initially dir1/syslog.1'); 1662*0Sstevel@tonic-gate set_file('dir1/syslog.2', 'initially dir1/syslog.2'); 1663*0Sstevel@tonic-gate set_file('dir1/syslog.3', 'initially dir1/syslog.3'); 1664*0Sstevel@tonic-gate set_file('dir1/syslog.4', 'initially dir1/syslog.4'); 1665*0Sstevel@tonic-gate set_file('dir1/syslog.5', 'initially dir1/syslog.5'); 1666*0Sstevel@tonic-gate set_file('dir1/syslog.6', 'initially dir1/syslog.6'); 1667*0Sstevel@tonic-gate set_file('dir1/syslog.7', 'initially dir1/syslog.7'); 1668*0Sstevel@tonic-gate mkdir 'dir2', 0777 or die "mkdir dir2: $!\n"; 1669*0Sstevel@tonic-gate set_file('dir2/messages', 'initially dir2/messages'); 1670*0Sstevel@tonic-gate set_file('dir2/messages.0', 'initially dir2/messages.0'); 1671*0Sstevel@tonic-gate set_file('dir2/messages.1', 'initially dir2/messages.1'); 1672*0Sstevel@tonic-gate set_file('dir2/messages.2', 'initially dir2/messages.2'); 1673*0Sstevel@tonic-gate set_file('dir2/messages.3', 'initially dir2/messages.3'); 1674*0Sstevel@tonic-gate 1675*0Sstevel@tonic-gate set_file('logadm.conf', <<'EOF'); 1676*0Sstevel@tonic-gate# 1677*0Sstevel@tonic-gate# logadm.conf 1678*0Sstevel@tonic-gate# 1679*0Sstevel@tonic-gate# Default settings for system log file management. 1680*0Sstevel@tonic-gate# The -w option to logadm(1M) is the preferred way to write to this file, 1681*0Sstevel@tonic-gate# but if you do edit it by hand, use "logadm -V" to check it for errors. 1682*0Sstevel@tonic-gate# but if you do edit it by hand, use "logadm -V" to check it for errors. 1683*0Sstevel@tonic-gate# 1684*0Sstevel@tonic-gate# The format of lines in this file is: 1685*0Sstevel@tonic-gate# <logname> <options> 1686*0Sstevel@tonic-gate# For each logname listed here, the default options to logadm 1687*0Sstevel@tonic-gate# are given. Options given on the logadm command line override 1688*0Sstevel@tonic-gate# the defaults contained in this file. 1689*0Sstevel@tonic-gate# 1690*0Sstevel@tonic-gate# logadm typically runs early every morning via an entry in 1691*0Sstevel@tonic-gate# root's crontab (see crontab(1)). 1692*0Sstevel@tonic-gate# 1693*0Sstevel@tonic-gatedir1/syslog -C 8 -a 'echo kill -HUP `cat /etc/syslog.pid` >> cmd.out' 1694*0Sstevel@tonic-gatedir2/messages -C 4 -a 'echo kill -HUP `cat /etc/syslog.pid` >> cmd.out' 1695*0Sstevel@tonic-gate# 1696*0Sstevel@tonic-gate# The entry below is used by turnacct(1M) 1697*0Sstevel@tonic-gate# 1698*0Sstevel@tonic-gate/var/adm/pacct -C 0 -a '/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -p never 1699*0Sstevel@tonic-gateEOF 1700*0Sstevel@tonic-gate 1701*0Sstevel@tonic-gate $gid = $); 1702*0Sstevel@tonic-gate $gid =~ s/ .*//; 1703*0Sstevel@tonic-gate set_file('grep.out.expect', <<'EOF'.<<"EOF".<<'EOF'.<<"EOF".<<'EOF'); 1704*0Sstevel@tonic-gate# loading logadm.conf 1705*0Sstevel@tonic-gate# processing logname: dir1/syslog 1706*0Sstevel@tonic-gate# using default rotate rules: -s1b -p1w 1707*0Sstevel@tonic-gate# using default template: $file.$n 1708*0Sstevel@tonic-gatemkdir -p dir1 # verify directory exists 1709*0Sstevel@tonic-gatemv -f dir1/syslog.7 dir1/syslog.8 # rotate log file 1710*0Sstevel@tonic-gatemkdir -p dir1 # verify directory exists 1711*0Sstevel@tonic-gatemv -f dir1/syslog.6 dir1/syslog.7 # rotate log file 1712*0Sstevel@tonic-gatemkdir -p dir1 # verify directory exists 1713*0Sstevel@tonic-gatemv -f dir1/syslog.5 dir1/syslog.6 # rotate log file 1714*0Sstevel@tonic-gatemkdir -p dir1 # verify directory exists 1715*0Sstevel@tonic-gatemv -f dir1/syslog.4 dir1/syslog.5 # rotate log file 1716*0Sstevel@tonic-gatemkdir -p dir1 # verify directory exists 1717*0Sstevel@tonic-gatemv -f dir1/syslog.3 dir1/syslog.4 # rotate log file 1718*0Sstevel@tonic-gatemkdir -p dir1 # verify directory exists 1719*0Sstevel@tonic-gatemv -f dir1/syslog.2 dir1/syslog.3 # rotate log file 1720*0Sstevel@tonic-gatemkdir -p dir1 # verify directory exists 1721*0Sstevel@tonic-gatemv -f dir1/syslog.1 dir1/syslog.2 # rotate log file 1722*0Sstevel@tonic-gatemkdir -p dir1 # verify directory exists 1723*0Sstevel@tonic-gatemv -f dir1/syslog.0 dir1/syslog.1 # rotate log file 1724*0Sstevel@tonic-gatemkdir -p dir1 # verify directory exists 1725*0Sstevel@tonic-gatemv -f dir1/syslog dir1/syslog.0 # rotate log file 1726*0Sstevel@tonic-gatetouch dir1/syslog 1727*0Sstevel@tonic-gateEOF 1728*0Sstevel@tonic-gatechown $>:$gid dir1/syslog 1729*0Sstevel@tonic-gateEOF 1730*0Sstevel@tonic-gatechmod 664 dir1/syslog 1731*0Sstevel@tonic-gate# processing logname: dir2/messages 1732*0Sstevel@tonic-gate# using default rotate rules: -s1b -p1w 1733*0Sstevel@tonic-gate# using default template: $file.$n 1734*0Sstevel@tonic-gatemkdir -p dir2 # verify directory exists 1735*0Sstevel@tonic-gatemv -f dir2/messages.3 dir2/messages.4 # rotate log file 1736*0Sstevel@tonic-gatemkdir -p dir2 # verify directory exists 1737*0Sstevel@tonic-gatemv -f dir2/messages.2 dir2/messages.3 # rotate log file 1738*0Sstevel@tonic-gatemkdir -p dir2 # verify directory exists 1739*0Sstevel@tonic-gatemv -f dir2/messages.1 dir2/messages.2 # rotate log file 1740*0Sstevel@tonic-gatemkdir -p dir2 # verify directory exists 1741*0Sstevel@tonic-gatemv -f dir2/messages.0 dir2/messages.1 # rotate log file 1742*0Sstevel@tonic-gatemkdir -p dir2 # verify directory exists 1743*0Sstevel@tonic-gatemv -f dir2/messages dir2/messages.0 # rotate log file 1744*0Sstevel@tonic-gatetouch dir2/messages 1745*0Sstevel@tonic-gateEOF 1746*0Sstevel@tonic-gatechown $>:$gid dir2/messages 1747*0Sstevel@tonic-gateEOF 1748*0Sstevel@tonic-gatechmod 664 dir2/messages 1749*0Sstevel@tonic-gate# processing logname: /var/adm/pacct 1750*0Sstevel@tonic-gate# using default template: $file.$n 1751*0Sstevel@tonic-gatesh -c echo kill -HUP `cat /etc/syslog.pid` >> cmd.out # -a cmd 1752*0Sstevel@tonic-gate# logadm.conf unchanged 1753*0Sstevel@tonic-gateEOF 1754*0Sstevel@tonic-gate 1755*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1756*0Sstevel@tonic-gate[ -s std.err ] && exit 1 1757*0Sstevel@tonic-gate[ -f std.out ] || exit 1 1758*0Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1 1759*0Sstevel@tonic-gate[ "xinitially dir1/syslog" = "x`/bin/cat dir1/syslog`" ] || exit 1 1760*0Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1 1761*0Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.0`" ] || exit 1 1762*0Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1 1763*0Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/cat dir1/syslog.1`" ] || exit 1 1764*0Sstevel@tonic-gate[ -f dir1/syslog.2 ] || exit 1 1765*0Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/cat dir1/syslog.2`" ] || exit 1 1766*0Sstevel@tonic-gate[ -f dir1/syslog.3 ] || exit 1 1767*0Sstevel@tonic-gate[ "xinitially dir1/syslog.3" = "x`/bin/cat dir1/syslog.3`" ] || exit 1 1768*0Sstevel@tonic-gate[ -f dir1/syslog.4 ] || exit 1 1769*0Sstevel@tonic-gate[ "xinitially dir1/syslog.4" = "x`/bin/cat dir1/syslog.4`" ] || exit 1 1770*0Sstevel@tonic-gate[ -f dir1/syslog.5 ] || exit 1 1771*0Sstevel@tonic-gate[ "xinitially dir1/syslog.5" = "x`/bin/cat dir1/syslog.5`" ] || exit 1 1772*0Sstevel@tonic-gate[ -f dir1/syslog.6 ] || exit 1 1773*0Sstevel@tonic-gate[ "xinitially dir1/syslog.6" = "x`/bin/cat dir1/syslog.6`" ] || exit 1 1774*0Sstevel@tonic-gate[ -f dir1/syslog.7 ] || exit 1 1775*0Sstevel@tonic-gate[ "xinitially dir1/syslog.7" = "x`/bin/cat dir1/syslog.7`" ] || exit 1 1776*0Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1 1777*0Sstevel@tonic-gate 1778*0Sstevel@tonic-gate[ -f dir2/messages ] || exit 1 1779*0Sstevel@tonic-gate[ "xinitially dir2/messages" = "x`/bin/cat dir2/messages`" ] || exit 1 1780*0Sstevel@tonic-gate[ -f dir2/messages.0 ] || exit 1 1781*0Sstevel@tonic-gate[ "xinitially dir2/messages.0" = "x`/bin/cat dir2/messages.0`" ] || exit 1 1782*0Sstevel@tonic-gate[ -f dir2/messages.1 ] || exit 1 1783*0Sstevel@tonic-gate[ "xinitially dir2/messages.1" = "x`/bin/cat dir2/messages.1`" ] || exit 1 1784*0Sstevel@tonic-gate[ -f dir2/messages.2 ] || exit 1 1785*0Sstevel@tonic-gate[ "xinitially dir2/messages.2" = "x`/bin/cat dir2/messages.2`" ] || exit 1 1786*0Sstevel@tonic-gate[ -f dir2/messages.3 ] || exit 1 1787*0Sstevel@tonic-gate[ "xinitially dir2/messages.3" = "x`/bin/cat dir2/messages.3`" ] || exit 1 1788*0Sstevel@tonic-gate[ -f dir2/messages.4 ] && exit 1 1789*0Sstevel@tonic-gate/bin/grep -v 'recording rotation date' std.out > grep.out 1790*0Sstevel@tonic-gateexec /bin/diff grep.out grep.out.expect 1791*0Sstevel@tonic-gateEOF 1792*0Sstevel@tonic-gate 1793*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1794*0Sstevel@tonic-gate# test "logadm14" 1795*0Sstevel@tonic-gate$envsetup 1796*0Sstevel@tonic-gateexec $bindir/logadm -nv -f logadm.conf >std.out 2>std.err 1797*0Sstevel@tonic-gateEOF 1798*0Sstevel@tonic-gate} 1799*0Sstevel@tonic-gate 1800*0Sstevel@tonic-gate########################################################################### 1801*0Sstevel@tonic-gate# 1802*0Sstevel@tonic-gate# logadm15 -- test of -T 1803*0Sstevel@tonic-gate# 1804*0Sstevel@tonic-gate########################################################################### 1805*0Sstevel@tonic-gatesub logadm15 { 1806*0Sstevel@tonic-gate set_file('logfile', ''); 1807*0Sstevel@tonic-gate set_file('logfile.0', 'initially logfile.0'); 1808*0Sstevel@tonic-gate set_file('logfile.1', 'initially logfile.1'); 1809*0Sstevel@tonic-gate set_file('logfile.2', 'initially logfile.2'); 1810*0Sstevel@tonic-gate set_file('logfile.3', 'initially logfile.3'); 1811*0Sstevel@tonic-gate set_file('logfile.4', 'initially logfile.4'); 1812*0Sstevel@tonic-gate set_file('logfile.5', 'initially logfile.5'); 1813*0Sstevel@tonic-gate set_file('logfile.6', 'initially logfile.6'); 1814*0Sstevel@tonic-gate set_file('logfile.7', 'initially logfile.7'); 1815*0Sstevel@tonic-gate set_file('logfile.8', 'initially logfile.8'); 1816*0Sstevel@tonic-gate set_file('logfile.9', 'initially logfile.9'); 1817*0Sstevel@tonic-gate 1818*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1819*0Sstevel@tonic-gate[ -s std.err ] && exit 1 1820*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1821*0Sstevel@tonic-gate[ -f logfile ] || exit 1 1822*0Sstevel@tonic-gate[ "x" = "x`/bin/cat logfile`" ] || exit 1 1823*0Sstevel@tonic-gate[ -f logfile.0 ] || exit 1 1824*0Sstevel@tonic-gate[ "xinitially logfile.0" = "x`/bin/cat logfile.0`" ] || exit 1 1825*0Sstevel@tonic-gate[ -f logfile.1 ] || exit 1 1826*0Sstevel@tonic-gate[ "xinitially logfile.1" = "x`/bin/cat logfile.1`" ] || exit 1 1827*0Sstevel@tonic-gate[ -f logfile.2 ] || exit 1 1828*0Sstevel@tonic-gate[ "xinitially logfile.2" = "x`/bin/cat logfile.2`" ] || exit 1 1829*0Sstevel@tonic-gate[ -f logfile.3 ] && exit 1 1830*0Sstevel@tonic-gate[ -f logfile.4 ] || exit 1 1831*0Sstevel@tonic-gate[ "xinitially logfile.4" = "x`/bin/cat logfile.4`" ] || exit 1 1832*0Sstevel@tonic-gate[ -f logfile.5 ] && exit 1 1833*0Sstevel@tonic-gate[ -f logfile.6 ] || exit 1 1834*0Sstevel@tonic-gate[ "xinitially logfile.6" = "x`/bin/cat logfile.6`" ] || exit 1 1835*0Sstevel@tonic-gate[ -f logfile.7 ] && exit 1 1836*0Sstevel@tonic-gate[ -f logfile.8 ] || exit 1 1837*0Sstevel@tonic-gate[ "xinitially logfile.8" = "x`/bin/cat logfile.8`" ] || exit 1 1838*0Sstevel@tonic-gate[ -f logfile.9 ] && exit 1 1839*0Sstevel@tonic-gate[ -f logfile.10 ] && exit 1 1840*0Sstevel@tonic-gateexit 0 1841*0Sstevel@tonic-gateEOF 1842*0Sstevel@tonic-gate 1843*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1844*0Sstevel@tonic-gate# test "logadm15" 1845*0Sstevel@tonic-gate$envsetup 1846*0Sstevel@tonic-gateexec $bindir/logadm -f /dev/null logfile -C1 -T '*.[13579]'>std.out 2>std.err 1847*0Sstevel@tonic-gateEOF 1848*0Sstevel@tonic-gate} 1849*0Sstevel@tonic-gate 1850*0Sstevel@tonic-gate########################################################################### 1851*0Sstevel@tonic-gate# 1852*0Sstevel@tonic-gate# logadm16 -- test of -h 1853*0Sstevel@tonic-gate# 1854*0Sstevel@tonic-gate########################################################################### 1855*0Sstevel@tonic-gatesub logadm16 { 1856*0Sstevel@tonic-gate set_file('std.err.expect', <<'EOF'); 1857*0Sstevel@tonic-gateUsage: logadm [options] 1858*0Sstevel@tonic-gate (processes all entries in /etc/logadm.conf or conffile given by -f) 1859*0Sstevel@tonic-gate or: logadm [options] logname... 1860*0Sstevel@tonic-gate (processes the given lognames) 1861*0Sstevel@tonic-gate 1862*0Sstevel@tonic-gateGeneral options: 1863*0Sstevel@tonic-gate -e mailaddr mail errors to given address 1864*0Sstevel@tonic-gate -f conffile use conffile instead of /etc/logadm.conf 1865*0Sstevel@tonic-gate -h display help 1866*0Sstevel@tonic-gate -N not an error if log file nonexistent 1867*0Sstevel@tonic-gate -n show actions, don't perform them 1868*0Sstevel@tonic-gate -r remove logname entry from conffile 1869*0Sstevel@tonic-gate -V ensure conffile entries exist, correct 1870*0Sstevel@tonic-gate -v print info about actions happening 1871*0Sstevel@tonic-gate -w entryname write entry to config file 1872*0Sstevel@tonic-gate 1873*0Sstevel@tonic-gateOptions which control when a logfile is rotated: 1874*0Sstevel@tonic-gate(default is: -s1b -p1w if no -s or -p) 1875*0Sstevel@tonic-gate -p period only rotate if period passed since last rotate 1876*0Sstevel@tonic-gate -P timestamp used to store rotation date in conffile 1877*0Sstevel@tonic-gate -s size only rotate if given size or greater 1878*0Sstevel@tonic-gate 1879*0Sstevel@tonic-gateOptions which control how a logfile is rotated: 1880*0Sstevel@tonic-gate(default is: -t '$file.$n', owner/group/mode taken from log file) 1881*0Sstevel@tonic-gate -a cmd execute cmd after taking actions 1882*0Sstevel@tonic-gate -b cmd execute cmd before taking actions 1883*0Sstevel@tonic-gate -c copy & truncate logfile, don't rename 1884*0Sstevel@tonic-gate -g group new empty log file group 1885*0Sstevel@tonic-gate -m mode new empty log file mode 1886*0Sstevel@tonic-gate -M cmd execute cmd to rotate the log file 1887*0Sstevel@tonic-gate -o owner new empty log file owner 1888*0Sstevel@tonic-gate -R cmd run cmd on file after rotate 1889*0Sstevel@tonic-gate -t template template for naming old logs 1890*0Sstevel@tonic-gate -z count gzip old logs except most recent count 1891*0Sstevel@tonic-gate 1892*0Sstevel@tonic-gateOptions which control the expiration of old logfiles: 1893*0Sstevel@tonic-gate(default is: -C10 if no -A, -C, or -S) 1894*0Sstevel@tonic-gate -A age expire logs older than age 1895*0Sstevel@tonic-gate -C count expire old logs until count remain 1896*0Sstevel@tonic-gate -E cmd run cmd on file to expire 1897*0Sstevel@tonic-gate -S size expire until space used is below size 1898*0Sstevel@tonic-gate -T pattern pattern for finding old logs 1899*0Sstevel@tonic-gateEOF 1900*0Sstevel@tonic-gate 1901*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1902*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1903*0Sstevel@tonic-gateexec /bin/diff std.err std.err.expect 1904*0Sstevel@tonic-gateEOF 1905*0Sstevel@tonic-gate 1906*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1907*0Sstevel@tonic-gate# test "logadm16" 1908*0Sstevel@tonic-gate$envsetup 1909*0Sstevel@tonic-gateexec $bindir/logadm -h >std.out 2>std.err 1910*0Sstevel@tonic-gateEOF 1911*0Sstevel@tonic-gate} 1912*0Sstevel@tonic-gate 1913*0Sstevel@tonic-gate########################################################################### 1914*0Sstevel@tonic-gate# 1915*0Sstevel@tonic-gate# logadm17 -- test that mkdir -p happens as necessary 1916*0Sstevel@tonic-gate# 1917*0Sstevel@tonic-gate########################################################################### 1918*0Sstevel@tonic-gatesub logadm17 { 1919*0Sstevel@tonic-gate set_file('logfile', 'initially logfile'); 1920*0Sstevel@tonic-gate 1921*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1922*0Sstevel@tonic-gate[ -s std.err ] && exit 1 1923*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1924*0Sstevel@tonic-gate[ -f dir1/dir2/logfile ] || exit 1 1925*0Sstevel@tonic-gate[ -f logfile ] || exit 1 1926*0Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat dir1/dir2/logfile`" ] || exit 1 1927*0Sstevel@tonic-gateexit 0 1928*0Sstevel@tonic-gateEOF 1929*0Sstevel@tonic-gate 1930*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1931*0Sstevel@tonic-gate# test "logadm17" 1932*0Sstevel@tonic-gate$envsetup 1933*0Sstevel@tonic-gateexec $bindir/logadm -f /dev/null -t 'dir1/dir2/\$basename' logfile -p now >std.out 2>std.err 1934*0Sstevel@tonic-gateEOF 1935*0Sstevel@tonic-gate} 1936*0Sstevel@tonic-gate 1937*0Sstevel@tonic-gate########################################################################### 1938*0Sstevel@tonic-gate# 1939*0Sstevel@tonic-gate# logadm18 -- test of -M option 1940*0Sstevel@tonic-gate# 1941*0Sstevel@tonic-gate########################################################################### 1942*0Sstevel@tonic-gatesub logadm18 { 1943*0Sstevel@tonic-gate mkdir 'dir1', 0777 or die "mkdir dir1: $!\n"; 1944*0Sstevel@tonic-gate set_file('dir1/syslog', 'initially dir1/syslog'); 1945*0Sstevel@tonic-gate set_file('dir1/syslog.0', 'initially dir1/syslog.0'); 1946*0Sstevel@tonic-gate set_file('dir1/syslog.1', 'initially dir1/syslog.1'); 1947*0Sstevel@tonic-gate set_file('dir1/syslog.2', 'initially dir1/syslog.2'); 1948*0Sstevel@tonic-gate set_file('dir1/syslog.3', 'initially dir1/syslog.3'); 1949*0Sstevel@tonic-gate set_file('dir1/syslog.4', 'initially dir1/syslog.4'); 1950*0Sstevel@tonic-gate set_file('dir1/syslog.5', 'initially dir1/syslog.5'); 1951*0Sstevel@tonic-gate set_file('dir1/syslog.6', 'initially dir1/syslog.6'); 1952*0Sstevel@tonic-gate set_file('dir1/syslog.7', 'initially dir1/syslog.7'); 1953*0Sstevel@tonic-gate 1954*0Sstevel@tonic-gate set_file('logadm.conf', <<"EOF"); 1955*0Sstevel@tonic-gatedir1/syslog -C 8 -s 1b -M '/bin/tr [a-z] [A-Z] < \$file > \$nfile; /bin/rm -f \$file' 1956*0Sstevel@tonic-gateEOF 1957*0Sstevel@tonic-gate 1958*0Sstevel@tonic-gate set_file('checktest', <<'EOF'); 1959*0Sstevel@tonic-gate[ -s std.err ] && exit 1 1960*0Sstevel@tonic-gate[ -s std.out ] && exit 1 1961*0Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1 1962*0Sstevel@tonic-gate[ -s dir1/syslog ] && exit 1 1963*0Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1 1964*0Sstevel@tonic-gate[ "xINITIALLY DIR1/SYSLOG" = "x`/bin/cat dir1/syslog.0`" ] || exit 1 1965*0Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1 1966*0Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.1`" ] || exit 1 1967*0Sstevel@tonic-gate[ -f dir1/syslog.2 ] || exit 1 1968*0Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/cat dir1/syslog.2`" ] || exit 1 1969*0Sstevel@tonic-gate[ -f dir1/syslog.3 ] || exit 1 1970*0Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/cat dir1/syslog.3`" ] || exit 1 1971*0Sstevel@tonic-gate[ -f dir1/syslog.4 ] || exit 1 1972*0Sstevel@tonic-gate[ "xinitially dir1/syslog.3" = "x`/bin/cat dir1/syslog.4`" ] || exit 1 1973*0Sstevel@tonic-gate[ -f dir1/syslog.5 ] || exit 1 1974*0Sstevel@tonic-gate[ "xinitially dir1/syslog.4" = "x`/bin/cat dir1/syslog.5`" ] || exit 1 1975*0Sstevel@tonic-gate[ -f dir1/syslog.6 ] || exit 1 1976*0Sstevel@tonic-gate[ "xinitially dir1/syslog.5" = "x`/bin/cat dir1/syslog.6`" ] || exit 1 1977*0Sstevel@tonic-gate[ -f dir1/syslog.7 ] || exit 1 1978*0Sstevel@tonic-gate[ "xinitially dir1/syslog.6" = "x`/bin/cat dir1/syslog.7`" ] || exit 1 1979*0Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1 1980*0Sstevel@tonic-gate 1981*0Sstevel@tonic-gateexit 0 1982*0Sstevel@tonic-gateEOF 1983*0Sstevel@tonic-gate 1984*0Sstevel@tonic-gate set_file('runtest', <<"EOF"); 1985*0Sstevel@tonic-gate# test "logadm18" 1986*0Sstevel@tonic-gate$envsetup 1987*0Sstevel@tonic-gateexec $bindir/logadm -f logadm.conf >std.out 2>std.err 1988*0Sstevel@tonic-gateEOF 1989*0Sstevel@tonic-gate} 1990