releasing/makecbr/test/CTestScore.pm
author Zheng Shen <zheng.shen@nokia.com>
Tue, 26 Oct 2010 11:12:31 +0800
changeset 654 7c11c3d8d025
parent 602 3145852acc89
permissions -rw-r--r--
romtools 13.2.0.1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# \bin\perl
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
# CTestScore
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
package CTestScore;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
use lib qw(../);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use lib qw(../stages);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
sub New()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
	my $proto = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
	my $class = ref($proto) || $proto;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
	my $self = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
	bless($self, $class);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
	$self->Reset();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
	return $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
sub Reset()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
	my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
	$self->{tested} = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
	$self->{passed} = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
sub Test($$)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
	my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
	my ($passed, $testname) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
	if ($passed < 0)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
		{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
		$passed = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
	$self->{tested} = $self->{tested}+1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
	$self->{passed} = $self->{passed}+$passed;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
	if ($passed > 0)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
		{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
		print "-- $testname...OK\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
	else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
		{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
		print "*#*#* $testname...FAILED\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
sub Print()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
	my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
	my $tested = $self->{tested};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
	my $passed = $self->{passed};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
	my $score;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
	if ($tested == 0)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
		{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
		$score = "undefined";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
	else
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
		{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
		$score = int($passed/$tested*100);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
	print $score."% pass rate; of $tested tests run, $passed passed, ".($tested-$passed)." failed.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
1;