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