Esempio n. 1
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;
}
Esempio n. 2
0
/**
 * Executes the --list command of a module test file to get information about the available tests.
 *
 * @return
 * The number of bytes we read into the m_ListBuffer member variable by capturing the output of the --list command.
 */
DWORD
CWineTest::DoListCommand()
{
    DWORD BytesAvailable;
    DWORD Temp;
    wstring CommandLine;
    CPipe Pipe;

    /* Build the command line */
    CommandLine = m_TestPath;
    CommandLine += m_CurrentFile;
    CommandLine += L" --list";

    {
        /* Start the process for getting all available tests */
        CPipedProcess Process(CommandLine, Pipe);

        /* Wait till this process ended */
        if(WaitForSingleObject(Process.GetProcessHandle(), ListTimeout) == WAIT_FAILED)
            TESTEXCEPTION("WaitForSingleObject failed for the test list\n");
    }

    /* Read the output data into a buffer */
    if(!Pipe.Peek(NULL, 0, NULL, &BytesAvailable))
        TESTEXCEPTION("CPipe::Peek failed for the test list\n");

    /* Check if we got any */
    if(!BytesAvailable)
    {
        stringstream ss;

        ss << "The --list command did not return any data for " << UnicodeToAscii(m_CurrentFile) << endl;
        TESTEXCEPTION(ss.str());
    }

    /* Read the data */
    m_ListBuffer = new char[BytesAvailable];

    if(!Pipe.Read(m_ListBuffer, BytesAvailable, &Temp))
        TESTEXCEPTION("CPipe::Read failed\n");

    return BytesAvailable;
}
Esempio n. 3
0
/**
 * Executes the --list command of a module test file to get information about the available tests.
 *
 * @return
 * The number of bytes we read into the m_ListBuffer member variable by capturing the output of the --list command.
 */
DWORD
CWineTest::DoListCommand()
{
    DWORD BytesAvailable;
    DWORD Temp;
    wstring CommandLine;

    /* Build the command line */
    CommandLine = m_TestPath;
    CommandLine += m_CurrentFile;
    CommandLine += L" --list";

    {
        /* Start the process for getting all available tests */
        CProcess Process(CommandLine, &m_StartupInfo);

        /* Wait till this process ended */
        if(WaitForSingleObject(Process.GetProcessHandle(), ListTimeout) == WAIT_FAILED)
            FATAL("WaitForSingleObject failed for the test list\n");
    }

    /* Read the output data into a buffer */
    if(!PeekNamedPipe(m_hReadPipe, NULL, 0, NULL, &BytesAvailable, NULL))
        FATAL("PeekNamedPipe failed for the test list\n");

    /* Check if we got any */
    if(!BytesAvailable)
    {
        stringstream ss;

        ss << "The --list command did not return any data for " << UnicodeToAscii(m_CurrentFile) << endl;
        SSEXCEPTION;
    }

    /* Read the data */
    m_ListBuffer = new char[BytesAvailable];

    if(!ReadFile(m_hReadPipe, m_ListBuffer, BytesAvailable, &Temp, NULL))
        FATAL("ReadPipe failed\n");

    return BytesAvailable;
}
Esempio n. 4
0
//*****************************************************************************
bool CUtil::IsPathValid(
//Is a path valid.
//
//Params:
	const WCHAR* pszPath)      //(in)   Path should not end in separator.
//
//Returns:
//True if it is, false if it isn't.
{
	bool bIsValid;
#ifdef WIN32
	struct _stat buf;
	bIsValid = !_wstat(pszPath, &buf) ? (buf.st_mode & _S_IFDIR) != 0 : false;
#else
	WSTRING wstrPath = pszPath;
	char *szPath = new char[wstrPath.length()+1];
	struct stat buf;
	UnicodeToAscii(wstrPath, szPath);
	bIsValid = !stat(szPath, &buf) ? S_ISDIR(buf.st_mode) : false;
	delete[] szPath;
#endif
	return bIsValid;
}
Esempio n. 5
0
bool SMUSync::ParseData(DMXml& xml, SyncPlatformData& data)
{
	bool flag = true;
	do
	{
		{
			char* tmp =  xml.FindElement("StreamNo")->GetValueText();
			if(tmp)
			{
				data.SerialNumber  = tmp;
				free(tmp);
			}
			if(!xml.CheckNodeValid())
			{
				WriteToLog("Xml Error");
				flag = false;
				break;
			}
		}



		{
			char* tmp = xml.GetParent()->FindElement("OPFlag")->GetValueText();
			if(tmp)
			{
				data.CustState  = tmp;
				free(tmp);
			}
			if(!xml.CheckNodeValid())
			{
				WriteToLog("Xml Error");
				flag = false;
				break;
			}
		}
		{
			char* tmp = xml.GetParent()->FindElement("CustID")->GetValueText();
			if(tmp)
			{
				data.CustID  = tmp;
				free(tmp);
			}
			if(!xml.CheckNodeValid())
			{
				WriteToLog("Xml Error");
				flag = false;
				break;
			}
		}

		{
			char* tmp = xml.GetParent()->FindElement("CustAccount")->GetValueText();
			if(tmp)
			{
				data.CustAccunt   = tmp;
				free(tmp);
			}
			if(!xml.CheckNodeValid())
			{
				WriteToLog("Xml Error");
				flag = false;
				break;;
			}
		}
		
		{
			char* tmp = xml.GetParent()->FindElement("CustName")->GetValueText();
			if(tmp)
			{
				std::wstring wstr;
				wchar_t* unciode = Utf8ToUnicode(tmp);
				char* ascii = UnicodeToAscii((char*)unciode);
				data.CustName = ascii;
				free(ascii);
				free(unciode);
				free(tmp);
			}
			if(!xml.CheckNodeValid())
			{
				WriteToLog("Xml Error");
				flag = false;
				break;
			}
		}

		{
			char* tmp = xml.GetParent()->FindElement("InstalledAddress")->GetValueText();
			if(tmp)
			{
				
				wchar_t* unciode = Utf8ToUnicode(tmp);
				char* ascii = UnicodeToAscii((char*)unciode);
			
				data.LinkAddr = ascii;
				free(ascii);
				free(unciode);
				free(tmp);
			}
			if(!xml.CheckNodeValid())
			{
				WriteToLog("Xml Error");
				flag = false;
				break;
			}
		}
	}while(0);

	xml.GetParent();
	return flag;
}
Esempio n. 6
0
/**
 * Converts a Unicode string to an ASCII one.
 *
 * @param UnicodeString
 * Pointer to a std::wstring containing the Unicode string
 *
 * @return
 * The ASCII string as std::string
 */
string
UnicodeToAscii(const wstring& UnicodeString)
{
    return UnicodeToAscii(UnicodeString.c_str());
}
Esempio n. 7
0
EFI_STATUS
GenerateReport (
  IN EFI_DEVICE_PATH_PROTOCOL     *LogDevicePath,
  IN CHAR16                       *LogFilePath,
  IN EFI_DEVICE_PATH_PROTOCOL     *ReportDevicePath,
  IN CHAR16                       *ReportFileName
  )
/*++

Routine Description:

  Generate test report.

Arguments:

  LogDevicePath     - Device path of the key files.
  LogFilePath       - Path of the key files.
  ReportDevicePath  - Device path of the report file.
  ReportFileName    - Name of the report file.

  EFI_SUCCESS       - Generate the test report successfully.

--*/
{
  EFI_STATUS        Status;
  UINT32            PassNumber;
  UINT32            WarnNumber;
  UINT32            FailNumber;
  CHAR16            *FileName;
  CHAR16            *Buffer;
  UINTN             AsciiBufferSize;
  CHAR8             *AsciiBuffer;
  UINTN             ConfigBufferSize;
  CHAR8             *ConfigBuffer;
  EFI_FILE_HANDLE   Handle;

  //
  // Check parameters
  //
  if ((LogDevicePath    == NULL) || (LogFilePath    == NULL) ||
      (ReportDevicePath == NULL) || (ReportFileName == NULL)) {
    return EFI_INVALID_PARAMETER;
  }

  //
  // Initialize
  //
  PassNumber = 0;
  WarnNumber = 0;
  FailNumber = 0;

  //
  // Get the configuration data. Start this operation at first since the next
  //  operations will take more time. We could stop the entire process if we
  //  meet any problem in configuration collection.
  //
  Status = SctReportConfig (
             &ConfigBufferSize,
             &ConfigBuffer
             );
  if (EFI_ERROR (Status)) {
    EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"SctReportConfig: %r", Status));
    return Status;
  }

  //
  // Load the GUID database
  //
  FileName = PoolPrint (L"%s\\%s", gFT->FilePath, EFI_SCT_FILE_GUID_DATABASE);
  if (FileName == NULL) {
    EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"PoolPrint: Out of resources"));
    BS->FreePool (ConfigBuffer);
    return EFI_OUT_OF_RESOURCES;
  }

  Status = LoadGuidDatabase (gFT->DevicePath, FileName);
  if (EFI_ERROR (Status)) {
    EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Load GUID database - %r", Status));
    BS->FreePool (ConfigBuffer);
    BS->FreePool (FileName);
    return Status;
  }

  BS->FreePool (FileName);

  //
  // Load the assertion information from the log directory
  //
  Status = GetProtocolAssertion (
             LogDevicePath,
             LogFilePath,
             &PassNumber,
             &WarnNumber,
             &FailNumber
             );
  if (EFI_ERROR (Status)) {
    EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Get protocol assertion - %r", Status));
    BS->FreePool (ConfigBuffer);
    UnloadGuidDatabase ();
    UnloadReportInfor ();
    return Status;
  }

  //
  // Get the report information to a buffer
  //
  Status = GetReportInfor (&Buffer);
  if (EFI_ERROR (Status)) {
    EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Get report infor - %r", Status));
    BS->FreePool (ConfigBuffer);
    UnloadGuidDatabase ();
    UnloadReportInfor ();
    return Status;
  }

  UnloadGuidDatabase ();
  UnloadReportInfor ();

  //
  // Convert the buffer to ASCII buffer
  //
  AsciiBufferSize = StrLen(Buffer) + 1;

  Status = BS->AllocatePool (
                 EfiBootServicesData,
                 AsciiBufferSize,
                 &AsciiBuffer
                 );
  if (EFI_ERROR (Status)) {
    EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Allocate pool - %r", Status));
    BS->FreePool (ConfigBuffer);
    BS->FreePool (Buffer);
    return Status;
  }

  Status = UnicodeToAscii (Buffer, AsciiBuffer);
  if (EFI_ERROR (Status)) {
    EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Convert Unicode to ASCII - %r", Status));
    BS->FreePool (ConfigBuffer);
    BS->FreePool (Buffer);
    BS->FreePool (AsciiBuffer);
    return Status;
  }

  BS->FreePool (Buffer);

  //
  // Create the report file
  //
  Status = SctCreateFileFromDevicePath (
             ReportDevicePath,
             ReportFileName,
             &Handle
             );
  if (EFI_ERROR (Status)) {
    EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Create report file - %r", Status));
    BS->FreePool (ConfigBuffer);
    BS->FreePool (AsciiBuffer);
    return Status;
  }

  //
  // Write the ASCII buffer to the report file (remove the null-terminator)
  //
  AsciiBufferSize --;

  Status = Handle->Write (
                     Handle,
                     &AsciiBufferSize,
                     AsciiBuffer
                     );
  if (EFI_ERROR (Status)) {
    EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Write report file - %r", Status));
    BS->FreePool (ConfigBuffer);
    BS->FreePool (AsciiBuffer);
    Handle->Close (Handle);
    return Status;
  }

  //
  // Write the config buffer to the report file
  //
  Status = Handle->Write (
                     Handle,
                     &ConfigBufferSize,
                     ConfigBuffer
                     );
  if (EFI_ERROR (Status)) {
    EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Write report file - %r", Status));
    BS->FreePool (ConfigBuffer);
    BS->FreePool (AsciiBuffer);
    Handle->Close (Handle);
    return Status;
  }

  BS->FreePool (ConfigBuffer);
  BS->FreePool (AsciiBuffer);

  //
  // Close the report file
  //
  Handle->Close (Handle);

  //
  // Done
  //
  return EFI_SUCCESS;
}