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