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 230

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 229 diegovalve
my $RegressionsDirectory = "../regressions/single_core/";
12
my $CompilerDir = "../compiler/bin/";
13
my $SimulatonResultFile = "test_result.log";
14
my $Option_Quiet = 1;
15
my $TestConfig;
16 230 diegovalve
my $UserTest = undef;
17 214 diegovalve
#Set the enviroment variable THEIA_PROJECT_FOLDER
18
my $tmp = `pwd`;
19
chomp $tmp;
20
$tmp .= "/../";
21
$ENV{'THEIA_PROJECT_FOLDER'} = $tmp;
22
 
23 229 diegovalve
#find all the *.vp files
24 223 diegovalve
 
25 230 diegovalve
my @Tests;
26
if (not defined $ARGV[0])
27
{
28
  @Tests =  <$RegressionsDirectory/*.vp>;
29
} else {
30
 
31
  $UserTest = "$RegressionsDirectory/$ARGV[0]";
32
  die "Test $UserTest not found\n" if (not -e "$UserTest");
33
  @Tests = ($UserTest);
34
}
35 214 diegovalve
for my $Test (@Tests)
36
{
37
        print sprintf("Running test %-60s  ",$Test);
38
        #Compile the test
39 229 diegovalve
        my $CompilationOutput = `$CompilerDir/theia_compile $Test`;
40 214 diegovalve
        if ($CompilationOutput =~ /ERROR/)
41
        {
42
                print $CompilationOutput;
43
                print "ERROR: theia_compile failed!\n";
44 230 diegovalve
                `ls *.mem | grep -v tmem.mem | xargs rm `;
45 214 diegovalve
                next;
46
        }
47
        print $CompilationOutput if ($Option_Quiet == 0);
48
        #Run the test
49
        my $SimulationOutput = `make run`;
50
        print $SimulationOutput if ($Option_Quiet == 0);
51
 
52
 
53
        #now check for the existance of the test_config file
54
        my $TestBaseName = `basename $Test .vp`;
55
        chomp $TestBaseName;
56
        $TestConfig =  $RegressionsDirectory . "/" . $TestBaseName . ".config";
57
 
58
        if (not -e $TestConfig)
59
        {
60
                print "ERROR: test configuration file $TestConfig does not exist\n";
61 230 diegovalve
                `ls *.mem | grep -v tmem.mem | xargs rm `;
62 214 diegovalve
                next;
63
        }
64
        ParseConfigFile( $TestConfig );
65
 
66
 
67
 
68
 
69
 
70
}
71
print "Ran " .@Tests .  " tests\n";
72
#-------------------------------------------------------------------------
73
sub ParseConfigFile
74
{
75
        my $ConfigFile = shift;
76
        my $Line = 0;
77
        my $Failed = 0;
78
        my $block, my $vp;
79
        my $vpindex;
80
        open CONFIG_FILE , $ConfigFile or die "Could not open $ConfigFile : $!\n";
81 230 diegovalve
        print "Parsing configuration file $ConfigFile\n" if ($Option_Quiet == 0);
82 214 diegovalve
        while (<CONFIG_FILE>)
83
        {
84
                $Line++;
85
                next if m/\/\/.*/;              #skip comments
86
                if (m/==/)
87
                {
88
                        (my $left, my $ExpectedValue) = split /==/;
89
                        $ExpectedValue =~ s/\s+//g;
90
                        chomp $ExpectedValue;
91
                        #print "left $left\n";
92
                        #print "ExpectedValue $ExpectedValue\n";
93
                        ( $vp,  $block) = split (/\./,$left);
94
 
95
                        if ($vp =~ m/vp\[\s*(\d+)\s*\]/)        #get the vp <index>, expr vp[ <index> ]
96
                                {       $vpindex = $1; }
97
                        else
98
                                { die "Error line $Line: Invalid left had side '$vp'\n"; }
99
                        #Now get the block type
100
                        if ($block =~ m/r\[\s*(\d+)\s*\]/)                                      #get the register <index>, expr r[ <index> ]
101
                        {
102
                                my $index = $1;
103
                                my $log_file = "rf.vp." . $vpindex . ".log";
104
                                die "Could not open $log_file  : $!\n" if (not -e $log_file);
105
                                my $RegValue = `grep r$index $log_file| awk '{print \$2 \$3 \$4}'`;
106 230 diegovalve
                                chomp $RegValue;
107 214 diegovalve
                                if (not ($RegValue =~ m/$ExpectedValue/))
108
                                {
109
                                        $Failed = 1;
110
                                        print "\n\t ASSERTION : Expecting vp[ $vpindex ].r[ $index ] == '$ExpectedValue', but simulation has value '$RegValue' \n";
111
                                }
112
 
113
                        } elsif ($block =~ m/omem\[\s*(\d+)\s*\]/) {            #get the OMEM <index>, expr omem[ <index> ]
114
 
115
                                my $index = $1;
116 230 diegovalve
                                my $log_file = "OMEM.vp." . $vpindex . ".log";
117
                                die "Could not open $log_file  : $!\n" if (not -e $log_file);
118
                                print "Expected Value:  $ExpectedValue\n" if ($Option_Quiet == 0);
119
                                my $GrepString;
120
                                $GrepString = sprintf("grep @%02d %s| awk '{print  $2 }'",$index,$log_file);
121
                                my $OmemValue = `$GrepString`;
122
                                chomp $OmemValue;
123
                                print " $GrepString\n" if ($Option_Quiet == 0);
124
                                if (not ($OmemValue =~ m/$ExpectedValue/))
125
                                {
126
                                        $Failed = 1;
127
                                        print "\n\t ASSERTION : Expecting vp[ $vpindex ].omem[ $index ] == '$ExpectedValue', but simulation has value '$OmemValue' \n";
128
                                }
129 214 diegovalve
 
130
                        } else {
131
                                die "Error parsing '$ConfigFile' unknown block type '$block'\n";
132
                        }
133
 
134
 
135
                }
136
 
137
 
138
        }
139
        if ($Failed == 0)
140
        {
141
                print "Test passed\n";
142
        } else {
143
                print "Teset failed\n"
144
        }
145
 
146
        close CONFIG_FILE;
147
}
148
#-------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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