#!/usr/bin/perl
# $Id: set_finish,v 1.4 2011/10/28 07:23:00 sofc Exp $
my $VERSION = 0.1;
my $PROGRAM = 'set_finish';

$ENV{'BASH_ENV'} = '/bin:/usr/bin:/usr/local/bin';
$ENV{'ENV'} = '/bin:/usr/bin:/usr/local/bin';
use RFC::Rig;
use RFC::Main;
use RFC::Header;
use File::Touch;

my $debug = 0;
my $test = 0;
my $edit = 0;
my $inter = 0;
my $do = 1;
for my $string (@ARGV)
{
    if ($string =~ /--version/)
    {
	warn "$PROGRAM is: $VERSION\n";
	exit 0;
    }
}

if (scalar(@ARGV) < 2)
{
    print "Not enough parameters for $PROGRAM\nUse: $PROGRAM \$rig \$test\n";
    exit 1;
}


my $rig = RFC::Rig->new(shift);
$rig->check_run;

my $testno = $rig->session;;
if ( @ARGV ) 
{
    my $ttestno = shift;
    $ttestno =~ /(\d+)/;
    $testno = $1;
}

my $file = $RFC::Header::publicdir.'rig'.$rig->name.'/'.$rig->name.'test'.$testno.'/report.fin';

touch($file);
if (get_cv('database','server') && get_cv('database','db'))
{
    system('/usr/local/bin/celltest/load_test_data_db.pl '.$rig->name.' '.$testno);
}
