ServDoc_errortest

Code Index:



NAME

ServDoc_errortest - check the STDERR output of ServDoc


VERSION

$Id: ServDoc_errortest,v 1.1 2003/02/02 13:59:08 uherbst Exp $


SYNOPSIS

ServDoc_errortest [-h|help] [-v|version]


DESCRIPTION

ServDoc_errortest runs

  ../ServDoc --debug="ALL,9" > /dev/null

and compares the output (=STDERR) with known messages in <SERVDOC-DIR>/tests. If there are unknown messages, an error is returned.

In the known messages - files, comments are allowed (# at the line beginning).


OPTIONS

-h|help
This help.

-v|version
Version


AUTHORS

Ulrich Herbst <Ulrich.Herbst@gmx.de>


#!/usr/bin/perl -w

#----------------------------------------------------------------------

# standard perl modules
use strict;                       # print error about unknown variables ...
use English;                      # long internal variable names;
use FindBin;                      # In which directory is ServDoc itself ?

my $testdir="$FindBin::Bin";
#----------------------------------------------------------------------


my $cmdstring = "$EXECUTABLE_NAME $FindBin::Bin/../ServDoc --debug='ALL,9'";

my @errors = `$cmdstring 2>&1 1>/dev/null`;

my $username = $UID == 0 ? "root" : "nonroot";

foreach my $errorfile ("$testdir/known_errors.all",
		       "$testdir/known_errors.$OSNAME",
		       "$testdir/known_errors.$OSNAME.$username",
		      ) {
  next if ( ! -r $errorfile);
  my $regex = readknownerrors($errorfile);
  my @errors1 = grep !/$regex/, @errors;
  @errors = @errors1;
}

if ($#errors > -1) {
  print "ERROR:\nOS: $OSNAME, User: $username\n@errors\n";
  exit 1;
}
exit 0;

#----------------------------------------------------------------------
sub readknownerrors {
  my $file = shift;

  open( FILE, $file );
  my $text = join "|",
             grep !/^#/,
             grep {chomp ($_)}
	     <FILE>;
  close(FILE);
  return $text;
}