599
|
1 |
#
|
|
2 |
# Copyright (c) 2007 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 "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 |
#
|
|
16 |
|
|
17 |
# Unit tests for Feature Variant Parser (featurevariantparser.pm)
|
|
18 |
# Will only work with EPOCROOT = \, due to some hard coded paths in the VAR files
|
|
19 |
# To use a custom EPOCROOT, update the VAR files to reflect the correct paths
|
|
20 |
# This test script can either be called on its own, or run through the test harness under ../unittest.pl
|
|
21 |
|
|
22 |
use strict;
|
|
23 |
use Test;
|
|
24 |
use lib "../../e32util";
|
|
25 |
use lib "../e32util";
|
|
26 |
use featurevariantparser;
|
|
27 |
use File::Spec;
|
|
28 |
use File::Basename;
|
|
29 |
|
|
30 |
BEGIN { plan tests => 18 }
|
|
31 |
|
|
32 |
# Current Working Directory
|
|
33 |
my $dir = dirname($0);
|
|
34 |
|
|
35 |
my @buildincludes;
|
|
36 |
my $buildincs;
|
|
37 |
my $romincs;
|
|
38 |
my @romincludes;
|
|
39 |
my @parentnodes;
|
|
40 |
my $parents;
|
|
41 |
my @childnodes;
|
|
42 |
my $children;
|
|
43 |
|
|
44 |
# Uncommenting the next line will enable verbose mode
|
|
45 |
#$featurevariantparser::verbose=1;
|
|
46 |
|
|
47 |
# Load first variant file
|
|
48 |
my %variant1 = featurevariantparser->GetVariant( "default", "$dir" );
|
|
49 |
|
|
50 |
#1
|
|
51 |
print "\nCheck the NAME of the variant:\n";
|
|
52 |
ok( 'default', $variant1{'NAME'} );
|
|
53 |
|
|
54 |
#2
|
|
55 |
print "\nCheck the FULL PATH:\n";
|
|
56 |
ok( File::Spec->rel2abs("$dir\\default.var"), $variant1{'FULLPATH'} );
|
|
57 |
|
|
58 |
#3
|
|
59 |
print "\nCheck if variant is VALID:\n";
|
|
60 |
ok( $variant1{'VALID'} );
|
|
61 |
|
|
62 |
#4
|
|
63 |
print "\nCheck if this is a VIRTUAL node:\n";
|
|
64 |
ok( $variant1{'VIRTUAL'} );
|
|
65 |
|
|
66 |
#5
|
|
67 |
my $tmp = "$ENV{EPOCROOT}epoc32\\include\\variant\\Symbian_OS.hrh";
|
|
68 |
print "\nTest the VARIANT_HRH:\n";
|
|
69 |
ok( File::Spec->canonpath($tmp), $variant1{'VARIANT_HRH'} );
|
|
70 |
|
|
71 |
#6
|
|
72 |
print "\nTesting the BUILD_INCLUDES with 'append' keyword:\n";
|
|
73 |
@buildincludes = ("$ENV{EPOCROOT}epoc32/include/build");
|
|
74 |
$buildincs = $variant1{'BUILD_INCLUDES'};
|
|
75 |
ok( File::Spec->canonpath("@buildincludes"), "@$buildincs" );
|
|
76 |
|
|
77 |
#7
|
|
78 |
print "\nTesting the ROM_INCLUDES:\n";
|
|
79 |
@romincludes = ("$ENV{EPOCROOT}epoc32\\include\\rom");
|
|
80 |
$romincs = $variant1{'ROM_INCLUDES'};
|
|
81 |
ok( File::Spec->canonpath("@romincludes"), "@$romincs" );
|
|
82 |
|
|
83 |
# Load Second Variant File
|
|
84 |
my %variant2 = featurevariantparser->GetVariant( "a1", "$dir" );
|
|
85 |
|
|
86 |
#8
|
|
87 |
print "\nTesting PARENT NODES:\n";
|
|
88 |
@parentnodes = ("groupA default");
|
|
89 |
$parents = $variant2{'PARENTS'};
|
|
90 |
ok( "@parentnodes", "@$parents" );
|
|
91 |
|
|
92 |
#9
|
|
93 |
print "\nTesting CHILD NODES:\n";
|
|
94 |
@childnodes = ( "b1a", "b1b" );
|
|
95 |
$children = $variant2{'CHILDREN'};
|
|
96 |
ok( "@childnodes", "@$children" );
|
|
97 |
|
|
98 |
#10
|
|
99 |
print "\nTesting BUILD_INCLUDES of a child variant with 'prepend' keyword:\n";
|
|
100 |
@buildincludes = (
|
|
101 |
"$ENV{EPOCROOT}prepend/include/A1",
|
|
102 |
"$ENV{EPOCROOT}epoc32/include/build",
|
|
103 |
"$ENV{EPOCROOT}epoc32/include/groupA/build",
|
|
104 |
"$ENV{EPOCROOT}epoc32/include/A1/build"
|
|
105 |
);
|
|
106 |
$buildincs = $variant2{'BUILD_INCLUDES'};
|
|
107 |
ok( File::Spec->canonpath("@buildincludes"), "@$buildincs" );
|
|
108 |
|
|
109 |
#11
|
|
110 |
print "\nTesting ROM_INCLUDES of a child variant:\n";
|
|
111 |
@romincludes = (
|
|
112 |
"$ENV{EPOCROOT}epoc32/include/A1/rom",
|
|
113 |
"$ENV{EPOCROOT}epoc32/include/rom",
|
|
114 |
"$ENV{EPOCROOT}epoc32/include/groupA/rom"
|
|
115 |
);
|
|
116 |
$romincs = $variant2{'ROM_INCLUDES'};
|
|
117 |
ok( File::Spec->canonpath("@romincludes"), "@$romincs" );
|
|
118 |
|
|
119 |
|
|
120 |
#12
|
|
121 |
print "\nTesting Invalid Variant file (Missing HRH location). Expect an error from this test\n";
|
|
122 |
# Load third Variant File
|
|
123 |
my %variant3 = featurevariantparser->GetVariant( "b2", "$dir" );
|
|
124 |
ok( !$variant3{'VALID'} );
|
|
125 |
|
|
126 |
#13
|
|
127 |
my %info4 = featurevariantparser->GetVariant( "a2", "$dir" );
|
|
128 |
print "\nTesting the BUILD_INCLUDES of a child node with 'set' keyword:\n";
|
|
129 |
@buildincludes = (
|
|
130 |
"$ENV{EPOCROOT}epoc32/include/A2/build",
|
|
131 |
"$ENV{EPOCROOT}epoc32/include/A2/build2"
|
|
132 |
);
|
|
133 |
$buildincs = $info4{'BUILD_INCLUDES'};
|
|
134 |
ok( File::Spec->canonpath("@buildincludes"), "@$buildincs" );
|
|
135 |
|
|
136 |
#14
|
|
137 |
print "\nTesting for function which searches for default variant file in a given directory\n";
|
|
138 |
ok(featurevariantparser->DefaultExists("$dir"));
|
|
139 |
|
|
140 |
|
|
141 |
#15
|
|
142 |
print "\nTesting for function which searches for default variant file in the default directory\n";
|
|
143 |
if ( -e "$ENV{EPOCROOT}epoc32/tools/variant/default.var" ) {
|
|
144 |
ok(featurevariantparser->DefaultExists());
|
|
145 |
}
|
|
146 |
else {
|
|
147 |
ok(!featurevariantparser->DefaultExists());
|
|
148 |
}
|
|
149 |
|
|
150 |
|
|
151 |
#16
|
|
152 |
print "\nTesting GetBuildableFeatureVariants(). Ignore the generated errors\n";
|
|
153 |
my @list =featurevariantparser->GetBuildableFeatureVariants($dir);
|
|
154 |
my $validlist = "b1a";
|
|
155 |
ok($list[0],$validlist);
|
|
156 |
|
|
157 |
|
|
158 |
#17
|
|
159 |
print "\nTesting ResolveFeatureVariant().Ignore the generated errors\n";
|
|
160 |
my @list2 = featurevariantparser->ResolveFeatureVariant("default",$dir);
|
|
161 |
my @validlist2 = ("b1a");
|
|
162 |
ok(@list2,@validlist2);
|
|
163 |
|
|
164 |
#18
|
|
165 |
print "\nTesting GetValidVariant().Ignore the generated errors\n";
|
|
166 |
my @list3 = featurevariantparser->GetValidVariants($dir);
|
|
167 |
my @validlist3 = ("a1","a2","b1a","default","groupa");
|
|
168 |
ok("@list3","@validlist3");
|