#! /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;

$cmd = 'job_core_initialdir_sched.cmd';
$testdesc =  'condor_submit initialdir works - scheduler U';
$testname = "job_core_initialdir_sched";


runcmd("mkdir -p initd_sched");

#CondorTest::RegisterExitedSuccess( $testname, \&CondorTest::DefaultOutputTest );


$ExitSuccess = sub 
{
	my %info = @_;

	my $goal = "";
	CondorTest::debug("Looking for $goal\n",1);
#	# Pull out requested environment values
	my $logs   = $info{"log"};
	CondorTest::debug("Log is $logs\n",1);
	my $initialdir = $info{"initialdir"};
	CondorTest::debug("initialdir is $initialdir\n",1);
	$goal = "$initialdir" . "/" . "$logs";
	if( ! -s $goal )
	{
		CondorTest::debug("Expected logfile not found<$goal>\n",1);
		die "Initialdir does not contain user log\n";
	}
	# clean up
	CondorTest::debug("Expected logfile found<$goal>\n",1);
	# the test suite has open file handles to the event log, causing
	# the following command to fail on NFS-based workign directories.
	runcmd("rm -rf initd_sched || :");
};


CondorTest::RegisterExitedSuccess( $testname, $ExitSuccess );

if( CondorTest::RunTest($testname, $cmd, 0) ) {
	CondorTest::debug("$testname: SUCCESS\n",1);
	exit(0);
} else {
	die "$testname: CondorTest::RunTest() failed\n";
}

