releasing/makecbr/test/unit_CConfig.pm
author marvin shi <marvin.shi@nokia.com>
Wed, 17 Nov 2010 14:05:07 +0800
changeset 691 9eeecb73a5d4
parent 602 3145852acc89
permissions -rw-r--r--
fix ou1cimx1#651819
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
#!bin\perl
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
# Unit test for CConfig
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 unit_CConfig;
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
use FindBin;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use Cwd;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
use lib $FindBin::Bin."\\..";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
use CConfig;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
use CTestScore;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
sub RunTest($)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
	my ($testscore) = @_;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
	print "> *** Testing CConfig ***\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
	if (!defined($testscore))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
		{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
		$testscore = New CTestScore();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
	if (!defined($ENV{TEMP}))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
		{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
		print STDOUT "TEMP environment variable must be defined before testing of CConfig is run.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
		return $testscore;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
		
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
	my $testFilename = $ENV{TEMP}."\\CConfig.tst";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
	if (-e $testFilename)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
		{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
		print STDOUT "File '$testFilename' already exists.\nPlease delete this file to enable testing of CConfig.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
		return $testscore;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
		
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
	open(TESTFILE,">$testFilename");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
	print TESTFILE "Key:value\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
	close(TESTFILE);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
	my $testConfig=New CConfig($testFilename);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
	$testscore->Test($testConfig->Get("Key") eq "value", "Loaded in file");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
	$testscore->Test($testConfig->Get("kEy") eq "value", "Tested key case insensitivity");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
	$testscore->Test($testConfig->Set("key:2", "value2"), "Set extra key");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
	$testscore->Test( ($testConfig->Get("Key") eq "value") && ($testConfig->Get("key:2") eq "value2"), "Returned all key values");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
	$testscore->Test(!defined($testConfig->Get("nokey")), "Getting invalid key is undefined");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
	$testscore->Test($testConfig->Set("key3", ["value3","value4"]), "Set list value");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
	my $listref=$testConfig->Get("key3");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
	$testscore->Test( (ref($listref) eq "ARRAY") && (($listref->[0]) eq "value3") && (($listref->[1]) eq "value4"), "Returned list value");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
	$testscore->Test($testConfig->Save($testFilename), "Saved file");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
	$testConfig->Set("key4", "value5");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
	$testscore->Test($testConfig->Reload($testFilename), "Loaded file");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
	$listref=$testConfig->Get("key3");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
	$testscore->Test( ($testConfig->Get("Key") eq "value") && ($testConfig->Get("key:2") eq "value2") && (ref($listref) eq "ARRAY") && (($listref->[0]) eq "value3") && (($listref->[1]) eq "value4") && (!defined( $testConfig->Get("key4") )), "Returned all key values");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
	$testscore->Test(!($testConfig->Set(undef, "val")), "Can't set undefined key");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
	$testscore->Test(!($testConfig->Set("key5", undef)), "Can't set undefined value");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
	$testscore->Test($testConfig->Set("key6", ""), "Can set empty value");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
	$testscore->Test($testConfig->Set("", "val"), "Can set empty key");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
	$testscore->Test(!($testConfig->Set("key7", {"hashkey"=>"hashval"})), "Can't set hash value");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
  # Support for additional behaviour to handle Error message, scanlog format etc.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
	my $logFilename = "CConfig_scanlog.log";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
  TestConfigStatus($testConfig, $testscore);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
  TestLogFile($testFilename, $logFilename, $testscore);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
  ValidateLogFile($logFilename, $testscore);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
	unlink $logFilename;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
  TestDieConditions($testFilename, $testscore);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
	unlink $testFilename;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
	return $testscore;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
	} 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
sub TestConfigStatus($$)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
  my $testConfig = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
  my $testScore = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
  # First check the initial internal state of CConfig
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
  $testScore->Test($testConfig->{iPhaseErrorCount} == 0, "Initial error count is zero");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
  $testScore->Test(!defined ($testConfig->{iPhase}), "Initial undefined initial phase");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
# This writes out a log file
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
sub TestLogFile($$)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
	{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
  my $testFilename = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
  my $logFilename = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
  my $testScore = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
  my $testConfig = New CConfig($testFilename);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
  # This puts a logfile in the current working directory
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
  # i.e. test/CConfig.log
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
	#my $logFilename = "CConfig_scanlog.log";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
  $testConfig->SetLog($logFilename);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
  #$testConfig->Command("Command");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
  $testConfig->PhaseStart("Phase_1");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
  $testScore->Test($testConfig->{iPhase} eq "Phase_1", "Phase_1 defined");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
  $testConfig->Component("Component_1");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
  $testConfig->Error("Phase_1 error message");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
  $testConfig->Warning("Phase_1 warning message");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
  my $phaseErrors = $testConfig->PhaseEnd();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
  $testScore->Test($phaseErrors == 1, "Phase_1 reported 1 error");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
  $testConfig->PhaseStart("Phase_2");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
  $testConfig->Warning("Phase_2 warning message");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
  $testConfig->Print("Opening Phase_3 should finish Phase_2");  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
  $testConfig->PhaseStart("Phase_3");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
  $testScore->Test(1, "Phase switching didn't die");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
  $phaseErrors = $testConfig->PhaseEnd();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
  $testScore->Test($phaseErrors == 0, "Phase_3 reported no errors");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
  #my $logPath = cwd()."/".$logFilename;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
  #print "> *** Please check CConfig log file at $logPath ***\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
  $testScore->Test(1, "Logfile \"$logFilename\" written");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
sub ValidateLogFile($$)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
  # This is the expected log file output - without the date/time stamp
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
  my $logFilename = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
  my $testScore = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
  my $logFileExpected = "===-------------------------------------------------
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
=== Phase_1
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
===-------------------------------------------------
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
=== Phase_1 started 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
=== Phase_1 == Component_1
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
ERROR: Phase_1 error message
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
WARNING: Phase_1 warning message
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
=== Phase_1 finished 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
===-------------------------------------------------
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
=== Phase_2
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
===-------------------------------------------------
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
=== Phase_2 started 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
WARNING: Phase_2 warning message
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
Opening Phase_3 should finish Phase_2
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
=== Phase_2 finished 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
===-------------------------------------------------
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
=== Phase_3
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
===-------------------------------------------------
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
=== Phase_3 started 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
=== Phase_3 finished 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
  $testScore->Test($logFileExpected eq ReadTimelessLogFile($logFilename), "Logfile \"$logFilename\" matches");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
# Read a scanlog file and strip the time/date stamp
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
sub ReadTimelessLogFile($)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
    my $filename = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
    my $retVal;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
  	open(LOGFILE,"$filename");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
    while (defined (my $line = <LOGFILE>))
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
      {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
      if ($line =~ m/.+started .+/)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
        $line =~ s/(.+started ).+/$1/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
      elsif ($line =~ m/.+finished .+/)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
        {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
        $line =~ s/(.+finished ).+/$1/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
      $retVal .= $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
    #print "\nParsed:\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
    #print $retVal;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
    return $retVal;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
sub TestDieConditions($$)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
    my $testFilename = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
    my $testScore = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
    my $testConfig;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
    my $logFilename = "CConfig_scrap.log";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
    # Try a direct Die() call
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
    $testConfig = New CConfig($testFilename);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
    eval
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
      {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
      $testConfig->Die("Die message.");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
      };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
    if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
      $testScore->Test(1, "Died on Die() command");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
    } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
      $testScore->Test(0, "Failed to die on Die() command");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
    # Try setting SetErrorDie() then calling Error()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
    $testConfig = New CConfig($testFilename);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
    $testConfig->SetLog($logFilename);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
    # Try PhaseEnd() before any PhaseStart() has been called
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
    $testConfig = New CConfig($testFilename);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
    $testConfig->SetLog($logFilename);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
    eval
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
      {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
      # No PhaseStart() has been made so a PhaseEnd() should fail
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
      $testConfig->PhaseEnd();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
      };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
    if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
      $testScore->Test(1, "Died on PhaseEnd() command when there was no prior PhaseStart()");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
    } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
      $testScore->Test(0, "Failed to die on PhaseEnd() command");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
    # Try setting provoking PhaseEnd() when phase has errors
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
    $testConfig = New CConfig($testFilename);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
    $testConfig->SetLog($logFilename);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
    $testConfig->PhaseStart("Error_Phase_1");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
    $testConfig->Error("Error message.");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
    eval
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
      {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
      # Here is the killer line that should cause it to fail.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
      # Phase 1 has an error but the phase has not been collected
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
      # before starting False_Phase_2
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
      $testConfig->PhaseStart("False_phase_2");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
      };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
    if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
      $testScore->Test(1, "Died on PhaseStart() command when previous phase had Error() calls");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
    } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
      $testScore->Test(0, "Failed to die on Error() command");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
  	unlink $logFilename;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
1;