OpenCores
URL https://opencores.org/ocsvn/theia_gpu/theia_gpu/trunk

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_2.0/] [scripts/] [run_regressions.pl] - Blame information for rev 223

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 214 diegovalve
#!/usr/bin/perl
2
 
3
use strict;
4
use Cwd;
5
use File::Copy;
6
use File::Find;
7
use HTTP::Date;
8
use Data::Dumper;
9
 
10
 
11 223 diegovalve
my $RegressionsDirectory                        = "../regressions/single_core/";
12
my $CompilerDir                                         = "../compiler/bin/";
13
my $SimulatonResultFile                         = "test_result.log";
14
my $TestConfig                                          = undef;
15
my $Option_Quiet                                        = 1;
16
#Set the debug option from the command line
17
$Option_Quiet = 0 if (defined $ARGV[0] and $ARGV[0] == "-debug");
18
 
19
#Check to see if the necessary bash scripts are present and have
20
#the proper execution permissions
21
die "-E- '$CompilerDir/theia_compile' does not exists or does not have execute permissions\n"   if (not -e "$CompilerDir/theia_compile"         or not -x "$CompilerDir/theia_compile");
22
die "-E- '$CompilerDir/theia_vp_compile' does not exists or does not have execute permissions\n"        if (not -e "$CompilerDir/theia_vp_compile"      or not -x "$CompilerDir/theia_vp_compile");
23
die "-E- '$CompilerDir/theia_cp_compile' does not exists or does not have execute permissions\n"        if (not -e "$CompilerDir/theia_cp_compile"      or not -x "$CompilerDir/theia_cp_compile");
24
 
25 214 diegovalve
#Set the enviroment variable THEIA_PROJECT_FOLDER
26 223 diegovalve
#this variable is used by the compiler wrapper bash
27
#scripts under $CompilerDir
28 214 diegovalve
my $tmp = `pwd`;
29
chomp $tmp;
30
$tmp .= "/../";
31
$ENV{'THEIA_PROJECT_FOLDER'} = $tmp;
32 223 diegovalve
print "THEIA_PROJECT_FOLDER = $ENV{'THEIA_PROJECT_FOLDER'}\n" if ($Option_Quiet == 0);
33 214 diegovalve
 
34 223 diegovalve
 
35 214 diegovalve
#find all the *.vp files
36
my @Tests =  <$RegressionsDirectory/*.vp>;
37
for my $Test (@Tests)
38
{
39
        print sprintf("Running test %-60s  ",$Test);
40
        #Compile the test
41 223 diegovalve
        print "\nCommand: $CompilerDir/theia_compile $Test\n" if ($Option_Quiet == 0);
42
        my $CompilationOutput = `source $CompilerDir/theia_compile $Test`;
43 214 diegovalve
        if ($CompilationOutput =~ /ERROR/)
44
        {
45
                print $CompilationOutput;
46
                print "ERROR: theia_compile failed!\n";
47
                `rm *.mem`;
48
                next;
49
        }
50
        print $CompilationOutput if ($Option_Quiet == 0);
51
        #Run the test
52
        my $SimulationOutput = `make run`;
53
        print $SimulationOutput if ($Option_Quiet == 0);
54
 
55
 
56
        #now check for the existance of the test_config file
57
        my $TestBaseName = `basename $Test .vp`;
58
        chomp $TestBaseName;
59
        $TestConfig =  $RegressionsDirectory . "/" . $TestBaseName . ".config";
60
 
61
        if (not -e $TestConfig)
62
        {
63
                print "ERROR: test configuration file $TestConfig does not exist\n";
64
                `rm *.mem`;
65
                next;
66
        }
67
        ParseConfigFile( $TestConfig );
68
 
69
 
70
 
71
 
72
 
73
}
74
print "Ran " .@Tests .  " tests\n";
75
#-------------------------------------------------------------------------
76
sub ParseConfigFile
77
{
78
        my $ConfigFile = shift;
79
        my $Line = 0;
80
        my $Failed = 0;
81
        my $block, my $vp;
82
        my $vpindex;
83
        open CONFIG_FILE , $ConfigFile or die "Could not open $ConfigFile : $!\n";
84
        while (<CONFIG_FILE>)
85
        {
86
                $Line++;
87
                next if m/\/\/.*/;              #skip comments
88
                #print "* $_ \n";
89
                if (m/==/)
90
                {
91
                        (my $left, my $ExpectedValue) = split /==/;
92
                        $ExpectedValue =~ s/\s+//g;
93
                        chomp $ExpectedValue;
94
                        #print "left $left\n";
95
                        #print "ExpectedValue $ExpectedValue\n";
96
                        ( $vp,  $block) = split (/\./,$left);
97
 
98
                        if ($vp =~ m/vp\[\s*(\d+)\s*\]/)        #get the vp <index>, expr vp[ <index> ]
99
                                {       $vpindex = $1; }
100
                        else
101
                                { die "Error line $Line: Invalid left had side '$vp'\n"; }
102
                        #Now get the block type
103
                        if ($block =~ m/r\[\s*(\d+)\s*\]/)                                      #get the register <index>, expr r[ <index> ]
104
                        {
105
                                my $index = $1;
106
                                my $log_file = "rf.vp." . $vpindex . ".log";
107
                                die "Could not open $log_file  : $!\n" if (not -e $log_file);
108
                                my $RegValue = `grep r$index $log_file| awk '{print \$2 \$3 \$4}'`;
109
                                if (not ($RegValue =~ m/$ExpectedValue/))
110
                                {
111
                                        $Failed = 1;
112
                                        print "\n\t ASSERTION : Expecting vp[ $vpindex ].r[ $index ] == '$ExpectedValue', but simulation has value '$RegValue' \n";
113
                                }
114
 
115
                        } elsif ($block =~ m/omem\[\s*(\d+)\s*\]/) {            #get the OMEM <index>, expr omem[ <index> ]
116
 
117
                                my $index = $1;
118
 
119
 
120
                        } else {
121
                                die "Error parsing '$ConfigFile' unknown block type '$block'\n";
122
                        }
123
 
124
 
125
                }
126
 
127
 
128
        }
129
        if ($Failed == 0)
130
        {
131
                print "Test passed\n";
132
        } else {
133
                print "Teset failed\n"
134
        }
135
 
136
        close CONFIG_FILE;
137
}
138
#-------------------------------------------------------------------------

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.