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.

264 lines
8.6 KiB

  1. /////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c)2000 Microsoft Corporation, All Rights Reserved
  4. //
  5. /////////////////////////////////////////////////////////////////////////////////////////////
  6. #ifndef _BVT_HEADER
  7. #define _BVT_HEADER
  8. /////////////////////////////////////////////////////////////////////////////////////////////
  9. //*******************************************************************************************
  10. //
  11. // Common headers
  12. //
  13. //*******************************************************************************************
  14. /////////////////////////////////////////////////////////////////////////////////////////////
  15. #include <windows.h>
  16. #include <stdio.h>
  17. #include <wbemcli.h>
  18. #include <oahelp.inl>
  19. #include <wbemutil.h>
  20. #include <flexarry.h>
  21. #include <cominit.h>
  22. /////////////////////////////////////////////////////////////////////////////////////////////
  23. //*******************************************************************************************
  24. //
  25. // Common macros and define
  26. //
  27. //*******************************************************************************************
  28. /////////////////////////////////////////////////////////////////////////////////////////////
  29. #define SAFE_DELETE_PTR(pv) \
  30. { if(pv) delete pv; \
  31. pv = NULL; }
  32. #define SAFE_RELEASE_PTR(pv) \
  33. { if(pv){ pv->Release(); } \
  34. pv = NULL; }
  35. #define SAFE_DELETE_ARRAY(pv) \
  36. { if(pv) delete []pv; \
  37. pv = NULL; }
  38. #define SUCCESS 0
  39. #define WARNING 10
  40. #define FATAL_ERROR 20
  41. #define FAILED_AS_EXPECTED 30
  42. #define NO_MORE_DATA 40
  43. #define ADD_CLASS 0
  44. #define DELETE_CLASS 1
  45. //====================================================================================================
  46. // The Repository tests
  47. //====================================================================================================
  48. #define APITEST1 1
  49. #define APITEST2 2
  50. #define APITEST3 3
  51. #define APITEST4 4
  52. #define APITEST5 5
  53. #define APITEST6 6
  54. #define APITEST7 7
  55. #define APITEST8 8
  56. #define APITEST9 9
  57. #define APITEST10 10
  58. #define APITEST11 11
  59. #define APITEST12 12
  60. #define APITEST13 13
  61. #define APITEST14 14
  62. #define APITEST15 15
  63. #define APITEST16 16
  64. #define APITEST17 17
  65. #define APITEST18 18
  66. #define APITEST19 19
  67. #define APITEST20 20
  68. #define APITEST21 21
  69. #define APITEST22 22
  70. #define APITEST23 23
  71. #define APITEST24 24
  72. //====================================================================================================
  73. // The Provider CIMV2 tests
  74. //====================================================================================================
  75. #define APITEST200 200
  76. #define APITEST201 201
  77. #define APITEST202 202
  78. #define APITEST203 203
  79. #define APITEST204 204
  80. //====================================================================================================
  81. // Scripting tests
  82. //====================================================================================================
  83. #define SCRIPTTEST1 1001
  84. #define NO_ERRORS_EXPECTED FALSE,__FILE__,__LINE__
  85. #define ERRORS_CAN_BE_EXPECTED TRUE,__FILE__,__LINE__
  86. /////////////////////////////////////////////////////////////////////////////////////////////
  87. //*******************************************************************************************1
  88. //
  89. // Typedefs
  90. //
  91. //*******************************************************************************************
  92. /////////////////////////////////////////////////////////////////////////////////////////////
  93. typedef struct _IniInfo
  94. {
  95. LPWSTR Key;
  96. LPWSTR Value;
  97. } IniInfo;
  98. typedef struct _PropertyInfo
  99. {
  100. const WCHAR * Property;
  101. const WCHAR * QualifierName;
  102. CVARIANT Var;
  103. long Type;
  104. _PropertyInfo() { QualifierName = Property = NULL; }
  105. ~_PropertyInfo() {}
  106. } PropertyInfo;
  107. typedef struct _CPropertyList
  108. {
  109. CFlexArray m_List;
  110. void Add( PropertyInfo * p) { m_List.Add(p);}
  111. inline long Size() { return m_List.Size(); }
  112. PropertyInfo * GetAt(int x) { return (PropertyInfo*)m_List.GetAt(x);}
  113. _CPropertyList() {}
  114. ~_CPropertyList();
  115. } CPropertyList;
  116. typedef struct _ClassInfo
  117. {
  118. const WCHAR * Class;
  119. BOOL fProcessed;
  120. BOOL fAction;
  121. _ClassInfo() { Class = NULL; fProcessed = 0; fAction = 0; }
  122. ~_ClassInfo() {}
  123. }ClassInfo;
  124. typedef struct _ClassList
  125. {
  126. CFlexArray m_List;
  127. void Add( ClassInfo * p) { m_List.Add(p);}
  128. inline long Size() { return m_List.Size(); }
  129. ClassInfo * GetAt(int x) { return (ClassInfo*)m_List.GetAt(x);}
  130. int ClassesCompareAsExpectedAndLogErrors(WCHAR * wcsNamespace, BOOL fExpectedFailure, const char * csFile, const ULONG Line);
  131. int ClassInListAndLogErrors(WCHAR * wcsClass, WCHAR * wcsNamespace, BOOL fExpectedFailure, const char * csFile, const ULONG Line);
  132. _ClassList() {}
  133. ~_ClassList();
  134. } ClassList;
  135. /////////////////////////////////////////////////////////////////////////////////////////////
  136. //*******************************************************************************************1
  137. //
  138. // Prototypes
  139. //
  140. //*******************************************************************************************
  141. /////////////////////////////////////////////////////////////////////////////////////////////
  142. int BasicConnectUsingIWbemLocator(void); // Test 1
  143. int BasicSyncConnectUsingIWbemConnection(void); // Test 2
  144. int BasicAsyncConnectUsingIWbemConnection(void); // Test 3
  145. int CreateNewTestNamespace(void); // Test 4
  146. int CreateNewClassesInTestNamespace(void); // Test 5
  147. int DeleteAndRecreateNewClassesInTestNamespace(void); // Test 6
  148. int CreateSimpleAssociations(); // Test 7
  149. int QueryAllClassesInTestNamespace(void); // Test 8
  150. /////////////////////////////////////////////////////////////////////////////////////////////
  151. //*******************************************************************************************
  152. //
  153. // Class definitions
  154. //
  155. //*******************************************************************************************
  156. /////////////////////////////////////////////////////////////////////////////////////////////
  157. class CVARIANTEx : public CVARIANT
  158. {
  159. public:
  160. CVARIANTEx() {}
  161. CVARIANTEx(const WCHAR * pSrc) { VariantInit(&v); SetStr(pSrc); }
  162. ~CVARIANTEx() {}
  163. void SetStr(const WCHAR * pSrc)
  164. { Clear(); V_VT(&v) = pSrc ? VT_BSTR : VT_NULL;
  165. V_BSTR(&v) = pSrc ? SysAllocString(pSrc) : 0;
  166. }
  167. };
  168. class CCriticalSection
  169. {
  170. public:
  171. CCriticalSection() { Init(); }
  172. ~CCriticalSection() { Delete(); }
  173. inline void Init() { InitializeCriticalSection(&m_criticalsection); }
  174. inline void Delete() { DeleteCriticalSection(&m_criticalsection); }
  175. inline void Enter() { EnterCriticalSection(&m_criticalsection); }
  176. inline void Leave() { LeaveCriticalSection(&m_criticalsection); }
  177. private:
  178. CRITICAL_SECTION m_criticalsection; // standby critical section
  179. };
  180. /////////////////////////////////////////////////////////////////////////////////////////////
  181. class CAutoBlock
  182. {
  183. private:
  184. CCriticalSection *m_pCriticalSection;
  185. public:
  186. CAutoBlock(CCriticalSection *pCriticalSection)
  187. {
  188. m_pCriticalSection = NULL;
  189. if(pCriticalSection)
  190. {
  191. pCriticalSection->Enter();
  192. }
  193. m_pCriticalSection = pCriticalSection;
  194. }
  195. ~CAutoBlock()
  196. {
  197. if(m_pCriticalSection)
  198. m_pCriticalSection->Leave();
  199. }
  200. };
  201. /////////////////////////////////////////////////////////////////////////////////////////////
  202. #include "bvtutil.h"
  203. #include "bvtcom.h"
  204. #include "bvtapi.h"
  205. /////////////////////////////////////////////////////////////////////////////////////////////
  206. //*******************************************************************************************
  207. //
  208. // Global Variables
  209. //
  210. //*******************************************************************************************
  211. /////////////////////////////////////////////////////////////////////////////////////////////
  212. #ifndef DECLARE_GLOBALS
  213. extern CLogAndDisplayOnScreen g_LogFile;
  214. extern CIniFileAndGlobalOptions g_Options;
  215. extern g_nDefaultTests[];
  216. #else
  217. CLogAndDisplayOnScreen g_LogFile;
  218. CIniFileAndGlobalOptions g_Options;
  219. int g_nDefaultTests[] = {1,2,3,4,5,6,7,8,9,10};
  220. #endif
  221. #endif