#! /usr/bin/env perl
##**************************************************************
##
## Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
## University of Wisconsin-Madison, WI.
## 
## Licensed under the Apache License, Version 2.0 (the "License"); you
## may not use this file except in compliance with the License.  You may
## obtain a copy of the License at
## 
##    http://www.apache.org/licenses/LICENSE-2.0
## 
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
##**************************************************************


my @got;
$testdesc =  'condor_procapi - runs prebuilt procapi tests';
$testname = "lib_procapi";
$test = "./condor_procapi";

print scalar localtime() . "\n";


open(ELOG,"$test 2>&1 |") || die "Could not run test<<$test>>: $!\n";
while(<ELOG>) {
	chomp;
	push  @got, $_;
	#print "seeing: $_\n";
}
close(ELOG);

print "We have $#got lines of test output\n";

my $lastsave = "";
foreach $line (@got) {
	chomp($line);
	$lastsave = $line;
	if($line =~ /^.*test\s+\d+\s+failed.*$/) {
		print "$line\n";
	}
	#print "$line\n";
}


if($lastsave =~ /^.*Tests\s+completed\s+sucessfully.*$/) {
	print "Lastline was: $lastsave\n";
	print "Procapi Test passed!\n";
} else {
	print "*********** Procapi Test failed! ***************\n";
	print "Lastline was: $lastsave\n";
	foreach $line (@got) {
	    chomp($line);
		print "$line\n";
	}
	die "*********** Procapi Test failed! ***************\n";
}

