• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • Ns2中的測試用例Ns2中的測試用例(2)

    發表于:2016-01-07來源:uml.org.cn作者:不詳點擊數: 標簽:測試用例
    ) { printf( %s failed (%d).\n, cmd, GetLastError() ); exit(1); } WaitForSingleObject( pi.hProcess, INFINITE ); GetExitCodeProcess(pi.hProcess, code); CloseHandle( pi.hProcess ); CloseHandle( pi.hThrea

      )

      {

      printf( "%s failed (%d).\n", cmd, GetLastError() );

      exit(1);

      }

      WaitForSingleObject( pi.hProcess, INFINITE );

      GetExitCodeProcess(pi.hProcess, &code);

      CloseHandle( pi.hProcess );

      CloseHandle( pi.hThread );

      if(code != 0)

      {

      printf("%s failed with code (%d)\n", cmd, code);

      exit(code);

      }

      }

      bool IsComment(char* p)

      {

      while((*p == ' ' || *p == '\t') && *p != 0) p++;

      return *p == '#';

      }

      void ProcessOneFile(char* file_name)

      {

      // 處理一個文件

      char tcl_file[MAX_PATH];

      sprintf(tcl_file, "%stest-suite-%s.tcl", TEST_PATH, file_name);

      ifstream src(tcl_file);

      if(!src.is_open())

      {

      printf("%s open failed!\n", tcl_file);

      return;

      }

      sprintf(tcl_file, "%s_tmp.tcl", TEST_PATH);

      FILE* dst = fopen(tcl_file, "wt");

      if(dst == NULL)

      {

      printf("create temp tcl failed\n");

      src.close();

      return;

      }

      fprintf(dst, "set PERL {perl}\n");

      fprintf(dst, "set quiet true\n");

      char cClass[1000][100];

      int nClass = 0;

      while(!src.eof())

      {

      char line[2048];

      char* p;

      src.getline(line, 2048);

      if(IsComment(line)) continue;

      if(strstr(line, "Class") && (p = strstr(line, "Test/")))

      {

      int idx = 0;

      p += 5;

      while(*p != 0 && *p != ' ') cClass[nClass][idx++] = *p++;

      cClass[nClass][idx] = 0;

      nClass++;

      }

      else if(strstr(line, "xgraph"))

      {

      fprintf(dst, "#");

      }

      fprintf(dst, "%s\n", line);

      }

      src.close();

      fclose(dst);

      // 執行TCL文件并進行比較

      for(int i = 0; i < nClass; i++)

      {

      printf("%s testcase begin...", cClass[i]);

      char cmd[2560];

      sprintf(cmd, "%s %s_tmp.tcl %s", NS_PATH, TEST_PATH, cClass[i]);

      Exec(cmd);

      // 備份壓縮文件

      sprintf(cmd, "cp %stest-output-%s\\%s.Z %stest-output-%s\\%s_bak.Z", TEST_PATH, file_name, cClass[i], TEST_PATH, file_name, cClass[i]);

      Exec(cmd);

      // 解壓縮

      sprintf(cmd, "gzip -daf %stest-output-%s\\%s.Z", TEST_PATH, file_name, cClass[i]);

      Exec(cmd);

      // 還原壓縮文件

      sprintf(cmd, "mv %stest-output-%s\\%s_bak.Z %stest-output-%s\\%s.Z", TEST_PATH, file_name, cClass[i], TEST_PATH, file_name, cClass[i]);

      Exec(cmd);

      // 比較文件

      char f1[MAX_PATH], f2[MAX_PATH];

      sprintf(f1, "%stest-output-%s\\%s", TEST_PATH, file_name, cClass[i]);

      sprintf(f2, "%stemp.rands", TEST_PATH);

      Compare(f1, f2);

      // 刪除解壓縮后的文件

      sprintf(cmd, "rm -f %stest-output-%s\\%s", TEST_PATH, file_name, cClass[i]);

      Exec(cmd);

      printf("OK\n");

      }

      }

      int _tmain(int argc, _TCHAR* argv[])

      {

      // 查找測試文件所在目錄下的所有文件

      WIN32_FIND_DATA fdata;

      HANDLE hFind = FindFirstFile(FIND_MASK, &fdata);

      if(hFind == INVALID_HANDLE_VALUE)

      {

      printf("find file failed");

      return 1;

      }

      do

      {

      bool bProcess = false;

      if(argc > 1)

      {

      for(int i = 1; i < argc; i++)

      {

      if(strstr(fdata.cFileName, argv[i]))

      {

      bProcess = true;

      break;

      }

      }

      }

      else

      bProcess = true;

      if(bProcess)

      {

      printf("\n%s processing...\n", fdata.cFileName);

      fdata.cFileName[strlen(fdata.cFileName) - 4] = 0;

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>