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.

281 lines
6.9 KiB

  1. '////////////////////////////////////////////////////////////////////////////
  2. '
  3. ' Copyright (c) 1999-2000 Microsoft Corp. All Rights Reserved.
  4. '
  5. ' File name:
  6. '
  7. ' test.vbs
  8. '
  9. ' Abstract:
  10. '
  11. ' Windows Embedded Prototype Script for Printers
  12. '
  13. ' Remarks:
  14. '
  15. ' This file tests dependency mapping functionality
  16. '
  17. ' Author:
  18. '
  19. ' Larry Zhu (lzhu) 11-29-2000
  20. '
  21. '////////////////////////////////////////////////////////////////////////////
  22. 'Option Explicit
  23. ' fake cmi global variables so test.vbs can execute standalone
  24. Public cmiInclude: cmiInclude = 0
  25. Public cmiExactlyOne: cmiExactlyOne = 1
  26. ' this function tests one test case
  27. Function DependencyMappingTestOne(files(), componentIDs)
  28. initializeTables ' safe to call it more than once
  29. Dim componentFlagArray()
  30. ReDim componentFlagArray(g_nComponents - 1)
  31. ' initialize componentFlagArray
  32. initComponentFlagArray componentFlagArray
  33. If Not isValid(componentFlagArray) Then
  34. DependencyMappingTestOne = False
  35. Exit Function
  36. End If
  37. ' now map all the files
  38. Dim bIgnore: bIgnore = False
  39. Dim i
  40. For i = 0 To UBound(files)
  41. bIgnore = MapIt(files(i), componentFlagArray)
  42. WScript.Echo "Mapping " & files(i) & " ... mapped? " & bIgnore
  43. Next
  44. ' check if the mapping is correct
  45. For i = 0 To UBound(componentIDs)
  46. If Not componentFlagArray(componentIDs(i)) Then
  47. WScript.Echo "Wrong Component Mapped"
  48. DependencyMappingTestOne = False
  49. Exit Function
  50. End If
  51. componentFlagArray(componentIDs(i)) = False
  52. Next
  53. For i = 0 To UBound(componentFlagArray)
  54. If componentFlagArray(i) Then
  55. WScript.Echo "Extra Component Mapped"
  56. DependencyMappingTestOne = False
  57. Exit Function
  58. End If
  59. Next
  60. DependencyMappingTestOne = True
  61. End Function
  62. ' this sub tests all the test cases and prints a "Success" when it succeedes
  63. Sub DependencyMappingTest()
  64. Dim bSuccess: bSuccess = False
  65. Dim files()
  66. Dim componentIDs()
  67. ' test case one
  68. WScript.Echo "'''''''''''''''''''' Test case one '''''''''''''''''''''''"
  69. ReDim files(0)
  70. files(0) = "pscript5.dll"
  71. ReDim componentIDs(0)
  72. componentIDs(0) = 0
  73. bSuccess = DependencyMappingTestOne(files, componentIDs)
  74. If Not bSuccess Then
  75. WScript.Echo " Failed "
  76. Exit Sub
  77. End If
  78. ' test case two
  79. WScript.Echo "'''''''''''''''''''' Test case two '''''''''''''''''''''''"
  80. ReDim files(3)
  81. files(0) = "pscript5.dll"
  82. files(1) = "ps5ui.dll"
  83. files(2) = "localspl.dll"
  84. files(3) = "pscript5.ntf"
  85. ReDim componentIDs(0)
  86. componentIDs(0) = 0
  87. bSuccess = DependencyMappingTestOne(files, componentIDs)
  88. If Not bSuccess Then
  89. WScript.Echo " Failed "
  90. Exit Sub
  91. End If
  92. ' test case three
  93. WScript.Echo "'''''''''''''''''''' Test case three '''''''''''''''''''''''"
  94. ReDim files(3)
  95. files(0) = "pscript5.dll"
  96. files(1) = "ps5ui.dll"
  97. files(2) = "unidrv.dll"
  98. files(3) = "pscript5.ntf"
  99. ReDim componentIDs(1)
  100. componentIDs(0) = 0
  101. componentIDs(1) = 1
  102. bSuccess = DependencyMappingTestOne(files, componentIDs)
  103. If Not bSuccess Then
  104. WScript.Echo " Failed "
  105. Exit Sub
  106. End If
  107. ' test case four
  108. WScript.Echo "'''''''''''''''''''' Test case four '''''''''''''''''''''''"
  109. ReDim files(3)
  110. files(0) = "pscript5.dll"
  111. files(1) = "ps5ui.dll"
  112. files(2) = "unidrv.dll"
  113. files(3) = "pscript5.ntf"
  114. ReDim componentIDs(1)
  115. componentIDs(0) = 0
  116. componentIDs(1) = 1
  117. bSuccess = DependencyMappingTestOne(files, componentIDs)
  118. If Not bSuccess Then
  119. WScript.Echo " Failed "
  120. Exit Sub
  121. End If
  122. ' test case five
  123. WScript.Echo "'''''''''''''''''''' Test case five '''''''''''''''''''''''"
  124. ReDim files(3)
  125. files(0) = "pscript5.dll"
  126. files(1) = "ps5ui.dll"
  127. files(2) = "plotter.dll"
  128. files(3) = "pscript5.ntf"
  129. ReDim componentIDs(1)
  130. componentIDs(0) = 0
  131. componentIDs(1) = 2
  132. bSuccess = DependencyMappingTestOne(files, componentIDs)
  133. If Not bSuccess Then
  134. WScript.Echo " Failed "
  135. Exit Sub
  136. End If
  137. ' test case six
  138. WScript.Echo "'''''''''''''''''''' Test case six '''''''''''''''''''''''"
  139. ReDim files(6)
  140. files(0) = "pscript5.dll"
  141. files(1) = "ps5ui.dll"
  142. files(2) = "uniDrv.dll"
  143. files(3) = "unidRVUi.dll"
  144. files(4) = "plotui.dll"
  145. files(5) = "csrspl.dll"
  146. files(6) = "plotter.dll"
  147. ReDim componentIDs(2)
  148. componentIDs(0) = 0
  149. componentIDs(1) = 1
  150. componentIDs(2) = 2
  151. bSuccess = DependencyMappingTestOne(files, componentIDs)
  152. If Not bSuccess Then
  153. WScript.Echo " Failed "
  154. Exit Sub
  155. End If
  156. '''''''''''''''''''''''''''''''''''''''''''''''''''''
  157. ' fail cases
  158. '''''''''''''''''''''''''''''''''''''''''''''''''''''
  159. ' test case 1
  160. WScript.Echo "'''''''''''''''''''' failed case 1 '''''''''''''''''''''''"
  161. ReDim files(3)
  162. files(0) = "pscript5.dll"
  163. files(1) = "ps5ui.dll"
  164. files(2) = "ploTTER.dll"
  165. files(3) = "pscript5.ntf"
  166. ReDim componentIDs(1)
  167. componentIDs(0) = 0
  168. componentIDs(1) = 1 ' wrong component
  169. bSuccess = DependencyMappingTestOne(files, componentIDs)
  170. If bSuccess Then ' shall fail
  171. Debug.Print " Failed "
  172. Exit Sub
  173. End If
  174. ' test case 2
  175. WScript.Echo "'''''''''''''''''''' failed case 2 '''''''''''''''''''''''"
  176. ReDim files(3)
  177. files(0) = "pscript5.dll"
  178. files(1) = "ps5ui.dll"
  179. files(2) = "plotter.dll"
  180. files(3) = "pscript5.ntf"
  181. ReDim componentIDs(0)
  182. componentIDs(0) = 0
  183. bSuccess = DependencyMappingTestOne(files, componentIDs)
  184. If bSuccess Then ' shall fail
  185. WScript.Echo " Failed "
  186. Exit Sub
  187. End If
  188. ' test case 3
  189. WScript.Echo "'''''''''''''''''''' failed case 3 '''''''''''''''''''''''"
  190. ReDim files(3)
  191. files(0) = "pscript5.dll"
  192. files(1) = "ps5ui.dll"
  193. files(2) = "plotter.dll"
  194. files(3) = "pscript5.ntf"
  195. ReDim componentIDs(0)
  196. componentIDs(0) = 2
  197. bSuccess = DependencyMappingTestOne(files, componentIDs)
  198. If bSuccess Then ' shall fail
  199. WScript.Echo " Failed "
  200. Exit Sub
  201. End If
  202. ' declare success
  203. WScript.Echo "'''''''''''''''''''' The End '''''''''''''''''''''''"
  204. WScript.Echo " Success "
  205. End Sub
  206. ' run the test
  207. DependencyMappingTest