xref: /onnv-gate/usr/src/cmd/logadm/tester (revision 954:3ca84f048d8e)
10Sstevel@tonic-gate#!/usr/bin/perl -w
20Sstevel@tonic-gate#
30Sstevel@tonic-gate# CDDL HEADER START
40Sstevel@tonic-gate#
50Sstevel@tonic-gate# The contents of this file are subject to the terms of the
60Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
70Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
80Sstevel@tonic-gate# with the License.
90Sstevel@tonic-gate#
100Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
110Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
120Sstevel@tonic-gate# See the License for the specific language governing permissions
130Sstevel@tonic-gate# and limitations under the License.
140Sstevel@tonic-gate#
150Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
160Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
170Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
180Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
190Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
200Sstevel@tonic-gate#
210Sstevel@tonic-gate# CDDL HEADER END
220Sstevel@tonic-gate#
230Sstevel@tonic-gate#
24*954Sgm149974# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
250Sstevel@tonic-gate# Use is subject to license terms.
260Sstevel@tonic-gate#
270Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"
280Sstevel@tonic-gate#
290Sstevel@tonic-gate#
300Sstevel@tonic-gate# tester - run logadm tests
310Sstevel@tonic-gate#
320Sstevel@tonic-gate# requires a <bindir> argument to say where the various logadm
330Sstevel@tonic-gate# binaries live (conftest, globtest, kwtest, luttest, optstest, and
340Sstevel@tonic-gate# logadm itself).
350Sstevel@tonic-gate#
360Sstevel@tonic-gate# to run all the tests:
370Sstevel@tonic-gate# 	tester [-f] <bindir>
380Sstevel@tonic-gate#
390Sstevel@tonic-gate# to run just a few tests, given their names:
400Sstevel@tonic-gate# 	tester [-f] <bindir> globtest1 luttest1
410Sstevel@tonic-gate#
420Sstevel@tonic-gate# to setup a test and stop so you can run it by hand:
430Sstevel@tonic-gate# 	tester [-f] -s globtest1 <bindir>
440Sstevel@tonic-gate#
450Sstevel@tonic-gate# 	tester will tell you what tmp directory it created for
460Sstevel@tonic-gate# 	the test.  to run it, cd there and run:
470Sstevel@tonic-gate# 		sh runtest
480Sstevel@tonic-gate# 	to check the results, run:
490Sstevel@tonic-gate# 		sh checktest
500Sstevel@tonic-gate#
510Sstevel@tonic-gate# -f means "fast" -- without it, watchmalloc(3MALLOC) is setup for
520Sstevel@tonic-gate# each test and they run a zillion times slower and produce core
530Sstevel@tonic-gate# dumps when malloc/free problems are detected.
540Sstevel@tonic-gate#
550Sstevel@tonic-gate$watchmalloc=1;		# default is to use watchmalloc
560Sstevel@tonic-gate${ENV} = "/bin";
570Sstevel@tonic-gateumask 002;
580Sstevel@tonic-gate
590Sstevel@tonic-gate# list of tests we run by default
600Sstevel@tonic-gate@tests = (
610Sstevel@tonic-gate	"conftest1",
620Sstevel@tonic-gate	"conftest2",
630Sstevel@tonic-gate	"globtest1",
640Sstevel@tonic-gate	"globtest2",
650Sstevel@tonic-gate	"kwtest1",
660Sstevel@tonic-gate	"kwtest2",
670Sstevel@tonic-gate	"luttest1",
680Sstevel@tonic-gate	"optstest1",
690Sstevel@tonic-gate	"optstest2",
700Sstevel@tonic-gate	"logadmV1",
710Sstevel@tonic-gate	"logadmV2",
720Sstevel@tonic-gate	"logadmr",
730Sstevel@tonic-gate	"logadmw",
740Sstevel@tonic-gate	"logadm1",
750Sstevel@tonic-gate	"logadm1c",
760Sstevel@tonic-gate	"logadm2",
770Sstevel@tonic-gate	"logadm3",
780Sstevel@tonic-gate	"logadm4",
790Sstevel@tonic-gate	"logadm5",
800Sstevel@tonic-gate	"logadm6",
810Sstevel@tonic-gate	"logadm7",
820Sstevel@tonic-gate	"logadm8",
830Sstevel@tonic-gate	"logadm9",
840Sstevel@tonic-gate	"logadm9d",
850Sstevel@tonic-gate	"logadm10",
860Sstevel@tonic-gate	"logadm11",
870Sstevel@tonic-gate	"logadm12",
880Sstevel@tonic-gate	"logadm13",
890Sstevel@tonic-gate	"logadm14",
900Sstevel@tonic-gate	"logadm15",
910Sstevel@tonic-gate	"logadm16",
920Sstevel@tonic-gate	"logadm17",
930Sstevel@tonic-gate	"logadm18",
94*954Sgm149974	"logadm19",
950Sstevel@tonic-gate);
960Sstevel@tonic-gate
970Sstevel@tonic-gateuse Getopt::Std;
980Sstevel@tonic-gateuse File::Find;
990Sstevel@tonic-gate
1000Sstevel@tonic-gate$usage_summary = '[-s test-name] [-d dir] bindir [test-name...]';
1010Sstevel@tonic-gate$usage_getopts = 'fd:s:';
1020Sstevel@tonic-gate%usage = (
1030Sstevel@tonic-gate	d=>'use dir for tests rather than creating one in /tmp',
1040Sstevel@tonic-gate	s=>'setup only, do not run test');
1050Sstevel@tonic-gate
1060Sstevel@tonic-gate# spew usage message, plus any given message, and exit
1070Sstevel@tonic-gatesub usage {
1080Sstevel@tonic-gate	my $msg = shift;
1090Sstevel@tonic-gate
1100Sstevel@tonic-gate	if ($msg) {
1110Sstevel@tonic-gate		chomp $msg;
1120Sstevel@tonic-gate		warn "$0: $msg\n" if $msg;
1130Sstevel@tonic-gate	}
1140Sstevel@tonic-gate	warn "Usage: $0 $usage_summary\n";
1150Sstevel@tonic-gate	foreach (sort keys %usage) {
1160Sstevel@tonic-gate		warn "       -$_ $usage{$_}\n";
1170Sstevel@tonic-gate	}
1180Sstevel@tonic-gate	exit 1;
1190Sstevel@tonic-gate}
1200Sstevel@tonic-gate
1210Sstevel@tonic-gate#
1220Sstevel@tonic-gate# basic argument processing
1230Sstevel@tonic-gate#
1240Sstevel@tonic-gate$myname = $0;
1250Sstevel@tonic-gate$myname =~ s/.*\///;	# just show last component in error mesages
1260Sstevel@tonic-gategetopts($usage_getopts) or usage;
1270Sstevel@tonic-gate$bindir = shift or usage;
1280Sstevel@tonic-gateusage("$bindir does not exist") unless -d $bindir;
1290Sstevel@tonic-gateusage("cannot list more than one test with -s option") if $opt_s && @ARGV;
1300Sstevel@tonic-gate@tests = @ARGV if @ARGV;
1310Sstevel@tonic-gateprint "Fast mode\n" if $opt_f;
1320Sstevel@tonic-gate$watchmalloc = 0 if $opt_f;
1330Sstevel@tonic-gate
1340Sstevel@tonic-gate$mydir=`pwd`;
1350Sstevel@tonic-gatechomp $mydir;
1360Sstevel@tonic-gate
1370Sstevel@tonic-gate$dir = $opt_d;
1380Sstevel@tonic-gate$dir = "/tmp/logadmtest$$" unless $dir = $opt_d;
1390Sstevel@tonic-gate
1400Sstevel@tonic-gateif (!-d $dir) {
1410Sstevel@tonic-gate	mkdir $dir, 0777 or die "$myname: mkdir $dir: $!\n";
1420Sstevel@tonic-gate	$needrmdir = 1;
1430Sstevel@tonic-gate}
1440Sstevel@tonic-gate
1450Sstevel@tonic-gatechdir $dir or die "$myname: $dir: $!\n";
1460Sstevel@tonic-gate
1470Sstevel@tonic-gate# common commands in runtest by tests
1480Sstevel@tonic-gateif ($watchmalloc) {
1490Sstevel@tonic-gate	$envsetup =
1500Sstevel@tonic-gate		"HOME=$dir export HOME; " .
1510Sstevel@tonic-gate		"LD_PRELOAD=watchmalloc.so.1 export LD_PRELOAD; " .
1520Sstevel@tonic-gate		"MALLOC_DEBUG=RW export MALLOC_DEBUG";
1530Sstevel@tonic-gate} else {
1540Sstevel@tonic-gate	$envsetup = "HOME=$dir export HOME; ";
1550Sstevel@tonic-gate}
1560Sstevel@tonic-gate
1570Sstevel@tonic-gate$| = 1;		# a.k.a. setbuf(stdout, NULL)
1580Sstevel@tonic-gate
1590Sstevel@tonic-gateif ($opt_s) {
1600Sstevel@tonic-gate	#
1610Sstevel@tonic-gate	# just setup the test, explain how to use it, and exit
1620Sstevel@tonic-gate	#
1630Sstevel@tonic-gate	$testname = $opt_s;
1640Sstevel@tonic-gate	eval "&$opt_s";
1650Sstevel@tonic-gate	die "$myname: ERROR: $@" if $@;
1660Sstevel@tonic-gate	print "$myname: $testname setup complete, to run, cd to:\n";
1670Sstevel@tonic-gate	print "    $dir\n";
1680Sstevel@tonic-gate	print "and run the command:\n";
1690Sstevel@tonic-gate	print "    sh runtest\n";
1700Sstevel@tonic-gate	print "to check the results, run the command:\n";
1710Sstevel@tonic-gate	print "    sh checktest\n";
1720Sstevel@tonic-gate	exit 0;
1730Sstevel@tonic-gate} else {
1740Sstevel@tonic-gate	#
1750Sstevel@tonic-gate	# run all the tests
1760Sstevel@tonic-gate	#
1770Sstevel@tonic-gate	foreach (@tests) {
1780Sstevel@tonic-gate		$testname = $_;
1790Sstevel@tonic-gate		print "Running $testname...";
1800Sstevel@tonic-gate		eval "&$_";
1810Sstevel@tonic-gate		if ($@) {
1820Sstevel@tonic-gate			print " SETUP FAILURE\n";
1830Sstevel@tonic-gate			print STDERR "$myname: ERROR: $@";
1840Sstevel@tonic-gate			exit 1;
1850Sstevel@tonic-gate		}
1860Sstevel@tonic-gate		eval "runner('runtest')";
1870Sstevel@tonic-gate		if ($@) {
1880Sstevel@tonic-gate			print " RUNTEST FAILURE\n";
1890Sstevel@tonic-gate			print STDERR "$myname: ERROR: $@";
1900Sstevel@tonic-gate			print STDERR "results captured in directory $dir\n";
1910Sstevel@tonic-gate			print STDERR "  or use: $myname -s $testname $bindir\n";
1920Sstevel@tonic-gate			print STDERR "  to do a fresh setup of this test.\n";
1930Sstevel@tonic-gate			exit 1;
1940Sstevel@tonic-gate		}
1950Sstevel@tonic-gate		eval "runner('checktest')";
1960Sstevel@tonic-gate		if ($@) {
1970Sstevel@tonic-gate			print " CHECKTEST FAILURE\n";
1980Sstevel@tonic-gate			print STDERR "$myname: ERROR: $@";
1990Sstevel@tonic-gate			print STDERR "results captured in directory $dir\n";
2000Sstevel@tonic-gate			print STDERR "  or use: $myname -s $testname $bindir\n";
2010Sstevel@tonic-gate			print STDERR "  to do a fresh setup of this test.\n";
2020Sstevel@tonic-gate			exit 1;
2030Sstevel@tonic-gate		}
2040Sstevel@tonic-gate		print "pass\n";
2050Sstevel@tonic-gate		# sanity...
2060Sstevel@tonic-gate		die "unexpected dir $dir" unless $dir =~ m,/.+/,;
2070Sstevel@tonic-gate		system("/bin/rm -rf $dir/*");
2080Sstevel@tonic-gate	}
2090Sstevel@tonic-gate}
2100Sstevel@tonic-gate
2110Sstevel@tonic-gate# if we were the ones who created $dir, remove it
2120Sstevel@tonic-gateif ($needrmdir) {
2130Sstevel@tonic-gate	chdir $mydir;
2140Sstevel@tonic-gate	rmdir $dir || die "$myname: rmdir $dir: $!\n";
2150Sstevel@tonic-gate}
2160Sstevel@tonic-gate
2170Sstevel@tonic-gateexit 0;
2180Sstevel@tonic-gate
2190Sstevel@tonic-gate#
2200Sstevel@tonic-gate# run a shell script and check for failure
2210Sstevel@tonic-gate#
2220Sstevel@tonic-gate# the shell scripts generated by this program always "exec" the binary
2230Sstevel@tonic-gate# under test so checking here are for exit code, signals, and core dump
2240Sstevel@tonic-gate# is actually checking the program under test and not /bin/sh
2250Sstevel@tonic-gate#
2260Sstevel@tonic-gatesub runner {
2270Sstevel@tonic-gate	my $cmd = shift;
2280Sstevel@tonic-gate	my $fullcmd = "/bin/sh $cmd";
2290Sstevel@tonic-gate	my $rc = 0xffff & system("$fullcmd");
2300Sstevel@tonic-gate
2310Sstevel@tonic-gate	if ($rc == 0) {
2320Sstevel@tonic-gate		return;		# cmd completed normally
2330Sstevel@tonic-gate	} elsif ($rc == 0xff00) {
2340Sstevel@tonic-gate		die "command \"$cmd\" failed: $!\n";
2350Sstevel@tonic-gate	} elsif (($rc & 0xff) == 0) {
2360Sstevel@tonic-gate		$rc >>= 8;
2370Sstevel@tonic-gate		die "command \"$cmd\" exit $rc\n";
2380Sstevel@tonic-gate	} else {
2390Sstevel@tonic-gate		my $coremsg;
2400Sstevel@tonic-gate		$coremsg = " (core dumped)" if ($rc & 0x80);
2410Sstevel@tonic-gate		$rc &= ~0x80;
2420Sstevel@tonic-gate		die "command \"$cmd\" signal $rc$coremsg\n" ;
2430Sstevel@tonic-gate	}
2440Sstevel@tonic-gate}
2450Sstevel@tonic-gate
2460Sstevel@tonic-gate#
2470Sstevel@tonic-gate# set_file(filename [, contents]) -- create a file, optionally with contents
2480Sstevel@tonic-gate#
2490Sstevel@tonic-gatesub set_file {
2500Sstevel@tonic-gate	my $file = shift;
2510Sstevel@tonic-gate	my $contents = shift;
2520Sstevel@tonic-gate
2530Sstevel@tonic-gate	open SF, ">$file" or die "create \"$file\": $!\n";
2540Sstevel@tonic-gate	print SF $contents if defined($contents);
2550Sstevel@tonic-gate	close SF;
2560Sstevel@tonic-gate}
2570Sstevel@tonic-gate
2580Sstevel@tonic-gate#############
2590Sstevel@tonic-gate#############
2600Sstevel@tonic-gate#############    THE TESTS START AFTER HERE...
2610Sstevel@tonic-gate#############
2620Sstevel@tonic-gate#############
2630Sstevel@tonic-gate
2640Sstevel@tonic-gate# common setup step -- create a testfile.conf
2650Sstevel@tonic-gatesub set_testconffile {
2660Sstevel@tonic-gate	my $fname = shift;
2670Sstevel@tonic-gate	$fname = 'testfile.conf' unless defined($fname);
2680Sstevel@tonic-gate
2690Sstevel@tonic-gate	set_file($fname, <<'EOF');
2700Sstevel@tonic-gate#
2710Sstevel@tonic-gate# logadm.conf
2720Sstevel@tonic-gate#
2730Sstevel@tonic-gate# Default settings for system log file management.
2740Sstevel@tonic-gate# The -w option to logadm(1M) is the preferred way to write to this file,
2750Sstevel@tonic-gate# but if you do edit it by hand, use "logadm -V" to check it for errors.
2760Sstevel@tonic-gate#
2770Sstevel@tonic-gate# The format of lines in this file is:
2780Sstevel@tonic-gate#       <logname> <options>
2790Sstevel@tonic-gate# For each logname listed here, the default options to logadm
2800Sstevel@tonic-gate# are given.  Options given on the logadm command line override
2810Sstevel@tonic-gate# the defaults contained in this file.
2820Sstevel@tonic-gate#
2830Sstevel@tonic-gate# logadm typically runs early every morning via an entry in
2840Sstevel@tonic-gate# root's crontab (see crontab(1)).
2850Sstevel@tonic-gate#
2860Sstevel@tonic-gate/var/adm/messages -C 4 -P 'Thu Nov  1 16:56:42 2001' -a 'kill -HUP `cat /var/run/syslog.pid`'
2870Sstevel@tonic-gate/var/cron/log -s 512k -t /var/cron/olog
2880Sstevel@tonic-gate/var/lp/logs/lpsched -C 2 -N -t '$file.$N'
2890Sstevel@tonic-gate#
2900Sstevel@tonic-gate# The entry below is used by turnacct(1M)
2910Sstevel@tonic-gate#
2920Sstevel@tonic-gate/var/adm/pacct -C 0 -a '/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -p never
2930Sstevel@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'
2940Sstevel@tonic-gate/var/log/syslog -C 8 -P 'Thu Nov  1 09:16:38 2001' -a 'kill -HUP `cat /var/run/syslog.pid`'
2950Sstevel@tonic-gate/var/apache/logs/access_log -P 'Thu Nov  1 08:27:56 2001'
2960Sstevel@tonic-gate/var/apache/logs/error_log -P 'Thu Nov  1 08:27:56 2001'
2970Sstevel@tonic-gate/var/apache/logs/suexec_log -P 'Thu Nov  1 08:27:56 2001'
2980Sstevel@tonic-gate/var/apache/logs/mod_jserv.log -P 'Thu Nov  1 08:27:56 2001'
2990Sstevel@tonic-gate/var/apache/logs/jserv.log -P 'Thu Nov  1 08:27:56 2001'
3000Sstevel@tonic-gateEOF
3010Sstevel@tonic-gate}
3020Sstevel@tonic-gate
3030Sstevel@tonic-gate
3040Sstevel@tonic-gate###########################################################################
3050Sstevel@tonic-gate#
3060Sstevel@tonic-gate#	conftest1 -- minimal basic test of the conf.c code
3070Sstevel@tonic-gate#
3080Sstevel@tonic-gate###########################################################################
3090Sstevel@tonic-gatesub conftest1 {
3100Sstevel@tonic-gate	set_testconffile;
3110Sstevel@tonic-gate
3120Sstevel@tonic-gate	set_file('checktest', <<'EOF');
3130Sstevel@tonic-gate[ -s std.err ] && exit 1
3140Sstevel@tonic-gate/bin/sed '/^conffile <testfile.conf>:$/d' <std.out >sed.out
3150Sstevel@tonic-gateexec /bin/diff sed.out testfile.conf
3160Sstevel@tonic-gateEOF
3170Sstevel@tonic-gate
3180Sstevel@tonic-gate	set_file('runtest', <<"EOF");
3190Sstevel@tonic-gate# test "conftest1"
3200Sstevel@tonic-gate$envsetup
3210Sstevel@tonic-gateexec $bindir/conftest testfile.conf >std.out 2>std.err
3220Sstevel@tonic-gateEOF
3230Sstevel@tonic-gate}
3240Sstevel@tonic-gate
3250Sstevel@tonic-gate###########################################################################
3260Sstevel@tonic-gate#
3270Sstevel@tonic-gate#	conftest2 -- error path through conf.c
3280Sstevel@tonic-gate#
3290Sstevel@tonic-gate###########################################################################
3300Sstevel@tonic-gatesub conftest2 {
3310Sstevel@tonic-gate	set_file('testfile.conf', 'line fragment');
3320Sstevel@tonic-gate
3330Sstevel@tonic-gate	set_file('std.err.expect', <<'EOF');
3340Sstevel@tonic-gateconftest: Warning: config file doesn't end with newline, last line ignored.
3350Sstevel@tonic-gateEOF
3360Sstevel@tonic-gate
3370Sstevel@tonic-gate	set_file('checktest', <<'EOF');
3380Sstevel@tonic-gateexec /bin/diff std.err std.err.expect
3390Sstevel@tonic-gateEOF
3400Sstevel@tonic-gate
3410Sstevel@tonic-gate	set_file('runtest', <<"EOF");
3420Sstevel@tonic-gate# test "conftest2"
3430Sstevel@tonic-gate$envsetup
3440Sstevel@tonic-gate$bindir/conftest testfile.conf >std.out 2>std.err || exit 0
3450Sstevel@tonic-gateexit 1
3460Sstevel@tonic-gateEOF
3470Sstevel@tonic-gate}
3480Sstevel@tonic-gate
3490Sstevel@tonic-gate###########################################################################
3500Sstevel@tonic-gate#
3510Sstevel@tonic-gate#	globtest1 -- minimal basic test of the glob.c code
3520Sstevel@tonic-gate#
3530Sstevel@tonic-gate###########################################################################
3540Sstevel@tonic-gatesub globtest1 {
3550Sstevel@tonic-gate	set_file('fileBname12');
3560Sstevel@tonic-gate	sleep 2;	# ensure above name is odler than below name
3570Sstevel@tonic-gate	set_file('fileAname12');
3580Sstevel@tonic-gate	set_file('fileAname1');
3590Sstevel@tonic-gate	set_file('fileAname3');
3600Sstevel@tonic-gate	set_file('fileAname5');
3610Sstevel@tonic-gate	set_file('fileAname7');
3620Sstevel@tonic-gate	set_file('fileAname9');
3630Sstevel@tonic-gate	set_file('fileAname11');
3640Sstevel@tonic-gate	set_file('fileBname0');
3650Sstevel@tonic-gate	set_file('fileBname2');
3660Sstevel@tonic-gate	set_file('fileBname4');
3670Sstevel@tonic-gate	set_file('fileBname6');
3680Sstevel@tonic-gate	set_file('fileBname8');
3690Sstevel@tonic-gate	set_file('fileBname10');
3700Sstevel@tonic-gate	mkdir 'dir1', 0777 or die "mkdir dir1: $!\n";
3710Sstevel@tonic-gate	mkdir 'dir2', 0777 or die "mkdir dir2: $!\n";
3720Sstevel@tonic-gate	mkdir 'dir3', 0777 or die "mkdir dir3: $!\n";
3730Sstevel@tonic-gate	mkdir 'dir1/dirA', 0777 or die "mkdir dir1/dirA: $!\n";
3740Sstevel@tonic-gate	mkdir 'dir1/dirB', 0777 or die "mkdir dir1/dirB: $!\n";
3750Sstevel@tonic-gate	mkdir 'dir1/dirC', 0777 or die "mkdir dir1/dirC: $!\n";
3760Sstevel@tonic-gate	mkdir 'dir2/dirA', 0777 or die "mkdir dir2/dirA: $!\n";
3770Sstevel@tonic-gate	mkdir 'dir2/dirB', 0777 or die "mkdir dir2/dirB: $!\n";
3780Sstevel@tonic-gate	mkdir 'dir2/dirC', 0777 or die "mkdir dir2/dirC: $!\n";
3790Sstevel@tonic-gate	set_file('dir1/fileAname1');
3800Sstevel@tonic-gate	set_file('dir1/fileAname2');
3810Sstevel@tonic-gate	set_file('dir1/fileAname3');
3820Sstevel@tonic-gate	set_file('dir1/fileAname4');
3830Sstevel@tonic-gate	set_file('dir1/fileAname5');
3840Sstevel@tonic-gate	set_file('dir1/fileBname1');
3850Sstevel@tonic-gate	set_file('dir1/fileBname2');
3860Sstevel@tonic-gate	set_file('dir1/fileBname3');
3870Sstevel@tonic-gate	set_file('dir1/fileBname4');
3880Sstevel@tonic-gate	set_file('dir1/fileBname5');
3890Sstevel@tonic-gate	# supply some varying sizes to produce different total size values
3900Sstevel@tonic-gate	set_file('dir1/dirA/fileAname4', '4444');
3910Sstevel@tonic-gate	sleep 2;	# ensure above file is oldest in dirA
3920Sstevel@tonic-gate	set_file('dir1/dirA/fileAname1', '1');
3930Sstevel@tonic-gate	set_file('dir1/dirA/fileAname2', '22');
3940Sstevel@tonic-gate	set_file('dir1/dirA/fileAname3', '333');
3950Sstevel@tonic-gate	set_file('dir1/dirA/fileAname5', '55555');
3960Sstevel@tonic-gate	set_file('dir1/dirA/fileBname1', '1');
3970Sstevel@tonic-gate	set_file('dir1/dirA/fileBname2', '22');
3980Sstevel@tonic-gate	set_file('dir1/dirA/fileBname3', '333');
3990Sstevel@tonic-gate	set_file('dir1/dirA/fileBname4', '4444');
4000Sstevel@tonic-gate	set_file('dir1/dirA/fileBname5', '55555');
4010Sstevel@tonic-gate	set_file('dir1/dirB/fileAname1', '1');
4020Sstevel@tonic-gate	set_file('dir1/dirB/fileAname2', '22');
4030Sstevel@tonic-gate	set_file('dir1/dirB/fileAname3', '333');
4040Sstevel@tonic-gate	set_file('dir1/dirB/fileAname4', '4444');
4050Sstevel@tonic-gate	set_file('dir1/dirB/fileAname5', '55555');
4060Sstevel@tonic-gate	set_file('dir1/dirB/fileBname1', '1');
4070Sstevel@tonic-gate	set_file('dir1/dirB/fileBname2', '22');
4080Sstevel@tonic-gate	set_file('dir1/dirB/fileBname3', '333');
4090Sstevel@tonic-gate	set_file('dir1/dirB/fileBname4', '4444');
4100Sstevel@tonic-gate	set_file('dir1/dirB/fileBname5', '55555');
4110Sstevel@tonic-gate	set_file('dir1/dirC/fileAname10', '12345678901');
4120Sstevel@tonic-gate	set_file('dir1/dirC/fileAname20', '123456789022');
4130Sstevel@tonic-gate	set_file('dir1/dirC/fileAname30', '1234567890333');
4140Sstevel@tonic-gate	set_file('dir1/dirC/fileAname40', '12345678904444');
4150Sstevel@tonic-gate	set_file('dir1/dirC/fileAname50', '123456789055555');
4160Sstevel@tonic-gate	set_file('dir1/dirC/fileBname10', '12345678901');
4170Sstevel@tonic-gate	set_file('dir1/dirC/fileBname20', '123456789022');
4180Sstevel@tonic-gate	set_file('dir1/dirC/fileBname30', '1234567890333');
4190Sstevel@tonic-gate	set_file('dir1/dirC/fileBname40', '12345678904444');
4200Sstevel@tonic-gate	set_file('dir1/dirC/fileBname50', '123456789055555');
4210Sstevel@tonic-gate
4220Sstevel@tonic-gate	set_file('std.out.expect', <<'EOF');
4230Sstevel@tonic-gate<file{A,B,C}name*>:
4240Sstevel@tonic-gate    <./fileAname12>
4250Sstevel@tonic-gate    <./fileAname1>
4260Sstevel@tonic-gate    <./fileAname3>
4270Sstevel@tonic-gate    <./fileAname5>
4280Sstevel@tonic-gate    <./fileAname7>
4290Sstevel@tonic-gate    <./fileAname9>
4300Sstevel@tonic-gate    <./fileAname11>
4310Sstevel@tonic-gate    <./fileBname12>
4320Sstevel@tonic-gate    <./fileBname0>
4330Sstevel@tonic-gate    <./fileBname2>
4340Sstevel@tonic-gate    <./fileBname4>
4350Sstevel@tonic-gate    <./fileBname6>
4360Sstevel@tonic-gate    <./fileBname8>
4370Sstevel@tonic-gate    <./fileBname10>
4380Sstevel@tonic-gatetotal size: 0
4390Sstevel@tonic-gate    oldest <./fileBname12>
4400Sstevel@tonic-gate    oldest <./fileBname8>
4410Sstevel@tonic-gate    oldest <./fileBname6>
4420Sstevel@tonic-gate    oldest <./fileBname4>
4430Sstevel@tonic-gate    oldest <./fileBname2>
4440Sstevel@tonic-gate    oldest <./fileBname10>
4450Sstevel@tonic-gate    oldest <./fileBname0>
4460Sstevel@tonic-gate    oldest <./fileAname9>
4470Sstevel@tonic-gate    oldest <./fileAname7>
4480Sstevel@tonic-gate    oldest <./fileAname5>
4490Sstevel@tonic-gate    oldest <./fileAname3>
4500Sstevel@tonic-gate    oldest <./fileAname12>
4510Sstevel@tonic-gate    oldest <./fileAname11>
4520Sstevel@tonic-gate    oldest <./fileAname1>
4530Sstevel@tonic-gate<file{A,B,C}name>:
4540Sstevel@tonic-gate    <fileAname>
4550Sstevel@tonic-gate    <fileBname>
4560Sstevel@tonic-gate    <fileCname>
4570Sstevel@tonic-gatetotal size: 0
4580Sstevel@tonic-gate    oldest <fileCname>
4590Sstevel@tonic-gate    oldest <fileBname>
4600Sstevel@tonic-gate    oldest <fileAname>
4610Sstevel@tonic-gate<dir1/dirA/file*>:
4620Sstevel@tonic-gate    <./dir1/dirA/fileAname4>
4630Sstevel@tonic-gate    <./dir1/dirA/fileAname1>
4640Sstevel@tonic-gate    <./dir1/dirA/fileAname2>
4650Sstevel@tonic-gate    <./dir1/dirA/fileAname3>
4660Sstevel@tonic-gate    <./dir1/dirA/fileAname5>
4670Sstevel@tonic-gate    <./dir1/dirA/fileBname1>
4680Sstevel@tonic-gate    <./dir1/dirA/fileBname2>
4690Sstevel@tonic-gate    <./dir1/dirA/fileBname3>
4700Sstevel@tonic-gate    <./dir1/dirA/fileBname4>
4710Sstevel@tonic-gate    <./dir1/dirA/fileBname5>
4720Sstevel@tonic-gatetotal size: 30
4730Sstevel@tonic-gate    oldest <./dir1/dirA/fileAname4>
4740Sstevel@tonic-gate    oldest <./dir1/dirA/fileBname5>
4750Sstevel@tonic-gate    oldest <./dir1/dirA/fileBname4>
4760Sstevel@tonic-gate    oldest <./dir1/dirA/fileBname3>
4770Sstevel@tonic-gate    oldest <./dir1/dirA/fileBname2>
4780Sstevel@tonic-gate    oldest <./dir1/dirA/fileBname1>
4790Sstevel@tonic-gate    oldest <./dir1/dirA/fileAname5>
4800Sstevel@tonic-gate    oldest <./dir1/dirA/fileAname3>
4810Sstevel@tonic-gate    oldest <./dir1/dirA/fileAname2>
4820Sstevel@tonic-gate    oldest <./dir1/dirA/fileAname1>
4830Sstevel@tonic-gate<dir[13]/[e-z]*>:
4840Sstevel@tonic-gate    <./dir1/fileAname1>
4850Sstevel@tonic-gate    <./dir1/fileAname2>
4860Sstevel@tonic-gate    <./dir1/fileAname3>
4870Sstevel@tonic-gate    <./dir1/fileAname4>
4880Sstevel@tonic-gate    <./dir1/fileAname5>
4890Sstevel@tonic-gate    <./dir1/fileBname1>
4900Sstevel@tonic-gate    <./dir1/fileBname2>
4910Sstevel@tonic-gate    <./dir1/fileBname3>
4920Sstevel@tonic-gate    <./dir1/fileBname4>
4930Sstevel@tonic-gate    <./dir1/fileBname5>
4940Sstevel@tonic-gatetotal size: 0
4950Sstevel@tonic-gate    oldest <./dir1/fileBname5>
4960Sstevel@tonic-gate    oldest <./dir1/fileBname4>
4970Sstevel@tonic-gate    oldest <./dir1/fileBname3>
4980Sstevel@tonic-gate    oldest <./dir1/fileBname2>
4990Sstevel@tonic-gate    oldest <./dir1/fileBname1>
5000Sstevel@tonic-gate    oldest <./dir1/fileAname5>
5010Sstevel@tonic-gate    oldest <./dir1/fileAname4>
5020Sstevel@tonic-gate    oldest <./dir1/fileAname3>
5030Sstevel@tonic-gate    oldest <./dir1/fileAname2>
5040Sstevel@tonic-gate    oldest <./dir1/fileAname1>
5050Sstevel@tonic-gate<dir?/dir[AC]/fileBname[2-9]>:
5060Sstevel@tonic-gate    <./dir1/dirA/fileBname2>
5070Sstevel@tonic-gate    <./dir1/dirA/fileBname3>
5080Sstevel@tonic-gate    <./dir1/dirA/fileBname4>
5090Sstevel@tonic-gate    <./dir1/dirA/fileBname5>
5100Sstevel@tonic-gatetotal size: 14
5110Sstevel@tonic-gate    oldest <./dir1/dirA/fileBname5>
5120Sstevel@tonic-gate    oldest <./dir1/dirA/fileBname4>
5130Sstevel@tonic-gate    oldest <./dir1/dirA/fileBname3>
5140Sstevel@tonic-gate    oldest <./dir1/dirA/fileBname2>
5150Sstevel@tonic-gate<file[A-Z]n.*e([0-9]+)$0>:
5160Sstevel@tonic-gate    <./fileBname12>
5170Sstevel@tonic-gate    <./fileAname12>
5180Sstevel@tonic-gate    <./fileAname1>
5190Sstevel@tonic-gate    <./fileAname3>
5200Sstevel@tonic-gate    <./fileAname5>
5210Sstevel@tonic-gate    <./fileAname7>
5220Sstevel@tonic-gate    <./fileAname9>
5230Sstevel@tonic-gate    <./fileAname11>
5240Sstevel@tonic-gate    <./fileBname0>
5250Sstevel@tonic-gate    <./fileBname2>
5260Sstevel@tonic-gate    <./fileBname4>
5270Sstevel@tonic-gate    <./fileBname6>
5280Sstevel@tonic-gate    <./fileBname8>
5290Sstevel@tonic-gate    <./fileBname10>
5300Sstevel@tonic-gatetotal size: 0
5310Sstevel@tonic-gate    oldest <./fileBname12>
5320Sstevel@tonic-gate    oldest <./fileAname12>
5330Sstevel@tonic-gate    oldest <./fileAname11>
5340Sstevel@tonic-gate    oldest <./fileBname10>
5350Sstevel@tonic-gate    oldest <./fileAname9>
5360Sstevel@tonic-gate    oldest <./fileBname8>
5370Sstevel@tonic-gate    oldest <./fileAname7>
5380Sstevel@tonic-gate    oldest <./fileBname6>
5390Sstevel@tonic-gate    oldest <./fileAname5>
5400Sstevel@tonic-gate    oldest <./fileBname4>
5410Sstevel@tonic-gate    oldest <./fileAname3>
5420Sstevel@tonic-gate    oldest <./fileBname2>
5430Sstevel@tonic-gate    oldest <./fileAname1>
5440Sstevel@tonic-gate    oldest <./fileBname0>
5450Sstevel@tonic-gateEOF
5460Sstevel@tonic-gate
5470Sstevel@tonic-gate	set_file('checktest', <<'EOF');
5480Sstevel@tonic-gate[ -s std.err ] && exit 1
5490Sstevel@tonic-gateexec /bin/diff std.out std.out.expect
5500Sstevel@tonic-gateEOF
5510Sstevel@tonic-gate
5520Sstevel@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\'';
5530Sstevel@tonic-gate
5540Sstevel@tonic-gate	set_file('runtest', <<"EOF");
5550Sstevel@tonic-gate# test "globtest1"
5560Sstevel@tonic-gate$envsetup
5570Sstevel@tonic-gateexec $bindir/globtest $testglobs >std.out 2>std.err
5580Sstevel@tonic-gateEOF
5590Sstevel@tonic-gate}
5600Sstevel@tonic-gate
5610Sstevel@tonic-gate###########################################################################
5620Sstevel@tonic-gate#
5630Sstevel@tonic-gate#	globtest2 -- error path through glob.c
5640Sstevel@tonic-gate#
5650Sstevel@tonic-gate###########################################################################
5660Sstevel@tonic-gatesub globtest2 {
5670Sstevel@tonic-gate	set_file('std.err.expect', <<'EOF');
5680Sstevel@tonic-gateglobtest: Error: Missing }
5690Sstevel@tonic-gateEOF
5700Sstevel@tonic-gate
5710Sstevel@tonic-gate	set_file('checktest', <<'EOF');
5720Sstevel@tonic-gateexec /bin/diff std.err std.err.expect
5730Sstevel@tonic-gateEOF
5740Sstevel@tonic-gate
5750Sstevel@tonic-gate	set_file('runtest', <<"EOF");
5760Sstevel@tonic-gate# test "globtest2"
5770Sstevel@tonic-gate$envsetup
5780Sstevel@tonic-gate$bindir/globtest 'hello{there' >std.out 2>std.err || exit 0
5790Sstevel@tonic-gateexit 1
5800Sstevel@tonic-gateEOF
5810Sstevel@tonic-gate}
5820Sstevel@tonic-gate
5830Sstevel@tonic-gate###########################################################################
5840Sstevel@tonic-gate#
5850Sstevel@tonic-gate#	kwtest1 -- minimal basic test of the kw.c code
5860Sstevel@tonic-gate#
5870Sstevel@tonic-gate###########################################################################
5880Sstevel@tonic-gatesub kwtest1 {
5890Sstevel@tonic-gate	$domainname = `/bin/domainname`; chomp $domainname;
5900Sstevel@tonic-gate	$isa = `/bin/uname -p`; chomp $isa;
5910Sstevel@tonic-gate	$platform = `/bin/uname -i`; chomp $platform;
5920Sstevel@tonic-gate	$nodename = `/bin/uname -n`; chomp $nodename;
5930Sstevel@tonic-gate	$machine = `/bin/uname -m`; chomp $machine;
5940Sstevel@tonic-gate	$release = `/bin/uname -r`; chomp $release;
5950Sstevel@tonic-gate$secondblob=<<'EOF';
5960Sstevel@tonic-gateexpand<$file.$n> n -1 hasn 1 result </var/log/syslog\.([0-9]+)$0>
5970Sstevel@tonic-gateexpand<$file.$n> n 0 hasn 1 result </var/log/syslog.0>
5980Sstevel@tonic-gateexpand<$file.$n> n 1 hasn 1 result </var/log/syslog.1>
5990Sstevel@tonic-gateexpand<moose%d.$n> n -1 hasn 1 result <moose[0-9]+\.([0-9]+)$0>
6000Sstevel@tonic-gateexpand<moose%d.$n> n 0 hasn 1 result <moose%d.0>
6010Sstevel@tonic-gateexpand<moose%d.$n> n 1 hasn 1 result <moose%d.1>
6020Sstevel@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>
6030Sstevel@tonic-gateexpand</var/logs-%Y/moose-$isa$#porklips%d.$n> n 0 hasn 1 result </var/logs-%Y/moose-ISAporklips%d.0>
6040Sstevel@tonic-gateexpand</var/logs-%Y/moose-$isa$#porklips%d.$n> n 1 hasn 1 result </var/logs-%Y/moose-ISAporklips%d.1>
6050Sstevel@tonic-gateEOF
6060Sstevel@tonic-gate	$percentd = `/bin/env TZ=UTC /bin/date +%d`; chomp $percentd;
6070Sstevel@tonic-gate	$percentY = `/bin/env TZ=UTC /bin/date +%Y`; chomp $percentY;
6080Sstevel@tonic-gate	$secondblob =~ s/%d/$percentd/mg;
6090Sstevel@tonic-gate	$secondblob =~ s/%Y/$percentY/mg;
6100Sstevel@tonic-gate	$secondblob =~ s/ISA/$isa/mg;
611*954Sgm149974	$utcenv = "TZ=UTC export TZ";
6120Sstevel@tonic-gate	chomp $secondblob;
6130Sstevel@tonic-gate	set_file('sed.out.expect', <<"EOF");
6140Sstevel@tonic-gate            basename syslog
6150Sstevel@tonic-gate             dirname /var/log
6160Sstevel@tonic-gate              domain $domainname
6170Sstevel@tonic-gate                file /var/log/syslog
6180Sstevel@tonic-gate                home $dir
6190Sstevel@tonic-gate                 isa $isa
6200Sstevel@tonic-gate             logname $ENV{LOGNAME}
6210Sstevel@tonic-gate             machine $machine
6220Sstevel@tonic-gate               nfile
6230Sstevel@tonic-gate            nodename $nodename
6240Sstevel@tonic-gate            platform $platform
6250Sstevel@tonic-gate             release $release
6260Sstevel@tonic-gate                user $ENV{USER}
6270Sstevel@tonic-gate$secondblob
6280Sstevel@tonic-gateEOF
6290Sstevel@tonic-gate
6300Sstevel@tonic-gate	set_file('checktest', <<'EOF');
6310Sstevel@tonic-gate[ -s std.err ] && exit 1
6320Sstevel@tonic-gate/bin/sed -e '/^ *secs [0-9][0-9]*$/d'\
6330Sstevel@tonic-gate	-e "s/%d/`/bin/env TZ=UTC /bin/date +%d`/g"\
6340Sstevel@tonic-gate	-e "s/%Y/`/bin/env TZ=UTC /bin/date +%Y`/g"\
6350Sstevel@tonic-gate	<std.out >sed.out
6360Sstevel@tonic-gateexec /bin/diff sed.out sed.out.expect
6370Sstevel@tonic-gateEOF
6380Sstevel@tonic-gate
6390Sstevel@tonic-gate	$kwtest='kwtest /var/log/syslog \'$file.$n\' \'moose%d.$n\' \'/var/logs-%Y/moose-$isa$#porklips%d.$n\'';
6400Sstevel@tonic-gate	set_file('runtest', <<"EOF");
6410Sstevel@tonic-gate# test "kwtest1"
6420Sstevel@tonic-gate$envsetup
643*954Sgm149974$utcenv
6440Sstevel@tonic-gateexec $bindir/$kwtest >std.out 2>std.err
6450Sstevel@tonic-gateEOF
6460Sstevel@tonic-gate}
6470Sstevel@tonic-gate
6480Sstevel@tonic-gate###########################################################################
6490Sstevel@tonic-gate#
6500Sstevel@tonic-gate#	kwtest2 -- NULL environment variables test of the kw.c code
6510Sstevel@tonic-gate#
6520Sstevel@tonic-gate###########################################################################
6530Sstevel@tonic-gatesub kwtest2 {
6540Sstevel@tonic-gate	$domainname = `/bin/domainname`; chomp $domainname;
6550Sstevel@tonic-gate	$isa = `/bin/uname -p`; chomp $isa;
6560Sstevel@tonic-gate	$platform = `/bin/uname -i`; chomp $platform;
6570Sstevel@tonic-gate	$nodename = `/bin/uname -n`; chomp $nodename;
6580Sstevel@tonic-gate	$machine = `/bin/uname -m`; chomp $machine;
6590Sstevel@tonic-gate	$release = `/bin/uname -r`; chomp $release;
6600Sstevel@tonic-gate$secondblob=<<'EOF';
6610Sstevel@tonic-gateexpand<$file.$n> n -1 hasn 1 result </var/log/syslog\.([0-9]+)$0>
6620Sstevel@tonic-gateexpand<$file.$n> n 0 hasn 1 result </var/log/syslog.0>
6630Sstevel@tonic-gateexpand<$file.$n> n 1 hasn 1 result </var/log/syslog.1>
6640Sstevel@tonic-gateexpand<moose%d.$n> n -1 hasn 1 result <moose[0-9]+\.([0-9]+)$0>
6650Sstevel@tonic-gateexpand<moose%d.$n> n 0 hasn 1 result <moose%d.0>
6660Sstevel@tonic-gateexpand<moose%d.$n> n 1 hasn 1 result <moose%d.1>
6670Sstevel@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>
6680Sstevel@tonic-gateexpand</var/logs-%Y/moose-$isa$#porklips%d.$n> n 0 hasn 1 result </var/logs-%Y/moose-ISAporklips%d.0>
6690Sstevel@tonic-gateexpand</var/logs-%Y/moose-$isa$#porklips%d.$n> n 1 hasn 1 result </var/logs-%Y/moose-ISAporklips%d.1>
6700Sstevel@tonic-gateEOF
6710Sstevel@tonic-gate	$percentd = `/bin/env TZ=UTC /bin/date +%d`; chomp $percentd;
6720Sstevel@tonic-gate	$percentY = `/bin/env TZ=UTC /bin/date +%Y`; chomp $percentY;
6730Sstevel@tonic-gate	$secondblob =~ s/%d/$percentd/mg;
6740Sstevel@tonic-gate	$secondblob =~ s/%Y/$percentY/mg;
6750Sstevel@tonic-gate	$secondblob =~ s/ISA/$isa/mg;
6760Sstevel@tonic-gate	chomp $secondblob;
6770Sstevel@tonic-gate	set_file('sed.out.expect', <<"EOF");
6780Sstevel@tonic-gate            basename syslog
6790Sstevel@tonic-gate             dirname /var/log
6800Sstevel@tonic-gate              domain $domainname
6810Sstevel@tonic-gate                file /var/log/syslog
6820Sstevel@tonic-gate                home
6830Sstevel@tonic-gate                 isa $isa
6840Sstevel@tonic-gate             logname
6850Sstevel@tonic-gate             machine $machine
6860Sstevel@tonic-gate               nfile
6870Sstevel@tonic-gate            nodename $nodename
6880Sstevel@tonic-gate            platform $platform
6890Sstevel@tonic-gate             release $release
6900Sstevel@tonic-gate                user
6910Sstevel@tonic-gate$secondblob
6920Sstevel@tonic-gateEOF
6930Sstevel@tonic-gate
6940Sstevel@tonic-gate	set_file('checktest', <<'EOF');
6950Sstevel@tonic-gate[ -s std.err ] && exit 1
6960Sstevel@tonic-gate/bin/sed -e '/^ *secs [0-9][0-9]*$/d'\
6970Sstevel@tonic-gate	-e "s/%d/`/bin/env TZ=UTC /bin/date +%d`/g"\
6980Sstevel@tonic-gate	-e "s/%Y/`/bin/env TZ=UTC /bin/date +%Y`/g"\
6990Sstevel@tonic-gate	<std.out >sed.out
7000Sstevel@tonic-gateexec /bin/diff sed.out sed.out.expect
7010Sstevel@tonic-gateEOF
7020Sstevel@tonic-gate
7030Sstevel@tonic-gate	$kwtest='kwtest /var/log/syslog \'$file.$n\' \'moose%d.$n\' \'/var/logs-%Y/moose-$isa$#porklips%d.$n\'';
7040Sstevel@tonic-gate	set_file('runtest', <<"EOF");
7050Sstevel@tonic-gate# test "kwtest2"
7060Sstevel@tonic-gate$envsetup
7070Sstevel@tonic-gateLOGNAME=
7080Sstevel@tonic-gateexport LOGNAME
7090Sstevel@tonic-gateHOME=
7100Sstevel@tonic-gateexport HOME
7110Sstevel@tonic-gateUSER=
7120Sstevel@tonic-gateexport USER
7130Sstevel@tonic-gateexec $bindir/$kwtest >std.out 2>std.err
7140Sstevel@tonic-gateEOF
7150Sstevel@tonic-gate}
7160Sstevel@tonic-gate
7170Sstevel@tonic-gate###########################################################################
7180Sstevel@tonic-gate#
7190Sstevel@tonic-gate#	luttest1 -- minimal basic test of the lut.c code
7200Sstevel@tonic-gate#
7210Sstevel@tonic-gate###########################################################################
7220Sstevel@tonic-gatesub luttest1 {
7230Sstevel@tonic-gate	set_file('std.out.expect', <<'EOF');
7240Sstevel@tonic-gatelut contains:
7250Sstevel@tonic-gate<fix> <NULL> (<NULL>)
7260Sstevel@tonic-gate<one> <two> (<two>)
7270Sstevel@tonic-gate<seven> <eight> (<eight>)
7280Sstevel@tonic-gate<six> <NULL> (<NULL>)
7290Sstevel@tonic-gate<three> <four> (<four>)
7300Sstevel@tonic-gatedup lut contains:
7310Sstevel@tonic-gate<fix> <NULL> (<NULL>)
7320Sstevel@tonic-gate<one> <two> (<two>)
7330Sstevel@tonic-gate<seven> <eight> (<eight>)
7340Sstevel@tonic-gate<six> <NULL> (<NULL>)
7350Sstevel@tonic-gate<three> <four> (<four>)
7360Sstevel@tonic-gateEOF
7370Sstevel@tonic-gate
7380Sstevel@tonic-gate	set_file('checktest', <<'EOF');
7390Sstevel@tonic-gate[ -s std.err ] && exit 1
7400Sstevel@tonic-gateexec /bin/diff std.out std.out.expect
7410Sstevel@tonic-gateEOF
7420Sstevel@tonic-gate
7430Sstevel@tonic-gate	set_file('runtest', <<"EOF");
7440Sstevel@tonic-gate# test "luttest1"
7450Sstevel@tonic-gate$envsetup
7460Sstevel@tonic-gateexec $bindir/luttest one=two three=four fix six seven=eight >std.out 2>std.err
7470Sstevel@tonic-gateEOF
7480Sstevel@tonic-gate}
7490Sstevel@tonic-gate
7500Sstevel@tonic-gate###########################################################################
7510Sstevel@tonic-gate#
7520Sstevel@tonic-gate#	optstest1 -- minimal basic test of the opts.c code
7530Sstevel@tonic-gate#
7540Sstevel@tonic-gate###########################################################################
7550Sstevel@tonic-gatesub optstest1 {
7560Sstevel@tonic-gate	$options="-a -b moose -c 1h -d 'Fri Nov  2 13:19:55 2001' -e 1k -f 2 one two three";
7570Sstevel@tonic-gate	set_file('std.out.expect', <<"EOF");
7580Sstevel@tonic-gateoptions: $options
7590Sstevel@tonic-gateEOF
7600Sstevel@tonic-gate
7610Sstevel@tonic-gate	set_file('checktest', <<'EOF');
7620Sstevel@tonic-gate[ -s std.err ] && exit 1
7630Sstevel@tonic-gateexec /bin/diff std.out std.out.expect
7640Sstevel@tonic-gateEOF
7650Sstevel@tonic-gate
7660Sstevel@tonic-gate	set_file('runtest', <<"EOF");
7670Sstevel@tonic-gate# test "optstest1"
7680Sstevel@tonic-gate$envsetup
7690Sstevel@tonic-gateexec $bindir/optstest $options >std.out 2>std.err
7700Sstevel@tonic-gateEOF
7710Sstevel@tonic-gate}
7720Sstevel@tonic-gate
7730Sstevel@tonic-gate###########################################################################
7740Sstevel@tonic-gate#
7750Sstevel@tonic-gate#	optstest2 -- error path through opts.c code
7760Sstevel@tonic-gate#
7770Sstevel@tonic-gate###########################################################################
7780Sstevel@tonic-gatesub optstest2 {
7790Sstevel@tonic-gate	$options="-a -b -c 1h -d 'Fri Nov  2 13:19:55 2001' -e 1k -f 2 one two three";
7800Sstevel@tonic-gate	set_file('std.err.expect', <<'EOF');
7810Sstevel@tonic-gateoptstest: Error: Option 'b' requires an argument
7820Sstevel@tonic-gateoptstest: Error: opts parsing failed
7830Sstevel@tonic-gateEOF
7840Sstevel@tonic-gate
7850Sstevel@tonic-gate	set_file('checktest', <<'EOF');
7860Sstevel@tonic-gate[ -s std.out ] && exit 1
7870Sstevel@tonic-gateexec /bin/diff std.err std.err.expect
7880Sstevel@tonic-gateEOF
7890Sstevel@tonic-gate
7900Sstevel@tonic-gate	set_file('runtest', <<"EOF");
7910Sstevel@tonic-gate# test "optstest2"
7920Sstevel@tonic-gate$envsetup
7930Sstevel@tonic-gate$bindir/optstest $options >std.out 2>std.err || exit 0
7940Sstevel@tonic-gateexit 1
7950Sstevel@tonic-gateEOF
7960Sstevel@tonic-gate}
7970Sstevel@tonic-gate
7980Sstevel@tonic-gate###########################################################################
7990Sstevel@tonic-gate#
8000Sstevel@tonic-gate#	logadmV1 -- test of "logadm -V"
8010Sstevel@tonic-gate#
8020Sstevel@tonic-gate###########################################################################
8030Sstevel@tonic-gatesub logadmV1 {
8040Sstevel@tonic-gate	set_testconffile;
8050Sstevel@tonic-gate
8060Sstevel@tonic-gate	set_file('std.out.expect', <<'EOF');
8070Sstevel@tonic-gate/var/adm/messages -C 4 -P 'Thu Nov  1 16:56:42 2001' -a 'kill -HUP `cat /var/run/syslog.pid`'
8080Sstevel@tonic-gate/var/cron/log -s 512k -t /var/cron/olog
8090Sstevel@tonic-gate/var/lp/logs/lpsched -C 2 -N -t '$file.$N'
8100Sstevel@tonic-gate/var/adm/pacct -C 0 -a '/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -p never
8110Sstevel@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'
8120Sstevel@tonic-gate/var/log/syslog -C 8 -P 'Thu Nov  1 09:16:38 2001' -a 'kill -HUP `cat /var/run/syslog.pid`'
8130Sstevel@tonic-gate/var/apache/logs/access_log -P 'Thu Nov  1 08:27:56 2001'
8140Sstevel@tonic-gate/var/apache/logs/error_log -P 'Thu Nov  1 08:27:56 2001'
8150Sstevel@tonic-gate/var/apache/logs/suexec_log -P 'Thu Nov  1 08:27:56 2001'
8160Sstevel@tonic-gate/var/apache/logs/mod_jserv.log -P 'Thu Nov  1 08:27:56 2001'
8170Sstevel@tonic-gate/var/apache/logs/jserv.log -P 'Thu Nov  1 08:27:56 2001'
8180Sstevel@tonic-gateEOF
8190Sstevel@tonic-gate
8200Sstevel@tonic-gate	set_file('checktest', <<'EOF');
8210Sstevel@tonic-gate[ -s std.err ] && exit 1
8220Sstevel@tonic-gateexec /bin/diff std.out std.out.expect
8230Sstevel@tonic-gateEOF
8240Sstevel@tonic-gate
8250Sstevel@tonic-gate	set_file('runtest', <<"EOF");
8260Sstevel@tonic-gate# test "logadmV1"
8270Sstevel@tonic-gate$envsetup
8280Sstevel@tonic-gateexec $bindir/logadm -f testfile.conf -V >std.out 2>std.err
8290Sstevel@tonic-gateEOF
8300Sstevel@tonic-gate}
8310Sstevel@tonic-gate
8320Sstevel@tonic-gate###########################################################################
8330Sstevel@tonic-gate#
8340Sstevel@tonic-gate#	logadmV2 -- test of "logadm -V <entry>"
8350Sstevel@tonic-gate#
8360Sstevel@tonic-gate###########################################################################
8370Sstevel@tonic-gatesub logadmV2 {
8380Sstevel@tonic-gate	set_testconffile;
8390Sstevel@tonic-gate
8400Sstevel@tonic-gate	set_file('std.out.expect', <<'EOF');
8410Sstevel@tonic-gate/var/cron/log -s 512k -t /var/cron/olog
8420Sstevel@tonic-gate/var/adm/pacct -C 0 -a '/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -p never
8430Sstevel@tonic-gateEOF
8440Sstevel@tonic-gate
8450Sstevel@tonic-gate	set_file('checktest', <<'EOF');
8460Sstevel@tonic-gate[ -s std.err ] && exit 1
8470Sstevel@tonic-gateexec /bin/diff std.out std.out.expect
8480Sstevel@tonic-gateEOF
8490Sstevel@tonic-gate
8500Sstevel@tonic-gate	set_file('runtest', <<"EOF");
8510Sstevel@tonic-gate# test "logadmV2"
8520Sstevel@tonic-gate$envsetup
8530Sstevel@tonic-gateexec $bindir/logadm -f testfile.conf -V /var/cron/log /var/adm/pacct >std.out 2>std.err
8540Sstevel@tonic-gateEOF
8550Sstevel@tonic-gate}
8560Sstevel@tonic-gate
8570Sstevel@tonic-gate###########################################################################
8580Sstevel@tonic-gate#
8590Sstevel@tonic-gate#	logadmr -- test of "logadm -r <entry>"
8600Sstevel@tonic-gate#
8610Sstevel@tonic-gate###########################################################################
8620Sstevel@tonic-gatesub logadmr {
8630Sstevel@tonic-gate	set_testconffile;
8640Sstevel@tonic-gate	set_testconffile('testfile.conf.orig');
8650Sstevel@tonic-gate
8660Sstevel@tonic-gate	set_file('diff.out.expect', <<'EOF');
8670Sstevel@tonic-gate17a18
8680Sstevel@tonic-gate> /var/cron/log -s 512k -t /var/cron/olog
8690Sstevel@tonic-gate21a23
8700Sstevel@tonic-gate> /var/adm/pacct -C 0 -a '/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -p never
8710Sstevel@tonic-gateEOF
8720Sstevel@tonic-gate
8730Sstevel@tonic-gate	set_file('checktest', <<'EOF');
8740Sstevel@tonic-gate[ -s std.err ] && exit 1
8750Sstevel@tonic-gate/bin/diff testfile.conf testfile.conf.orig > diff.out
8760Sstevel@tonic-gateexec /bin/diff diff.out diff.out.expect
8770Sstevel@tonic-gateEOF
8780Sstevel@tonic-gate
8790Sstevel@tonic-gate	set_file('runtest', <<"EOF");
8800Sstevel@tonic-gate# test "logadmr"
8810Sstevel@tonic-gate$envsetup
8820Sstevel@tonic-gateexec $bindir/logadm -f testfile.conf -r /var/cron/log /var/adm/pacct >std.out 2>std.err
8830Sstevel@tonic-gateEOF
8840Sstevel@tonic-gate}
8850Sstevel@tonic-gate
8860Sstevel@tonic-gate###########################################################################
8870Sstevel@tonic-gate#
8880Sstevel@tonic-gate#	logadmw -- test of "logadm -w <entry>"
8890Sstevel@tonic-gate#
8900Sstevel@tonic-gate###########################################################################
8910Sstevel@tonic-gatesub logadmw {
8920Sstevel@tonic-gate	set_testconffile;
8930Sstevel@tonic-gate	set_testconffile('testfile.conf.orig');
8940Sstevel@tonic-gate
8950Sstevel@tonic-gate	set_file('diff.out.expect', <<'EOF');
8960Sstevel@tonic-gate31d30
8970Sstevel@tonic-gate< moose -C 20 -a moose_after_cmd -g pig -m 664 -o cow -p never /moose/file
8980Sstevel@tonic-gateEOF
8990Sstevel@tonic-gate
9000Sstevel@tonic-gate	set_file('checktest', <<'EOF');
9010Sstevel@tonic-gate[ -s std.err ] && exit 1
9020Sstevel@tonic-gate/bin/diff testfile.conf testfile.conf.orig > diff.out
9030Sstevel@tonic-gateexec /bin/diff diff.out diff.out.expect
9040Sstevel@tonic-gateEOF
9050Sstevel@tonic-gate
9060Sstevel@tonic-gate	set_file('runtest', <<"EOF");
9070Sstevel@tonic-gate# test "logadmw"
9080Sstevel@tonic-gate$envsetup
9090Sstevel@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
9100Sstevel@tonic-gateEOF
9110Sstevel@tonic-gate}
9120Sstevel@tonic-gate
9130Sstevel@tonic-gate###########################################################################
9140Sstevel@tonic-gate#
9150Sstevel@tonic-gate#	logadm1 -- minimal basic test of logadm rotation
9160Sstevel@tonic-gate#
9170Sstevel@tonic-gate###########################################################################
9180Sstevel@tonic-gatesub logadm1 {
9190Sstevel@tonic-gate	set_file('logfile', 'initially logfile');
9200Sstevel@tonic-gate	set_file('logfile.0', 'initially logfile.0');
9210Sstevel@tonic-gate	my ($stdev, $stino, $stmode, $stnlink, $stuid, $stgid, $strdev,
9220Sstevel@tonic-gate		$stsize, $statime, $stmtime, $stctime, $stblksize, $stblocks) =
9230Sstevel@tonic-gate		lstat 'logfile' or die "lstat logfile: $!\n";
9240Sstevel@tonic-gate
9250Sstevel@tonic-gate	set_file('checktest', <<"EOF");
9260Sstevel@tonic-gate[ -s std.err ] && exit 1
9270Sstevel@tonic-gate[ -s std.out ] && exit 1
9280Sstevel@tonic-gate[ -s logfile ] && exit 1
9290Sstevel@tonic-gate[ -f logfile.0 ] || exit 1
9300Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat logfile.0`" ] || exit 1
9310Sstevel@tonic-gate[ "`/bin/ls -i logfile.0 | /bin/awk '{ print \$1; }'`" = "$stino" ] || exit 1
9320Sstevel@tonic-gate[ -f logfile.1 ] || exit 1
9330Sstevel@tonic-gate[ "xinitially logfile.0" = "x`/bin/cat logfile.1`" ] || exit 1
9340Sstevel@tonic-gateexit 0
9350Sstevel@tonic-gateEOF
9360Sstevel@tonic-gate
9370Sstevel@tonic-gate	set_file('runtest', <<"EOF");
9380Sstevel@tonic-gate# test "logadm1"
9390Sstevel@tonic-gate$envsetup
9400Sstevel@tonic-gateexec $bindir/logadm -f /dev/null -p now logfile >std.out 2>std.err
9410Sstevel@tonic-gateEOF
9420Sstevel@tonic-gate}
9430Sstevel@tonic-gate
9440Sstevel@tonic-gate###########################################################################
9450Sstevel@tonic-gate#
9460Sstevel@tonic-gate#	logadm1c -- same as logadm1 but with -c option
9470Sstevel@tonic-gate#
9480Sstevel@tonic-gate###########################################################################
9490Sstevel@tonic-gatesub logadm1c {
9500Sstevel@tonic-gate	set_file('logfile', 'initially logfile');
9510Sstevel@tonic-gate	set_file('logfile.0', 'initially logfile.0');
9520Sstevel@tonic-gate	my ($stdev, $stino, $stmode, $stnlink, $stuid, $stgid, $strdev,
9530Sstevel@tonic-gate		$stsize, $statime, $stmtime, $stctime, $stblksize, $stblocks) =
9540Sstevel@tonic-gate		lstat 'logfile' or die "lstat logfile: $!\n";
9550Sstevel@tonic-gate
9560Sstevel@tonic-gate	set_file('checktest', <<"EOF");
9570Sstevel@tonic-gate[ -s std.err ] && exit 1
9580Sstevel@tonic-gate[ -s std.out ] && exit 1
9590Sstevel@tonic-gate[ -s logfile ] && exit 1
9600Sstevel@tonic-gate[ -f logfile.0 ] || exit 1
9610Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat logfile.0`" ] || exit 1
9620Sstevel@tonic-gate[ "`/bin/ls -i logfile.0 | /bin/awk '{ print \$1; }'`" = "$stino" ] && exit 1
9630Sstevel@tonic-gate[ -f logfile.1 ] || exit 1
9640Sstevel@tonic-gate[ "xinitially logfile.0" = "x`/bin/cat logfile.1`" ] || exit 1
9650Sstevel@tonic-gateexit 0
9660Sstevel@tonic-gateEOF
9670Sstevel@tonic-gate
9680Sstevel@tonic-gate	set_file('runtest', <<"EOF");
9690Sstevel@tonic-gate# test "logadm1c"
9700Sstevel@tonic-gate$envsetup
9710Sstevel@tonic-gateexec $bindir/logadm -f /dev/null -p now -c logfile >std.out 2>std.err
9720Sstevel@tonic-gateEOF
9730Sstevel@tonic-gate}
9740Sstevel@tonic-gate
9750Sstevel@tonic-gate###########################################################################
9760Sstevel@tonic-gate#
9770Sstevel@tonic-gate#	logadm2 -- minimal basic test of logadm expiration
9780Sstevel@tonic-gate#
9790Sstevel@tonic-gate###########################################################################
9800Sstevel@tonic-gatesub logadm2 {
9810Sstevel@tonic-gate	set_file('logfile', 'initially logfile');
9820Sstevel@tonic-gate	set_file('logfile.0', 'initially logfile.0');
9830Sstevel@tonic-gate	set_file('logfile.1', 'initially logfile.1');
9840Sstevel@tonic-gate
9850Sstevel@tonic-gate	set_file('checktest', <<'EOF');
9860Sstevel@tonic-gate[ -s std.err ] && exit 1
9870Sstevel@tonic-gate[ -s std.out ] && exit 1
9880Sstevel@tonic-gate[ -s logfile ] && exit 1
9890Sstevel@tonic-gate[ -f logfile.0 ] || exit 1
9900Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat logfile.0`" ] || exit 1
9910Sstevel@tonic-gate[ -f logfile.1 ] || exit 1
9920Sstevel@tonic-gate[ "xinitially logfile.0" = "x`/bin/cat logfile.1`" ] || exit 1
9930Sstevel@tonic-gate[ -f logfile.2 ] && exit 1
9940Sstevel@tonic-gateexit 0
9950Sstevel@tonic-gateEOF
9960Sstevel@tonic-gate
9970Sstevel@tonic-gate	set_file('runtest', <<"EOF");
9980Sstevel@tonic-gate# test "logadm2"
9990Sstevel@tonic-gate$envsetup
10000Sstevel@tonic-gateexec $bindir/logadm -f /dev/null -p now logfile -C2 >std.out 2>std.err
10010Sstevel@tonic-gateEOF
10020Sstevel@tonic-gate}
10030Sstevel@tonic-gate
10040Sstevel@tonic-gate###########################################################################
10050Sstevel@tonic-gate#
10060Sstevel@tonic-gate#	logadm3 -- minimal basic test of logadm pre/post-commands
10070Sstevel@tonic-gate#
10080Sstevel@tonic-gate###########################################################################
10090Sstevel@tonic-gatesub logadm3 {
10100Sstevel@tonic-gate	set_file('logfile', 'initially logfile');
10110Sstevel@tonic-gate	set_file('logfile.0', 'initially logfile.0');
10120Sstevel@tonic-gate	set_file('logfile.1', 'initially logfile.1');
10130Sstevel@tonic-gate
10140Sstevel@tonic-gate	set_file('checktest', <<'EOF');
10150Sstevel@tonic-gate[ -s std.err ] && exit 1
10160Sstevel@tonic-gate[ -s std.out ] && exit 1
10170Sstevel@tonic-gate[ -s logfile ] && exit 1
10180Sstevel@tonic-gate[ -f logfile.0 ] || exit 1
10190Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat logfile.0`" ] || exit 1
10200Sstevel@tonic-gate[ -f logfile.1 ] || exit 1
10210Sstevel@tonic-gate[ "xinitially logfile.0" = "x`/bin/cat logfile.1`" ] || exit 1
10220Sstevel@tonic-gate[ -f logfile.2 ] && exit 1
10230Sstevel@tonic-gate[ -f pre.out ] || exit 1
10240Sstevel@tonic-gate[ "xpre-command-stuff" = "x`/bin/cat pre.out`" ] || exit 1
10250Sstevel@tonic-gate[ -f post.out ] || exit 1
10260Sstevel@tonic-gate[ "xpost-command-stuff" = "x`/bin/cat post.out`" ] || exit 1
10270Sstevel@tonic-gateexit 0
10280Sstevel@tonic-gateEOF
10290Sstevel@tonic-gate
10300Sstevel@tonic-gate	set_file('runtest', <<"EOF");
10310Sstevel@tonic-gate# test "logadm3"
10320Sstevel@tonic-gate$envsetup
10330Sstevel@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
10340Sstevel@tonic-gateEOF
10350Sstevel@tonic-gate}
10360Sstevel@tonic-gate
10370Sstevel@tonic-gate###########################################################################
10380Sstevel@tonic-gate#
10390Sstevel@tonic-gate#	logadm4 -- test of -t template
10400Sstevel@tonic-gate#
10410Sstevel@tonic-gate###########################################################################
10420Sstevel@tonic-gatesub logadm4 {
10430Sstevel@tonic-gate	set_file('logfile', 'initially logfile');
10440Sstevel@tonic-gate
10450Sstevel@tonic-gate	set_file('checktest', <<'EOF');
10460Sstevel@tonic-gate[ -s std.err ] && exit 1
10470Sstevel@tonic-gate[ -s std.out ] && exit 1
10480Sstevel@tonic-gate[ -s logfile ] && exit 1
10490Sstevel@tonic-gateTZ=UTC export TZ
10500Sstevel@tonic-gated=`/bin/date +%d`
10510Sstevel@tonic-gate[ -f logfile.$d ] || exit 1
10520Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat logfile.$d`" ] || exit 1
10530Sstevel@tonic-gateexit 0
10540Sstevel@tonic-gateEOF
10550Sstevel@tonic-gate
10560Sstevel@tonic-gate	set_file('runtest', <<"EOF");
10570Sstevel@tonic-gate# test "logadm4"
10580Sstevel@tonic-gate$envsetup
10590Sstevel@tonic-gateexec $bindir/logadm -f /dev/null -p now logfile -t '\$file.\%d' >std.out 2>std.err
10600Sstevel@tonic-gateEOF
10610Sstevel@tonic-gate}
10620Sstevel@tonic-gate
10630Sstevel@tonic-gate###########################################################################
10640Sstevel@tonic-gate#
10650Sstevel@tonic-gate#	logadm5 -- test of -R cmd and -E cmd
10660Sstevel@tonic-gate#
10670Sstevel@tonic-gate###########################################################################
10680Sstevel@tonic-gatesub logadm5 {
10690Sstevel@tonic-gate	set_file('logfile', 'initially logfile');
10700Sstevel@tonic-gate	set_file('logfile.0', 'initially logfile.0');
10710Sstevel@tonic-gate
10720Sstevel@tonic-gate	set_file('cmd.out.expect', <<'EOF');
10730Sstevel@tonic-gatejust rotated: initially logfile
10740Sstevel@tonic-gatejust expired: initially logfile.0
10750Sstevel@tonic-gateEOF
10760Sstevel@tonic-gate
10770Sstevel@tonic-gate	set_file('checktest', <<'EOF');
10780Sstevel@tonic-gate[ -s std.err ] && exit 1
10790Sstevel@tonic-gate[ -s std.out ] && exit 1
10800Sstevel@tonic-gate[ -s logfile ] && exit 1
10810Sstevel@tonic-gate[ -f logfile.0 ] || exit 1
10820Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat logfile.0`" ] || exit 1
10830Sstevel@tonic-gate[ -f logfile.1 ] || exit 1
10840Sstevel@tonic-gate[ "xinitially logfile.0" = "x`/bin/cat logfile.1`" ] || exit 1
10850Sstevel@tonic-gateexec /bin/diff cmd.out cmd.out.expect
10860Sstevel@tonic-gateEOF
10870Sstevel@tonic-gate
10880Sstevel@tonic-gate	set_file('runtest', <<"EOF");
10890Sstevel@tonic-gate# test "logadm5"
10900Sstevel@tonic-gate$envsetup
10910Sstevel@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
10920Sstevel@tonic-gateEOF
10930Sstevel@tonic-gate}
10940Sstevel@tonic-gate
10950Sstevel@tonic-gate###########################################################################
10960Sstevel@tonic-gate#
10970Sstevel@tonic-gate#	logadm6 -- test of -m, -o, -g
10980Sstevel@tonic-gate#
10990Sstevel@tonic-gate###########################################################################
11000Sstevel@tonic-gatesub logadm6 {
11010Sstevel@tonic-gate        set_file('logfile', 'initially logfile');
11020Sstevel@tonic-gate
11030Sstevel@tonic-gate        set_file('std.err.expect', <<'EOF');
11040Sstevel@tonic-gatelogadm: Warning: command failed: /bin/chown _nonexistentuser_:_nonexistentgroup_ logfile
11050Sstevel@tonic-gatechown: unknown group id _nonexistentgroup_
11060Sstevel@tonic-gateEOF
11070Sstevel@tonic-gate
11080Sstevel@tonic-gate        set_file('checktest', <<'EOF');
11090Sstevel@tonic-gate[ -s std.err ] || exit 1
11100Sstevel@tonic-gate[ -s std.out ] && exit 1
11110Sstevel@tonic-gate[ -s logfile ] && exit 1
11120Sstevel@tonic-gate[ -f logfile.0 ] || exit 1
11130Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat logfile.0`" ] || exit 1
11140Sstevel@tonic-gate[ "`/bin/ls -l logfile | /bin/awk '{ print $1; }'`" = "-r----x--x" ] || exit 1
11150Sstevel@tonic-gateexec /bin/diff std.err std.err.expect
11160Sstevel@tonic-gateEOF
11170Sstevel@tonic-gate
11180Sstevel@tonic-gate        set_file('runtest', <<"EOF");
11190Sstevel@tonic-gate# test "logadm6"
11200Sstevel@tonic-gate$envsetup
11210Sstevel@tonic-gateexec $bindir/logadm -f /dev/null -p now logfile -m 411 -o _nonexistentuser_ -g _nonexistentgroup_ >std.out 2>std.err
11220Sstevel@tonic-gateEOF
11230Sstevel@tonic-gate}
11240Sstevel@tonic-gate
11250Sstevel@tonic-gate###########################################################################
11260Sstevel@tonic-gate#
11270Sstevel@tonic-gate#       logadm7 -- test running through a conffile
11280Sstevel@tonic-gate#
11290Sstevel@tonic-gate###########################################################################
11300Sstevel@tonic-gatesub logadm7 {
11310Sstevel@tonic-gate	mkdir 'dir1', 0777 or die "mkdir dir1: $!\n";
11320Sstevel@tonic-gate	set_file('dir1/syslog', 'initially dir1/syslog');
11330Sstevel@tonic-gate	set_file('dir1/syslog.0', 'initially dir1/syslog.0');
11340Sstevel@tonic-gate	set_file('dir1/syslog.1', 'initially dir1/syslog.1');
11350Sstevel@tonic-gate	set_file('dir1/syslog.2', 'initially dir1/syslog.2');
11360Sstevel@tonic-gate	set_file('dir1/syslog.3', 'initially dir1/syslog.3');
11370Sstevel@tonic-gate	set_file('dir1/syslog.4', 'initially dir1/syslog.4');
11380Sstevel@tonic-gate	set_file('dir1/syslog.5', 'initially dir1/syslog.5');
11390Sstevel@tonic-gate	set_file('dir1/syslog.6', 'initially dir1/syslog.6');
11400Sstevel@tonic-gate	set_file('dir1/syslog.7', 'initially dir1/syslog.7');
11410Sstevel@tonic-gate	mkdir 'dir2', 0777 or die "mkdir dir2: $!\n";
11420Sstevel@tonic-gate	set_file('dir2/messages', 'initially dir2/messages');
11430Sstevel@tonic-gate	set_file('dir2/messages.0', 'initially dir2/messages.0');
11440Sstevel@tonic-gate	set_file('dir2/messages.1', 'initially dir2/messages.1');
11450Sstevel@tonic-gate	set_file('dir2/messages.2', 'initially dir2/messages.2');
11460Sstevel@tonic-gate	set_file('dir2/messages.3', 'initially dir2/messages.3');
11470Sstevel@tonic-gate
11480Sstevel@tonic-gate	set_file('logadm.conf', <<'EOF');
11490Sstevel@tonic-gate#
11500Sstevel@tonic-gate# logadm.conf
11510Sstevel@tonic-gate#
11520Sstevel@tonic-gate#	this comment # has at least another #-sign in it #...
11530Sstevel@tonic-gate#
11540Sstevel@tonic-gate# Default settings for system log file management.
11550Sstevel@tonic-gate# The -w option to logadm(1M) is the preferred way to write to this file,
11560Sstevel@tonic-gate# but if you do edit it by hand, use "logadm -V" to check it for errors.
11570Sstevel@tonic-gate# but if you do edit it by hand, use "logadm -V" to check it for errors.
11580Sstevel@tonic-gate#
11590Sstevel@tonic-gate# The format of lines in this file is:
11600Sstevel@tonic-gate#       <logname> <options>
11610Sstevel@tonic-gate# For each logname listed here, the default options to logadm
11620Sstevel@tonic-gate# are given.  Options given on the logadm command line override
11630Sstevel@tonic-gate# the defaults contained in this file.
11640Sstevel@tonic-gate#
11650Sstevel@tonic-gate# logadm typically runs early every morning via an entry in
11660Sstevel@tonic-gate# root's crontab (see crontab(1)).
11670Sstevel@tonic-gate#
11680Sstevel@tonic-gatedir1/syslog -C 8 -a 'echo kill -HUP `cat /etc/syslog.pid` >> cmd.out'
11690Sstevel@tonic-gatedir2/messages -C 4 -a 'echo kill -HUP `cat /etc/syslog.pid` >> cmd.out'
11700Sstevel@tonic-gate#
11710Sstevel@tonic-gate# The entry below is used by turnacct(1M)
11720Sstevel@tonic-gate#
11730Sstevel@tonic-gate/var/adm/pacct -C 0 -a '/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -p never
11740Sstevel@tonic-gateEOF
11750Sstevel@tonic-gate
11760Sstevel@tonic-gate	system("/bin/cp logadm.conf logadm.conf.orig");
11770Sstevel@tonic-gate
11780Sstevel@tonic-gate	$pid=`cat /etc/syslog.pid`;
11790Sstevel@tonic-gate	chomp $pid;
11800Sstevel@tonic-gate	set_file('cmd.out.expect', <<"EOF");
11810Sstevel@tonic-gatekill -HUP $pid
11820Sstevel@tonic-gatesecond kill -HUP $pid
11830Sstevel@tonic-gateEOF
11840Sstevel@tonic-gate
11850Sstevel@tonic-gate	set_file('checktest', <<'EOF');
11860Sstevel@tonic-gate[ -s std.err ] && exit 1
11870Sstevel@tonic-gate[ -s std.out ] && exit 1
11880Sstevel@tonic-gate[ -s std.err2 ] && exit 1
11890Sstevel@tonic-gate[ -s std.out2 ] && exit 1
11900Sstevel@tonic-gate[ -s std.err3 ] && exit 1
11910Sstevel@tonic-gate[ -s std.out3 ] && exit 1
11920Sstevel@tonic-gate[ -s std.err4 ] && exit 1
11930Sstevel@tonic-gate[ -s std.out4 ] && exit 1
11940Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1
11950Sstevel@tonic-gate[ "xsomething" = "x`/bin/cat dir1/syslog`" ] || exit 1
11960Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1
11970Sstevel@tonic-gate[ "xinitially dir1/syslog" = "x`/bin/cat dir1/syslog.0`" ] || exit 1
11980Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1
11990Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.1`" ] || exit 1
12000Sstevel@tonic-gate[ -f dir1/syslog.2 ] || exit 1
12010Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/cat dir1/syslog.2`" ] || exit 1
12020Sstevel@tonic-gate[ -f dir1/syslog.3 ] || exit 1
12030Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/cat dir1/syslog.3`" ] || exit 1
12040Sstevel@tonic-gate[ -f dir1/syslog.4 ] || exit 1
12050Sstevel@tonic-gate[ "xinitially dir1/syslog.3" = "x`/bin/cat dir1/syslog.4`" ] || exit 1
12060Sstevel@tonic-gate[ -f dir1/syslog.5 ] || exit 1
12070Sstevel@tonic-gate[ "xinitially dir1/syslog.4" = "x`/bin/cat dir1/syslog.5`" ] || exit 1
12080Sstevel@tonic-gate[ -f dir1/syslog.6 ] || exit 1
12090Sstevel@tonic-gate[ "xinitially dir1/syslog.5" = "x`/bin/cat dir1/syslog.6`" ] || exit 1
12100Sstevel@tonic-gate[ -f dir1/syslog.7 ] || exit 1
12110Sstevel@tonic-gate[ "xinitially dir1/syslog.6" = "x`/bin/cat dir1/syslog.7`" ] || exit 1
12120Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1
12130Sstevel@tonic-gate
12140Sstevel@tonic-gate[ -s dir2/messages ] && exit 1
12150Sstevel@tonic-gate[ -f dir2/messages.0 ] || exit 1
12160Sstevel@tonic-gate[ "xsomething" = "x`/bin/cat dir2/messages.0`" ] || exit 1
12170Sstevel@tonic-gate[ -f dir2/messages.1 ] || exit 1
12180Sstevel@tonic-gate[ "xinitially dir2/messages" = "x`/bin/cat dir2/messages.1`" ] || exit 1
12190Sstevel@tonic-gate[ -f dir2/messages.2 ] || exit 1
12200Sstevel@tonic-gate[ "xinitially dir2/messages.0" = "x`/bin/cat dir2/messages.2`" ] || exit 1
12210Sstevel@tonic-gate[ -f dir2/messages.3 ] || exit 1
12220Sstevel@tonic-gate[ "xinitially dir2/messages.1" = "x`/bin/cat dir2/messages.3`" ] || exit 1
12230Sstevel@tonic-gate[ -f dir2/messages.4 ] && exit 1
12240Sstevel@tonic-gate/bin/sed "s/-P '[^']*' *//" < logadm.conf > sed.out
12250Sstevel@tonic-gateexec /bin/diff sed.out logadm.conf.orig
12260Sstevel@tonic-gateEOF
12270Sstevel@tonic-gate
12280Sstevel@tonic-gate        # first logadm call will rotate both syslog and messages
12290Sstevel@tonic-gate        # second one won't because size is zero
12300Sstevel@tonic-gate        # third one won't because of -P timestamps stored in conffile
12310Sstevel@tonic-gate        # fourth one will do messages because of -p now on command line
12320Sstevel@tonic-gate        set_file('runtest', <<"EOF");
12330Sstevel@tonic-gate# test "logadm7"
12340Sstevel@tonic-gate$envsetup
12350Sstevel@tonic-gate$bindir/logadm -f logadm.conf >std.out 2>std.err || exit 1
12360Sstevel@tonic-gate$bindir/logadm -f logadm.conf dir1/syslog dir2/messages >std.out2 2>std.err2 || exit 1
12370Sstevel@tonic-gateecho something > dir1/syslog
12380Sstevel@tonic-gateecho something > dir2/messages
12390Sstevel@tonic-gate$bindir/logadm -f logadm.conf >std.out3 2>std.err3 || exit 1
12400Sstevel@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
12410Sstevel@tonic-gateEOF
12420Sstevel@tonic-gate}
12430Sstevel@tonic-gate
12440Sstevel@tonic-gate###########################################################################
12450Sstevel@tonic-gate#
12460Sstevel@tonic-gate#       logadm8 -- test of -z
12470Sstevel@tonic-gate#
12480Sstevel@tonic-gate###########################################################################
12490Sstevel@tonic-gatesub logadm8 {
12500Sstevel@tonic-gate	mkdir 'dir1', 0777 or die "mkdir dir1: $!\n";
12510Sstevel@tonic-gate	set_file('dir1/syslog', 'initially dir1/syslog');
12520Sstevel@tonic-gate	set_file('dir1/syslog.0', 'initially dir1/syslog.0');
12530Sstevel@tonic-gate	set_file('dir1/syslog.1', 'initially dir1/syslog.1');
12540Sstevel@tonic-gate	set_file('dir1/syslog.2', 'initially dir1/syslog.2');
12550Sstevel@tonic-gate	system("/bin/gzip dir1/syslog.2");
12560Sstevel@tonic-gate	die "gzip dir1/syslog.2 didn't work\n" unless -f 'dir1/syslog.2.gz';
12570Sstevel@tonic-gate	set_file('dir1/syslog.3', 'initially dir1/syslog.3');
12580Sstevel@tonic-gate	system("/bin/gzip dir1/syslog.3");
12590Sstevel@tonic-gate	die "gzip dir1/syslog.3 didn't work\n" unless -f 'dir1/syslog.3.gz';
12600Sstevel@tonic-gate	set_file('dir1/syslog.4', 'initially dir1/syslog.4');
12610Sstevel@tonic-gate	system("/bin/gzip dir1/syslog.4");
12620Sstevel@tonic-gate	die "gzip dir1/syslog.4 didn't work\n" unless -f 'dir1/syslog.4.gz';
12630Sstevel@tonic-gate	set_file('dir1/syslog.5', 'initially dir1/syslog.5');
12640Sstevel@tonic-gate	system("/bin/gzip dir1/syslog.5");
12650Sstevel@tonic-gate	die "gzip dir1/syslog.5 didn't work\n" unless -f 'dir1/syslog.5.gz';
12660Sstevel@tonic-gate	set_file('dir1/syslog.6', 'initially dir1/syslog.6');
12670Sstevel@tonic-gate	system("/bin/gzip dir1/syslog.6");
12680Sstevel@tonic-gate	die "gzip dir1/syslog.6 didn't work\n" unless -f 'dir1/syslog.6.gz';
12690Sstevel@tonic-gate	set_file('dir1/syslog.7', 'initially dir1/syslog.7');
12700Sstevel@tonic-gate	system("/bin/gzip dir1/syslog.7");
12710Sstevel@tonic-gate	die "gzip dir1/syslog.7 didn't work\n" unless -f 'dir1/syslog.7.gz';
12720Sstevel@tonic-gate
12730Sstevel@tonic-gate	set_file('checktest', <<'EOF');
12740Sstevel@tonic-gate[ -s std.err ] && exit 1
12750Sstevel@tonic-gate[ -s std.out ] && exit 1
12760Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1
12770Sstevel@tonic-gate[ -s dir1/syslog ] && exit 1
12780Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1
12790Sstevel@tonic-gate[ "xinitially dir1/syslog" = "x`/bin/cat dir1/syslog.0`" ] || exit 1
12800Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1
12810Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.1`" ] || exit 1
12820Sstevel@tonic-gate[ -f dir1/syslog.2.gz ] || exit 1
12830Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/gzcat dir1/syslog.2.gz`" ] || exit 1
12840Sstevel@tonic-gate[ -f dir1/syslog.3.gz ] || exit 1
12850Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/gzcat dir1/syslog.3.gz`" ] || exit 1
12860Sstevel@tonic-gate[ -f dir1/syslog.4.gz ] || exit 1
12870Sstevel@tonic-gate[ "xinitially dir1/syslog.3" = "x`/bin/gzcat dir1/syslog.4.gz`" ] || exit 1
12880Sstevel@tonic-gate[ -f dir1/syslog.5.gz ] || exit 1
12890Sstevel@tonic-gate[ "xinitially dir1/syslog.4" = "x`/bin/gzcat dir1/syslog.5.gz`" ] || exit 1
12900Sstevel@tonic-gate[ -f dir1/syslog.6.gz ] || exit 1
12910Sstevel@tonic-gate[ "xinitially dir1/syslog.5" = "x`/bin/gzcat dir1/syslog.6.gz`" ] || exit 1
12920Sstevel@tonic-gate[ -f dir1/syslog.7.gz ] || exit 1
12930Sstevel@tonic-gate[ "xinitially dir1/syslog.6" = "x`/bin/gzcat dir1/syslog.7.gz`" ] || exit 1
12940Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1
12950Sstevel@tonic-gate[ -f dir1/syslog.8.gz ] && exit 1
12960Sstevel@tonic-gateexit 0
12970Sstevel@tonic-gateEOF
12980Sstevel@tonic-gate
12990Sstevel@tonic-gate        set_file('runtest', <<"EOF");
13000Sstevel@tonic-gate# test "logadm8"
13010Sstevel@tonic-gate$envsetup
13020Sstevel@tonic-gateexec $bindir/logadm -f /dev/null dir1/syslog -z 2 -C 8 >std.out 2>std.err
13030Sstevel@tonic-gateEOF
13040Sstevel@tonic-gate}
13050Sstevel@tonic-gate
13060Sstevel@tonic-gate###########################################################################
13070Sstevel@tonic-gate#
13080Sstevel@tonic-gate#       logadm9 -- test of age check
13090Sstevel@tonic-gate#
13100Sstevel@tonic-gate###########################################################################
13110Sstevel@tonic-gatesub logadm9 {
13120Sstevel@tonic-gate	mkdir 'dir1', 0777 or die "mkdir dir1: $!\n";
13130Sstevel@tonic-gate	set_file('dir1/syslog', 'initially dir1/syslog');
13140Sstevel@tonic-gate	set_file('dir1/syslog.0', 'initially dir1/syslog.0');
13150Sstevel@tonic-gate	set_file('dir1/syslog.1', 'initially dir1/syslog.1');
13160Sstevel@tonic-gate	set_file('dir1/syslog.2', 'initially dir1/syslog.2');
13170Sstevel@tonic-gate	set_file('dir1/syslog.3', 'initially dir1/syslog.3');
13180Sstevel@tonic-gate	set_file('dir1/syslog.4', 'initially dir1/syslog.4');
13190Sstevel@tonic-gate	set_file('dir1/syslog.5', 'initially dir1/syslog.5');
13200Sstevel@tonic-gate	set_file('dir1/syslog.6', 'initially dir1/syslog.6');
13210Sstevel@tonic-gate	set_file('dir1/syslog.7', 'initially dir1/syslog.7');
13220Sstevel@tonic-gate	mkdir 'dir2', 0777 or die "mkdir dir2: $!\n";
13230Sstevel@tonic-gate	set_file('dir2/messages', 'initially dir2/messages');
13240Sstevel@tonic-gate	set_file('dir2/messages.0', 'initially dir2/messages.0');
13250Sstevel@tonic-gate	set_file('dir2/messages.1', 'initially dir2/messages.1');
13260Sstevel@tonic-gate	set_file('dir2/messages.2', 'initially dir2/messages.2');
13270Sstevel@tonic-gate	set_file('dir2/messages.3', 'initially dir2/messages.3');
13280Sstevel@tonic-gate
13290Sstevel@tonic-gate	$now = time;
13300Sstevel@tonic-gate	$nowstr = gmtime($now);
13310Sstevel@tonic-gate	# a week minus 30 seconds ago...
13320Sstevel@tonic-gate	# technically not a full week, but the heuristic used by logadm
13330Sstevel@tonic-gate	# should think this is "close enough" to a full week
13340Sstevel@tonic-gate	$closetoweeksecs = $now - (60 * 60 * 24 * 7 - 30);
13350Sstevel@tonic-gate	$closetoweek = gmtime($closetoweeksecs);
13360Sstevel@tonic-gate	# a week minus six hours ago...
13370Sstevel@tonic-gate	$lessthanweeksecs = $now - (60 * 60 * 24 * 7 - 60 * 60 * 6);
13380Sstevel@tonic-gate	$lessthanweek = gmtime($lessthanweeksecs);
13390Sstevel@tonic-gate
13400Sstevel@tonic-gate	set_file('logadm.conf', <<"EOF");
13410Sstevel@tonic-gate# now: $nowstr is $now
13420Sstevel@tonic-gate# $closetoweek is $closetoweeksecs
13430Sstevel@tonic-gatedir1/syslog -C 8 -P '$closetoweek'
13440Sstevel@tonic-gate# $lessthanweek is $lessthanweeksecs
13450Sstevel@tonic-gatedir2/messages -C 4 -P '$lessthanweek'
13460Sstevel@tonic-gateEOF
13470Sstevel@tonic-gate
13480Sstevel@tonic-gate	set_file('checktest', <<'EOF');
13490Sstevel@tonic-gate[ -s std.err ] && exit 1
13500Sstevel@tonic-gate[ -s std.out ] && exit 1
13510Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1
13520Sstevel@tonic-gate[ -s dir1/syslog ] && exit 1
13530Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1
13540Sstevel@tonic-gate[ "xinitially dir1/syslog" = "x`/bin/cat dir1/syslog.0`" ] || exit 1
13550Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1
13560Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.1`" ] || exit 1
13570Sstevel@tonic-gate[ -f dir1/syslog.2 ] || exit 1
13580Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/cat dir1/syslog.2`" ] || exit 1
13590Sstevel@tonic-gate[ -f dir1/syslog.3 ] || exit 1
13600Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/cat dir1/syslog.3`" ] || exit 1
13610Sstevel@tonic-gate[ -f dir1/syslog.4 ] || exit 1
13620Sstevel@tonic-gate[ "xinitially dir1/syslog.3" = "x`/bin/cat dir1/syslog.4`" ] || exit 1
13630Sstevel@tonic-gate[ -f dir1/syslog.5 ] || exit 1
13640Sstevel@tonic-gate[ "xinitially dir1/syslog.4" = "x`/bin/cat dir1/syslog.5`" ] || exit 1
13650Sstevel@tonic-gate[ -f dir1/syslog.6 ] || exit 1
13660Sstevel@tonic-gate[ "xinitially dir1/syslog.5" = "x`/bin/cat dir1/syslog.6`" ] || exit 1
13670Sstevel@tonic-gate[ -f dir1/syslog.7 ] || exit 1
13680Sstevel@tonic-gate[ "xinitially dir1/syslog.6" = "x`/bin/cat dir1/syslog.7`" ] || exit 1
13690Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1
13700Sstevel@tonic-gate
13710Sstevel@tonic-gate[ -f dir2/messages ] || exit 1
13720Sstevel@tonic-gate[ "xinitially dir2/messages" = "x`/bin/cat dir2/messages`" ] || exit 1
13730Sstevel@tonic-gate[ -f dir2/messages.0 ] || exit 1
13740Sstevel@tonic-gate[ "xinitially dir2/messages.0" = "x`/bin/cat dir2/messages.0`" ] || exit 1
13750Sstevel@tonic-gate[ -f dir2/messages.1 ] || exit 1
13760Sstevel@tonic-gate[ "xinitially dir2/messages.1" = "x`/bin/cat dir2/messages.1`" ] || exit 1
13770Sstevel@tonic-gate[ -f dir2/messages.2 ] || exit 1
13780Sstevel@tonic-gate[ "xinitially dir2/messages.2" = "x`/bin/cat dir2/messages.2`" ] || exit 1
13790Sstevel@tonic-gate[ -f dir2/messages.3 ] || exit 1
13800Sstevel@tonic-gate[ "xinitially dir2/messages.3" = "x`/bin/cat dir2/messages.3`" ] || exit 1
13810Sstevel@tonic-gate[ -f dir2/messages.4 ] && exit 1
13820Sstevel@tonic-gateexit 0
13830Sstevel@tonic-gateEOF
13840Sstevel@tonic-gate
13850Sstevel@tonic-gate        set_file('runtest', <<"EOF");
13860Sstevel@tonic-gate# test "logadm9"
13870Sstevel@tonic-gate$envsetup
13880Sstevel@tonic-gateexec $bindir/logadm -f logadm.conf >std.out 2>std.err
13890Sstevel@tonic-gateEOF
13900Sstevel@tonic-gate}
13910Sstevel@tonic-gate
13920Sstevel@tonic-gate###########################################################################
13930Sstevel@tonic-gate#
13940Sstevel@tonic-gate#       logadm9d -- test of age check like logadm9, but age is a couple days
13950Sstevel@tonic-gate#
13960Sstevel@tonic-gate###########################################################################
13970Sstevel@tonic-gatesub logadm9d {
13980Sstevel@tonic-gate	mkdir 'dir1', 0777 or die "mkdir dir1: $!\n";
13990Sstevel@tonic-gate	set_file('dir1/syslog', 'initially dir1/syslog');
14000Sstevel@tonic-gate	set_file('dir1/syslog.0', 'initially dir1/syslog.0');
14010Sstevel@tonic-gate	set_file('dir1/syslog.1', 'initially dir1/syslog.1');
14020Sstevel@tonic-gate	set_file('dir1/syslog.2', 'initially dir1/syslog.2');
14030Sstevel@tonic-gate	set_file('dir1/syslog.3', 'initially dir1/syslog.3');
14040Sstevel@tonic-gate	set_file('dir1/syslog.4', 'initially dir1/syslog.4');
14050Sstevel@tonic-gate	set_file('dir1/syslog.5', 'initially dir1/syslog.5');
14060Sstevel@tonic-gate	set_file('dir1/syslog.6', 'initially dir1/syslog.6');
14070Sstevel@tonic-gate	set_file('dir1/syslog.7', 'initially dir1/syslog.7');
14080Sstevel@tonic-gate	mkdir 'dir2', 0777 or die "mkdir dir2: $!\n";
14090Sstevel@tonic-gate	set_file('dir2/messages', 'initially dir2/messages');
14100Sstevel@tonic-gate	set_file('dir2/messages.0', 'initially dir2/messages.0');
14110Sstevel@tonic-gate	set_file('dir2/messages.1', 'initially dir2/messages.1');
14120Sstevel@tonic-gate	set_file('dir2/messages.2', 'initially dir2/messages.2');
14130Sstevel@tonic-gate	set_file('dir2/messages.3', 'initially dir2/messages.3');
14140Sstevel@tonic-gate
14150Sstevel@tonic-gate	$now = time;
14160Sstevel@tonic-gate	$nowstr = gmtime($now);
14170Sstevel@tonic-gate	# a day minus 30 seconds ago...
14180Sstevel@tonic-gate	$closetodaysecs = $now - (60 * 60 * 24 - 30);
14190Sstevel@tonic-gate	$closetoday = gmtime($closetodaysecs);
14200Sstevel@tonic-gate	# a day minus six hours ago...
14210Sstevel@tonic-gate	$lessthandaysecs = $now - (60 * 60 * 24 - 60 * 60 * 6);
14220Sstevel@tonic-gate	$lessthanday = gmtime($lessthandaysecs);
14230Sstevel@tonic-gate
14240Sstevel@tonic-gate	set_file('logadm.conf', <<"EOF");
14250Sstevel@tonic-gate# now: $nowstr is $now
14260Sstevel@tonic-gate# $closetoday is $closetodaysecs
14270Sstevel@tonic-gatedir1/syslog -p 1d -C 8 -P '$closetoday'
14280Sstevel@tonic-gate# $lessthanday is $lessthandaysecs
14290Sstevel@tonic-gatedir2/messages -p 1d -C 4 -P '$lessthanday'
14300Sstevel@tonic-gateEOF
14310Sstevel@tonic-gate
14320Sstevel@tonic-gate	set_file('checktest', <<'EOF');
14330Sstevel@tonic-gate[ -s std.err ] && exit 1
14340Sstevel@tonic-gate[ -s std.out ] && exit 1
14350Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1
14360Sstevel@tonic-gate[ -s dir1/syslog ] && exit 1
14370Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1
14380Sstevel@tonic-gate[ "xinitially dir1/syslog" = "x`/bin/cat dir1/syslog.0`" ] || exit 1
14390Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1
14400Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.1`" ] || exit 1
14410Sstevel@tonic-gate[ -f dir1/syslog.2 ] || exit 1
14420Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/cat dir1/syslog.2`" ] || exit 1
14430Sstevel@tonic-gate[ -f dir1/syslog.3 ] || exit 1
14440Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/cat dir1/syslog.3`" ] || exit 1
14450Sstevel@tonic-gate[ -f dir1/syslog.4 ] || exit 1
14460Sstevel@tonic-gate[ "xinitially dir1/syslog.3" = "x`/bin/cat dir1/syslog.4`" ] || exit 1
14470Sstevel@tonic-gate[ -f dir1/syslog.5 ] || exit 1
14480Sstevel@tonic-gate[ "xinitially dir1/syslog.4" = "x`/bin/cat dir1/syslog.5`" ] || exit 1
14490Sstevel@tonic-gate[ -f dir1/syslog.6 ] || exit 1
14500Sstevel@tonic-gate[ "xinitially dir1/syslog.5" = "x`/bin/cat dir1/syslog.6`" ] || exit 1
14510Sstevel@tonic-gate[ -f dir1/syslog.7 ] || exit 1
14520Sstevel@tonic-gate[ "xinitially dir1/syslog.6" = "x`/bin/cat dir1/syslog.7`" ] || exit 1
14530Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1
14540Sstevel@tonic-gate
14550Sstevel@tonic-gate[ -f dir2/messages ] || exit 1
14560Sstevel@tonic-gate[ "xinitially dir2/messages" = "x`/bin/cat dir2/messages`" ] || exit 1
14570Sstevel@tonic-gate[ -f dir2/messages.0 ] || exit 1
14580Sstevel@tonic-gate[ "xinitially dir2/messages.0" = "x`/bin/cat dir2/messages.0`" ] || exit 1
14590Sstevel@tonic-gate[ -f dir2/messages.1 ] || exit 1
14600Sstevel@tonic-gate[ "xinitially dir2/messages.1" = "x`/bin/cat dir2/messages.1`" ] || exit 1
14610Sstevel@tonic-gate[ -f dir2/messages.2 ] || exit 1
14620Sstevel@tonic-gate[ "xinitially dir2/messages.2" = "x`/bin/cat dir2/messages.2`" ] || exit 1
14630Sstevel@tonic-gate[ -f dir2/messages.3 ] || exit 1
14640Sstevel@tonic-gate[ "xinitially dir2/messages.3" = "x`/bin/cat dir2/messages.3`" ] || exit 1
14650Sstevel@tonic-gate[ -f dir2/messages.4 ] && exit 1
14660Sstevel@tonic-gateexit 0
14670Sstevel@tonic-gateEOF
14680Sstevel@tonic-gate
14690Sstevel@tonic-gate        set_file('runtest', <<"EOF");
14700Sstevel@tonic-gate# test "logadm9d"
14710Sstevel@tonic-gate$envsetup
14720Sstevel@tonic-gateexec $bindir/logadm -f logadm.conf >std.out 2>std.err
14730Sstevel@tonic-gateEOF
14740Sstevel@tonic-gate}
14750Sstevel@tonic-gate
14760Sstevel@tonic-gate###########################################################################
14770Sstevel@tonic-gate#
14780Sstevel@tonic-gate#       logadm10 -- test of size-based rotation check
14790Sstevel@tonic-gate#
14800Sstevel@tonic-gate###########################################################################
14810Sstevel@tonic-gatesub logadm10 {
14820Sstevel@tonic-gate	mkdir 'dir1', 0777 or die "mkdir dir1: $!\n";
14830Sstevel@tonic-gate	set_file('dir1/syslog', 'initially dir1/syslogXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
14840Sstevel@tonic-gate	set_file('dir1/syslog.0', 'initially dir1/syslog.0');
14850Sstevel@tonic-gate	set_file('dir1/syslog.1', 'initially dir1/syslog.1');
14860Sstevel@tonic-gate	set_file('dir1/syslog.2', 'initially dir1/syslog.2');
14870Sstevel@tonic-gate	set_file('dir1/syslog.3', 'initially dir1/syslog.3');
14880Sstevel@tonic-gate	set_file('dir1/syslog.4', 'initially dir1/syslog.4');
14890Sstevel@tonic-gate	set_file('dir1/syslog.5', 'initially dir1/syslog.5');
14900Sstevel@tonic-gate	set_file('dir1/syslog.6', 'initially dir1/syslog.6');
14910Sstevel@tonic-gate	set_file('dir1/syslog.7', 'initially dir1/syslog.7');
14920Sstevel@tonic-gate	mkdir 'dir2', 0777 or die "mkdir dir2: $!\n";
14930Sstevel@tonic-gate	set_file('dir2/messages', 'initially dir2/messages');
14940Sstevel@tonic-gate	set_file('dir2/messages.0', 'initially dir2/messages.0');
14950Sstevel@tonic-gate	set_file('dir2/messages.1', 'initially dir2/messages.1');
14960Sstevel@tonic-gate	set_file('dir2/messages.2', 'initially dir2/messages.2');
14970Sstevel@tonic-gate	set_file('dir2/messages.3', 'initially dir2/messages.3');
14980Sstevel@tonic-gate
14990Sstevel@tonic-gate	set_file('logadm.conf', <<"EOF");
15000Sstevel@tonic-gatedir1/syslog -C 8 -s 30b
15010Sstevel@tonic-gatedir2/messages -C 4 -s 30b
15020Sstevel@tonic-gateEOF
15030Sstevel@tonic-gate
15040Sstevel@tonic-gate	set_file('checktest', <<'EOF');
15050Sstevel@tonic-gate[ -s std.err ] && exit 1
15060Sstevel@tonic-gate[ -s std.out ] && exit 1
15070Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1
15080Sstevel@tonic-gate[ -s dir1/syslog ] && exit 1
15090Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1
15100Sstevel@tonic-gate[ "xinitially dir1/syslogXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" = "x`/bin/cat dir1/syslog.0`" ] || exit 1
15110Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1
15120Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.1`" ] || exit 1
15130Sstevel@tonic-gate[ -f dir1/syslog.2 ] || exit 1
15140Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/cat dir1/syslog.2`" ] || exit 1
15150Sstevel@tonic-gate[ -f dir1/syslog.3 ] || exit 1
15160Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/cat dir1/syslog.3`" ] || exit 1
15170Sstevel@tonic-gate[ -f dir1/syslog.4 ] || exit 1
15180Sstevel@tonic-gate[ "xinitially dir1/syslog.3" = "x`/bin/cat dir1/syslog.4`" ] || exit 1
15190Sstevel@tonic-gate[ -f dir1/syslog.5 ] || exit 1
15200Sstevel@tonic-gate[ "xinitially dir1/syslog.4" = "x`/bin/cat dir1/syslog.5`" ] || exit 1
15210Sstevel@tonic-gate[ -f dir1/syslog.6 ] || exit 1
15220Sstevel@tonic-gate[ "xinitially dir1/syslog.5" = "x`/bin/cat dir1/syslog.6`" ] || exit 1
15230Sstevel@tonic-gate[ -f dir1/syslog.7 ] || exit 1
15240Sstevel@tonic-gate[ "xinitially dir1/syslog.6" = "x`/bin/cat dir1/syslog.7`" ] || exit 1
15250Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1
15260Sstevel@tonic-gate
15270Sstevel@tonic-gate[ -f dir2/messages ] || exit 1
15280Sstevel@tonic-gate[ "xinitially dir2/messages" = "x`/bin/cat dir2/messages`" ] || exit 1
15290Sstevel@tonic-gate[ -f dir2/messages.0 ] || exit 1
15300Sstevel@tonic-gate[ "xinitially dir2/messages.0" = "x`/bin/cat dir2/messages.0`" ] || exit 1
15310Sstevel@tonic-gate[ -f dir2/messages.1 ] || exit 1
15320Sstevel@tonic-gate[ "xinitially dir2/messages.1" = "x`/bin/cat dir2/messages.1`" ] || exit 1
15330Sstevel@tonic-gate[ -f dir2/messages.2 ] || exit 1
15340Sstevel@tonic-gate[ "xinitially dir2/messages.2" = "x`/bin/cat dir2/messages.2`" ] || exit 1
15350Sstevel@tonic-gate[ -f dir2/messages.3 ] || exit 1
15360Sstevel@tonic-gate[ "xinitially dir2/messages.3" = "x`/bin/cat dir2/messages.3`" ] || exit 1
15370Sstevel@tonic-gate[ -f dir2/messages.4 ] && exit 1
15380Sstevel@tonic-gateexit 0
15390Sstevel@tonic-gateEOF
15400Sstevel@tonic-gate
15410Sstevel@tonic-gate        set_file('runtest', <<"EOF");
15420Sstevel@tonic-gate# test "logadm10"
15430Sstevel@tonic-gate$envsetup
15440Sstevel@tonic-gateexec $bindir/logadm -f logadm.conf >std.out 2>std.err
15450Sstevel@tonic-gateEOF
15460Sstevel@tonic-gate}
15470Sstevel@tonic-gate
15480Sstevel@tonic-gate###########################################################################
15490Sstevel@tonic-gate#
15500Sstevel@tonic-gate#       logadm11 -- test of size-based expiration check
15510Sstevel@tonic-gate#
15520Sstevel@tonic-gate###########################################################################
15530Sstevel@tonic-gatesub logadm11 {
15540Sstevel@tonic-gate	mkdir 'dir1', 0777 or die "mkdir dir1: $!\n";
15550Sstevel@tonic-gate	set_file('dir1/syslog', 'initially dir1/syslog');
15560Sstevel@tonic-gate	set_file('dir1/syslog.0', 'initially dir1/syslog.0');
15570Sstevel@tonic-gate	set_file('dir1/syslog.1', 'initially dir1/syslog.1');
15580Sstevel@tonic-gate	set_file('dir1/syslog.2', 'initially dir1/syslog.2');
15590Sstevel@tonic-gate	set_file('dir1/syslog.3', 'initially dir1/syslog.3');
15600Sstevel@tonic-gate	set_file('dir1/syslog.4', 'initially dir1/syslog.4');
15610Sstevel@tonic-gate	set_file('dir1/syslog.5', 'initially dir1/syslog.5');
15620Sstevel@tonic-gate	set_file('dir1/syslog.6', 'initially dir1/syslog.6');
15630Sstevel@tonic-gate	set_file('dir1/syslog.7', 'initially dir1/syslog.7');
15640Sstevel@tonic-gate	mkdir 'dir2', 0777 or die "mkdir dir2: $!\n";
15650Sstevel@tonic-gate	set_file('dir2/messages', 'initially dir2/messages');
15660Sstevel@tonic-gate	set_file('dir2/messages.0', 'initially dir2/messages.0');
15670Sstevel@tonic-gate	set_file('dir2/messages.1', 'initially dir2/messages.1');
15680Sstevel@tonic-gate	set_file('dir2/messages.2', 'initially dir2/messages.2');
15690Sstevel@tonic-gate	set_file('dir2/messages.3', 'initially dir2/messages.3');
15700Sstevel@tonic-gate
15710Sstevel@tonic-gate	set_file('logadm.conf', <<"EOF");
15720Sstevel@tonic-gatedir1/syslog -C 8 -s 30b -S 75b
15730Sstevel@tonic-gatedir2/messages -C 4 -s 30b -S 75b
15740Sstevel@tonic-gateEOF
15750Sstevel@tonic-gate
15760Sstevel@tonic-gate	set_file('checktest', <<'EOF');
15770Sstevel@tonic-gate[ -s std.err ] && exit 1
15780Sstevel@tonic-gate[ -s std.out ] && exit 1
15790Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1
15800Sstevel@tonic-gate[ "xinitially dir1/syslog" = "x`/bin/cat dir1/syslog`" ] || exit 1
15810Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1
15820Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.0`" ] || exit 1
15830Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1
15840Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/cat dir1/syslog.1`" ] || exit 1
15850Sstevel@tonic-gate[ -f dir1/syslog.2 ] || exit 1
15860Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/cat dir1/syslog.2`" ] || exit 1
15870Sstevel@tonic-gate[ -f dir1/syslog.3 ] && exit 1
15880Sstevel@tonic-gate[ -f dir1/syslog.4 ] && exit 1
15890Sstevel@tonic-gate[ -f dir1/syslog.5 ] && exit 1
15900Sstevel@tonic-gate[ -f dir1/syslog.6 ] && exit 1
15910Sstevel@tonic-gate[ -f dir1/syslog.7 ] && exit 1
15920Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1
15930Sstevel@tonic-gate
15940Sstevel@tonic-gate[ -f dir2/messages ] || exit 1
15950Sstevel@tonic-gate[ "xinitially dir2/messages" = "x`/bin/cat dir2/messages`" ] || exit 1
15960Sstevel@tonic-gate[ -f dir2/messages.0 ] || exit 1
15970Sstevel@tonic-gate[ "xinitially dir2/messages.0" = "x`/bin/cat dir2/messages.0`" ] || exit 1
15980Sstevel@tonic-gate[ -f dir2/messages.1 ] || exit 1
15990Sstevel@tonic-gate[ "xinitially dir2/messages.1" = "x`/bin/cat dir2/messages.1`" ] || exit 1
16000Sstevel@tonic-gate[ -f dir2/messages.2 ] || exit 1
16010Sstevel@tonic-gate[ "xinitially dir2/messages.2" = "x`/bin/cat dir2/messages.2`" ] || exit 1
16020Sstevel@tonic-gate[ -f dir2/messages.3 ] && exit 1
16030Sstevel@tonic-gate[ -f dir2/messages.4 ] && exit 1
16040Sstevel@tonic-gateexit 0
16050Sstevel@tonic-gateEOF
16060Sstevel@tonic-gate
16070Sstevel@tonic-gate        set_file('runtest', <<"EOF");
16080Sstevel@tonic-gate# test "logadm11"
16090Sstevel@tonic-gate$envsetup
16100Sstevel@tonic-gateexec $bindir/logadm -f logadm.conf >std.out 2>std.err
16110Sstevel@tonic-gateEOF
16120Sstevel@tonic-gate}
16130Sstevel@tonic-gate
16140Sstevel@tonic-gate###########################################################################
16150Sstevel@tonic-gate#
16160Sstevel@tonic-gate#	logadm12 -- ENOENT error path
16170Sstevel@tonic-gate#
16180Sstevel@tonic-gate###########################################################################
16190Sstevel@tonic-gatesub logadm12 {
16200Sstevel@tonic-gate	set_file('std.err.expect', <<'EOF');
16210Sstevel@tonic-gatelogadm: Warning: logfile: No such file or directory
16220Sstevel@tonic-gateEOF
16230Sstevel@tonic-gate
16240Sstevel@tonic-gate	set_file('checktest', <<"EOF");
16250Sstevel@tonic-gate[ -s std.out ] && exit 1
16260Sstevel@tonic-gateexec /bin/diff std.err std.err.expect
16270Sstevel@tonic-gateEOF
16280Sstevel@tonic-gate
16290Sstevel@tonic-gate	set_file('runtest', <<"EOF");
16300Sstevel@tonic-gate# test "logadm12"
16310Sstevel@tonic-gate$envsetup
16320Sstevel@tonic-gateexec $bindir/logadm -f /dev/null logfile >std.out 2>std.err
16330Sstevel@tonic-gateEOF
16340Sstevel@tonic-gate}
16350Sstevel@tonic-gate
16360Sstevel@tonic-gate###########################################################################
16370Sstevel@tonic-gate#
16380Sstevel@tonic-gate#	logadm13 -- ENOENT error path with -N flag
16390Sstevel@tonic-gate#
16400Sstevel@tonic-gate###########################################################################
16410Sstevel@tonic-gatesub logadm13 {
16420Sstevel@tonic-gate	set_file('checktest', <<"EOF");
16430Sstevel@tonic-gate[ -s std.out ] && exit 1
16440Sstevel@tonic-gate[ -s std.err ] && exit 1
16450Sstevel@tonic-gateexit 0
16460Sstevel@tonic-gateEOF
16470Sstevel@tonic-gate
16480Sstevel@tonic-gate	set_file('runtest', <<"EOF");
16490Sstevel@tonic-gate# test "logadm13"
16500Sstevel@tonic-gate$envsetup
16510Sstevel@tonic-gateexec $bindir/logadm -N -f /dev/null logfile >std.out 2>std.err
16520Sstevel@tonic-gateEOF
16530Sstevel@tonic-gate}
16540Sstevel@tonic-gate
16550Sstevel@tonic-gate###########################################################################
16560Sstevel@tonic-gate#
16570Sstevel@tonic-gate#       logadm14 -- test of -n and -v flags
16580Sstevel@tonic-gate#
16590Sstevel@tonic-gate###########################################################################
16600Sstevel@tonic-gatesub logadm14 {
16610Sstevel@tonic-gate	mkdir 'dir1', 0777 or die "mkdir dir1: $!\n";
16620Sstevel@tonic-gate	set_file('dir1/syslog', 'initially dir1/syslog');
16630Sstevel@tonic-gate	set_file('dir1/syslog.0', 'initially dir1/syslog.0');
16640Sstevel@tonic-gate	set_file('dir1/syslog.1', 'initially dir1/syslog.1');
16650Sstevel@tonic-gate	set_file('dir1/syslog.2', 'initially dir1/syslog.2');
16660Sstevel@tonic-gate	set_file('dir1/syslog.3', 'initially dir1/syslog.3');
16670Sstevel@tonic-gate	set_file('dir1/syslog.4', 'initially dir1/syslog.4');
16680Sstevel@tonic-gate	set_file('dir1/syslog.5', 'initially dir1/syslog.5');
16690Sstevel@tonic-gate	set_file('dir1/syslog.6', 'initially dir1/syslog.6');
16700Sstevel@tonic-gate	set_file('dir1/syslog.7', 'initially dir1/syslog.7');
16710Sstevel@tonic-gate	mkdir 'dir2', 0777 or die "mkdir dir2: $!\n";
16720Sstevel@tonic-gate	set_file('dir2/messages', 'initially dir2/messages');
16730Sstevel@tonic-gate	set_file('dir2/messages.0', 'initially dir2/messages.0');
16740Sstevel@tonic-gate	set_file('dir2/messages.1', 'initially dir2/messages.1');
16750Sstevel@tonic-gate	set_file('dir2/messages.2', 'initially dir2/messages.2');
16760Sstevel@tonic-gate	set_file('dir2/messages.3', 'initially dir2/messages.3');
16770Sstevel@tonic-gate
16780Sstevel@tonic-gate	set_file('logadm.conf', <<'EOF');
16790Sstevel@tonic-gate#
16800Sstevel@tonic-gate# logadm.conf
16810Sstevel@tonic-gate#
16820Sstevel@tonic-gate# Default settings for system log file management.
16830Sstevel@tonic-gate# The -w option to logadm(1M) is the preferred way to write to this file,
16840Sstevel@tonic-gate# but if you do edit it by hand, use "logadm -V" to check it for errors.
16850Sstevel@tonic-gate# but if you do edit it by hand, use "logadm -V" to check it for errors.
16860Sstevel@tonic-gate#
16870Sstevel@tonic-gate# The format of lines in this file is:
16880Sstevel@tonic-gate#       <logname> <options>
16890Sstevel@tonic-gate# For each logname listed here, the default options to logadm
16900Sstevel@tonic-gate# are given.  Options given on the logadm command line override
16910Sstevel@tonic-gate# the defaults contained in this file.
16920Sstevel@tonic-gate#
16930Sstevel@tonic-gate# logadm typically runs early every morning via an entry in
16940Sstevel@tonic-gate# root's crontab (see crontab(1)).
16950Sstevel@tonic-gate#
16960Sstevel@tonic-gatedir1/syslog -C 8 -a 'echo kill -HUP `cat /etc/syslog.pid` >> cmd.out'
16970Sstevel@tonic-gatedir2/messages -C 4 -a 'echo kill -HUP `cat /etc/syslog.pid` >> cmd.out'
16980Sstevel@tonic-gate#
16990Sstevel@tonic-gate# The entry below is used by turnacct(1M)
17000Sstevel@tonic-gate#
17010Sstevel@tonic-gate/var/adm/pacct -C 0 -a '/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -p never
17020Sstevel@tonic-gateEOF
17030Sstevel@tonic-gate
17040Sstevel@tonic-gate	$gid = $);
17050Sstevel@tonic-gate	$gid =~ s/ .*//;
17060Sstevel@tonic-gate	set_file('grep.out.expect', <<'EOF'.<<"EOF".<<'EOF'.<<"EOF".<<'EOF');
17070Sstevel@tonic-gate# loading logadm.conf
17080Sstevel@tonic-gate# processing logname: dir1/syslog
17090Sstevel@tonic-gate#     using default rotate rules: -s1b -p1w
17100Sstevel@tonic-gate#     using default template: $file.$n
17110Sstevel@tonic-gatemkdir -p dir1 # verify directory exists
17120Sstevel@tonic-gatemv -f dir1/syslog.7 dir1/syslog.8 # rotate log file
17130Sstevel@tonic-gatemkdir -p dir1 # verify directory exists
17140Sstevel@tonic-gatemv -f dir1/syslog.6 dir1/syslog.7 # rotate log file
17150Sstevel@tonic-gatemkdir -p dir1 # verify directory exists
17160Sstevel@tonic-gatemv -f dir1/syslog.5 dir1/syslog.6 # rotate log file
17170Sstevel@tonic-gatemkdir -p dir1 # verify directory exists
17180Sstevel@tonic-gatemv -f dir1/syslog.4 dir1/syslog.5 # rotate log file
17190Sstevel@tonic-gatemkdir -p dir1 # verify directory exists
17200Sstevel@tonic-gatemv -f dir1/syslog.3 dir1/syslog.4 # rotate log file
17210Sstevel@tonic-gatemkdir -p dir1 # verify directory exists
17220Sstevel@tonic-gatemv -f dir1/syslog.2 dir1/syslog.3 # rotate log file
17230Sstevel@tonic-gatemkdir -p dir1 # verify directory exists
17240Sstevel@tonic-gatemv -f dir1/syslog.1 dir1/syslog.2 # rotate log file
17250Sstevel@tonic-gatemkdir -p dir1 # verify directory exists
17260Sstevel@tonic-gatemv -f dir1/syslog.0 dir1/syslog.1 # rotate log file
17270Sstevel@tonic-gatemkdir -p dir1 # verify directory exists
17280Sstevel@tonic-gatemv -f dir1/syslog dir1/syslog.0 # rotate log file
17290Sstevel@tonic-gatetouch dir1/syslog
17300Sstevel@tonic-gateEOF
17310Sstevel@tonic-gatechown $>:$gid dir1/syslog
17320Sstevel@tonic-gateEOF
17330Sstevel@tonic-gatechmod 664 dir1/syslog
17340Sstevel@tonic-gate# processing logname: dir2/messages
17350Sstevel@tonic-gate#     using default rotate rules: -s1b -p1w
17360Sstevel@tonic-gate#     using default template: $file.$n
17370Sstevel@tonic-gatemkdir -p dir2 # verify directory exists
17380Sstevel@tonic-gatemv -f dir2/messages.3 dir2/messages.4 # rotate log file
17390Sstevel@tonic-gatemkdir -p dir2 # verify directory exists
17400Sstevel@tonic-gatemv -f dir2/messages.2 dir2/messages.3 # rotate log file
17410Sstevel@tonic-gatemkdir -p dir2 # verify directory exists
17420Sstevel@tonic-gatemv -f dir2/messages.1 dir2/messages.2 # rotate log file
17430Sstevel@tonic-gatemkdir -p dir2 # verify directory exists
17440Sstevel@tonic-gatemv -f dir2/messages.0 dir2/messages.1 # rotate log file
17450Sstevel@tonic-gatemkdir -p dir2 # verify directory exists
17460Sstevel@tonic-gatemv -f dir2/messages dir2/messages.0 # rotate log file
17470Sstevel@tonic-gatetouch dir2/messages
17480Sstevel@tonic-gateEOF
17490Sstevel@tonic-gatechown $>:$gid dir2/messages
17500Sstevel@tonic-gateEOF
17510Sstevel@tonic-gatechmod 664 dir2/messages
17520Sstevel@tonic-gate# processing logname: /var/adm/pacct
17530Sstevel@tonic-gate#     using default template: $file.$n
17540Sstevel@tonic-gatesh -c echo kill -HUP `cat /etc/syslog.pid` >> cmd.out # -a cmd
17550Sstevel@tonic-gate# logadm.conf unchanged
17560Sstevel@tonic-gateEOF
17570Sstevel@tonic-gate
17580Sstevel@tonic-gate	set_file('checktest', <<'EOF');
17590Sstevel@tonic-gate[ -s std.err ] && exit 1
17600Sstevel@tonic-gate[ -f std.out ] || exit 1
17610Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1
17620Sstevel@tonic-gate[ "xinitially dir1/syslog" = "x`/bin/cat dir1/syslog`" ] || exit 1
17630Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1
17640Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.0`" ] || exit 1
17650Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1
17660Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/cat dir1/syslog.1`" ] || exit 1
17670Sstevel@tonic-gate[ -f dir1/syslog.2 ] || exit 1
17680Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/cat dir1/syslog.2`" ] || exit 1
17690Sstevel@tonic-gate[ -f dir1/syslog.3 ] || exit 1
17700Sstevel@tonic-gate[ "xinitially dir1/syslog.3" = "x`/bin/cat dir1/syslog.3`" ] || exit 1
17710Sstevel@tonic-gate[ -f dir1/syslog.4 ] || exit 1
17720Sstevel@tonic-gate[ "xinitially dir1/syslog.4" = "x`/bin/cat dir1/syslog.4`" ] || exit 1
17730Sstevel@tonic-gate[ -f dir1/syslog.5 ] || exit 1
17740Sstevel@tonic-gate[ "xinitially dir1/syslog.5" = "x`/bin/cat dir1/syslog.5`" ] || exit 1
17750Sstevel@tonic-gate[ -f dir1/syslog.6 ] || exit 1
17760Sstevel@tonic-gate[ "xinitially dir1/syslog.6" = "x`/bin/cat dir1/syslog.6`" ] || exit 1
17770Sstevel@tonic-gate[ -f dir1/syslog.7 ] || exit 1
17780Sstevel@tonic-gate[ "xinitially dir1/syslog.7" = "x`/bin/cat dir1/syslog.7`" ] || exit 1
17790Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1
17800Sstevel@tonic-gate
17810Sstevel@tonic-gate[ -f dir2/messages ] || exit 1
17820Sstevel@tonic-gate[ "xinitially dir2/messages" = "x`/bin/cat dir2/messages`" ] || exit 1
17830Sstevel@tonic-gate[ -f dir2/messages.0 ] || exit 1
17840Sstevel@tonic-gate[ "xinitially dir2/messages.0" = "x`/bin/cat dir2/messages.0`" ] || exit 1
17850Sstevel@tonic-gate[ -f dir2/messages.1 ] || exit 1
17860Sstevel@tonic-gate[ "xinitially dir2/messages.1" = "x`/bin/cat dir2/messages.1`" ] || exit 1
17870Sstevel@tonic-gate[ -f dir2/messages.2 ] || exit 1
17880Sstevel@tonic-gate[ "xinitially dir2/messages.2" = "x`/bin/cat dir2/messages.2`" ] || exit 1
17890Sstevel@tonic-gate[ -f dir2/messages.3 ] || exit 1
17900Sstevel@tonic-gate[ "xinitially dir2/messages.3" = "x`/bin/cat dir2/messages.3`" ] || exit 1
17910Sstevel@tonic-gate[ -f dir2/messages.4 ] && exit 1
17920Sstevel@tonic-gate/bin/grep -v 'recording rotation date' std.out > grep.out
17930Sstevel@tonic-gateexec /bin/diff grep.out grep.out.expect
17940Sstevel@tonic-gateEOF
17950Sstevel@tonic-gate
17960Sstevel@tonic-gate        set_file('runtest', <<"EOF");
17970Sstevel@tonic-gate# test "logadm14"
17980Sstevel@tonic-gate$envsetup
17990Sstevel@tonic-gateexec $bindir/logadm -nv -f logadm.conf >std.out 2>std.err
18000Sstevel@tonic-gateEOF
18010Sstevel@tonic-gate}
18020Sstevel@tonic-gate
18030Sstevel@tonic-gate###########################################################################
18040Sstevel@tonic-gate#
18050Sstevel@tonic-gate#	logadm15 -- test of -T
18060Sstevel@tonic-gate#
18070Sstevel@tonic-gate###########################################################################
18080Sstevel@tonic-gatesub logadm15 {
18090Sstevel@tonic-gate	set_file('logfile', '');
18100Sstevel@tonic-gate	set_file('logfile.0', 'initially logfile.0');
18110Sstevel@tonic-gate	set_file('logfile.1', 'initially logfile.1');
18120Sstevel@tonic-gate	set_file('logfile.2', 'initially logfile.2');
18130Sstevel@tonic-gate	set_file('logfile.3', 'initially logfile.3');
18140Sstevel@tonic-gate	set_file('logfile.4', 'initially logfile.4');
18150Sstevel@tonic-gate	set_file('logfile.5', 'initially logfile.5');
18160Sstevel@tonic-gate	set_file('logfile.6', 'initially logfile.6');
18170Sstevel@tonic-gate	set_file('logfile.7', 'initially logfile.7');
18180Sstevel@tonic-gate	set_file('logfile.8', 'initially logfile.8');
18190Sstevel@tonic-gate	set_file('logfile.9', 'initially logfile.9');
18200Sstevel@tonic-gate
18210Sstevel@tonic-gate	set_file('checktest', <<'EOF');
18220Sstevel@tonic-gate[ -s std.err ] && exit 1
18230Sstevel@tonic-gate[ -s std.out ] && exit 1
18240Sstevel@tonic-gate[ -f logfile ] || exit 1
18250Sstevel@tonic-gate[ "x" = "x`/bin/cat logfile`" ] || exit 1
18260Sstevel@tonic-gate[ -f logfile.0 ] || exit 1
18270Sstevel@tonic-gate[ "xinitially logfile.0" = "x`/bin/cat logfile.0`" ] || exit 1
18280Sstevel@tonic-gate[ -f logfile.1 ] || exit 1
18290Sstevel@tonic-gate[ "xinitially logfile.1" = "x`/bin/cat logfile.1`" ] || exit 1
18300Sstevel@tonic-gate[ -f logfile.2 ] || exit 1
18310Sstevel@tonic-gate[ "xinitially logfile.2" = "x`/bin/cat logfile.2`" ] || exit 1
18320Sstevel@tonic-gate[ -f logfile.3 ] && exit 1
18330Sstevel@tonic-gate[ -f logfile.4 ] || exit 1
18340Sstevel@tonic-gate[ "xinitially logfile.4" = "x`/bin/cat logfile.4`" ] || exit 1
18350Sstevel@tonic-gate[ -f logfile.5 ] && exit 1
18360Sstevel@tonic-gate[ -f logfile.6 ] || exit 1
18370Sstevel@tonic-gate[ "xinitially logfile.6" = "x`/bin/cat logfile.6`" ] || exit 1
18380Sstevel@tonic-gate[ -f logfile.7 ] && exit 1
18390Sstevel@tonic-gate[ -f logfile.8 ] || exit 1
18400Sstevel@tonic-gate[ "xinitially logfile.8" = "x`/bin/cat logfile.8`" ] || exit 1
18410Sstevel@tonic-gate[ -f logfile.9 ] && exit 1
18420Sstevel@tonic-gate[ -f logfile.10 ] && exit 1
18430Sstevel@tonic-gateexit 0
18440Sstevel@tonic-gateEOF
18450Sstevel@tonic-gate
18460Sstevel@tonic-gate	set_file('runtest', <<"EOF");
18470Sstevel@tonic-gate# test "logadm15"
18480Sstevel@tonic-gate$envsetup
18490Sstevel@tonic-gateexec $bindir/logadm -f /dev/null logfile -C1 -T '*.[13579]'>std.out 2>std.err
18500Sstevel@tonic-gateEOF
18510Sstevel@tonic-gate}
18520Sstevel@tonic-gate
18530Sstevel@tonic-gate###########################################################################
18540Sstevel@tonic-gate#
18550Sstevel@tonic-gate#	logadm16 -- test of -h
18560Sstevel@tonic-gate#
18570Sstevel@tonic-gate###########################################################################
18580Sstevel@tonic-gatesub logadm16 {
18590Sstevel@tonic-gate	set_file('std.err.expect', <<'EOF');
18600Sstevel@tonic-gateUsage: logadm [options]
18610Sstevel@tonic-gate       (processes all entries in /etc/logadm.conf or conffile given by -f)
18620Sstevel@tonic-gate   or: logadm [options] logname...
18630Sstevel@tonic-gate       (processes the given lognames)
18640Sstevel@tonic-gate
18650Sstevel@tonic-gateGeneral options:
18660Sstevel@tonic-gate        -e mailaddr     mail errors to given address
18670Sstevel@tonic-gate        -f conffile     use conffile instead of /etc/logadm.conf
18680Sstevel@tonic-gate        -h              display help
18690Sstevel@tonic-gate        -N              not an error if log file nonexistent
18700Sstevel@tonic-gate        -n              show actions, don't perform them
18710Sstevel@tonic-gate        -r              remove logname entry from conffile
18720Sstevel@tonic-gate        -V              ensure conffile entries exist, correct
18730Sstevel@tonic-gate        -v              print info about actions happening
18740Sstevel@tonic-gate        -w entryname    write entry to config file
18750Sstevel@tonic-gate
18760Sstevel@tonic-gateOptions which control when a logfile is rotated:
18770Sstevel@tonic-gate(default is: -s1b -p1w if no -s or -p)
18780Sstevel@tonic-gate        -p period       only rotate if period passed since last rotate
18790Sstevel@tonic-gate        -P timestamp    used to store rotation date in conffile
18800Sstevel@tonic-gate        -s size         only rotate if given size or greater
18810Sstevel@tonic-gate
18820Sstevel@tonic-gateOptions which control how a logfile is rotated:
18830Sstevel@tonic-gate(default is: -t '$file.$n', owner/group/mode taken from log file)
18840Sstevel@tonic-gate        -a cmd          execute cmd after taking actions
18850Sstevel@tonic-gate        -b cmd          execute cmd before taking actions
18860Sstevel@tonic-gate        -c              copy & truncate logfile, don't rename
18870Sstevel@tonic-gate        -g group        new empty log file group
1888*954Sgm149974        -l              rotate log file with local time rather than UTC
18890Sstevel@tonic-gate        -m mode         new empty log file mode
18900Sstevel@tonic-gate        -M cmd          execute cmd to rotate the log file
18910Sstevel@tonic-gate        -o owner        new empty log file owner
18920Sstevel@tonic-gate        -R cmd          run cmd on file after rotate
18930Sstevel@tonic-gate        -t template     template for naming old logs
18940Sstevel@tonic-gate        -z count        gzip old logs except most recent count
18950Sstevel@tonic-gate
18960Sstevel@tonic-gateOptions which control the expiration of old logfiles:
18970Sstevel@tonic-gate(default is: -C10 if no -A, -C, or -S)
18980Sstevel@tonic-gate        -A age          expire logs older than age
18990Sstevel@tonic-gate        -C count        expire old logs until count remain
19000Sstevel@tonic-gate        -E cmd          run cmd on file to expire
19010Sstevel@tonic-gate        -S size         expire until space used is below size
19020Sstevel@tonic-gate        -T pattern      pattern for finding old logs
19030Sstevel@tonic-gateEOF
19040Sstevel@tonic-gate
19050Sstevel@tonic-gate	set_file('checktest', <<'EOF');
19060Sstevel@tonic-gate[ -s std.out ] && exit 1
19070Sstevel@tonic-gateexec /bin/diff std.err std.err.expect
19080Sstevel@tonic-gateEOF
19090Sstevel@tonic-gate
19100Sstevel@tonic-gate	set_file('runtest', <<"EOF");
19110Sstevel@tonic-gate# test "logadm16"
19120Sstevel@tonic-gate$envsetup
19130Sstevel@tonic-gateexec $bindir/logadm -h >std.out 2>std.err
19140Sstevel@tonic-gateEOF
19150Sstevel@tonic-gate}
19160Sstevel@tonic-gate
19170Sstevel@tonic-gate###########################################################################
19180Sstevel@tonic-gate#
19190Sstevel@tonic-gate#       logadm17 -- test that mkdir -p happens as necessary
19200Sstevel@tonic-gate#
19210Sstevel@tonic-gate###########################################################################
19220Sstevel@tonic-gatesub logadm17 {
19230Sstevel@tonic-gate	set_file('logfile', 'initially logfile');
19240Sstevel@tonic-gate
19250Sstevel@tonic-gate	set_file('checktest', <<'EOF');
19260Sstevel@tonic-gate[ -s std.err ] && exit 1
19270Sstevel@tonic-gate[ -s std.out ] && exit 1
19280Sstevel@tonic-gate[ -f dir1/dir2/logfile ] || exit 1
19290Sstevel@tonic-gate[ -f logfile ] || exit 1
19300Sstevel@tonic-gate[ "xinitially logfile" = "x`/bin/cat dir1/dir2/logfile`" ] || exit 1
19310Sstevel@tonic-gateexit 0
19320Sstevel@tonic-gateEOF
19330Sstevel@tonic-gate
19340Sstevel@tonic-gate        set_file('runtest', <<"EOF");
19350Sstevel@tonic-gate# test "logadm17"
19360Sstevel@tonic-gate$envsetup
19370Sstevel@tonic-gateexec $bindir/logadm -f /dev/null -t 'dir1/dir2/\$basename' logfile -p now >std.out 2>std.err
19380Sstevel@tonic-gateEOF
19390Sstevel@tonic-gate}
19400Sstevel@tonic-gate
19410Sstevel@tonic-gate###########################################################################
19420Sstevel@tonic-gate#
19430Sstevel@tonic-gate#       logadm18 -- test of -M option
19440Sstevel@tonic-gate#
19450Sstevel@tonic-gate###########################################################################
19460Sstevel@tonic-gatesub logadm18 {
19470Sstevel@tonic-gate	mkdir 'dir1', 0777 or die "mkdir dir1: $!\n";
19480Sstevel@tonic-gate	set_file('dir1/syslog', 'initially dir1/syslog');
19490Sstevel@tonic-gate	set_file('dir1/syslog.0', 'initially dir1/syslog.0');
19500Sstevel@tonic-gate	set_file('dir1/syslog.1', 'initially dir1/syslog.1');
19510Sstevel@tonic-gate	set_file('dir1/syslog.2', 'initially dir1/syslog.2');
19520Sstevel@tonic-gate	set_file('dir1/syslog.3', 'initially dir1/syslog.3');
19530Sstevel@tonic-gate	set_file('dir1/syslog.4', 'initially dir1/syslog.4');
19540Sstevel@tonic-gate	set_file('dir1/syslog.5', 'initially dir1/syslog.5');
19550Sstevel@tonic-gate	set_file('dir1/syslog.6', 'initially dir1/syslog.6');
19560Sstevel@tonic-gate	set_file('dir1/syslog.7', 'initially dir1/syslog.7');
19570Sstevel@tonic-gate
19580Sstevel@tonic-gate	set_file('logadm.conf', <<"EOF");
19590Sstevel@tonic-gatedir1/syslog -C 8 -s 1b -M '/bin/tr [a-z] [A-Z] < \$file > \$nfile; /bin/rm -f \$file'
19600Sstevel@tonic-gateEOF
19610Sstevel@tonic-gate
19620Sstevel@tonic-gate	set_file('checktest', <<'EOF');
19630Sstevel@tonic-gate[ -s std.err ] && exit 1
19640Sstevel@tonic-gate[ -s std.out ] && exit 1
19650Sstevel@tonic-gate[ -f dir1/syslog ] || exit 1
19660Sstevel@tonic-gate[ -s dir1/syslog ] && exit 1
19670Sstevel@tonic-gate[ -f dir1/syslog.0 ] || exit 1
19680Sstevel@tonic-gate[ "xINITIALLY DIR1/SYSLOG" = "x`/bin/cat dir1/syslog.0`" ] || exit 1
19690Sstevel@tonic-gate[ -f dir1/syslog.1 ] || exit 1
19700Sstevel@tonic-gate[ "xinitially dir1/syslog.0" = "x`/bin/cat dir1/syslog.1`" ] || exit 1
19710Sstevel@tonic-gate[ -f dir1/syslog.2 ] || exit 1
19720Sstevel@tonic-gate[ "xinitially dir1/syslog.1" = "x`/bin/cat dir1/syslog.2`" ] || exit 1
19730Sstevel@tonic-gate[ -f dir1/syslog.3 ] || exit 1
19740Sstevel@tonic-gate[ "xinitially dir1/syslog.2" = "x`/bin/cat dir1/syslog.3`" ] || exit 1
19750Sstevel@tonic-gate[ -f dir1/syslog.4 ] || exit 1
19760Sstevel@tonic-gate[ "xinitially dir1/syslog.3" = "x`/bin/cat dir1/syslog.4`" ] || exit 1
19770Sstevel@tonic-gate[ -f dir1/syslog.5 ] || exit 1
19780Sstevel@tonic-gate[ "xinitially dir1/syslog.4" = "x`/bin/cat dir1/syslog.5`" ] || exit 1
19790Sstevel@tonic-gate[ -f dir1/syslog.6 ] || exit 1
19800Sstevel@tonic-gate[ "xinitially dir1/syslog.5" = "x`/bin/cat dir1/syslog.6`" ] || exit 1
19810Sstevel@tonic-gate[ -f dir1/syslog.7 ] || exit 1
19820Sstevel@tonic-gate[ "xinitially dir1/syslog.6" = "x`/bin/cat dir1/syslog.7`" ] || exit 1
19830Sstevel@tonic-gate[ -f dir1/syslog.8 ] && exit 1
19840Sstevel@tonic-gate
19850Sstevel@tonic-gateexit 0
19860Sstevel@tonic-gateEOF
19870Sstevel@tonic-gate
19880Sstevel@tonic-gate        set_file('runtest', <<"EOF");
19890Sstevel@tonic-gate# test "logadm18"
19900Sstevel@tonic-gate$envsetup
19910Sstevel@tonic-gateexec $bindir/logadm -f logadm.conf >std.out 2>std.err
19920Sstevel@tonic-gateEOF
19930Sstevel@tonic-gate}
1994*954Sgm149974
1995*954Sgm149974#############################################################################
1996*954Sgm149974#
1997*954Sgm149974#         logadm19 -- test of  -l
1998*954Sgm149974#
1999*954Sgm149974#############################################################################
2000*954Sgm149974sub logadm19 {
2001*954Sgm149974        set_file('logfile', 'initially logfile');
2002*954Sgm149974
2003*954Sgm149974        set_file('checktest', <<'EOF');
2004*954Sgm149974[ -s std.err ] && exit 1
2005*954Sgm149974[ -s std.out ] && exit 1
2006*954Sgm149974[ -s logfile ] && exit 1
2007*954Sgm149974TZ= export TZ
2008*954Sgm149974d=`/bin/date +\%d\%H\%M`
2009*954Sgm149974[ -f logfile.$d ] || exit 1
2010*954Sgm149974[ "xinitially logfile" = "x`/bin/cat logfile.$d`" ] || exit 1
2011*954Sgm149974exit 0
2012*954Sgm149974EOF
2013*954Sgm149974
2014*954Sgm149974        set_file('runtest', <<"EOF");
2015*954Sgm149974# test "logadm4"
2016*954Sgm149974$envsetup
2017*954Sgm149974exec $bindir/logadm -f /dev/null -l -p now logfile -t '\$file.\%d\%H\%M' >std.out 2>std.err
2018*954Sgm149974EOF
2019*954Sgm149974}
2020