602
|
1 |
#!\bin\perl -w
|
|
2 |
# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
# distillsrc.pl test script
|
|
16 |
#
|
|
17 |
#
|
|
18 |
|
|
19 |
use FindBin;
|
|
20 |
use Cwd ('chdir','abs_path');
|
|
21 |
|
|
22 |
my $cwd = abs_path($FindBin::Bin."\\..");
|
|
23 |
chdir($cwd) or die "Couldn't change directory to $cwd\n";
|
|
24 |
|
|
25 |
# Test cases
|
|
26 |
#
|
|
27 |
# Entry format: [parameters, [[pass regexps],[fail regexps]]]
|
|
28 |
#
|
|
29 |
# [pass regexps] and [fail regexps] are lists of regular expressions, each
|
|
30 |
# as a string. All pass regexps must match. No fail regexps may match.
|
|
31 |
# If a line matches both, it is said to have passed (hence a generic failure
|
|
32 |
# rule can be written to match any output which wasn't expected)
|
|
33 |
my @testcases =
|
|
34 |
(
|
|
35 |
['-r fred -l beech' ,
|
|
36 |
[
|
|
37 |
['^ERROR: RealTimeBuild:.*srcpath must be given'],
|
|
38 |
['^ERROR: RealTimeBuild:']
|
|
39 |
]
|
|
40 |
],
|
|
41 |
['-s fred -l beech' ,
|
|
42 |
[
|
|
43 |
['^ERROR: RealTimeBuild:.*srcroot must be given'],
|
|
44 |
['^ERROR: RealTimeBuild:']
|
|
45 |
]
|
|
46 |
],
|
|
47 |
['-r fred -s src' ,
|
|
48 |
[
|
|
49 |
['^ERROR: RealTimeBuild:.*platform'],
|
|
50 |
['^ERROR: RealTimeBuild:']
|
|
51 |
]
|
|
52 |
],
|
|
53 |
['-d -r test -s source -p prefix -l fred -c test\options.txt -N' ,
|
|
54 |
[
|
|
55 |
[
|
|
56 |
'= spacey$',
|
|
57 |
'= whole$',
|
|
58 |
'^DUMMY: File test\\\\source\\\\fixer.mrp',
|
|
59 |
'^DUMMY: File test\\\\source\\\\DISTRIBUTION\\.POLICY',
|
|
60 |
'^DUMMY: File test\\\\source\\\\missing\\\\unowned'
|
|
61 |
],
|
|
62 |
[
|
|
63 |
'^DUMMY:.*is not specified in any \\.mrp file',
|
|
64 |
'does not include itself'
|
|
65 |
]
|
|
66 |
]
|
|
67 |
],
|
|
68 |
['-d -r test -s source -p prefix -l fred -c test\options.txt -m test\source\fixer.mrp' ,
|
|
69 |
[
|
|
70 |
[
|
|
71 |
'= spacey$',
|
|
72 |
'= whole$',
|
|
73 |
'= fixer$',
|
|
74 |
'WARNING: \[fixer\] Case of .test\\\\soUrce\\\\DIStribuTION.poliCY. does not match.* Should be test\\\\source\\\\DISTRIBUTION.POLICY$',
|
|
75 |
'WARNING: \[fixer\] Case of .test\\\\soUrce\\\\missing.* does not match.* Should be test\\\\source\\\\missing',
|
|
76 |
'source\\\\spacey\\\\spa cey.txt = spacey$',
|
|
77 |
],
|
|
78 |
[
|
|
79 |
'^DUMMY:.*is not specified in any \\.mrp file',
|
|
80 |
'does not include itself'
|
|
81 |
]
|
|
82 |
]
|
|
83 |
],
|
|
84 |
['-d -r test -s source -p prefix -l fred -f test\base.txt' ,
|
|
85 |
[
|
|
86 |
[
|
|
87 |
'= whole$',
|
|
88 |
'^DUMMY: File test\\\\source\\\\fixer\\.mrp',
|
|
89 |
'^DUMMY: File test\\\\source\\\\DISTRIBUTION\\.POLICY',
|
|
90 |
'^DUMMY: Directory test\\\\source\\\\missing',
|
|
91 |
'^DUMMY: File test\\\\source\\\\shared\\\\missing',
|
|
92 |
'^DUMMY: Directory test\\\\source\\\\spacey'
|
|
93 |
],
|
|
94 |
[
|
|
95 |
'^DUMMY:.*is not specified in any \\.mrp file',
|
|
96 |
'does not include itself'
|
|
97 |
]
|
|
98 |
]
|
|
99 |
],
|
|
100 |
['-d -r test -s nowt -l fred -m test\naughty.mrp' ,
|
|
101 |
[
|
|
102 |
[
|
|
103 |
'nothing_important.* doesn\'t exist',
|
|
104 |
'No \.mrp files claim any source',
|
|
105 |
'naughty\.mrp.*does not include itself'
|
|
106 |
],
|
|
107 |
['^DUMMY:.*is not specified in any \\.mrp file']
|
|
108 |
]
|
|
109 |
],
|
|
110 |
['-r test -s source -l fred -m test\not_present.mrp' ,
|
|
111 |
[
|
|
112 |
['^ERROR: RealTimeBuild:.*not_present\\.mrp.*does not exist'],
|
|
113 |
[]
|
|
114 |
]
|
|
115 |
],
|
|
116 |
['-r test -s source -l fred -m test\duffer.mrp',
|
|
117 |
[
|
|
118 |
['^ERROR: RealTimeBuild:.*not a valid command.*test\\\\duffer\\.mrp'],
|
|
119 |
['= duffer$']
|
|
120 |
]
|
|
121 |
],
|
|
122 |
['-d -r test -s source -p prefix -l fred -f test\base.txt',
|
|
123 |
[
|
|
124 |
[
|
|
125 |
'^WARNING:.*Case of \'.*complete.mrp\' does not match.* Should be.*source.*$',
|
|
126 |
'^WARNING:.*Case of \'.*whole.mrp\' does not match.* Should be.*whole.whole.*$',
|
|
127 |
],
|
|
128 |
['^WARNING:.*Case of .* does not match.* Should be.*$']
|
|
129 |
]
|
|
130 |
],
|
|
131 |
['-d -r test -s source -p prefix -l fred -m test\bincase.mrp',
|
|
132 |
[
|
|
133 |
[
|
|
134 |
'^REMARK:.*\\\\epoc32\\\\thisOneIsnt should be lower case',
|
|
135 |
'^REMARK:.*\\\\epoc32\\\\andNorIs\/thisone should be lower case',
|
|
136 |
'^REMARK:.*\\\\epoc32\\\\thisonesNot should be lower case',
|
|
137 |
'^REMARK:.*\\\\epoc32\\\\norThis\\\\one should be lower case'
|
|
138 |
],
|
|
139 |
['^REMARK:.*should be lower case.*$']
|
|
140 |
]
|
|
141 |
]
|
|
142 |
);
|
|
143 |
|
|
144 |
my $passes = 0;
|
|
145 |
my $tests = 0;
|
|
146 |
|
|
147 |
foreach my $testcase (@testcases)
|
|
148 |
{
|
|
149 |
my $cmd = "distillsrc.pl ".$testcase->[0];
|
|
150 |
print "\nRunning $cmd\n";
|
|
151 |
my @output = `perl $cmd 2>&1`;
|
|
152 |
my @passregexps = @{$testcase->[1]->[0]};
|
|
153 |
my @failregexps = @{$testcase->[1]->[1]};
|
|
154 |
|
|
155 |
my $testpass = -1; # (unset)
|
|
156 |
|
|
157 |
foreach my $line (@output)
|
|
158 |
{
|
|
159 |
chomp ($line);
|
|
160 |
my $pass = 0;
|
|
161 |
my $fail = 0;
|
|
162 |
|
|
163 |
foreach my $passregexp (@passregexps)
|
|
164 |
{
|
|
165 |
if ($line =~ /$passregexp/)
|
|
166 |
{
|
|
167 |
$pass = 1;
|
|
168 |
|
|
169 |
# Remove rule from list
|
|
170 |
@passregexps = grep($_ ne $passregexp, @passregexps);
|
|
171 |
}
|
|
172 |
}
|
|
173 |
|
|
174 |
if (!$pass)
|
|
175 |
{
|
|
176 |
foreach my $failregexp (@failregexps)
|
|
177 |
{
|
|
178 |
if ($line =~ /$failregexp/)
|
|
179 |
{
|
|
180 |
$fail = 1;
|
|
181 |
}
|
|
182 |
}
|
|
183 |
}
|
|
184 |
|
|
185 |
if ($pass)
|
|
186 |
{
|
|
187 |
print "GOOD:$line\n";
|
|
188 |
if ($testpass == -1)
|
|
189 |
{
|
|
190 |
$testpass = 1; # Passed (so far)
|
|
191 |
}
|
|
192 |
}
|
|
193 |
elsif ($fail)
|
|
194 |
{
|
|
195 |
print "BAD:$line\n";
|
|
196 |
$testpass = 0; # Failed
|
|
197 |
}
|
|
198 |
else { print "OKEH:$line\n"; }
|
|
199 |
}
|
|
200 |
|
|
201 |
if ($testpass == 1)
|
|
202 |
{
|
|
203 |
if ((scalar @passregexps) == 0)
|
|
204 |
{
|
|
205 |
print "*** PASS\n";
|
|
206 |
$passes ++;
|
|
207 |
}
|
|
208 |
else
|
|
209 |
{
|
|
210 |
print "*** FAIL - tests not matched:\n> ";
|
|
211 |
print join("\n> ", @passregexps)."\n";
|
|
212 |
}
|
|
213 |
}
|
|
214 |
elsif ($testpass == 0)
|
|
215 |
{
|
|
216 |
print "*** FAIL - hard fail\n";
|
|
217 |
}
|
|
218 |
else
|
|
219 |
{
|
|
220 |
print "*** FAIL - no tests matched\n";
|
|
221 |
}
|
|
222 |
|
|
223 |
$tests ++;
|
|
224 |
}
|
|
225 |
|
|
226 |
print "*** Out of $tests tests, $passes passed\n";
|