Esempio n. 1
0
bool Tokenize()
{
	TCHAR cDIR[MAX_STR_LEN];
	GetCurrentDirectory(MAX_STR_LEN, cDIR);

	_tprintf(_T("%s>>"), cDIR);
	_getts_s(cmdString);
	_tcscpy_s(cmdHistory[historyNum++], cmdString);

	int nowNum = historyNum - 1;
	while (cmdString[0] == '!')
	{
		if (cmdString[1] == '!')
		{
			if (_tcslen(cmdString) == 2 && nowNum >= 1)
			{
				_tcscpy(cmdString, cmdHistory[nowNum - 1]);
				nowNum = nowNum - 1;
			}
			else
			{
				_tprintf(_T("이전 명령어가 존재하지 않습니다.\n"));
				return false;
			}
		}
		else
		{
			int num = SearchToken();
			if (num != -1)
			{
				_tcscpy(cmdString, cmdHistory[num]);
				nowNum = num;
			}
			else
			{
				_tprintf(_T("이전 명령어가 존재하지 않습니다.\n"));
				return false;
			}
		}
	}
	_tcscpy_s(cmdCopy, cmdString);
	



	TCHAR * token = _tcstok(cmdString, seps);


	while (token != NULL){
		_tcscpy(
			cmdTokenList[tokenNum++], StrLower(token)
			);
		token = _tcstok(NULL, seps);
	}

	return true;
}
Esempio n. 2
0
/*********************************************************
 *   Main Function Entry
 *
 *********************************************************/
int _cdecl main(int argc, char **argv)
{
    HANDLE hFile;
    DWORD dwReturn;
    TCHAR szTemp[256] = {0};

    //DOSName works fine
    //TODO::Need understand why \Device\Example is not working
    //End with \ will return ERROR_PATH_NOT_FOUND (0x3)
    //End without \ will return ERROR_WRONG_TARGET_NAME (0x574)
    //Seems no way to make \Device\Example works
    _stprintf_s(szTemp,256, TEXT("\\\\.\\ExampleFilter\\%s"), argv[1]);
    //_stprintf_s(szTemp, 256, TEXT("\\\\.\\Example"));
    
    hFile = CreateFile(szTemp, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

    if(hFile != INVALID_HANDLE_VALUE)
    {

        while(szTemp[0] != 'q' && szTemp[0] != 'Q')
        {
        
            printf("Press enter to get a string from the driver or 'Q' to quit\n");
            _getts_s(szTemp,256);

            if(szTemp[0] != 'q' &&  szTemp[0] != 'Q')
            {
               memset(szTemp, 0, sizeof(szTemp));
               dwReturn = 0;
               ReadFile(hFile, szTemp, sizeof(szTemp), &dwReturn, NULL); 
               printf("%d bytes read\n", dwReturn);
               _tprintf(TEXT("%s\n"), szTemp);
            }
        }
        
        CloseHandle(hFile);
    }
    else
    {
        printf("CreateFile failed %0X\r\n", GetLastError());
    }
    return 0;
}
Esempio n. 3
0
int _tmain(int argc, TCHAR** argv)
{  
    if(argc==1)
    {  
        _tprintf(_T("\nDo you want to run tests from a folder containing Chinese characters to test UNICODE compatibility (y/n)?\n"));
        _tprintf(_T("Your choice > "));
        TCHAR szAnswer[1024]=_T("");
#if _MSC_VER>=1400
        _getts_s(szAnswer, 1024);  
#else
        _getts(szAnswer);  
#endif

        if(_tcscmp(szAnswer, _T("y"))==0 || 
            _tcscmp(szAnswer, _T("Y"))==0)
        {
            // Relaunch this process from another working directory containing UNICODE symbols in path.
            // This is needed to test all functionality on UNICODE compatibility.     
            g_bRunningFromUNICODEFolder = TRUE;  
        }    

        if(g_bRunningFromUNICODEFolder)
        {
            _tprintf(_T("Launching tests in another process:\n"));
            if(g_bRunningFromUNICODEFolder)
                _tprintf(_T(" - with working directory having UNICODE symbols in path\n"));
            return fork();    
        }
    }
    else
    {
        int argnum;
        for(argnum=1; argnum<argc; argnum++)
        {
            TCHAR* szArg = argv[argnum];
            if(_tcscmp(szArg, _T("/unicode"))==0)
                g_bRunningFromUNICODEFolder = TRUE;
        }    
    }

    printf("\n=== Automated tests for CrashRpt v.%d.%d.%d ===\n\n",
        CRASHRPT_VER/1000,
        (CRASHRPT_VER%1000)/100,
        (CRASHRPT_VER%1000)%100);

    CTestRegistry* pRegistry = CTestRegistry::GetRegistry();  
    CTestSuite* pTopSuite = pRegistry->GetTopSuite();

    // Print the list of test suites

    printf("The list of avaliable test suites:\n");

    UINT nSuiteCount = pTopSuite->GetChildSuiteCount();
    UINT i;
    for(i=0; i<nSuiteCount; i++)
    {
        CTestSuite* pSuite = pTopSuite->GetChildSuite(i);
        std::string sSuiteName;
        std::string sDescription;
        pSuite->GetSuiteInfo(sSuiteName, sDescription);

        printf(" - %s : %s\n", sSuiteName.c_str(), sDescription.c_str());    
    }

    printf("\nEnter which test suites to run (separate names by space) or enter empty line to run all test suites.\n");
    printf("Your choice > ");
    char szSuiteList[1024]="";
#if _MSC_VER>=1400
    gets_s(szSuiteList, 1024);  
#else
    gets(szSuiteList);  
#endif

    // Create the list of test suites to run
    std::string sSuiteList = szSuiteList;
    std::vector<std::string> aTokens = explode(sSuiteList);
    std::set<std::string> aTestSuitesToRun;
    for(i=0; i<aTokens.size(); i++) 
        aTestSuitesToRun.insert(aTokens[i]);

    // Determine how many tests to run

    std::vector<std::string> test_list = pTopSuite->GetTestList(aTestSuitesToRun, true);
    size_t nTestsToRun = test_list.size();

    printf("\nRunning tests...\n");

    DWORD dwStartTicks = GetTickCount();

    pTopSuite->Run(aTestSuitesToRun);

    DWORD dwFinishTicks = GetTickCount();
    double dTimeElapsed = (dwFinishTicks-dwStartTicks)/1000.0;

    printf("\n=== Summary ===\n\n");

    // Print all errors (if exist)  
    std::vector<std::string> error_list = pTopSuite->GetErrorList(true);
    if(error_list.size()>0)
    {
        printf("Error list:\n");

        for(i=0; i<error_list.size(); i++)
        {
            printf("%d: %s\n", i+1, error_list[i].c_str());
        }
    }

    printf("\n Time elapsed: %0.2f sec.\n", dTimeElapsed);
    printf("   Test count: %d\n", nTestsToRun);
    size_t nErrorCount = error_list.size();
    printf(" Tests passed: %d\n", nTestsToRun-nErrorCount);
    printf(" Tests failed: %d\n", nErrorCount);

    // Wait for key press
    _getch();

    // Return non-zero value if there were errors
    return nErrorCount==0?0:1;
}
Esempio n. 4
0
int _tmain(int argc, TCHAR** argv)
{  
  if(argc==1)
  {  
    _tprintf(_T("\nDo you want to run tests from a folder cotaining Chineese characters to test UNICODE compatibility (y/n)?\n"));
    _tprintf(_T("Your choice > "));
    TCHAR szAnswer[1024]=_T("");
#if _MSC_VER>=1400
    _getts_s(szAnswer, 1024);  
#else
    _getts(szAnswer);  
#endif

    if(_tcscmp(szAnswer, _T("y"))==0 || 
       _tcscmp(szAnswer, _T("Y"))==0)
    {
      // Relaunch this process from another working directory containing UNICODE symbols in path.
      // This is needed to test all functionality on UNICODE compatibility.     
      g_bRunningFromUNICODEFolder = TRUE;  
    }    

    if(g_bRunningFromUNICODEFolder)
    {
      _tprintf(_T("Launching tests in another process:\n"));
      if(g_bRunningFromUNICODEFolder)
        _tprintf(_T(" - with working directory having UNICODE symbols in path\n"));
      return fork();    
    }
  }
  else
  {
    int argnum;
    for(argnum=1; argnum<argc; argnum++)
    {
      TCHAR* szArg = argv[argnum];
      if(_tcscmp(szArg, _T("/unicode"))==0)
        g_bRunningFromUNICODEFolder = TRUE;
    }    
  }

  printf("\n=== Automated tests for CrashRpt v.%d.%d.%d ===\n\n",
    CRASHRPT_VER/1000,
    (CRASHRPT_VER%1000)/100,
    (CRASHRPT_VER%1000)%100);

  printf("The list of avaliable test suites:\n");

  // Print the list of test suites
  std::map<std::string, std::string>::iterator siter;  
  for(siter=g_pTestSuiteList->begin(); siter!=g_pTestSuiteList->end(); siter++)
  {
    printf(" - %s : %s\n", siter->first.c_str(), siter->second.c_str());    
  }

  printf("\nEnter which test suites to run (separate names by space) or enter empty line to run all test suites.\n");
  printf("Your choice > ");
  char szSuiteList[1024]="";
#if _MSC_VER>=1400
  gets_s(szSuiteList, 1024);  
#else
  gets(szSuiteList);  
#endif

  // Create the list of test suites to run
  std::string sSuiteList = szSuiteList;
  std::vector<std::string> aTokens = explode(sSuiteList);
  std::set<std::string> aTestSuitesToRun;
  size_t i;
  for(i=0; i<aTokens.size(); i++) 
    aTestSuitesToRun.insert(aTokens[i]);
  
  // Determine how many tests to run
  size_t nTestsToRun = 0;
  if(aTestSuitesToRun.size()==0)
  {
    nTestsToRun = g_pTestList->size();
  }
  else
  {    
    std::map<std::string, PFNTEST>::iterator iter;
    for(iter=g_pTestList->begin(); iter!=g_pTestList->end(); iter++)
    {
      std::string sName = iter->first;
      size_t pos = sName.find(':');
      std::string sTestSuite = sName.substr(0, pos);    
      std::set<std::string>::iterator sit = 
        aTestSuitesToRun.find(sTestSuite);
      if(sit!=aTestSuitesToRun.end())
      {
        nTestsToRun++;        
      }      
    }
  }
  
  if(nTestsToRun==0)
  {
    printf("\nNo tests selected, exiting.\n");
    return 0;
  }

  printf("\nRunning tests...\n");

  // Walk through all registered test and run each one
  std::map<std::string, PFNTEST>::iterator iter;
  int n = 1;
  for(iter=g_pTestList->begin(); iter!=g_pTestList->end(); iter++)
  {
    std::string sName = iter->first;
    size_t pos = sName.find(':');
    std::string sTestSuite = sName.substr(0, pos);    
    std::set<std::string>::iterator sit = 
      aTestSuitesToRun.find(sTestSuite);
    if(aTestSuitesToRun.size()==0 || sit!=aTestSuitesToRun.end())
    {
      printf("- %d/%d: %s ...\n", n, nTestsToRun, iter->first.c_str());
      n++;
      iter->second();
    }          
  }

  printf("\n=== Summary ===\n\n");
  
  // Print all errors (if exist)
  if(g_pErrorList!=NULL)
  {
    size_t i;
    for(i=0; i<g_pErrorList->size(); i++)
    {
      printf("Error %d: %s\n", i, (*g_pErrorList)[i].c_str());
    }
  }

  printf("\n   Test count: %d\n", nTestsToRun);
  size_t nErrorCount = g_pErrorList!=NULL?g_pErrorList->size():0;
  printf(" Tests passed: %d\n", nTestsToRun-nErrorCount);
  printf(" Tests failed: %d\n", nErrorCount);

  // Wait for key press
  _getch();

  // Clean up
  if(g_pTestSuiteList!=NULL)
    delete g_pTestSuiteList;

  if(g_pTestList!=NULL)
    delete g_pTestList;

  if(g_pErrorList)
    delete g_pErrorList;

  // Return non-zero value if there were errors
  return nErrorCount==0?0:1;
}