os/mm/mmtestenv/mmtesttools/Scripts/TestResultsComparisonTool/TestScriptResults.pm
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmtestenv/mmtesttools/Scripts/TestResultsComparisonTool/TestScriptResults.pm Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,217 @@
1.4 +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +# All rights reserved.
1.6 +# This component and the accompanying materials are made available
1.7 +# under the terms of "Eclipse Public License v1.0"
1.8 +# which accompanies this distribution, and is available
1.9 +# at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +#
1.11 +# Initial Contributors:
1.12 +# Nokia Corporation - initial contribution.
1.13 +#
1.14 +# Contributors:
1.15 +#
1.16 +# Description:
1.17 +#
1.18 +
1.19 +package TestScriptResults;
1.20 +use strict;
1.21 +use Exporter;
1.22 +use base 'Exporter';
1.23 +
1.24 +# Crashing enums
1.25 +my $KTestDidNotCrash = 0;
1.26 +my $KTestCrashed = 1;
1.27 +
1.28 +# Test Harness enums
1.29 +our $KCoreConfTest = "CoreConf";
1.30 +our $KTEFTest = "TEF";
1.31 +our $KTEFNoTestcasesTest = "TEFNoTestcases"; # Some of the older MM TEF tests were implemented without using testcases, in these cases we use the test steps in their place
1.32 +our $KTestFrameworkTest = "TF";
1.33 +
1.34 +our @EXPORT = qw($KCoreConfTest, $KTEFTest, $KTEFNoTestcasesTest, $KTestFrameworkTest);
1.35 +
1.36 +# Constructor
1.37 +sub TestScriptResults
1.38 + {
1.39 + my $this = {};
1.40 + $this->{ScriptName} = undef;
1.41 + $this->{FilePath} = undef;
1.42 + $this->{DidItCrash} = $KTestDidNotCrash;
1.43 + $this->{TotalNumberTestCases} = undef;
1.44 + $this->{Inconclusives} = [1]; # First entry gives the next free index
1.45 + $this->{Fails} = [1]; # First entry gives the next free index
1.46 + $this->{TestHarness} = undef;
1.47 + bless($this);
1.48 + return $this;
1.49 + }
1.50 +
1.51 +sub SetScriptName
1.52 + {
1.53 + my $this = shift;
1.54 + $this->{ScriptName} = shift;
1.55 + }
1.56 +
1.57 +sub ScriptName
1.58 + {
1.59 + my $this = shift;
1.60 + return $this->{ScriptName};
1.61 + }
1.62 +
1.63 +sub SetFilePath
1.64 + {
1.65 + my $this = shift;
1.66 + $this->{FilePath} = shift;
1.67 + }
1.68 +
1.69 +sub FilePath
1.70 + {
1.71 + my $this = shift;
1.72 + return $this->{FilePath};
1.73 + }
1.74 +
1.75 +sub CoreConfTest
1.76 + {
1.77 + my $this = shift;
1.78 + $this->{TestHarness} = $KCoreConfTest;
1.79 + }
1.80 +
1.81 +sub TEFTest
1.82 + {
1.83 + my $this = shift;
1.84 + $this->{TestHarness} = $KTEFTest;
1.85 + }
1.86 +
1.87 +sub TEFNoTestcasesTest
1.88 + {
1.89 + my $this = shift;
1.90 + $this->{TestHarness} = $KTEFNoTestcasesTest;
1.91 + }
1.92 +
1.93 +sub TestFrameworkTest
1.94 + {
1.95 + my $this = shift;
1.96 + $this->{TestHarness} = $KTestFrameworkTest;
1.97 + }
1.98 +
1.99 +sub TestHarness
1.100 + {
1.101 + my $this = shift;
1.102 + return $this->{TestHarness};
1.103 + }
1.104 +
1.105 +sub AddInconclusiveResult
1.106 + {
1.107 + my $this = shift;
1.108 + my $currentFreeIndex = $this->{Inconclusives}[0];
1.109 + $this->{Inconclusives}[$currentFreeIndex] = shift;
1.110 + $currentFreeIndex++;
1.111 + $this->{Inconclusives}[0] = $currentFreeIndex;
1.112 + }
1.113 +
1.114 +sub ResetInconclusives
1.115 + {
1.116 + my $this = shift;
1.117 + $this->{Inconclusives}[0] = 1;
1.118 + }
1.119 +
1.120 +sub Inconclusives
1.121 + {
1.122 + my $this = shift;
1.123 + my @inconList = @{$this->{Inconclusives}};
1.124 + my $finalIndex = $inconList[0] - 1;
1.125 + return @inconList[1 .. $finalIndex];
1.126 + }
1.127 +
1.128 +sub AddFailureResult
1.129 + {
1.130 + my $this = shift;
1.131 + my $currentFreeIndex = $this->{Fails}[0];
1.132 + $this->{Fails}[$currentFreeIndex] = shift;
1.133 + $currentFreeIndex++;
1.134 + $this->{Fails}[0] = $currentFreeIndex;
1.135 + }
1.136 +
1.137 +sub ResetFailures
1.138 + {
1.139 + my $this = shift;
1.140 + $this->{Fails}[0] = 1;
1.141 + }
1.142 +
1.143 +sub Failures
1.144 + {
1.145 + my $this = shift;
1.146 + my @failureList = @{$this->{Fails}};
1.147 + my $finalIndex = $failureList[0] - 1;
1.148 + return @failureList[1 .. $finalIndex];
1.149 + }
1.150 +
1.151 +sub SetTotalTestCount
1.152 + {
1.153 + my $this = shift;
1.154 + $this->{TotalNumberTestCases} = shift;
1.155 + }
1.156 +
1.157 +sub TotalTestCount
1.158 + {
1.159 + my $this = shift;
1.160 + return $this->{TotalNumberTestCases};
1.161 + }
1.162 +
1.163 +sub TestCrashed
1.164 + {
1.165 + my $this = shift;
1.166 + $this->{DidItCrash} = $KTestCrashed;
1.167 + }
1.168 +
1.169 +sub ResetCrashed
1.170 + {
1.171 + my $this = shift;
1.172 + $this->{DidItCrash} = $KTestDidNotCrash;
1.173 + }
1.174 +
1.175 +sub DidItCrash
1.176 + {
1.177 + my $this = shift;
1.178 + return $this->{DidItCrash};
1.179 + }
1.180 +
1.181 +sub AnyFailures
1.182 + {
1.183 + my $this = shift;
1.184 + if (($this->{Fails}[0] > 1) || ($this->{Inconclusives}[0] > 1) || ($this->DidItCrash()))
1.185 + {
1.186 + return 1;
1.187 + }
1.188 + return 0;
1.189 + }
1.190 +
1.191 +sub DebugPrint
1.192 + {
1.193 + my $this = shift;
1.194 + print "\nTest script: $this->{ScriptName}\n$this->{FilePath}\n";
1.195 + if ($this->{DidItCrash} == $KTestCrashed)
1.196 + {
1.197 + print "It CRASHED\n";
1.198 + }
1.199 + print "Test cases run: $this->{TotalNumberTestCases}\n";
1.200 +
1.201 + my $lastIndex = $this->{Inconclusives}[0] - 1;
1.202 + if ($lastIndex > 0)
1.203 + {
1.204 + print "INCONCLUSIVES:\n";
1.205 + foreach my $inconclusiveResult (@{$this->{Inconclusives}}[1 .. $lastIndex])
1.206 + {
1.207 + print "$inconclusiveResult\n";
1.208 + }
1.209 + }
1.210 +
1.211 + $lastIndex = $this->{Fails}[0] - 1;
1.212 + if ($lastIndex > 0)
1.213 + {
1.214 + print "FAILS:\n";
1.215 + foreach my $failResult (@{$this->{Fails}}[1 .. $lastIndex])
1.216 + {
1.217 + print "$failResult\n";
1.218 + }
1.219 + }
1.220 + }
1.221 \ No newline at end of file