Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
392 dpurdie 1
########################################################################
2
# Copyright (C) 1998-2012 Vix Technology, All rights reserved
3
#
4
# Module name   : cc2svn_cctest_paths.pl
5
# Module type   : Makefile system
6
# Compiler(s)   : Perl
7
# Environment(s): jats
8
#
9
# Description   : Test CC paths
10
#                 Process a cc2svn.raw.txt file and examine the CC
11
#                 tags for validity.
12
#
13
#                 Not fast as it creates a dynamic view for each one
14
#                 About one evry two seconds :(
15
#
16
#                 Creates a log file
17
#
1197 dpurdie 18
#                 Can be stopped by creating a stop file
392 dpurdie 19
#
20
#                 Can read in a log file and not retry known good labels
21
#
22
#......................................................................#
23
 
24
require 5.006_001;
25
use strict;
26
use warnings;
27
use JatsError;
28
use JatsSystem;
29
use Getopt::Long;
30
use Pod::Usage;                                 # required for help support
31
use JatsRmApi;
32
 
33
 
34
my $opt_verbose = 1;
35
my $opt_help = 0;
36
my $opt_manual;
1270 dpurdie 37
my $opt_retest;
392 dpurdie 38
 
39
#
40
#   Package information
41
#
42
our %ScmReleases;
43
our %ScmPackages;
44
our %ScmSuffixes;
45
 
46
my %Good;
1270 dpurdie 47
my %Bad;
392 dpurdie 48
my $goodFile = 'cc2svn_labeltest.txt';
49
my $badFile ='cc2svn_labeltest.bad.txt';
50
 
51
 
52
#-------------------------------------------------------------------------------
53
# Function        : Main Entry
54
#
55
# Description     :
56
#
57
# Inputs          :
58
#
59
# Returns         :
60
#
61
my $result = GetOptions (
62
                "help+"         => \$opt_help,          # flag, multiple use allowed
63
                "manual"        => \$opt_manual,        # flag
64
                "verbose+"      => \$opt_verbose,       # flag
1270 dpurdie 65
                "retest"        => \$opt_retest,        # flag
392 dpurdie 66
                );
67
 
68
#
69
#   Process help and manual options
70
#
71
pod2usage(-verbose => 0)  if ($opt_help == 1  || ! $result);
72
pod2usage(-verbose => 1)  if ($opt_help == 2 );
73
pod2usage(-verbose => 2)  if ($opt_manual || ($opt_help > 2));
74
 
75
 
76
ErrorConfig( 'name'    =>'CCTEST_PATHS' );
77
Message ("Reading input data");
78
inputData();
79
inputPastData();
80
 
1270 dpurdie 81
#
82
#   If retesting, then delete the Bad data
83
#
84
if ( $opt_retest )
85
{
86
    Message ("Deleting Bad Tag database");
87
    unlink $badFile;
88
    %Bad = ();
89
}
90
 
392 dpurdie 91
    #
92
    #   Process the data and attempt to validate the label for each package
93
    #
94
    SystemConfig ('ExitOnError' => 0);
1197 dpurdie 95
    foreach ( sort {lc($ScmPackages{$a}{name}) cmp lc($ScmPackages{$b}{name}) } keys %ScmPackages )
392 dpurdie 96
    {
97
        next if ( exists $Good{$_} );
1270 dpurdie 98
        next if ( exists $Bad{$_} );
99
 
392 dpurdie 100
        if ( -f 'stop' )
101
        {
102
            unlink 'stop';
103
            Error ("Stop file encountered");
104
        }
105
        my $tag = $ScmPackages{$_}{vcstag};
106
        my $name = $ScmPackages{$_}{name};
107
        my $rv = 0;
108
        next if ( $tag =~ m~^SVN::~ );                     # Skip packages in Subversion
109
        next if ( $name eq 'AtmelHAL' );                   # Skip - vob not available
110
 
111
        $tag =~ tr~\\/~/~;
112
        if ( $tag !~ m~^CC::~ || examineVcsTag ($tag)){
113
            $rv = 55;
114
        }
115
 
116
        unless ( $rv )
117
        {
118
            $rv = JatsToolPrint ( 'cc2svn_cctest_path.pl', $tag );
119
        }
120
 
121
        doLog ($rv, "$_, $name: $tag, $rv");
122
    }
123
 
124
sub JatsToolPrint
125
{
126
#    Information ("Command: @_");
127
    JatsTool @_;
128
}
129
 
130
 
131
#-------------------------------------------------------------------------------
132
# Function        : inputData
133
#
134
# Description     : Write out data in a form to allow post processing
135
#
136
# Inputs          : 
137
#
138
# Returns         : 
139
#
140
sub inputData
141
{
142
 
143
    my $fname = 'cc2svn.raw.txt';
144
    Error "Cannot locate $fname" unless ( -f $fname );
145
    require $fname;
146
 
147
    Error "Data in $fname is not valid\n"
148
        unless ( keys(%ScmReleases) >= 0 );
149
 
150
#    DebugDumpData("ScmReleases", \%ScmReleases );
151
#    DebugDumpData("ScmPackages", \%ScmPackages );
152
#    DebugDumpData("ScmSuffixes", \%ScmSuffixes );
153
}
154
 
155
#-------------------------------------------------------------------------------
156
# Function        : examineVcsTag
157
#
158
# Description     : Examine a VCS Tag and determine if it looks like rubbish
159
#
160
# Inputs          : Tag to examine
161
#
162
# Returns         : Badness
163
#
164
sub examineVcsTag
165
{
166
    my ($vcstag) = @_;
167
    my $bad = 0;
168
    if ( $vcstag =~ m~^CC::(.*?)(::(.+))?$~ )
169
    {
170
        my $path = $1  || '';
171
        my $label = $2 || '';
172
#print "$vcstag, $bad, $path, $label\n";
173
        $bad = 1 unless ( $label );
174
        $bad = 1 if ( $label =~ m~^N/A$~i || $label  =~ m~^na$~i );
175
 
176
        $bad = 1 unless ( $path );
177
        $bad = 1 if ( $path =~ m~^N/A$~i || $path  =~ m~^na$~i );
178
        $bad = 1 if ( $path =~ m~^/dpkg_archive~ );
179
        $bad = 1 if ( $path =~ m~^dpkg_archive~ );
180
        $bad = 1 if ( $path =~ m~^http:~i );
181
        $bad = 1 if ( $path =~ m~^[A-Za-z]\:~ );
182
        $bad = 1 if ( $path =~ m~^//~ );
183
#        $bad = 1 unless ( $path =~ m~^/~ );
184
    }
185
    else
186
    {
187
        $bad = 1;
188
    }
189
    return $bad;
190
}
191
 
192
#-------------------------------------------------------------------------------
193
# Function        : doLog
194
#
195
# Description     : Log data to output file
196
#
197
# Inputs          : $rv                 - Result code
198
#                                         Determine log file
199
#                   Data to log
200
#
201
# Returns         : 
202
#
203
sub doLog
204
{
205
    my $rv = shift;
206
    my $file = $rv ? $badFile : $goodFile;
207
    open (my $fh, '>>', $file);
208
    print $fh @_, "\n";
209
    close $fh;
210
}
211
 
212
#-------------------------------------------------------------------------------
213
# Function        : inputPastData
214
#
215
# Description     : Read in a previous log file and determine versions that
216
#                   have already been examined
217
#
218
# Inputs          : 
219
#
220
# Returns         : 
221
#
222
sub inputPastData
223
{
224
    Message ("Reading historical data");
225
    open (my $fh, '<', $goodFile );
226
    while ( <$fh> )
227
    {
228
        #
229
        #   Format of data is:
230
        #       pvid, $name:, $tag, $rv
231
        #
232
        chomp;
233
        next if ( m~^#~ );
234
        my @data = split (/\s*,\s*/, $_);
235
        next if ( $data[2] );
236
        next unless ( $data[0] );
237
 
238
        $Good{$data[0]} = 1;
239
    }
240
    close $fh;
1270 dpurdie 241
 
242
 
243
    #
244
    #   Also read in the 'known' bad data
245
    #
246
 
247
    if ( -f $badFile )
248
    {
249
        open (my $fh, '<', $badFile );
250
        while ( <$fh> )
251
        {
252
            #
253
            #   Format of data is:
254
            #       pvid, $name:, $tag, $rv
255
            #
256
            chomp;
257
            next if ( m~^#~ );
258
            my @data = split (/\s*,\s*/, $_);
259
            next unless ( $data[2] );
260
            next unless ( $data[0] );
261
 
262
            $Bad{$data[0]} = 1;
263
        }
264
        close $fh;
265
    }
392 dpurdie 266
}
267