#! /usr/bin/env perl
#testreq: personal
##**************************************************************
##
## 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.
##
##**************************************************************

use CondorTest;
use CondorUtils;
use Check::SimpleJob;

$testname = "job_core_err_van";
my $pid = $$;

my $error = "$testname" . "$pid.err";

$success = sub 
{
	my %info = @_;
	my $cluster = $info{"cluster"};
	my $job     = $info{"job"};
	die "Job should have failed due to Perl errors! $cluster.$job did not.\n";
};

$died = sub 
{
	my %info = @_;
	my $expectedsig = $info{"job"}+1;
	my $gotsig      = $info{"signal"};
	my $error 		= $info{"error"};
	CondorTest::debug("Good, an error as expected.\n",1);
	if(! -f $error )
	{
		die "Specified error file -$error- fails to exist\n";
	}
	else
	{
		CondorTest::debug("Error file $error created as expected\n",1);
		if( -s $error )
		{
			CondorTest::debug("Good file not empty!\n",1);
		}
		else
		{
			die "File was not expected to be empty!\n";
		}
	}
};


my $result = SimpleJob::RunCheck(
	test_name => $testname,
	runthis => "job_core_err.pl",
	on_success => $success,
	on_failure => $died,
	error => $error,
);

CondorTest::EndTest();

exit(0)
