Leaked source code of windows server 2003
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.

265 lines
6.7 KiB

  1. //-------------------------------------------------------------------------
  2. // File: tdinc.hxx
  3. //
  4. // Contents: Contains test driver class definitions for:
  5. //
  6. // -- CTDTestDrv
  7. // -- CTDRunObj
  8. // -- CTDTest
  9. // -- CTDGroup
  10. // -- CTDSwitch
  11. // -- CTDParser
  12. //
  13. // History: 03/22/98 BogdanT Created
  14. //--------------------------------------------------------------------------
  15. #ifndef __TDINC_HXX__
  16. #define __TDINC_HXX__
  17. #include <tdmacros.hxx>
  18. #include <tdlist.hxx>
  19. class CBaseCmdlineObj;
  20. class CTDRunObj;
  21. class CTDTest;
  22. class CTDGroup;
  23. class CTDSwitch;
  24. #define DEFAULT_TESTLOGINFO_SIZE 256
  25. //---------------------------------------------------------------------------
  26. // Class: CTDTestDrv
  27. //
  28. // Synopsis: test driver object definition
  29. //
  30. // History: 12/16/97 BogdanT Created
  31. //---------------------------------------------------------------------------
  32. class CTDTestDrv
  33. {
  34. public:
  35. CTDTestDrv();
  36. ~CTDTestDrv();
  37. HRESULT AddTest(LPTSTR ptszName,
  38. TESTENTRY pTestFunc,
  39. LPVOID pTestParam,
  40. LPTSTR ptszDescription);
  41. HRESULT AddGroup(LPTSTR ptszName,
  42. SETUPENTRY pSetupFunc,
  43. CLEANUPENTRY pCleanupFunc,
  44. LPTSTR ptszDescription,
  45. ...);
  46. HRESULT AddSwitch(SwitchType st,
  47. LPTSTR ptszName,
  48. LPTSTR ptszDefault,
  49. LPTSTR ptszDescription);
  50. HRESULT SetTestLogInfo(LPTSTR ptszFormat, ...);
  51. void EnableLogging(BOOL fSet) { m_fLogging = fSet; }
  52. HRESULT Init();
  53. HRESULT Run();
  54. LPCVOID GetSwitch (LPTSTR ptszName);
  55. BOOL SwitchFound(LPTSTR ptszName);
  56. FileSystem GetCurrentFileSystem();
  57. ULONG GetGlobalSeed() { return m_ulSeed; };
  58. friend class CTDTest;
  59. friend class CTDGroup;
  60. protected:
  61. BOOL SkipIt(CTDRunObj* pObj) { return NULL!=m_listSkip.PtrFound(pObj); }
  62. HRESULT TestPreRun (CTDTest* pTest);
  63. HRESULT TestPostRun (CTDTest* pTest);
  64. CTDTest *TestGetPointer(LPTSTR ptszName);
  65. HRESULT GroupPreRun (CTDGroup*) { return S_OK; }
  66. HRESULT GroupPostRun (CTDGroup*) { return S_OK; }
  67. CTDGroup *GroupGetPointer(LPTSTR ptszName);
  68. CTDSwitch* SwitchGetPointer(LPTSTR ptszName);
  69. HRESULT SetRepro (CTDTest* pTest);
  70. void LogResult(CTDTest* pTest);
  71. void RandomizeSeed(ULONG ulSeed = 0);
  72. LPTSTR m_ptszReproCmdline;
  73. ULONG m_ulSeed;
  74. DG_INTEGER m_dgi;
  75. LPTSTR m_ptszCrtTestLogInfo;
  76. BOOL m_fLogging;
  77. LPTSTR m_ptszStartTest;
  78. BOOL m_fStartTestFound;
  79. ULONG m_ulCountPass;
  80. ULONG m_ulCountFail;
  81. ULONG m_ulCountAbort;
  82. DWORD m_dwLocalSleepTime;
  83. DWORD m_dwGlobalSleepTime;
  84. TPtrList<CTDTest> m_listTests;
  85. TPtrList<CTDGroup> m_listGroups;
  86. TPtrList<CTDSwitch> m_listSwitches;
  87. TPtrList<CTDRunObj> m_listRun;
  88. TPtrList<CTDRunObj> m_listSkip;
  89. };
  90. //---------------------------------------------------------------------------
  91. // Class: CTDRunObj
  92. //
  93. // Synopsis: runable object definition; pure virtual class
  94. //
  95. // History: 03/22/98 BogdanT Created
  96. //---------------------------------------------------------------------------
  97. class CTDRunObj
  98. {
  99. public:
  100. virtual HRESULT Run() = 0;
  101. };
  102. //---------------------------------------------------------------------------
  103. // Class: CTDTest
  104. //
  105. // Synopsis: test object definition
  106. //
  107. // History: 03/22/98 BogdanT Created
  108. //---------------------------------------------------------------------------
  109. class CTDTest : public CTDRunObj
  110. {
  111. public:
  112. CTDTest();
  113. ~CTDTest();
  114. HRESULT Init(LPTSTR ptszName,
  115. TESTENTRY pTestFunc,
  116. LPVOID pTestParam,
  117. LPTSTR ptszDescription);
  118. HRESULT Run();
  119. friend class CTDTestDrv;
  120. protected:
  121. LPTSTR m_ptszName;
  122. TESTENTRY m_pTestFunc;
  123. LPVOID m_pTestParam;
  124. LPTSTR m_ptszDescription;
  125. HRESULT m_hr;
  126. };
  127. //---------------------------------------------------------------------------
  128. // Class: CTDGroup
  129. //
  130. // Synopsis: group object definition
  131. //
  132. // History: 03/22/98 BogdanT Created
  133. //---------------------------------------------------------------------------
  134. class CTDGroup : public CTDRunObj
  135. {
  136. public:
  137. CTDGroup();
  138. ~CTDGroup();
  139. HRESULT Init(LPTSTR ptszName,
  140. SETUPENTRY pSetupFunc,
  141. CLEANUPENTRY pCleanupFunc,
  142. LPTSTR ptszDescription);
  143. HRESULT AddTest(CTDTest* pTest);
  144. HRESULT Run();
  145. friend class CTDTestDrv;
  146. protected:
  147. LPTSTR m_ptszName;
  148. SETUPENTRY m_pSetupFunc;
  149. CLEANUPENTRY m_pCleanupFunc;
  150. LPTSTR m_ptszDescription;
  151. HRESULT m_hr;
  152. TPtrList<CTDTest> m_listTests;
  153. };
  154. //---------------------------------------------------------------------------
  155. // Class: CTDSwitch
  156. //
  157. // Synopsis: cmdline switch object definition
  158. //
  159. // History: 03/22/98 BogdanT Created
  160. //---------------------------------------------------------------------------
  161. class CTDSwitch
  162. {
  163. public:
  164. CTDSwitch();
  165. ~CTDSwitch();
  166. HRESULT Init(SwitchType st,
  167. LPTSTR ptszName,
  168. LPTSTR ptszDefault,
  169. LPTSTR ptszDescription);
  170. BOOL SwitchIsFound() { return m_pObj->IsFound(); }
  171. LPCVOID GetValue();
  172. friend class CTDTestDrv;
  173. protected:
  174. SwitchType m_st;
  175. LPTSTR m_ptszName;
  176. CBaseCmdlineObj *m_pObj;
  177. };
  178. #define STRING_SEPARATOR TEXT(',')
  179. //---------------------------------------------------------------------------
  180. // Class: CTDParser
  181. //
  182. // Synopsis: string parser object definition
  183. //
  184. // History: 03/22/98 BogdanT Created
  185. //---------------------------------------------------------------------------
  186. class CTDParser
  187. {
  188. public:
  189. CTDParser() { m_ptszText = NULL; m_ptszCrtPos = NULL; }
  190. ~CTDParser() { delete[] m_ptszText; }
  191. HRESULT Init(LPTSTR ptszText, TCHAR tchSeparator);
  192. HRESULT Next(LPTSTR &ptszNext);
  193. void Reset() { m_ptszCrtPos = m_ptszText; }
  194. protected:
  195. LPTSTR m_ptszText;
  196. LPTSTR m_ptszCrtPos;
  197. TCHAR m_tchSeparator;
  198. };
  199. #endif //__TDINC_HXX__