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
/**
 * Interface to other classes for running all desired Wine tests.
 */
void
CWineTest::Run()
{
    auto_ptr<CTestList> TestList;
    auto_ptr<CWebService> WebService;
    CTestInfo* TestInfo;
    SECURITY_ATTRIBUTES SecurityAttributes;

    /* Create a pipe for getting the output of the tests */
    SecurityAttributes.nLength = sizeof(SecurityAttributes);
    SecurityAttributes.bInheritHandle = TRUE;
    SecurityAttributes.lpSecurityDescriptor = NULL;

    if(!CreatePipe(&m_hReadPipe, &m_hWritePipe, &SecurityAttributes, 0))
        FATAL("CreatePipe failed\n");

    m_StartupInfo.cb = sizeof(m_StartupInfo);
    m_StartupInfo.dwFlags = STARTF_USESTDHANDLES;
    m_StartupInfo.hStdInput  = GetStdHandle(STD_INPUT_HANDLE);
    m_StartupInfo.hStdOutput = m_hWritePipe;
    m_StartupInfo.hStdError  = m_hWritePipe;

    /* The virtual test list is of course faster, so it should be preferred over
       the journaled one.
       Enable the journaled one only in case ...
          - we're running under ReactOS (as the journal is only useful in conjunction with sysreg2)
          - we shall keep information for Crash Recovery
          - and the user didn't specify a module (then doing Crash Recovery doesn't really make sense) */
    if(Configuration.IsReactOS() && Configuration.DoCrashRecovery() && Configuration.GetModule().empty())
    {
        /* Use a test list with a permanent journal */
        TestList.reset(new CJournaledTestList(this));
    }
    else
    {
        /* Use the fast virtual test list with no additional overhead */
        TestList.reset(new CVirtualTestList(this));
    }

    /* Initialize the Web Service interface if required */
    if(Configuration.DoSubmit())
        WebService.reset(new CWebService());

    /* Get information for each test to run */
    while((TestInfo = TestList->GetNextTestInfo()) != 0)
    {
        auto_ptr<CTestInfo> TestInfoPtr(TestInfo);

        RunTest(TestInfo);

        if(Configuration.DoSubmit() && !TestInfo->Log.empty())
            WebService->Submit("wine", TestInfo);

        StringOut("\n\n");
    }
}
Esempio n. 3
0
/**
 * Interface to other classes for running all desired Wine tests.
 */
void
CWineTest::Run()
{
    auto_ptr<CTestList> TestList;
    auto_ptr<CWebService> WebService;
    CTestInfo* TestInfo;
    DWORD ErrorMode;

    /* The virtual test list is of course faster, so it should be preferred over
       the journaled one.
       Enable the journaled one only in case ...
          - we're running under ReactOS (as the journal is only useful in conjunction with sysreg2)
          - we shall keep information for Crash Recovery
          - and the user didn't specify a module (then doing Crash Recovery doesn't really make sense) */
    if(Configuration.IsReactOS() && Configuration.DoCrashRecovery() && Configuration.GetModule().empty())
    {
        /* Use a test list with a permanent journal */
        TestList.reset(new CJournaledTestList(this));
    }
    else
    {
        /* Use the fast virtual test list with no additional overhead */
        TestList.reset(new CVirtualTestList(this));
    }

    /* Initialize the Web Service interface if required */
    if(Configuration.DoSubmit())
        WebService.reset(new CWebService());

    /* Disable error dialogs if we're running in non-interactive mode */
    if(!Configuration.IsInteractive())
        ErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);

    /* Get information for each test to run */
    while((TestInfo = TestList->GetNextTestInfo()) != 0)
    {
        auto_ptr<CTestInfo> TestInfoPtr(TestInfo);

        RunTest(TestInfo);

        if(Configuration.DoSubmit() && !TestInfo->Log.empty())
            WebService->Submit("wine", TestInfo);

        StringOut("\n\n");
    }

    /* We're done with all tests. Finish this run */
    if(Configuration.DoSubmit())
        WebService->Finish("wine");

    /* Restore the original error mode */
    if(!Configuration.IsInteractive())
        SetErrorMode(ErrorMode);
}
Esempio n. 4
0
/**
 * Runs a Wine test and captures the output
 *
 * @param TestInfo
 * Pointer to a CTestInfo object containing information about the test.
 * Will contain the test log afterwards if the user wants to submit data.
 */
void
CWineTest::RunTest(CTestInfo* TestInfo)
{
    DWORD BytesAvailable;
    stringstream ss, ssFinish;
    DWORD StartTime;
    float TotalTime;
    string tailString;
    CPipe Pipe;
    char Buffer[1024];

    ss << "Running Wine Test, Module: " << TestInfo->Module << ", Test: " << TestInfo->Test << endl;
    StringOut(ss.str());

    StartTime = GetTickCount();

    try
    {
        /* Execute the test */
        CPipedProcess Process(TestInfo->CommandLine, Pipe);

        /* Receive all the data from the pipe */
        while(Pipe.Read(Buffer, sizeof(Buffer) - 1, &BytesAvailable) && BytesAvailable)
        {
            /* Output text through StringOut, even while the test is still running */
            Buffer[BytesAvailable] = 0;
            tailString = StringOut(tailString.append(string(Buffer)), false);

            if(Configuration.DoSubmit())
                TestInfo->Log += Buffer;
        }
        if(GetLastError() != ERROR_BROKEN_PIPE)
            TESTEXCEPTION("CPipe::Read failed for the test run\n");
    }
    catch(CTestException& e)
    {
        if(!tailString.empty())
            StringOut(tailString);
        tailString.clear();
        StringOut(e.GetMessage());
        TestInfo->Log += e.GetMessage();
    }

    /* Print what's left */
    if(!tailString.empty())
        StringOut(tailString);

    TotalTime = ((float)GetTickCount() - StartTime)/1000;
    ssFinish << "Test " << TestInfo->Test << " completed in ";
    ssFinish << setprecision(2) << fixed << TotalTime << " seconds." << endl;
    StringOut(ssFinish.str());
    TestInfo->Log += ssFinish.str();
}
Esempio n. 5
0
void _cdecl DPE(char *DbgStr, ...)
#pragma warn(on)
{
   char *pStr = (char *) DbgStr;
#ifdef DEBUG
   char *BuildPtr=BuildString;
   char *SubStr;
   int numLeadingZeroes;
   union {
         void   *VoidPtr;
         USHORT *WordPtr;
         ULONG  *LongPtr;
         ULONG  *StringPtr;
         } Parm;
   USHORT wBuildOption;

   Parm.VoidPtr=(void *) &DbgStr;
   Parm.StringPtr++;                            // skip size of string pointer

   while (*pStr)
      {
       numLeadingZeroes=0;
      // don't overflow target
      if (BuildPtr >= (char *) &BuildString[1024-2])
         break;

      switch (*pStr)
         {
         case '%':
            wBuildOption=0;
            pStr++;
            if (*pStr=='0')
               {
               wBuildOption|=LEADING_ZEROES;
               pStr++;
       if(*pStr>='0' && *pStr<='9')
       {
        numLeadingZeroes=((int)(*pStr))-((int)'0');
        pStr++;
       }
               }
            if (*pStr=='u')                                                         // always unsigned
               pStr++;

            switch(*pStr)
               {
               case 'x':
	       case 'X':
                  BuildPtr=HexLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption,numLeadingZeroes);
                  pStr++;
                  continue;

               case 'd':
                  BuildPtr=DecLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption,numLeadingZeroes);
                  pStr++;
                  continue;

               case 's':
                  SubStr=(char *)*Parm.StringPtr;
                  while (0!=(*BuildPtr++ = *SubStr++));
                  Parm.StringPtr++;
                  BuildPtr--;                      // remove the \0
                  pStr++;
                  continue;

               case 'l':
                  pStr++;
                  switch (*pStr)
                  {
                  case 'x':
                  case 'X':
                  BuildPtr=HexLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption,numLeadingZeroes);
                  pStr++;
                  continue;

                  case 'd':
                     BuildPtr=DecLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption,numLeadingZeroes);
                     pStr++;
                     continue;
                  } // end switch
                  continue;                        // dunno what he wants

               case 0:
                  continue;
               } // end switch
            break;

      case '\\':
         pStr++;
         switch (*pStr)
            {
            case 'n':
            *BuildPtr++=LF;
            pStr++;
            continue;

            case 'r':
            *BuildPtr++=CR;
            pStr++;
            continue;

            case 0:
            continue;
            } // end switch

         break;
         } // end switch

      *BuildPtr++=*pStr++;
      } // end while

   *BuildPtr=0;                                 // cauterize the string
   StringOut((char *) BuildString);         // print to comm port
#endif                            //DEBUG
}
Esempio n. 6
0
/**
 * Runs a Wine test and captures the output
 *
 * @param TestInfo
 * Pointer to a CTestInfo object containing information about the test.
 * Will contain the test log afterwards if the user wants to submit data.
 */
void
CWineTest::RunTest(CTestInfo* TestInfo)
{
    bool BreakLoop = false;
    DWORD BytesAvailable;
    DWORD Temp;
    stringstream ss, ssFinish;
    DWORD StartTime = GetTickCount();
    float TotalTime;
    string tailString;

    ss << "Running Wine Test, Module: " << TestInfo->Module << ", Test: " << TestInfo->Test << endl;
    StringOut(ss.str());

    StartTime = GetTickCount();

    {
        /* Execute the test */
        CProcess Process(TestInfo->CommandLine, &m_StartupInfo);

        /* Receive all the data from the pipe */
        do
        {
            /* When the application finished, make sure that we peek the pipe one more time, so that we get all data.
               If the following condition would be the while() condition, we might hit a race condition:
                  - We check for data with PeekNamedPipe -> no data available
                  - The application outputs its data and finishes
                  - WaitForSingleObject reports that the application has finished and we break the loop without receiving any data
            */
            if(WaitForSingleObject(Process.GetProcessHandle(), 0) != WAIT_TIMEOUT)
                BreakLoop = true;

            if(!PeekNamedPipe(m_hReadPipe, NULL, 0, NULL, &BytesAvailable, NULL))
                FATAL("PeekNamedPipe failed for the test run\n");

            if(BytesAvailable)
            {
                /* There is data, so get it and output it */
                auto_array_ptr<char> Buffer(new char[BytesAvailable + 1]);

                if(!ReadFile(m_hReadPipe, Buffer, BytesAvailable, &Temp, NULL))
                    FATAL("ReadFile failed for the test run\n");

                /* Output text through StringOut, even while the test is still running */
                Buffer[BytesAvailable] = 0;
                tailString = StringOut(tailString.append(string(Buffer)), false);

                if(Configuration.DoSubmit())
                    TestInfo->Log += Buffer;
            }
        }
        while(!BreakLoop);
    }

    /* Print what's left */
    if(!tailString.empty())
        StringOut(tailString);

    TotalTime = ((float)GetTickCount() - StartTime)/1000;
    ssFinish << "Test " << TestInfo->Test << " completed in ";
    ssFinish << setprecision(2) << fixed << TotalTime << " seconds." << endl;
    StringOut(ssFinish.str());
}
Esempio n. 7
0
                                        //------------------------- PrintfOut -
void cdecl PrintfOut(char far *DbgStr , ...)
{
   char far *BuildPtr=BuildString;
   char far *pStr=(char far *) DbgStr;
   char far *SubStr;
   union {
         void    far *VoidPtr;
         USHORT    far *WordPtr;
         ULONG   far *LongPtr;
         ULONG far *StringPtr;
         } Parm;
   USHORT wBuildOption;

   Parm.VoidPtr=(void far *) &DbgStr;
   Parm.StringPtr++;                            // skip size of string pointer

   while (*pStr)
      {
      // don't overflow target
      if (BuildPtr >= (char far *) &BuildString[1024-2])
         break;

      switch (*pStr)
         {
         case '%':
            wBuildOption=0;
            pStr++;
            if (*pStr=='0')
               {
               wBuildOption|=LEADING_ZEROES;
               pStr++;
               }
            if (*pStr=='u')                                                         // always unsigned
               pStr++;

            switch(*pStr)
               {
               case 'x':
	       case 'X':
                  BuildPtr=HexWordToASCII(BuildPtr, *Parm.WordPtr++,wBuildOption);
                  pStr++;
                  continue;

               case 'd':
                  BuildPtr=DecWordToASCII(BuildPtr, *Parm.WordPtr++,wBuildOption);
                  pStr++;
                  continue;

               case 's':
                  SubStr=(char far *)*Parm.StringPtr;
                  while (*BuildPtr++ = *SubStr++);
                  Parm.StringPtr++;
                  BuildPtr--;                      // remove the \0
                  pStr++;
                  continue;

               case 'l':
                  pStr++;
                  switch (*pStr)
                  {
                  case 'x':
                  case 'X':
                  BuildPtr=HexLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption);
                  pStr++;
                  continue;

                  case 'd':
                     BuildPtr=DecLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption);
                     pStr++;
                     continue;
                  } // end switch
                  continue;                        // dunno what he wants

               case 0:
                  continue;
               } // end switch
            break;

      case '\\':
         pStr++;
         switch (*pStr)
            {
            case 'n':
            *BuildPtr++=LF;
            pStr++;
            continue;

            case 'r':
            *BuildPtr++=CR;
            pStr++;
            continue;

            case 0:
            continue;
            break;
            } // end switch

         break;
         } // end switch

      *BuildPtr++=*pStr++;
      } // end while

   *BuildPtr=0;                                 // cauterize the string
   StringOut((char far *) BuildString);         // print to comm port
}
Esempio n. 8
0
 Performance(std::string const& name, std::ostream& out) { init(StringOut(out, name + prefixSeparator())); }
Esempio n. 9
0
static int 
ProcessDocs (query_data * qd, int num, int verbatim,
	     char OutputType, FILE * Output)
{
  int max_buf = 0;
  int DocCount = 0;
  char *doc_sepstr = NULL;
  char *para_sepstr = NULL;
  char *para_start = NULL;
  int heads_length = atoi (GetDefEnv ("heads_length", "50"));
  char QueryType = get_query_type ();
  int need_text = (OutputType == OUTPUT_TEXT || OutputType == OUTPUT_HILITE ||
	       OutputType == OUTPUT_HEADERS || OutputType == OUTPUT_SILENT);

  if (OutputType == OUTPUT_TEXT || OutputType == OUTPUT_HILITE)
    {
      if (QueryType == QUERY_APPROX || QueryType == QUERY_RANKED)
	{
	  doc_sepstr = de_escape_string (
				    Xstrdup (GetDefEnv ("ranked_doc_sepstr",
			   "---------------------------------- %n %w\\n")));
	}
      else
	{
	  doc_sepstr = de_escape_string (
					  Xstrdup (GetDefEnv ("doc_sepstr",
			      "---------------------------------- %n\\n")));
	}
      para_sepstr = de_escape_string (
				       Xstrdup (GetDefEnv ("para_sepstr",
				  "\\n######## PARAGRAPH %n ########\\n")));

      para_start = de_escape_string (
				      Xstrdup (GetDefEnv ("para_start",
					    "***** Weight = %w *****\\n")));
    }

  if (need_text)
    {
      max_buf = atoi (GetDefEnv ("buffer", "1048576"));
    }

  do
    {
      u_char *UDoc = NULL;
      unsigned long ULen;

      if (need_text)
	{
	  /* load the compressed text */
	  if (LoadCompressedText (qd, max_buf))
	    {
	      Message ("Unable to load compressed text.");
	      FatalError (1, "This is probably due to lack of memory.");
	    }

	  /* uncompress the loaded text */
	  UDoc = GetDocText (qd, &ULen);
	  if (UDoc == NULL)
	    FatalError (1, "UDoc is unexpectedly NULL");
	}


      if (!UDoc || PostProc ((char *) UDoc, verbatim))
	{
	  switch (OutputType)
	    {
	    case OUTPUT_COUNT:
	    case OUTPUT_SILENT:
	      break;
	    case OUTPUT_DOCNUMS:	/* This prints out the docnums string */
	      if (PagerRunning)
		fprintf (Output, "%8d   %6.4f   %7lu\n", GetDocNum (qd),
			 GetDocWeight (qd), GetDocCompLength (qd));
	      break;
	    case OUTPUT_HEADERS:	/* This prints out the headers of the documents */
	      if (PagerRunning)
		fprintf (Output, "%d ", GetDocNum (qd));
	      HeaderOut (Output, UDoc, ULen, heads_length);
	      if (PagerRunning)
		fputc ('\n', Output);
	      break;
#if TREC_MODE
	    case OUTPUT_EXTRAS:	/* This prints out the docnums string */
	      if (PagerRunning && trec_ids)
		{
		  long DN, PN = GetDocNum (qd) - 1;
		  if (trec_paras)
		    DN = trec_paras[PN];
		  else
		    DN = PN;
		  fprintf (Output, "%-14.14s  %8ld  %10.5f\n",
			   &trec_ids[DN * 14], PN + 1, GetDocWeight (qd));
		}
	      break;
#endif
	    case OUTPUT_TEXT:
	    case OUTPUT_HILITE:
	      {
		int j, para = -1, curr_para = 0;
		int init_para = -1;
		DocEntry *de, *doc_chain = NULL;
		int p_on = 0;
		register char ch = ' ';
		register char lch = '\n';
		if (PagerRunning)
		  {
		    StringOut (Output, doc_sepstr,
			       1, GetDocNum (qd),
			       QueryType == 'A' || QueryType == 'R',
			       GetDocWeight (qd));
		  }
		if (qd->id->ifh.InvfLevel == 3)
		  {
		    init_para = FetchInitialParagraph (qd->td, GetDocNum (qd));
		    doc_chain = GetDocChain (qd);
		    para = GetDocNum (qd) - init_para;

		    StringOut (Output, para_sepstr,
			       1, curr_para + 1,
			       0, 0);

		    if ((de = in_chain (0, init_para, doc_chain)))
		      StringOut (Output, para_start,
				 0, 0,
				 1, de->Weight);

		    if (doc_chain->DocNum - init_para == 0)
		      p_on = 1;
		  }
		for (j = 0; j < ULen; j++)
		  {
		    ch = UDoc[j];
		    switch (ch)
		      {
		      case '\02':
			break;
		      case '\01':
			ch = '\n';
		      case '\03':
			p_on = 0;
			curr_para++;
			StringOut (Output, para_sepstr,
				   1, curr_para + 1,
				   0, 0);
			lch = *(strchr (para_sepstr, '\0') - 1);
			if ((de = in_chain (curr_para, init_para, doc_chain)))
			  StringOut (Output, para_start,
				     0, 0,
				     1, de->Weight);
			if (doc_chain &&
			    doc_chain->DocNum - init_para == curr_para)
			  p_on = 1;
			break;
		      default:
			{
			  if (PagerRunning)
			    {
			      fputc (ch, Output);
			      if (p_on && isprint (ch))
				{
				  fputc ('\b', Output);
				  fputc ('_', Output);
				}
			    }

			  lch = ch;
			}
		      }
		  }
		if (PagerRunning && lch != '\n')
		  fputc ('\n', Output);
		p_on = 0;
	      }
	    }
	  if (PagerRunning)
	    fflush (Output);
	}
      DocCount++;

    }
  while (NextDoc (qd) && PagerRunning && (!Ctrl_C));

  if (need_text)
    {
      FreeTextBuffer (qd);
    }

  if (OutputType == OUTPUT_TEXT || OutputType == OUTPUT_HILITE)
    {
      Xfree (doc_sepstr);
      Xfree (para_sepstr);
      Xfree (para_start);
    }

  return (DocCount);
}