core/builtins/ciftest.cpp
author Tom Sutcliffe <thomas.sutcliffe@accenture.com>
Wed, 15 Sep 2010 00:44:34 +0100
changeset 70 b06038904ef8
child 75 3c3961c1ae26
permissions -rw-r--r--
Added ==smoke-test support and ciftest command. Commands can now define a "==smoke-test" section in their CIF files, which defines a snippet of fshell script that will be run as part of "fshell smoketest" or by invoking ciftest directly. See the ciftest documentation for more details. Added ==smoke-test sections to a few commands, the ones that were easy to test!
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
70
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     1
// ciftest.cpp
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     2
//
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     3
// Copyright (c) 2010 Accenture. All rights reserved.
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     4
// This component and the accompanying materials are made available
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     5
// under the terms of the "Eclipse Public License v1.0"
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     6
// which accompanies this distribution, and is available
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     7
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     8
// 
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     9
// Initial Contributors:
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    10
// Accenture - Initial contribution
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    11
//
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    12
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    13
#include "ciftest.h"
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    14
#include "fshell.h"
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    15
#include "command_factory.h"
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    16
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    17
CCommandBase* CCmdCifTest::NewLC()
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    18
	{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    19
	CCmdCifTest* self = new(ELeave) CCmdCifTest();
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    20
	CleanupStack::PushL(self);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    21
	self->BaseConstructL();
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    22
	return self;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    23
	}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    24
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    25
CCmdCifTest::~CCmdCifTest()
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    26
	{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    27
	delete iCmd;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    28
	delete iParser;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    29
	delete iEnvForScript;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    30
	delete iCurrentCif;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    31
	iCifFiles.ResetAndDestroy();
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    32
	}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    33
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    34
CCmdCifTest::CCmdCifTest()
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    35
	: CCommandBase(EManualComplete | EReportAllErrors)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    36
	{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    37
	}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    38
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    39
const TDesC& CCmdCifTest::Name() const
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    40
	{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    41
	_LIT(KName, "ciftest");	
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    42
	return KName;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    43
	}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    44
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    45
void CCmdCifTest::ArgumentsL(RCommandArgumentList& aArguments)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    46
	{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    47
	aArguments.AppendStringL(iCmd, _L("command"));
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    48
	}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    49
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    50
void CCmdCifTest::OptionsL(RCommandOptionList& aOptions)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    51
	{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    52
	aOptions.AppendBoolL(iVerbose, _L("verbose"));
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    53
	aOptions.AppendBoolL(iKeepGoing, _L("keep-going"));
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    54
	}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    55
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    56
void CCmdCifTest::DoRunL()
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    57
	{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    58
	if (iCmd)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    59
		{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    60
		CCommandInfoFile* cif = CCommandInfoFile::NewL(FsL(), Env(), *iCmd);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    61
		TestCifL(cif); // Takes ownership
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    62
		}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    63
	else
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    64
		{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    65
		_LIT(KCifDir, "y:\\resource\\cif\\fshell\\");
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    66
		TFindFile find(FsL());
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    67
		CDir* dir = NULL;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    68
		TInt found = find.FindWildByDir(_L("*.cif"), KCifDir, dir);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    69
		while (found == KErrNone)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    70
			{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    71
			for (TInt i = 0; i < dir->Count(); i++)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    72
				{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    73
				iFileName.Copy(TParsePtrC(find.File()).DriveAndPath()); // The docs for TFindFile state you shouldn't need the extra TParsePtrC::DriveAndPath(). Sigh.
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    74
				iFileName.Append((*dir)[i].iName);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    75
				iCifFiles.AppendL(iFileName.AllocLC());
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    76
				CleanupStack::Pop();
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    77
				}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    78
			delete dir;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    79
			dir = NULL;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    80
			found = find.FindWild(dir);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    81
			}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    82
		NextCif();
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    83
		}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    84
	}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    85
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    86
void CCmdCifTest::NextCif()
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    87
	{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    88
	if (iNextCif == iCifFiles.Count())
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    89
		{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    90
		if (iVerbose)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    91
			{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    92
			Printf(_L("%d tests run, %d passes %d failures. %d commands have no tests defined.\r\n"), iPasses + iFailures, iPasses, iFailures, iCifFiles.Count() - iPasses - iFailures);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    93
			}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    94
		Complete(KErrNone);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    95
		}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    96
	else
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    97
		{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    98
		CCommandInfoFile* cif = NULL;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    99
		TRAPD(err, cif = CCommandInfoFile::NewL(FsL(), *iCifFiles[iNextCif]));
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   100
		if (!err)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   101
			{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   102
			TRAP(err, TestCifL(cif));
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   103
			if (err) PrintError(err, _L("Error setting up test for CIF %S"), iCifFiles[iNextCif]);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   104
			}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   105
		iNextCif++;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   106
		
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   107
		if (err)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   108
			{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   109
			iFailures++;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   110
			TestCompleted(err);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   111
			}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   112
		}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   113
	}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   114
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   115
void CCmdCifTest::TestCifL(CCommandInfoFile* aCif)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   116
	{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   117
	iCurrentCif = aCif;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   118
	if (iVerbose) Printf(_L("Checking %S\r\n"), &aCif->CifFileName());
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   119
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   120
	const TDesC& scriptData = aCif->SmokeTest();
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   121
	if (scriptData.Length() == 0)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   122
		{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   123
		if (iVerbose) Printf(_L("Cif has no smoketest section\r\n"));
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   124
		TestCompleted(KErrNone);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   125
		return;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   126
		}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   127
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   128
	iEnvForScript = CEnvironment::NewL(Env());
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   129
	iEnvForScript->SetL(_L("Error"), _L("fshell -e 'echo \"Test failed, env is:\" && env && error'"));
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   130
	iEnvForScript->SetL(_L("Quiet"), _L(">/dev/null"));
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   131
	iEnvForScript->SetL(_L("Silent"), _L("2>&1 >/dev/null"));
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   132
	iEnvForScript->Remove(_L("Verbose")); // In case it's ended up in our parent env
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   133
	if (iVerbose) iEnvForScript->SetL(_L("Verbose"), 1);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   134
	iFileName.Copy(aCif->CifFileName());
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   135
	iFileName.Append(_L(":smoke-test"));
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   136
	TParsePtrC parse(iFileName);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   137
	iEnvForScript->SetL(KScriptName, parse.NameAndExt());
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   138
	iEnvForScript->SetL(KScriptPath, parse.DriveAndPath());
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   139
	iEnvForScript->SetL(_L("0"), iFileName);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   140
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   141
	iParser = CParser::NewL(CParser::EExportLineNumbers, scriptData, IoSession(), Stdin(), Stdout(), Stderr(), *iEnvForScript, gShell->CommandFactory(), this, aCif->GetSmokeTestStartingLineNumber());
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   142
	iParser->Start();
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   143
	}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   144
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   145
void CCmdCifTest::HandleParserComplete(CParser& /*aParser*/, const TError& aError)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   146
	{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   147
	TInt err = aError.Error();
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   148
	if (err)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   149
		{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   150
		iFailures++;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   151
		PrintError(err, _L("%S failed at line %d"), &aError.ScriptFileName(), aError.ScriptLineNumber());
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   152
		}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   153
	else
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   154
		{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   155
		if (iVerbose)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   156
			{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   157
			Printf(_L("Smoketest for %S completed ok.\r\n"), &iCurrentCif->Name());
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   158
			}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   159
		iPasses++;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   160
		}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   161
	TestCompleted(err);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   162
	}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   163
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   164
void CCmdCifTest::TestCompleted(TInt aError)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   165
	{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   166
	// Delete interim data
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   167
	delete iEnvForScript;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   168
	iEnvForScript = NULL;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   169
	delete iParser;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   170
	iParser = NULL;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   171
	delete iCurrentCif;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   172
	iCurrentCif = NULL;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   173
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   174
	if (aError == KErrNone || iKeepGoing)
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   175
		{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   176
		// Async call NextCif()
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   177
		TRequestStatus* stat = &iStatus;
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   178
		User::RequestComplete(stat, KErrNone);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   179
		SetActive();
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   180
		}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   181
	else
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   182
		{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   183
		Complete(aError);
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   184
		}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   185
	}
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   186
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   187
void CCmdCifTest::RunL()
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   188
	{
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   189
	NextCif();
b06038904ef8 Added ==smoke-test support and ciftest command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   190
	}