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.

233 lines
11 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // BVTCIMv2.CPP
  4. //
  5. //
  6. // Copyright (c)2000 Microsoft Corporation, All Rights Reserved
  7. //
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. #include <bvt.h>
  10. #define NO_ERRORS_EXPECTED FALSE,__FILE__,__LINE__
  11. #define ERRORS_CAN_BE_EXPECTED TRUE,__FILE__,__LINE__
  12. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  13. //*****************************************************************************************************************
  14. // Test 200
  15. //*****************************************************************************************************************
  16. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  17. int CIMV2_OpenNamespace()
  18. {
  19. //==========================================================================
  20. // Open CIMV2 namespace
  21. //==========================================================================
  22. int nRc = FATAL_ERROR;
  23. IWbemServices * pNamespace = NULL;
  24. CHString sNamespace;
  25. if( g_Options.GetSpecificOptionForAPITest(L"NAMESPACE",sNamespace, 200) )
  26. {
  27. // =====================================================================
  28. // Open the namespace
  29. // =====================================================================
  30. nRc = OpenNamespaceAndKeepOpen( &pNamespace, WPTR sNamespace,FALSE,fCompareResults);
  31. // =====================================================================
  32. // Release the pointers
  33. // =====================================================================
  34. SAFE_RELEASE_PTR(pNamespace);
  35. }
  36. return nRc;
  37. }
  38. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  39. //*****************************************************************************************************************
  40. // Test 201
  41. //*****************************************************************************************************************
  42. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  43. int CIMV2_EnumerateClasses()
  44. {
  45. int nRc = FATAL_ERROR;
  46. //==========================================================================
  47. // Get class enumerator for the namespace to get list of classes
  48. //==========================================================================
  49. CHString sNamespace;
  50. if( g_Options.GetSpecificOptionForAPITest(L"NAMESPACE",sNamespace, 200) )
  51. {
  52. IWbemServices * pNamespace = NULL;
  53. // =====================================================================
  54. // Open the namespace
  55. // =====================================================================
  56. nRc = OpenNamespaceAndKeepOpen( &pNamespace, WPTR sNamespace,FALSE,fCompareResults);
  57. if( SUCCESS == nRc )
  58. {
  59. // =============================================================
  60. // Get the list of classes to make sure they are in namespace
  61. // =============================================================
  62. CHString sClassesToCompare;
  63. if( g_Options.GetSpecificOptionForAPITest( L"NAMESPACE",sClassesToCompare, 201 ) )
  64. {
  65. // =========================================================
  66. // Make sure those classes are in the namespace
  67. // =========================================================
  68. nRc = EnumerateClassesAndCompare(sClassesToCompare, 201,pNamespace, (WCHAR*)((const WCHAR*)sNamespace));
  69. }
  70. }
  71. // =====================================================================
  72. // Release the pointers
  73. // =====================================================================
  74. SAFE_RELEASE_PTR(pNamespace);
  75. }
  76. return nRc;
  77. }
  78. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  79. //*****************************************************************************************************************
  80. // Test 202
  81. //*****************************************************************************************************************
  82. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  83. int CIMV2_EnumerateInstances()
  84. {
  85. int nRc = FATAL_ERROR;
  86. //==========================================================================
  87. // Get instance enumerator for classes Win32_logicalDisk, Win32_Process
  88. //==========================================================================
  89. IWbemServices * pNamespace = NULL;
  90. CHString sNamespace;
  91. if( g_Options.GetSpecificOptionForAPITest(L"NAMESPACE",sNamespace, 200) )
  92. {
  93. IWbemServices * pNamespace = NULL;
  94. // =====================================================================
  95. // Open the namespace
  96. // =====================================================================
  97. nRc = OpenNamespaceAndKeepOpen( &pNamespace, sNamespace,FALSE,fCompareResults);
  98. if( SUCCESS == nRc )
  99. {
  100. // =============================================================
  101. // Get the list of classes to get instances for
  102. // =============================================================
  103. CHString sInstanceList;
  104. CHString sInstanceCompareList;
  105. if( g_Options.GetSpecificOptionForAPITest( L"INSTANCES",sInstanceList, 202 ) )
  106. {
  107. // =========================================================
  108. // Get the enumeration flags
  109. // =========================================================
  110. ItemList FlagList;
  111. nRc = GetFlags(202, FlagList);
  112. if( SUCCESS == nRc )
  113. {
  114. for( int i = 0; i < FlagList.Size(); i++ )
  115. {
  116. ItemInfo * p = FlagList.GetAt(i);
  117. // ===================================================
  118. // Make sure those instances are in the namespace
  119. // ===================================================
  120. nRc = GetInstanceAndCompare(pNamespace, p->dwFlags, sInstanceList, 202, (WCHAR*)((const WCHAR*) sNamespace));
  121. }
  122. }
  123. }
  124. }
  125. // =====================================================================
  126. // Release the pointers
  127. // =====================================================================
  128. SAFE_RELEASE_PTR(pNamespace);
  129. }
  130. return nRc;
  131. }
  132. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  133. //*****************************************************************************************************************
  134. // Test 203
  135. //*****************************************************************************************************************
  136. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  137. int CIMV2_GetObjects()
  138. {
  139. int nRc = FATAL_ERROR;
  140. //==========================================================================
  141. // Get classes/instances using path of the object
  142. //==========================================================================
  143. CHString sNamespace;
  144. if( g_Options.GetSpecificOptionForAPITest(L"NAMESPACE",sNamespace, 203) )
  145. {
  146. IWbemServices * pNamespace = NULL;
  147. // =====================================================================
  148. // Open the namespace
  149. // =====================================================================
  150. nRc = OpenNamespaceAndKeepOpen( &pNamespace, sNamespace,FALSE,fCompareResults);
  151. if( SUCCESS == nRc )
  152. {
  153. // =============================================================
  154. // Get the list of objexts to get
  155. // =============================================================
  156. CHString sObjects;
  157. if( g_Options.GetSpecificOptionForAPITest(L"LIST", sObjects, 203 ) )
  158. {
  159. // =========================================================
  160. // Get the requested objects
  161. // =========================================================
  162. nRc = GetSpecificObjects(sObjects, pNamespace, 203, (WCHAR*)((const WCHAR*)sNamespace));
  163. }
  164. }
  165. // =====================================================================
  166. // Release the pointers
  167. // =====================================================================
  168. SAFE_RELEASE_PTR(pNamespace);
  169. }
  170. return nRc;
  171. }
  172. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  173. //*****************************************************************************************************************
  174. // Test 204
  175. //*****************************************************************************************************************
  176. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  177. int CIMV2_ExecuteQueries()
  178. {
  179. int nRc = FATAL_ERROR;
  180. // Execute Association/Reference queries
  181. return nRc;
  182. }
  183. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  184. //*****************************************************************************************************************
  185. // Test 205
  186. //*****************************************************************************************************************
  187. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  188. int CIMV2_EnumerateClassAMethods()
  189. {
  190. int nRc = FATAL_ERROR;
  191. // Enumerate methods for a class/instance.
  192. return nRc;
  193. }
  194. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  195. //*****************************************************************************************************************
  196. // Test 206
  197. //*****************************************************************************************************************
  198. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  199. int CIMV2_EnumerateInstanceMethods()
  200. {
  201. int nRc = FATAL_ERROR;
  202. // Enumerate methods for a class/instance.
  203. return nRc;
  204. }
  205. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  206. //*****************************************************************************************************************
  207. // Test 207
  208. //*****************************************************************************************************************
  209. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  210. int CIMV2_ExecuteMethod()
  211. {
  212. int nRc = FATAL_ERROR;
  213. // Execute a method on one of the instance say Terminate method on Win32_process and check if the instance is removed.
  214. return nRc;
  215. }