Example #1
0
void CPolicyTest::PerformAction(TRequestStatus& aStatus)
	{
	if (aStatus < 0)
		{
		iState = EFinished;
		}

	switch (iState)
		{
		case EInit:
			{
			TDriveUnit sysDrive (RFs::GetSystemDrive());
			TDriveName sysDriveName (sysDrive.Name());
				
			TBuf<128> scriptFile (sysDriveName);
			scriptFile.Append(KPassScriptPath);
			WriteScriptFileL(scriptFile, *iPassAction);	
			
			scriptFile.Copy(sysDriveName);
			scriptFile.Append(KFailScriptPath);
			WriteScriptFileL(scriptFile, *iFailAction);
			}
			// fall through
		
		case ESetupTest:
			GetNextTest();
			if (iTestState == ETestFinished)
				{
				iState = EFinished;
				TRequestStatus* status = &aStatus;
				User::RequestComplete(status, KErrNone);
				}
			else
				{
				SetupTestL(aStatus);
				iState = ERunTest;
				}
			break;

		case ERunTest:
			CheckProcessTermintationL();
			RunTestL(aStatus);
			iState = EProcessResults;
			break;
			
		case EProcessResults:
			CheckProcessTermintationL();
			ProcessResultsL(aStatus);
			iState = ESetupTest;
			break;

		case EFinished:
			iActionState = EPostrequisite;				
			TRequestStatus* status = &aStatus;
			User::RequestComplete(status, aStatus.Int());
			break;
		}
	}
Example #2
0
/**
 * Interface to CTestList-derived classes for getting all information about the next test to be run.
 *
 * @return
 * Returns a pointer to a CTestInfo object containing all available information about the next test.
 */
CTestInfo*
CWineTest::GetNextTestInfo()
{
    while(!m_CurrentFile.empty() || GetNextFile())
    {
        try
        {
            while(GetNextTest())
            {
                /* If the user specified a test through the command line, check this here */
                if(!Configuration.GetTest().empty() && Configuration.GetTest() != m_CurrentTest)
                    continue;

                {
                    auto_ptr<CTestInfo> TestInfo(new CTestInfo());
                    size_t UnderscorePosition;

                    /* Build the command line */
                    TestInfo->CommandLine = m_TestPath;
                    TestInfo->CommandLine += m_CurrentFile;
                    TestInfo->CommandLine += ' ';
                    TestInfo->CommandLine += AsciiToUnicode(m_CurrentTest);

                    /* Store the Module name */
                    UnderscorePosition = m_CurrentFile.find_last_of('_');

                    if(UnderscorePosition == m_CurrentFile.npos)
                    {
                        stringstream ss;

                        ss << "Invalid test file name: " << UnicodeToAscii(m_CurrentFile) << endl;
                        SSEXCEPTION;
                    }

                    TestInfo->Module = UnicodeToAscii(m_CurrentFile.substr(0, UnderscorePosition));

                    /* Store the test */
                    TestInfo->Test = m_CurrentTest;

                    return TestInfo.release();
                }
            }
        }
        catch(CTestException& e)
        {
            stringstream ss;

            ss << "An exception occurred trying to list tests for: " << UnicodeToAscii(m_CurrentFile) << endl;
            StringOut(ss.str());
            StringOut(e.GetMessage());
            StringOut("\n");
            m_CurrentFile.clear();
            delete[] m_ListBuffer;
        }
    }

    return NULL;
}