#!/usr/bin/perl
#
# $Id: testterm.pl,v 1.3 2006/01/23 21:39:30 ddoughty Exp $
#
# Source File: testterm.pl
# Get config
require 'sitecfg.pl';
require 'testlib.pl';
&app_initialize;
print "Content-Type: text/html\n\n";
if (&get_session($FORM{'tid'})) {
$trash = join($pathsep, $testinprog, $FORM{'dbfile'});
$msg = "";
open (TESTFILE, "<$trash") or $msg="failed";
if ($msg eq 'failed') {
print "Test In Progress $FORM{'dbfile'} was completed before it could be terminated.
";
} else {
close TESTFILE;
($clid, $uid, $tstid) = split(/\./, $FORM{'dbfile'});
&get_test_sequence( $clid, $uid, $tstid, $testinprog);
($tstate,$tsubtest,$tqno) = split(/\./, $TEST_SESSION{'state'});
if (($tstate = $TEST_STATES{'_IN_PROGRESS'}) || ($tstate = $TEST_STATES{'_PAUSED_BY_USER'})) {
$tstate=$TEST_STATES{'_TERMINATED'};
$TEST_SESSION{'state'} = "$tstate.$tsubtest.$tqno";
$SUBTEST_SUMMARY{$tsubtest} = "Test Terminated by Administrator\n$FORM{'reason'}";
&put_test_sequence($testinprog, $clid, $uid, $tstid);
print "Test In Progress $FORM{'dbfile'} has been marked for termination.
";
} else {
if ($tstate eq $TEST_STATES{'_TERMINATED'}) {
print "Test $FORM{'dbfile'} was previously marked for termination.
";
} else {
print "Test $FORM{'dbfile'} can not be marked because it has been completed.
";
}
}
}
}