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