sort_test (version 1.0)
You can also look at:
#! /usr/bin/perl
##############################################################################
#
# SYNTAX: sort_test tool caller level stderr
#
# 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 statdard output
# from the STOOL
# stderr= the name of a file containing the statdard error
# output from the STOOL
#
# DESCRIPTION: This is an error checking routine for gissortcode, gissortsplit,
# DESCRIPTION: sis0sortcode, sis0sortsplit, sis1sortcode, sis1sortsplit.
# DESCRIPTION: These STOOLS exit with random codes and have routine
# DESCRIPTION: logging output in their stderr output.
# DESCRIPTION: This routine logs the stdoutput and raises an exception
# DESCRIPTION: only if there is an E@ or E# error in stderr.
#
# VERSION: 1.0
#
# HISTORY: 0.0 -> 1.0 1999-05-07
# HISTORY: Converted from ksh to perl
#
# CALLS: $UTIL/exception
# CALLS: $UTIL/log_entry
# CALLS: $UTIL/file_to_log
#
##############################################################################
use File::Basename;
#$DEBUG = 1;
($tool, $caller, $level, $stderr) = @ARGV;
$UTIL = $ENV{"UTIL"};
$code = 0;
if ( "$DEBUG" ) {
print "basename($0): tool=$tool\n";
print "basename($0): caller=$caller\n";
print "basename($0): level=$level\n";
print "basename($0): stderr=$stderr\n";
}
###########################
# Check for serious errors
###########################
chomp($errors = `grep E[123] $stderr | grep -v dropped | wc -l`);
if ( $errors > 0 ) {
#########################################
# There are errors so raise an exception
#########################################
`$UTIL/exception $caller $level "Error from STOOL $tool"`;
$code = 1;
}
##########################
# Log the standard output
##########################
if ( -r "$stderr" ) {
chomp($outlines = `wc -l <$stderr`);
}
else {
$outlines = 0;
}
if ( $outlines > 0 ) {
################################
# There is some standard output
################################
`$UTIL/log_entry "Standard Error Output From STOOL ${tool}:"`;
`$UTIL/file_to_log $stderr`;
}
unlink 'stderr.log';
exit;