#!c:\Perl\bin\perl
use strict;
use Win32::Process;
use Getopt::Long;
my $Evalid_command = 'C:\Program Files\Software Research\eValid\Program\evalid.exe';
my $Evalid_Project_Dir = 'C:\Program Files\Software Research\eValid\Program\Project\Group';
my $Evalid_TestName;
GetOptions ('test:s' => \$Evalid_TestName );
unless ($Evalid_TestName ne "") { warn "\nMissing required option -test \n\n"; exit 0; }
my $Evalid_Script_ref = $Evalid_Project_Dir . "\\" . $Evalid_TestName . ".evs";
##-my $Cmd = "\"$Evalid_command\" -B \"$Evalid_Script_ref\"";
##+my $Cmd = "\"$Evalid_command\" -B \"$Evalid_Script_ref\" -RT 30000";
my $Cmd = "\"$Evalid_command\" -B \"$Evalid_Script_ref\" -RT 30000 -LOG ET
-FE \"$Evalid_TestName\"-E.log -FT \"$Evalid_TestName\"-T.log -Minimize";
system $Cmd;
#print "Command: $Cmd";
my $log_file = "C:/Program Files/Software Research/eValid/Program/Project/Group/" .
$Evalid_TestName . '-T.log';
if ( !open ( LOG, $log_file )) {
print "Error: Cannot open Log file";
exit 2;
}
# You must specifiy the actual LOG filename...
my @file_contents = <LOG>;
close(LOG);
my $availability;
my $exit_code;
my $commands_completed;
my $commands_ok;
my @matching = grep { /Run time/ || /Commands Completed/ || /Commands resulting in OK/ || /Commands Resulting in in Not-OK/ || /Playback Exit Code/ || /Number of URLs visited/ || /Total Bytes Downloaded/ || /Previously Cached Bytes/ || /Downloading Time/ || /Active KB/ || /Overall KB/ } @file_contents;
foreach my $line (@matching ) {
$line =~s/\# //;
$line =~s/ \= /\=/;
my @tmp = split("=", $line);
my @results = split(" ", $tmp[1]);
if ( $tmp[0] =~/Downloading Time/ ) {
my @dlt = split(" ", $tmp[0]);
$line = $dlt[0] . " " . $dlt[1] . "=" . $results[0] . "\n";
} else {
my $line_matching = $tmp[0];
my $line_results = $results[0];
if ( $line_matching =~/Playback Exit Code/ ) {
$exit_code = $line_results;
}
$line = $line_matching . "=" . $line_results . "\n";
}
}
print @matching;
if ( $exit_code == 0 ) {
$availability = 0;
} elsif ( $exit_code >= 64 ) {
$availability = 2;
} elsif ( $exit_code < 64 && $exit_code > 0 ){
$availability = 1;
}
exit ( $availability );
|