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.

229 lines
5.3 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. tstpoint.c
  5. Abstract:
  6. Implementation of cluster test points
  7. Author:
  8. John Vert (jvert) 11/25/1996
  9. Revision History:
  10. --*/
  11. #include "initp.h"
  12. #ifdef CLUSTER_TESTPOINT
  13. PTESTPOINT_ENTRY TestArray=NULL;
  14. HANDLE gTestPtFileMapping;
  15. extern DWORD CsTestPoint;
  16. extern DWORD CsTestTrigger;
  17. extern DWORD CsTestAction;
  18. TESTPOINT_NAME TestPointNames[TestpointMax]={
  19. L"JoinFailPetition", //0
  20. L"FailNmJoinCluster", //1
  21. L"FailRegisterIntraClusterRpc", //2
  22. L"FailJoinCreateBindings", //3
  23. L"FailJoinPetitionForMembership", //4
  24. L"FailNmJoin", //5
  25. L"FailDmJoin", //6
  26. L"FailApiInitPhase1", //7
  27. L"FailFmJoinPhase1", //8
  28. L"FailDmUpdateJoinCluster", //9
  29. L"FailEvInitialize", //10
  30. L"FailNmJoinComplete", //11
  31. L"FailApiInitPhase2", //12
  32. L"FailFmJoinPhase2", //13
  33. L"FailLogCommitSize", //14
  34. L"FailClusterShutdown", //15
  35. L"FailLocalXsaction", //16
  36. L"FailOnlineResource", //17
  37. L"FailSecurityInit", //18
  38. L"FailOmInit", //19
  39. L"FailEpInit", //20
  40. L"FailDmInit", //21
  41. L"FailNmInit", //22
  42. L"FailGumInit", //23
  43. L"FailFmInit", //24
  44. L"FailLmInit", //25
  45. L"FailCpInit", //26
  46. L"FailNmPauseNode", //27
  47. L"FailNmResumeNode", //28
  48. L"FailNmEvictNodeAbort", //29
  49. L"FailNmEvictNodeHalt", //30
  50. L"FailNmCreateNetwork", //31
  51. L"FailNmSetNetworkPriorityOrder", //32
  52. L"FailNmSetNetworkPriorityOrder2", //33
  53. L"FailNmSetNetworkCommonProperties", //34
  54. L"FailNmSetInterfaceInfoAbort", //35
  55. L"FailNmSetInterfaceInfoHalt", //36
  56. L"FailPreMoveWithNodeDown", //37
  57. L"FailPostMoveWithNodeDown", //38
  58. L"FailFormNewCluster" //39
  59. };
  60. VOID
  61. TestpointInit(
  62. VOID
  63. )
  64. /*++
  65. Routine Description:
  66. Initializes the testpoint code.
  67. Arguments:
  68. None
  69. Return Value:
  70. None
  71. --*/
  72. {
  73. DWORD ArraySize;
  74. DWORD i;
  75. //
  76. // Create the array of testpoint entries in named shared memory.
  77. //
  78. ArraySize = sizeof(TESTPOINT_ENTRY)*TestpointMax;
  79. gTestPtFileMapping = CreateFileMapping((HANDLE)-1,
  80. NULL,
  81. PAGE_READWRITE,
  82. 0,
  83. ArraySize,
  84. L"Cluster_Testpoints");
  85. if (gTestPtFileMapping == NULL) {
  86. CL_UNEXPECTED_ERROR( GetLastError() );
  87. return;
  88. }
  89. TestArray = MapViewOfFile(gTestPtFileMapping,
  90. FILE_MAP_READ | FILE_MAP_WRITE,
  91. 0,0,
  92. ArraySize);
  93. if (TestArray == NULL) {
  94. CL_UNEXPECTED_ERROR( GetLastError() );
  95. return;
  96. }
  97. //
  98. // Initialize test point array
  99. //
  100. for (i=0; i<TestpointMax; i++) {
  101. lstrcpyW(TestArray[i].TestPointName,TestPointNames[i]);
  102. if ( i == CsTestPoint ) {
  103. TestArray[i].Trigger = CsTestTrigger;
  104. TestArray[i].Action = CsTestAction;
  105. } else {
  106. TestArray[i].Trigger = TestTriggerNever;
  107. TestArray[i].Action = TestActionTrue;
  108. }
  109. TestArray[i].HitCount = 0;
  110. TestArray[i].TargetCount = 0;
  111. }
  112. return;
  113. }
  114. void TestpointDeInit()
  115. {
  116. if (TestArray) UnmapViewOfFile(TestArray);
  117. if (gTestPtFileMapping) CloseHandle(gTestPtFileMapping);
  118. return;
  119. }
  120. BOOL
  121. TestpointCheck(
  122. IN TESTPOINT Testpoint
  123. )
  124. /*++
  125. Routine Description:
  126. Checks a testpoint to see if it should fire.
  127. Arguments:
  128. Testpoint - Supplies the testpoint number.
  129. Return Value:
  130. TRUE if the testpoint has fired.
  131. FALSE otherwise
  132. --*/
  133. {
  134. PTESTPOINT_ENTRY Entry;
  135. if (TestArray == NULL) {
  136. return(FALSE);
  137. }
  138. Entry = &TestArray[Testpoint];
  139. Entry->HitCount += 1;
  140. switch (Entry->Trigger) {
  141. case TestTriggerNever:
  142. return(FALSE);
  143. case TestTriggerAlways:
  144. break;
  145. case TestTriggerOnce:
  146. Entry->Trigger = TestTriggerNever;
  147. break;
  148. case TestTriggerTargetCount:
  149. if (Entry->HitCount == Entry->TargetCount) {
  150. Entry->HitCount = 0;
  151. break;
  152. } else {
  153. return(FALSE);
  154. }
  155. default:
  156. CL_UNEXPECTED_ERROR( Entry->Trigger );
  157. }
  158. CsDbgPrint(LOG_CRITICAL,
  159. "[TP] Testpoint %1!ws! being executed.\n",
  160. TestPointNames[Testpoint] );
  161. //
  162. // The testpoint has fired, figure out what we are supposed to do.
  163. //
  164. switch (Entry->Action) {
  165. case TestActionTrue:
  166. return(TRUE);
  167. case TestActionExit:
  168. ExitProcess(Testpoint);
  169. break;
  170. case TestActionDebugBreak:
  171. DebugBreak();
  172. break;
  173. }
  174. return(FALSE);
  175. }
  176. #endif