Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
3.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: SIFT.cxx
  7. //
  8. // Contents: Simulated Iterated Failure Testing Harness
  9. //
  10. // Functions: Sift
  11. //
  12. // History: 25-Jan-93 AlexT Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #include <headers.cxx>
  16. #pragma hdrstop
  17. #if DBG != 1
  18. #error FAIL.EXE requires DBG == 1
  19. #endif
  20. #include <sift.hxx>
  21. #define SET_DISPLAY_BUF_SIZE _wsetscreenbuf(_fileno(stdout), _WINBUFINF)
  22. void main (int argc, char *argv[])
  23. {
  24. int i;
  25. int cTests = TestCount();
  26. SiftInit();
  27. SET_DISPLAY_BUF_SIZE; //set QuickWin buffer size to infinite
  28. printf("SIFT %d tests.\n", cTests);
  29. for (i = 0; i < cTests; i++)
  30. {
  31. SiftDriver(TestItem(i));
  32. }
  33. // Be a good citizen and leave the Docfile clean
  34. SetFailLimit(0L);
  35. CoUninitialize();
  36. printf("SIFT complete.\n");
  37. }
  38. //+-------------------------------------------------------------------------
  39. //
  40. // Function: Initialize
  41. //
  42. // Synopsis: Standard initialization
  43. //
  44. // History: 21-Jan-93 AlexT Created
  45. //
  46. //--------------------------------------------------------------------------
  47. void SiftInit(void)
  48. {
  49. SCODE sc;
  50. #if WIN32 == 300
  51. if (FAILED(sc = DfGetScode(CoInitializeEx(NULL, COINIT_MULTITHREADED))))
  52. #else
  53. if (FAILED(sc = DfGetScode(CoInitialize(NULL))))
  54. #endif
  55. printf("SIFT: Unable to CoInitialize, sc = 0x%lX\n", sc);
  56. DfDebug(0x00100101, 0x101);
  57. }
  58. void SiftDriver(CTestCase *ptc)
  59. {
  60. SCODE sc;
  61. if (!ptc->Init())
  62. {
  63. // Test's obligation to display failure message
  64. return;
  65. }
  66. do
  67. {
  68. LONG iteration, lcf = 0;
  69. for (iteration = 0; iteration <= lcf; iteration++)
  70. {
  71. SetFailLimit(0L);
  72. sc = ptc->Prep(iteration);
  73. if (FAILED(sc))
  74. continue;
  75. SetFailLimit(iteration);
  76. sc = ptc->Call(iteration);
  77. if (SUCCEEDED(sc))
  78. {
  79. if (iteration == 0)
  80. {
  81. lcf = DfGetResLimit(DBR_FAILCOUNT);
  82. printf("%ld failure points\n", lcf);
  83. }
  84. else
  85. {
  86. // Shouldn't have succeeded
  87. printf("..Iteration %ld succeeded!\n", iteration);
  88. }
  89. SetFailLimit(0L);
  90. ptc->EndCall(iteration);
  91. }
  92. else
  93. {
  94. SetFailLimit(0L);
  95. ptc->CallVerify(iteration);
  96. }
  97. ptc->EndPrep(iteration);
  98. ptc->EndVerify(iteration);
  99. }
  100. } while (ptc->Next());
  101. }
  102. //+-------------------------------------------------------------------------
  103. //
  104. // Function: SetFailLimit
  105. //
  106. // Synopsis: clear count, set limit
  107. //
  108. // Arguments: [limit] -- failure limit
  109. //
  110. // History: 22-Jan-93 AlexT Created
  111. //
  112. //--------------------------------------------------------------------------
  113. void SetFailLimit(LONG limit)
  114. {
  115. DfSetResLimit(DBR_FAILCOUNT, 0);
  116. DfSetResLimit(DBR_FAILLIMIT, limit);
  117. }