599
|
1 |
# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
# All rights reserved.
|
|
3 |
# This component and the accompanying materials are made available
|
|
4 |
# under the terms of "Eclipse Public License v1.0"
|
|
5 |
# which accompanies this distribution, and is available
|
|
6 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
#
|
|
8 |
# Initial Contributors:
|
|
9 |
# Nokia Corporation - initial contribution.
|
|
10 |
#
|
|
11 |
# Contributors:
|
|
12 |
#
|
|
13 |
# Description:
|
|
14 |
# binary variation build test
|
|
15 |
#
|
|
16 |
# build a variant DLL and an invariant DLL and use them.
|
|
17 |
|
|
18 |
use strict;
|
|
19 |
use Test;
|
|
20 |
use Digest::MD5;
|
|
21 |
|
|
22 |
# how many tests do we plan to run?
|
|
23 |
BEGIN { plan tests => 204 }
|
|
24 |
|
|
25 |
# remember where we started
|
|
26 |
use Cwd;
|
|
27 |
my $cwd = getcwd();
|
|
28 |
|
|
29 |
# change to the test data directory
|
|
30 |
use File::Basename;
|
|
31 |
my $dir = dirname($0);
|
|
32 |
chdir($dir);
|
|
33 |
print "# running in $dir\n";
|
|
34 |
|
|
35 |
# create a local default.hrh, as it varies per OS version
|
|
36 |
# (make it just include the product include file)
|
|
37 |
my $epocroot = $ENV{'EPOCROOT'};
|
|
38 |
my $include = $epocroot . "epoc32/include/variant";
|
|
39 |
my $variant = $epocroot . "epoc32/tools/variant";
|
|
40 |
|
|
41 |
my $cfg = $variant . "/variant.cfg";
|
|
42 |
my $productInclude;
|
|
43 |
|
|
44 |
open(VARCFG, "$cfg") or die("cannot read $cfg\n");
|
|
45 |
while (<VARCFG>)
|
|
46 |
{
|
|
47 |
$productInclude = "$1" if /epoc32.+?([^\\\/]+\.hrh)$/i;
|
|
48 |
}
|
|
49 |
close(VARCFG);
|
|
50 |
die("no product include file in $cfg\n") unless ($productInclude);
|
|
51 |
|
|
52 |
open(DEFHRH, ">default.hrh") or die("cannot write $dir/default.hrh\n");
|
|
53 |
print(DEFHRH "#include <$productInclude>\n");
|
|
54 |
print(DEFHRH "\n#define FEATURE_VARIANT_DEFAULT\n");
|
|
55 |
close(DEFHRH);
|
|
56 |
print("# testing against product $productInclude\n");
|
|
57 |
|
|
58 |
# copy test files to EPOCROOT (make sure we do not destroy any valid
|
|
59 |
# files that are already there and remember to clean up afterwards)
|
|
60 |
#
|
|
61 |
# /epoc32/include/variant/default.hrh
|
|
62 |
# /epoc32/include/variant/variant_a.hrh
|
|
63 |
# /epoc32/include/variant/variant_b.hrh
|
|
64 |
# /epoc32/include/variant/a/variant_a_extra.hrh
|
|
65 |
# /epoc32/include/variant/b/variant_b_extra.hrh
|
|
66 |
# /epoc32/tools/variant/default.var
|
|
67 |
# /epoc32/tools/variant/variant_a.var
|
|
68 |
# /epoc32/tools/variant/variant_b.var
|
|
69 |
# /epoc32/tools/variant/variant_c.var
|
|
70 |
# /epoc32/include/variant/featurelists/bvtest.txt
|
|
71 |
|
|
72 |
my @created = ("$include/default.hrh",
|
|
73 |
"$include/variant_a.hrh",
|
|
74 |
"$include/variant_b.hrh",
|
|
75 |
"$include/a/variant_a_extra.hrh",
|
|
76 |
"$include/b/variant_b_extra.hrh",
|
|
77 |
"$variant/default.var",
|
|
78 |
"$variant/variant_a.var",
|
|
79 |
"$variant/variant_b.var",
|
|
80 |
"$variant/variant_c.var",
|
|
81 |
"$include/featurelists/bvtest.txt"
|
|
82 |
);
|
|
83 |
|
|
84 |
use File::Copy;
|
|
85 |
my $file;
|
|
86 |
foreach $file (@created)
|
|
87 |
{
|
|
88 |
my $epocDir = dirname($file);
|
|
89 |
my $localFile = basename($file);
|
|
90 |
|
|
91 |
mkdir($epocDir) if (!-d $epocDir);
|
|
92 |
move($file, "$file.bak") if (-f $file);
|
|
93 |
|
|
94 |
print "# copy $localFile $file\n";
|
|
95 |
unlink $file;
|
|
96 |
copy($localFile, $file) or die "Failed copy: $!";
|
|
97 |
}
|
|
98 |
|
|
99 |
###############################################################################
|
|
100 |
# THE TESTS #
|
|
101 |
###############################################################################
|
|
102 |
|
|
103 |
# we need to test the ABIv1 and ABIv2 builds
|
|
104 |
|
|
105 |
testABI("armv5");
|
|
106 |
testABI("armv5_abiv1");
|
|
107 |
|
|
108 |
###############################################################################
|
|
109 |
# END OF TESTS #
|
|
110 |
###############################################################################
|
|
111 |
|
|
112 |
# delete test files and restore backed up files to their original state
|
|
113 |
foreach $file (@created)
|
|
114 |
{
|
|
115 |
if (-f "$file.bak")
|
|
116 |
{
|
|
117 |
move("$file.bak", $file);
|
|
118 |
}
|
|
119 |
else
|
|
120 |
{
|
|
121 |
unlink($file);
|
|
122 |
}
|
|
123 |
}
|
|
124 |
|
|
125 |
# change back to the starting directory
|
|
126 |
chdir($cwd);
|
|
127 |
|
|
128 |
# ALL DONE
|
|
129 |
|
|
130 |
|
|
131 |
###############################################################################
|
|
132 |
# SUBROUTINES #
|
|
133 |
###############################################################################
|
|
134 |
|
|
135 |
sub testABI
|
|
136 |
{
|
|
137 |
my $platform = shift;
|
|
138 |
|
|
139 |
# remove the binaries if they already exist
|
|
140 |
my $release = $epocroot . "epoc32/release/$platform";
|
|
141 |
|
|
142 |
my @binaries = (
|
|
143 |
"$release/udeb/InvariantStaticDLL.dll",
|
|
144 |
"$release/urel/InvariantStaticDLL.dll",
|
|
145 |
);
|
|
146 |
|
|
147 |
foreach (@binaries)
|
|
148 |
{
|
|
149 |
unlink($_);
|
|
150 |
}
|
|
151 |
|
|
152 |
cleanVariants("$release/udeb", "VariantStaticDLL.dll");
|
|
153 |
cleanVariants("$release/urel", "VariantStaticDLL.dll");
|
|
154 |
cleanVariants("$release/udeb", "UseStaticDLL.exe");
|
|
155 |
cleanVariants("$release/urel", "UseStaticDLL.exe");
|
|
156 |
|
|
157 |
# we cannot test the command return values because they are always 0
|
|
158 |
system("bldmake bldfiles");
|
|
159 |
|
|
160 |
# clean out everything so makefiles have to be recreated
|
|
161 |
system("abld reallyclean $platform.variant_a >nul 2>&1");
|
|
162 |
system("abld reallyclean $platform.variant_b >nul 2>&1");
|
|
163 |
system("abld reallyclean $platform.variant_c >nul 2>&1");
|
|
164 |
system("abld reallyclean $platform >nul 2>&1");
|
|
165 |
|
|
166 |
# Build variants first to ensure the default makefile is created for invariant dlls
|
|
167 |
system("abld build $platform.variant_a");
|
|
168 |
system("abld build $platform.variant_b");
|
|
169 |
system("abld build $platform.variant_c");
|
|
170 |
system("abld build $platform");
|
|
171 |
|
|
172 |
# test for the existence of each invariant binary file
|
|
173 |
foreach (@binaries)
|
|
174 |
{
|
|
175 |
print "# checking $_\n";
|
|
176 |
ok(-f $_);
|
|
177 |
}
|
|
178 |
|
|
179 |
# test for the existence of each variant binary file
|
|
180 |
checkVariants("$release/udeb/VariantStaticDLL.dll");
|
|
181 |
checkVariants("$release/urel/VariantStaticDLL.dll");
|
|
182 |
checkVariants("$release/udeb/UseStaticDLL.exe");
|
|
183 |
checkVariants("$release/urel/UseStaticDLL.exe");
|
|
184 |
}
|
|
185 |
|
|
186 |
sub cleanVariants
|
|
187 |
{
|
|
188 |
my $dir = shift;
|
|
189 |
my $name = shift;
|
|
190 |
|
|
191 |
if (opendir(DIR, $dir))
|
|
192 |
{
|
|
193 |
while (my $file = readdir(DIR))
|
|
194 |
{
|
|
195 |
if ($file =~ /^$name/)
|
|
196 |
{
|
|
197 |
print "removing $dir/$file\n";
|
|
198 |
unlink("$dir/$file");
|
|
199 |
}
|
|
200 |
}
|
|
201 |
closedir(DIR);
|
|
202 |
}
|
|
203 |
else
|
|
204 |
{
|
|
205 |
print "cannot clean $dir/$name*\n";
|
|
206 |
}
|
|
207 |
}
|
|
208 |
|
|
209 |
sub checkVariants
|
|
210 |
{
|
|
211 |
my $root = shift;
|
|
212 |
|
|
213 |
$root =~ s/\.([^\.]+)$//;
|
|
214 |
my $ext = $1;
|
|
215 |
|
|
216 |
my $vmap = "$root.$ext.vmap";
|
|
217 |
|
|
218 |
# there should be a VMAP file
|
|
219 |
print "# checking $vmap\n";
|
|
220 |
ok(-f $vmap);
|
|
221 |
|
|
222 |
my $hashDefault = "0";
|
|
223 |
my $hashVariantA = "0";
|
|
224 |
my $hashVariantB = "0";
|
|
225 |
my $hashVariantC = "0";
|
|
226 |
|
|
227 |
# Variables to hold feature macro values
|
|
228 |
my ( $featDefault, $featVariantA, $featVariantB, $featVariantC );
|
|
229 |
|
|
230 |
if (open(VMAP, $vmap))
|
|
231 |
{
|
|
232 |
while (<VMAP>)
|
|
233 |
{
|
|
234 |
if (/([0-9a-f]{32})\s+(\S+)\s(\S+)/i)
|
|
235 |
{
|
|
236 |
my $var = lc($2);
|
|
237 |
|
|
238 |
# Store the data for later
|
|
239 |
( $hashDefault, $featDefault ) = ( $1, $3) if ($var eq 'default');
|
|
240 |
( $hashVariantA, $featVariantA ) = ( $1, $3) if ($var eq 'variant_a');
|
|
241 |
( $hashVariantB, $featVariantB ) = ( $1, $3) if ($var eq 'variant_b');
|
|
242 |
( $hashVariantC, $featVariantC ) = ( $1, $3) if ($var eq 'variant_c');
|
|
243 |
}
|
|
244 |
}
|
|
245 |
close(VMAP);
|
|
246 |
}
|
|
247 |
|
|
248 |
# the three hashes Default,A,B should be valid and different
|
|
249 |
ok($hashDefault);
|
|
250 |
ok($hashVariantA);
|
|
251 |
ok($hashVariantB);
|
|
252 |
|
|
253 |
ok($hashDefault ne $hashVariantA);
|
|
254 |
ok($hashDefault ne $hashVariantB);
|
|
255 |
ok($hashVariantA ne $hashVariantB);
|
|
256 |
|
|
257 |
# the three feature lists for Default,A,B should be valid and different
|
|
258 |
ok($featDefault);
|
|
259 |
ok($featVariantA);
|
|
260 |
ok($featVariantB);
|
|
261 |
|
|
262 |
ok($featDefault ne $featVariantA);
|
|
263 |
ok($featDefault ne $featVariantB);
|
|
264 |
ok($featVariantA ne $featVariantB);
|
|
265 |
|
|
266 |
# Check the feature lists are correct
|
|
267 |
ok($featDefault eq 'FEATURE_VARIANT_A=undefined,FEATURE_VARIANT_B=undefined');
|
|
268 |
ok($featVariantA eq 'FEATURE_VARIANT_A=defined,FEATURE_VARIANT_B=undefined');
|
|
269 |
ok($featVariantB eq 'FEATURE_VARIANT_A=undefined,FEATURE_VARIANT_B=\'123\'');
|
|
270 |
|
|
271 |
# Check the hash and feature lists match
|
|
272 |
ok($hashDefault eq Digest::MD5::md5_hex($featDefault));
|
|
273 |
ok($hashVariantA eq Digest::MD5::md5_hex($featVariantA));
|
|
274 |
ok($hashVariantB eq Digest::MD5::md5_hex($featVariantB));
|
|
275 |
|
|
276 |
# hashes A and C should be the same
|
|
277 |
ok($hashVariantA, $hashVariantC);
|
|
278 |
|
|
279 |
# feature lists for A and C should be the same
|
|
280 |
ok($featVariantA, $featVariantC);
|
|
281 |
|
|
282 |
# the corresponding binaries should exist
|
|
283 |
print("# checking $root.$hashDefault.$ext\n");
|
|
284 |
ok(-f "$root.$hashDefault.$ext");
|
|
285 |
|
|
286 |
print("# checking $root.$hashVariantA.$ext\n");
|
|
287 |
ok(-f "$root.$hashVariantA.$ext");
|
|
288 |
|
|
289 |
print("# checking $root.$hashVariantB.$ext\n");
|
|
290 |
ok(-f "$root.$hashVariantB.$ext");
|
|
291 |
|
|
292 |
print("# checking $root.$hashVariantC.$ext\n");
|
|
293 |
ok(-f "$root.$hashVariantC.$ext");
|
|
294 |
}
|
|
295 |
|