stool_test (version 2.0)
You can also look at:
#! /usr/bin/perl
##############################################################################
#
# SYNTAX: stool_test tool code caller level stdout stderr [filtered]
#
# where tool= the name of the STOOL which was just run
# code= the exit code returned by the STOOL
# caller= the name of the routine which called the STOOL
# level= the level of the error to be generated on failure
# stdout= the name of a file containing the standard output
# from the STOOL
# stderr= the name of a file containing the standard error
# output from the STOOL
# filtered= stderr with acceptable errors removed
#
# DESCRIPTION: This is a generic post-STOOL error checking and cleanup routine.
#
# VERSION: 2.0
#
# HISTORY: 0.0 -> 1.0 9/16/97
# HISTORY: Added an optional filtered stderr argument similar to ftool_test
# HISTORY:
# HISTORY: 1.0 -> 2.0 1999-05-07
# HISTORY: Converted from ksh to perl
#
# CALLS: $UTIL/log_entry
# CALLS: $UTIL/file_to_log
# CALLS: $UTIL/exception
#
##############################################################################
use File::Basename;
#$DEBUG = 1;
($tool, $code, $caller, $level, $stdout, $stderr, $filtered) = @ARGV;
$UTIL = $ENV{"UTIL"};
$scriptname = basename($0);
if ( "$DEBUG" ) {
print "$scriptname: tool=$tool\n";
print "$scriptname: code=$code\n";
print "$scriptname: caller=$caller\n";
print "$scriptname: level=$level\n";
print "$scriptname: stdout=$stdout\n";
print "$scriptname: stderr=$stderr\n";
print "$scriptname: filtered=$filtered\n";
}
##########################
# Log the standard output
##########################
if ( -r "$stdout" ) {
chomp($outlines = `wc -l <$stdout`);
}
else {
$outlines = 0;
}
if ( $outlines > 0 ) {
################################
# There is some standard output
################################
`$UTIL/log_entry "Standard Output From STOOL ${tool}:"`;
`$UTIL/file_to_log $stdout`;
}
######################################################
# Check the number of words in the standard error log
######################################################
$errorlines = 0;
if ( -r "$stderr" ) {
chomp($errorlines = `wc -w <$stderr`);
}
###########################################################
# Check the number of words in the filtered standard error
###########################################################
$filteredlines = $errorlines;
if ( -r "$filtered" ) {
chomp($filteredlines = `wc -w <$filtered`);
}
###################
# Debugging output
###################
if ( $DEBUG ) {
print "$scriptname: errorlines=$errorlines\n";
print "$scriptname: filteredlines=$filteredlines\n";
}
if ( $filteredlines > 0 or $code != 0 ) {
`$UTIL/exception $caller $level "Error from ${tool}. Exit code=${code}"`;
if ( $errorlines > 0 ) {
`$UTIL/log_entry "Standard Error Output From STOOL ${tool}"`;
`$UTIL/file_to_log $stderr`;
}
}
############################
# Remove logs if they exist
############################
if ( -e "$stdout" ) {
unlink $stdout;
}
if ( -e "$stderr" ) {
unlink $stderr;
}
if ( -e "$filtered" ) {
unlink $filtered;
}
exit $code;