os/mm/mmtestenv/mmtesttools/Scripts/TestResultsComparisonTool/TestScriptResults.pm
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
# All rights reserved.
sl@0
     3
# This component and the accompanying materials are made available
sl@0
     4
# under the terms of "Eclipse Public License v1.0"
sl@0
     5
# which accompanies this distribution, and is available
sl@0
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
#
sl@0
     8
# Initial Contributors:
sl@0
     9
# Nokia Corporation - initial contribution.
sl@0
    10
#
sl@0
    11
# Contributors:
sl@0
    12
#
sl@0
    13
# Description:
sl@0
    14
#
sl@0
    15
sl@0
    16
package TestScriptResults;
sl@0
    17
use strict;
sl@0
    18
use Exporter;
sl@0
    19
use base 'Exporter'; 
sl@0
    20
sl@0
    21
# Crashing enums
sl@0
    22
my $KTestDidNotCrash = 0;
sl@0
    23
my $KTestCrashed = 1;
sl@0
    24
sl@0
    25
# Test Harness enums
sl@0
    26
our $KCoreConfTest = "CoreConf";
sl@0
    27
our $KTEFTest = "TEF";
sl@0
    28
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
sl@0
    29
our $KTestFrameworkTest = "TF";
sl@0
    30
sl@0
    31
our @EXPORT = qw($KCoreConfTest, $KTEFTest, $KTEFNoTestcasesTest, $KTestFrameworkTest);
sl@0
    32
sl@0
    33
# Constructor
sl@0
    34
sub TestScriptResults
sl@0
    35
	{
sl@0
    36
	my $this = {};
sl@0
    37
	$this->{ScriptName} = undef;
sl@0
    38
	$this->{FilePath} = undef;
sl@0
    39
	$this->{DidItCrash} = $KTestDidNotCrash;
sl@0
    40
	$this->{TotalNumberTestCases} = undef;
sl@0
    41
	$this->{Inconclusives} = [1];	# First entry gives the next free index
sl@0
    42
	$this->{Fails} = [1];	# First entry gives the next free index
sl@0
    43
	$this->{TestHarness} = undef;
sl@0
    44
	bless($this);
sl@0
    45
	return $this;
sl@0
    46
	}
sl@0
    47
sl@0
    48
sub SetScriptName
sl@0
    49
	{
sl@0
    50
	my $this = shift;
sl@0
    51
	$this->{ScriptName} = shift;
sl@0
    52
	}
sl@0
    53
sl@0
    54
sub ScriptName
sl@0
    55
	{
sl@0
    56
	my $this = shift;
sl@0
    57
	return $this->{ScriptName};
sl@0
    58
	}
sl@0
    59
	
sl@0
    60
sub SetFilePath
sl@0
    61
	{
sl@0
    62
	my $this = shift;
sl@0
    63
	$this->{FilePath} = shift;
sl@0
    64
	}
sl@0
    65
sl@0
    66
sub FilePath
sl@0
    67
	{
sl@0
    68
	my $this = shift;
sl@0
    69
	return $this->{FilePath};
sl@0
    70
	}
sl@0
    71
sl@0
    72
sub CoreConfTest
sl@0
    73
	{
sl@0
    74
	my $this = shift;
sl@0
    75
	$this->{TestHarness} = $KCoreConfTest;	
sl@0
    76
	}
sl@0
    77
sl@0
    78
sub TEFTest
sl@0
    79
	{
sl@0
    80
	my $this = shift;
sl@0
    81
	$this->{TestHarness} = $KTEFTest;
sl@0
    82
	}
sl@0
    83
		
sl@0
    84
sub TEFNoTestcasesTest
sl@0
    85
	{
sl@0
    86
	my $this = shift;
sl@0
    87
	$this->{TestHarness} = $KTEFNoTestcasesTest;
sl@0
    88
	}
sl@0
    89
	
sl@0
    90
sub TestFrameworkTest
sl@0
    91
	{
sl@0
    92
	my $this = shift;
sl@0
    93
	$this->{TestHarness} = $KTestFrameworkTest;
sl@0
    94
	}
sl@0
    95
sl@0
    96
sub TestHarness
sl@0
    97
	{
sl@0
    98
	my $this = shift;
sl@0
    99
	return $this->{TestHarness};	
sl@0
   100
	}
sl@0
   101
	
sl@0
   102
sub AddInconclusiveResult
sl@0
   103
	{
sl@0
   104
	my $this = shift;
sl@0
   105
	my $currentFreeIndex = $this->{Inconclusives}[0];
sl@0
   106
	$this->{Inconclusives}[$currentFreeIndex] = shift;
sl@0
   107
	$currentFreeIndex++;
sl@0
   108
	$this->{Inconclusives}[0] = $currentFreeIndex;
sl@0
   109
	}
sl@0
   110
sl@0
   111
sub ResetInconclusives
sl@0
   112
	{
sl@0
   113
	my $this = shift;
sl@0
   114
	$this->{Inconclusives}[0] = 1;	
sl@0
   115
	}
sl@0
   116
	
sl@0
   117
sub Inconclusives
sl@0
   118
	{
sl@0
   119
	my $this = shift;
sl@0
   120
	my @inconList = @{$this->{Inconclusives}};	
sl@0
   121
	my $finalIndex = $inconList[0] - 1;
sl@0
   122
	return @inconList[1 .. $finalIndex];	
sl@0
   123
	}
sl@0
   124
	
sl@0
   125
sub AddFailureResult
sl@0
   126
	{
sl@0
   127
	my $this = shift;
sl@0
   128
	my $currentFreeIndex = $this->{Fails}[0];
sl@0
   129
	$this->{Fails}[$currentFreeIndex] = shift;
sl@0
   130
	$currentFreeIndex++;
sl@0
   131
	$this->{Fails}[0] = $currentFreeIndex;
sl@0
   132
	}
sl@0
   133
sl@0
   134
sub ResetFailures
sl@0
   135
	{
sl@0
   136
	my $this = shift;
sl@0
   137
	$this->{Fails}[0] = 1;	
sl@0
   138
	}	
sl@0
   139
	
sl@0
   140
sub Failures
sl@0
   141
	{
sl@0
   142
	my $this = shift;
sl@0
   143
	my @failureList = @{$this->{Fails}};	
sl@0
   144
	my $finalIndex = $failureList[0] - 1;
sl@0
   145
	return @failureList[1 .. $finalIndex];
sl@0
   146
	}	
sl@0
   147
	
sl@0
   148
sub SetTotalTestCount
sl@0
   149
	{
sl@0
   150
	my $this = shift;
sl@0
   151
	$this->{TotalNumberTestCases} = shift;
sl@0
   152
	}
sl@0
   153
sl@0
   154
sub TotalTestCount
sl@0
   155
	{
sl@0
   156
	my $this = shift;
sl@0
   157
	return $this->{TotalNumberTestCases};
sl@0
   158
	}
sl@0
   159
sl@0
   160
sub TestCrashed
sl@0
   161
	{
sl@0
   162
	my $this = shift;
sl@0
   163
	$this->{DidItCrash} = $KTestCrashed;
sl@0
   164
	}
sl@0
   165
sl@0
   166
sub ResetCrashed
sl@0
   167
	{
sl@0
   168
	my $this = shift;
sl@0
   169
	$this->{DidItCrash} = $KTestDidNotCrash;
sl@0
   170
	}
sl@0
   171
	
sl@0
   172
sub DidItCrash
sl@0
   173
	{
sl@0
   174
	my $this = shift;
sl@0
   175
	return $this->{DidItCrash};
sl@0
   176
	}
sl@0
   177
	
sl@0
   178
sub AnyFailures
sl@0
   179
	{
sl@0
   180
	my $this = shift;
sl@0
   181
	if (($this->{Fails}[0] > 1) || ($this->{Inconclusives}[0] > 1) || ($this->DidItCrash()))
sl@0
   182
		{
sl@0
   183
		return 1;
sl@0
   184
		}
sl@0
   185
	return 0;	
sl@0
   186
	}
sl@0
   187
	
sl@0
   188
sub DebugPrint
sl@0
   189
	{
sl@0
   190
	my $this = shift;
sl@0
   191
	print "\nTest script: $this->{ScriptName}\n$this->{FilePath}\n";
sl@0
   192
	if ($this->{DidItCrash} == $KTestCrashed)
sl@0
   193
		{
sl@0
   194
		print "It CRASHED\n";
sl@0
   195
		}
sl@0
   196
	print "Test cases run: $this->{TotalNumberTestCases}\n";
sl@0
   197
	
sl@0
   198
	my $lastIndex = $this->{Inconclusives}[0] - 1;
sl@0
   199
	if ($lastIndex > 0)
sl@0
   200
		{
sl@0
   201
		print "INCONCLUSIVES:\n";
sl@0
   202
		foreach my $inconclusiveResult (@{$this->{Inconclusives}}[1 .. $lastIndex])
sl@0
   203
			{
sl@0
   204
			print "$inconclusiveResult\n";
sl@0
   205
			}
sl@0
   206
		}
sl@0
   207
		
sl@0
   208
	$lastIndex = $this->{Fails}[0] - 1;
sl@0
   209
	if ($lastIndex > 0)
sl@0
   210
		{
sl@0
   211
		print "FAILS:\n";
sl@0
   212
		foreach my $failResult (@{$this->{Fails}}[1 .. $lastIndex])
sl@0
   213
			{
sl@0
   214
			print "$failResult\n";
sl@0
   215
			}
sl@0
   216
		}
sl@0
   217
	}