deprecated/eruntest/eruntest.cpp
author Zheng Shen <zheng.shen@nokia.com>
Tue, 20 Jul 2010 15:02:28 +0800
changeset 617 3a747a240983
parent 600 6d08f4a05d93
permissions -rw-r--r--
ROM Tools 12.2.0.4 Postlinker 2.2.5 Revert package_definition.xml to changeset 360bd6b35136
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
600
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     1
// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     2
// All rights reserved.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     3
// This component and the accompanying materials are made available
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     5
// which accompanies this distribution, and is available
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     7
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     8
// Initial Contributors:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    10
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    11
// Contributors:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    12
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    13
// Description:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    14
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    15
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    16
#include <windows.h>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    17
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    18
#ifdef __MSVCDOTNET__
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    19
 #include <iostream>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    20
 #include <fstream>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    21
 using namespace std;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    22
#else //!__MSVCDOTNET__
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    23
 #include <iostream.h>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    24
 #include <fstream.h>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    25
#endif //__MSVCDOTNET__
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    26
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    27
#include <stdio.h>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    28
#include <errno.h>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    29
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    30
#if defined(__VC32__) && !defined(__MSVCDOTNET__)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    31
#pragma warning( disable : 4710 )	// 'fn': function not inlined
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    32
#endif // old MSVC
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    33
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    34
const unsigned int KMaxLineLen=256;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    35
const unsigned int KTimeout=600000; // 10 minutes
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    36
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    37
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    38
void NumFileLines(ifstream& inStream, unsigned int &aNumLines)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    39
	{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    40
	// finds out how many lines are in the file specified
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    41
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    42
	aNumLines=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    43
	inStream.clear();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    44
	inStream.seekg(0);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    45
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    46
	char str[KMaxLineLen];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    47
	while (!inStream.eof())
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    48
		{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    49
		inStream.getline(str, KMaxLineLen);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    50
		aNumLines++;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    51
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    52
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    53
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    54
void GetTestData(ifstream& inStream, char (*aDataArray)[KMaxLineLen], unsigned int &aNumTests)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    55
	{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    56
	// fill the test data structure from the file stream
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    57
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    58
	aNumTests=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    59
	inStream.clear();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    60
	inStream.seekg(0);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    61
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    62
	char str[KMaxLineLen]="";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    63
	while (!inStream.eof())
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    64
		{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    65
		bool charsPresent=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    66
		inStream.getline(str, KMaxLineLen);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    67
		if (strlen(str))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    68
			{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    69
			unsigned int len=strlen(str);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    70
			for (unsigned int i=0; i<len; i++)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    71
				{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    72
				if (!isspace(str[i]))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    73
					{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    74
					charsPresent=1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    75
					break;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    76
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    77
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    78
			if (charsPresent)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    79
				{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    80
				strcpy(aDataArray[aNumTests], str);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    81
				aNumTests++;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    82
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    83
			}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    84
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    85
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    86
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    87
int GetTestOutFileName(char* aOutFile)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    88
	{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    89
	// Gets the temporary file in which RTest puts its output
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    90
		
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    91
	const char KTestOutFileName[16]="epocwind.out";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    92
	char tmpDir[KMaxLineLen]="";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    93
	int r=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    94
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    95
	aOutFile[0]='\0';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    96
	int len=GetTempPath(KMaxLineLen, tmpDir);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    97
	if (len==0||len>KMaxLineLen)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    98
		r=1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    99
	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   100
	if (!r)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   101
		if (KMaxLineLen > (strlen(KTestOutFileName)+strlen(tmpDir)))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   102
			{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   103
			strcpy(aOutFile, tmpDir);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   104
			strcat(aOutFile, KTestOutFileName);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   105
			}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   106
		else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   107
			r=1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   108
	return(r);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   109
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   110
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   111
void RemoveLeadingSpaces(char* aStr)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   112
	{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   113
	// removes leading whitespace from a string
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   114
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   115
	int spaces=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   116
	while (isspace(aStr[spaces]))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   117
		spaces++;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   118
	int newLen=strlen(aStr)-spaces;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   119
	for (int j=0;j<=newLen;j++)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   120
		aStr[j]=aStr[j+spaces];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   121
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   122
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   123
int TestSucceeded(char* aLastLineBut1)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   124
	{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   125
	// checks whether an EPOC RTest has succeeded by comparing the
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   126
	// last line but 1 in the EPOCWIND.OUT file with a template success
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   127
	// string
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   128
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   129
	int r=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   130
	const char KSuccessResult[20]="RTEST: SUCCESS :";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   131
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   132
	char testStr[KMaxLineLen];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   133
	strcpy(testStr,aLastLineBut1);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   134
	RemoveLeadingSpaces(testStr);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   135
	testStr[strlen(KSuccessResult)]='\0';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   136
	if (strcmp(testStr, KSuccessResult)==0)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   137
		r=1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   138
	return(r);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   139
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   140
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   141
int GetPenultimateLines(char* aFile, char* aLastLineBut1, char* aLastLineBut2)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   142
	{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   143
	// Gets the two penultimate lines in a file.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   144
	// Returns 0 if successful, 1 otherwise.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   145
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   146
	int r=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   147
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   148
	aLastLineBut1[0]='\0';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   149
	aLastLineBut2[0]='\0';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   150
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   151
	ifstream fileStream(aFile);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   152
	if (!fileStream)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   153
		r=1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   154
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   155
	if (!r)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   156
		{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   157
		char lastLine[KMaxLineLen]="";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   158
		while (!fileStream.eof())
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   159
			{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   160
			strcpy(aLastLineBut2, aLastLineBut1);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   161
			strcpy(aLastLineBut1, lastLine);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   162
			fileStream.getline(lastLine, KMaxLineLen);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   163
			}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   164
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   165
	return(r);	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   166
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   167
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   168
int main(int argc, char *argv[])
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   169
	{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   170
	FILE *stream = NULL;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   171
	if (argc != 2)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   172
		{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   173
		cerr << "Syntax: eruntest <batch_file>" << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   174
		return(1);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   175
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   176
	// Check if input file exists
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   177
	if( (stream  = fopen(argv[1], "r" )) == NULL)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   178
		{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   179
		cerr << "ERROR: Cannot open input file " << argv[1] << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   180
		return(1);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   181
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   182
	else 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   183
		fclose(stream); 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   184
//	stream the input file
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   185
	ifstream inFile(argv[1]);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   186
	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   187
	// get the number of lines in the input file
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   188
	unsigned int numLines=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   189
	NumFileLines(inFile, numLines);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   190
	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   191
	// allocate space for the tests names
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   192
	char (*pTests)[KMaxLineLen];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   193
	pTests = new char[numLines][KMaxLineLen];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   194
	if (!pTests)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   195
		{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   196
		cerr << "ERROR: Out of memory" << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   197
		return(1);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   198
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   199
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   200
	// populate the data structure for the tests
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   201
	unsigned int numTests=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   202
	GetTestData(inFile, pTests, numTests);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   203
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   204
	// Get the test output file name
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   205
	char testOutFile[KMaxLineLen];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   206
	if (GetTestOutFileName(testOutFile)!=0)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   207
		{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   208
		cerr << "Error getting temporary path" << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   209
		return(1);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   210
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   211
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   212
	// Get the current directory
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   213
	char currentDir[KMaxLineLen]="";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   214
	GetCurrentDirectory(KMaxLineLen, currentDir);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   215
	strcat(currentDir, "\\");
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   216
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   217
	// Retrieve the STARTUPINFO structure for the current process
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   218
	STARTUPINFO startUpInfo;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   219
	PROCESS_INFORMATION procInfo;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   220
	GetStartupInfo(&startUpInfo);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   221
	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   222
	unsigned failCount=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   223
	unsigned timeoutCount=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   224
	unsigned cantStartCount=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   225
	unsigned unknownCount=0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   226
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   227
	// run each test in turn
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   228
	for (unsigned int i=0; i<numTests; i++)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   229
		{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   230
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   231
		// remove epocwind.out
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   232
		remove(testOutFile);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   233
		if (errno==EACCES)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   234
			{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   235
			cerr << "Cannot remove " << testOutFile << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   236
			return(1);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   237
			}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   238
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   239
		// Create the child process
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   240
		if (!CreateProcess(0, pTests[i], 0, 0, FALSE, 0,0, 0, &startUpInfo, &procInfo))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   241
			{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   242
			// int error=GetLastError();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   243
			cout << "CAN'T START: " << currentDir << pTests[i] << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   244
			cantStartCount++;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   245
			continue;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   246
			}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   247
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   248
		// Wait for the child process to complete
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   249
		int ret=WaitForSingleObject(procInfo.hProcess, KTimeout);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   250
		ifstream testOutFileStream(testOutFile);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   251
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   252
		char lastLineBut1[KMaxLineLen]="";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   253
		char lastLineBut2[KMaxLineLen]="";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   254
		switch (ret)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   255
			{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   256
			case WAIT_OBJECT_0:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   257
				// find out if the test terminated successfully
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   258
				if (GetPenultimateLines(testOutFile, lastLineBut1, lastLineBut2)!=0)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   259
					{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   260
					cout << "UNKNOWN: " << currentDir << pTests[i] << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   261
					cout << "  <no test output file>" << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   262
					unknownCount++;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   263
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   264
				else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   265
					{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   266
					// make the comparison
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   267
					if (TestSucceeded(lastLineBut1))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   268
						cout << "PASSED: " << currentDir << pTests[i] << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   269
					else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   270
						{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   271
						cout << "FAILED(RTest): " << currentDir << pTests[i] << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   272
						cout << "  " << lastLineBut2 << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   273
						cout << "  " << lastLineBut1 << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   274
						cout << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   275
						failCount++;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   276
						}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   277
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   278
				break;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   279
			case WAIT_FAILED:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   280
				cout << "FAILED: " << currentDir << pTests[i] << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   281
				if (GetPenultimateLines(testOutFile, lastLineBut1, lastLineBut2)!=0)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   282
					{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   283
					cout << "  <no test output file>" << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   284
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   285
				else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   286
					{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   287
					cout << "  " << lastLineBut2 << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   288
					cout << "  " << lastLineBut1 << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   289
					cout << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   290
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   291
				failCount++;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   292
				break;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   293
			case WAIT_TIMEOUT:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   294
				cout << "TIMED OUT: " << currentDir << pTests[i] << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   295
				if (GetPenultimateLines(testOutFile, lastLineBut1, lastLineBut2)!=0)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   296
					{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   297
					cout << "  <no test output file>" << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   298
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   299
				else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   300
					{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   301
					cout << "  " << lastLineBut2 << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   302
					cout << "  " << lastLineBut1 << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   303
					cout << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   304
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   305
				timeoutCount++;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   306
				if (!TerminateProcess(procInfo.hProcess, 1))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   307
					{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   308
					cout << "FROZEN: " << currentDir << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   309
					cout << "  Cannot terminate - kill via Task Manager"  << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   310
					cout << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   311
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   312
				break;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   313
			}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   314
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   315
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   316
	delete [] pTests;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   317
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   318
	cout << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   319
	cout << "TotalErrors   " << dec << (failCount+timeoutCount+unknownCount+cantStartCount) << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   320
	cout << "  Failures    " << dec << failCount << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   321
	cout << "  Timeouts    " << dec << timeoutCount << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   322
	cout << "  Unknown     " << dec << unknownCount << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   323
	cout << "  Can't start " << dec << cantStartCount << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   324
	cout << endl;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   325
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   326
	return(0);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   327
	}