equal
deleted
inserted
replaced
|
1 # Copyright (c) 2003-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 the License "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 # \bin\perl |
|
15 # CTestScore |
|
16 # |
|
17 # |
|
18 |
|
19 package CTestScore; |
|
20 |
|
21 use lib qw(../); |
|
22 use lib qw(../stages); |
|
23 |
|
24 use strict; |
|
25 |
|
26 sub New() |
|
27 { |
|
28 my $proto = shift; |
|
29 my $class = ref($proto) || $proto; |
|
30 |
|
31 my $self = {}; |
|
32 bless($self, $class); |
|
33 |
|
34 $self->Reset(); |
|
35 |
|
36 return $self; |
|
37 } |
|
38 |
|
39 sub Reset() |
|
40 { |
|
41 my $self = shift; |
|
42 |
|
43 $self->{tested} = 0; |
|
44 $self->{passed} = 0; |
|
45 } |
|
46 |
|
47 sub Test($$) |
|
48 { |
|
49 my $self = shift; |
|
50 my ($passed, $testname) = @_; |
|
51 |
|
52 if ($passed < 0) |
|
53 { |
|
54 $passed = 1; |
|
55 } |
|
56 |
|
57 $self->{tested} = $self->{tested}+1; |
|
58 $self->{passed} = $self->{passed}+$passed; |
|
59 |
|
60 if ($passed > 0) |
|
61 { |
|
62 print "-- $testname...OK\n"; |
|
63 } |
|
64 else |
|
65 { |
|
66 print "*#*#* $testname...FAILED\n"; |
|
67 } |
|
68 } |
|
69 |
|
70 sub Print() |
|
71 { |
|
72 my $self = shift; |
|
73 |
|
74 my $tested = $self->{tested}; |
|
75 my $passed = $self->{passed}; |
|
76 my $score; |
|
77 if ($tested == 0) |
|
78 { |
|
79 $score = "undefined"; |
|
80 } |
|
81 else |
|
82 { |
|
83 $score = int($passed/$tested*100); |
|
84 } |
|
85 |
|
86 print $score."% pass rate; of $tested tests run, $passed passed, ".($tested-$passed)." failed.\n"; |
|
87 } |
|
88 1; |