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.

467 lines
19 KiB

  1. //-------------------------------------------------------------------------
  2. //
  3. // Microsoft OLE
  4. // Copyright (C) Microsoft Corporation, 1994 - 1995.
  5. //
  6. // File: init.hxx
  7. //
  8. // Contents: Contains data structures, defines, function prototypes for
  9. // storage base tests.
  10. //
  11. // History: 2-May-96 NarindK Created
  12. //
  13. //--------------------------------------------------------------------------
  14. #ifndef __INIT_HXX__
  15. #define __INIT_HXX__
  16. #include <debdlg.h>
  17. #include <math.h>
  18. #include <direct.h>
  19. // Utility functons
  20. HRESULT RunTestAltPath (int argc, char *argv[],
  21. HRESULT (*pfnTestFunc) (int argc, char*argv[], LPTSTR ptAltPath));
  22. HRESULT RunTest(int argc, char *argv[]) ;
  23. ULONG CountFilesInDirectory(LPTSTR ptszWildMask);
  24. HRESULT GetRandomSeekOffset(LONG *plSeekPosition, DG_INTEGER *pdgi);
  25. HRESULT SetItemsInStorage(VirtualCtrNode *pvcn, DG_INTEGER *pdgi);
  26. BOOL CompareSTATSTG(STATSTG sstg1, STATSTG sstg2);
  27. ULONG GetSeedFromCmdLineArgs(int argc, char *argv[]);
  28. HRESULT EnumerateDocFileInRandomChunks(
  29. VirtualCtrNode *pvcn,
  30. DG_INTEGER *pdgi,
  31. DWORD dwStgMode,
  32. ULONG uNumObjs,
  33. ULONG *pNumStg,
  34. ULONG *pNumStm );
  35. HRESULT EnumerateDocFileAndVerifyEnumCloneResetSkipNext(
  36. VirtualCtrNode *pvcn,
  37. DWORD dwStgMode,
  38. ULONG uNumObjs,
  39. ULONG *pNumStg,
  40. ULONG *pNumStm );
  41. HRESULT ModifyDocFile(
  42. VirtualDF *pVirtualDF,
  43. VirtualCtrNode *pvcn,
  44. DG_INTEGER *pdgi,
  45. DG_STRING *pdgu,
  46. DWORD dwStgMode,
  47. BOOL fCommitDocFile);
  48. HRESULT EnumerateAndWalkDocFile(
  49. VirtualCtrNode *pvcn,
  50. DG_INTEGER *pdgi,
  51. DWORD dwStgMode,
  52. ULONG uNumObjs);
  53. HRESULT CreateNewObject(
  54. LPSTORAGE pIStorage,
  55. DWORD dwStgMode,
  56. DG_INTEGER *pdgi,
  57. DG_STRING *pdgu);
  58. HRESULT ChangeStreamData(
  59. LPSTORAGE pIStorage,
  60. STATSTG *pStatStg,
  61. DG_INTEGER *pdgi,
  62. DG_STRING *pdgu);
  63. HRESULT ChangeExistingObject(
  64. LPSTORAGE pIStorage,
  65. STATSTG *pStatStg,
  66. DG_INTEGER *pdgi,
  67. DG_STRING *pdgu,
  68. BOOL fStgDeleted);
  69. HRESULT EnumerateAndProcessIStorage(
  70. LPSTORAGE pIStorage,
  71. DWORD dwStgMode,
  72. DG_INTEGER *pdgi,
  73. DG_STRING *pdgu);
  74. HRESULT IsEqualStream(
  75. IStream *pIOrigional,
  76. IStream *pICompare);
  77. HRESULT ILockBytesWriteTest(
  78. ILockBytes * pILockBytes,
  79. DWORD dwSeed,
  80. DWORD dwSize);
  81. HRESULT ILockBytesReadTest(
  82. ILockBytes *pILockBytes,
  83. DWORD dwSize);
  84. HRESULT IStreamWriteTest(
  85. IStream *pIStream,
  86. DWORD dwSeed,
  87. DWORD dwSize);
  88. HRESULT IStreamReadTest(
  89. IStream *pIStream,
  90. DWORD dwSize);
  91. HRESULT TraverseDocfileAndWriteOrReadSNB(
  92. VirtualCtrNode *pvcn,
  93. DG_INTEGER *pdgi,
  94. DG_STRING *pdgu,
  95. DWORD dwStgMode,
  96. SNB snbNamesToExclude,
  97. BOOL fIllegitFlag,
  98. BOOL fSelectObjectsToExclude);
  99. LONG DiffTime(DWORD EndTime, DWORD StartTime);
  100. HRESULT StreamCreate(
  101. DWORD dwRootMode,
  102. DG_STRING *pdgu,
  103. USHORT usTimeIndex,
  104. DWORD dwFlags,
  105. USHORT usNumCreates);
  106. HRESULT DocfileCreate(
  107. DWORD dwRootMode,
  108. DG_STRING *pdgu,
  109. USHORT usTimeIndex,
  110. DWORD dwFlags,
  111. USHORT usNumCreates);
  112. HRESULT StreamOpen(
  113. DWORD dwRootMode,
  114. DG_STRING *pdgu,
  115. USHORT usTimeIndex,
  116. DWORD dwFlags,
  117. USHORT usNumOpens);
  118. HRESULT WriteStreamInSameSizeChunks(
  119. DWORD dwRootMode,
  120. DG_STRING *pdgu,
  121. USHORT usTimeIndex,
  122. DWORD dwFlags,
  123. ULONG ulChunkSize,
  124. USHORT usIteration);
  125. HRESULT ReadStreamInSameSizeChunks(
  126. DWORD dwRootMode,
  127. USHORT usTimeIndex,
  128. DWORD dwFlags,
  129. ULONG ulChunkSize,
  130. USHORT usIteration);
  131. void Statistics(
  132. LONG *plData,
  133. USHORT usItems,
  134. LONG *plAverage,
  135. double *pdTotal,
  136. double *pdSD);
  137. void Statistics(
  138. double *pdData,
  139. USHORT usItems,
  140. double *pdAverage,
  141. double *pdTotal,
  142. double *pdSD);
  143. HRESULT CreateTestDocfile (
  144. int argc,
  145. char **argv,
  146. VirtualCtrNode **ppVirtualDFRoot,
  147. VirtualDF **ppTestVirtualDF,
  148. ChanceDF **ppTestChanceDF);
  149. HRESULT CreateTestDocfile (
  150. CDFD *pcdfd,
  151. LPTSTR pFileName,
  152. VirtualCtrNode **ppVirtualDFRoot,
  153. VirtualDF **ppTestVirtualDF,
  154. ChanceDF **ppTestChanceDF);
  155. HRESULT CleanupTestDocfile (
  156. VirtualCtrNode **ppVirtualDFRoot,
  157. VirtualDF **ppTestVirtualDF,
  158. ChanceDF **ppTestChanceDF,
  159. BOOL fDeleteFile=TRUE);
  160. // some osversion inline util funcs.
  161. // NTMAJVER - return major version number for NT. 0 for non-WinNT.
  162. inline DWORD NTMAJVER()
  163. {
  164. OSVERSIONINFO osver = {sizeof (OSVERSIONINFO),0, 0, 0, 0};
  165. GetVersionEx (&osver);
  166. if (osver.dwPlatformId != VER_PLATFORM_WIN32_NT)
  167. {
  168. return 0;
  169. }
  170. return osver.dwMajorVersion;
  171. }
  172. //RunningOnNT - returns TRUE/FALSE if running on WinNT.
  173. inline BOOL RunningOnNT()
  174. {
  175. OSVERSIONINFO osver = {sizeof (OSVERSIONINFO),0, 0, 0, 0};
  176. GetVersionEx (&osver);
  177. return (osver.dwPlatformId == VER_PLATFORM_WIN32_NT ? TRUE : FALSE);
  178. }
  179. // COMTEST Tests
  180. HRESULT COMTEST_100(int argc, char *argv[]) ; // Old Name: MiscAddrefTest
  181. HRESULT COMTEST_101(int argc, char *argv[]) ; // Old Name: DfTest
  182. HRESULT COMTEST_102(int argc, char *argv[]) ; // Old Name:IllegitInstEnumNormal
  183. HRESULT COMTEST_103(int argc, char *argv[]) ; // Old Name:LegitInstEnumNormal
  184. HRESULT COMTEST_104(int argc, char *argv[]) ; // Old Name:Part of IStorage_Test
  185. HRESULT COMTEST_105(int argc, char *argv[]) ;
  186. HRESULT COMTEST_106(int argc, char *argv[]) ;
  187. // DFTEST Tests
  188. HRESULT DFTEST_100(int argc, char *argv[]) ; // Old Name:LegitRootNormal
  189. HRESULT DFTEST_101(int argc, char *argv[]) ; // Old Name:DFREMOVE
  190. HRESULT DFTEST_102(int argc, char *argv[]) ; // Old Name:TransactedCommitTest
  191. HRESULT DFTEST_103(ULONG ulSeed) ; // Old Name:DFTESTN
  192. HRESULT DFTEST_104(int argc, char *argv[]) ; // Old Name:MiscDfVerify
  193. HRESULT DFTEST_105(int argc, char *argv[]) ; // Old Name:IllegitInstEnumRelease
  194. HRESULT DFTEST_106(int argc, char *argv[]) ; // Old Name:IllegitRootCreate
  195. HRESULT DFTEST_107(ULONG ulSeed) ; // Old Name:TestStdDocFile
  196. HRESULT DFTEST_108(ULONG ulSeed) ; // Old Name: -none-
  197. HRESULT DFTEST_109(ULONG ulSeed) ; // Old Name: -none-
  198. // APITEST Tests
  199. HRESULT APITEST_100(int argc, char *argv[]) ; // Old Name: IllegitAPIStg test
  200. HRESULT APITEST_101(int argc, char *argv[]) ; // Old Name: IllegitAPINames test
  201. HRESULT APITEST_102(int argc, char *argv[]) ; // Old Name: IllegitAPIEnum test
  202. HRESULT APITEST_103(int argc, char *argv[]) ; // Old Name:IllegitAPIStorage test
  203. HRESULT APITEST_104(int argc, char *argv[]) ; // Old Name:IllegitAPIStream test
  204. // Test new apis on NT5
  205. HRESULT APITEST_200(int argc, char *argv[]) ;
  206. HRESULT APITEST_201(int argc, char *argv[]) ;
  207. HRESULT APITEST_202(int argc, char *argv[]) ;
  208. HRESULT APITEST_203(int argc, char *argv[]) ;
  209. HRESULT APITEST_204(int argc, char *argv[]) ;
  210. // ROOTTEST Tests
  211. HRESULT ROOTTEST_100(int argc, char *argv[]) ; // Old Name: LegitRootCovert
  212. HRESULT ROOTTEST_101(int argc, char *argv[]) ; // Old Name: LegitRootNull
  213. HRESULT ROOTTEST_102(int argc, char *argv[]) ; // Old Name: LegitRootNormal
  214. HRESULT ROOTTEST_103(int argc, char *argv[]) ; // Old Name: LegitRootMultAccess
  215. HRESULT ROOTTEST_104(int argc, char *argv[]) ; //Old Name:LegitRootTwwDenyWrite
  216. // STMTEST Tests
  217. HRESULT STMTEST_100(int argc, char *argv[]) ; // Old Name: LegitStreamChange
  218. HRESULT STMTEST_101(int argc, char *argv[]) ; // Old Name: LegitStreamClone
  219. HRESULT STMTEST_102(int argc, char *argv[]) ; // Old Name: LegitStreamSetSize
  220. HRESULT STMTEST_103(int argc, char *argv[]) ; // Old Name: LegitStreamRead
  221. HRESULT STMTEST_104(int argc, char *argv[]) ; // Old Name: LegitStreamSeek
  222. HRESULT STMTEST_105(int argc, char *argv[]) ;
  223. // Old Name: LegitStreamSetSizeAbandon
  224. HRESULT STMTEST_106(int argc, char *argv[]) ; // Old Name: LegitStreamSectorSpan
  225. HRESULT STMTEST_107(int argc, char *argv[]) ; // Old Name: IllegitStreamNorm
  226. HRESULT STMTEST_108(int argc, char *argv[]) ;
  227. // Old Name: LegitStreamSmallObjects
  228. HRESULT STMTEST_109(int argc, char *argv[]) ; // Old name:-part of ole32\common
  229. // STGTEST Tests
  230. HRESULT STGTEST_100(int argc, char *argv[]) ; // Old Name: MiscCommitRelease
  231. HRESULT STGTEST_101(int argc, char *argv[]) ; // Old Name: MiscSetItems
  232. HRESULT STGTEST_102(int argc, char *argv[]) ; // Old Name: IllegitRenDest
  233. HRESULT STGTEST_103(int argc, char *argv[]) ; // Old Name: legitRenDestNormal
  234. HRESULT STGTEST_104(int argc, char *argv[]) ; // Old Name: legitRenDestSwap
  235. HRESULT STGTEST_105(int argc, char *argv[]) ; // Old Name: LegitMoveDFToRootDF
  236. HRESULT STGTEST_106(ULONG ulSeed) ; //Old Name:LegitInstRootTwwDenyWrite
  237. HRESULT STGTEST_107(int argc, char *argv[]) ; //Old Name: Part fm IStorage_Test
  238. HRESULT STGTEST_108(int argc, char *argv[]) ; //Old Name: Part fm IStorage_Test
  239. HRESULT STGTEST_109(int argc, char *argv[]) ; //Old Name: TestStgSetTime
  240. HRESULT STGTEST_110(int argc, char *argv[]) ; //Old Name: -none-
  241. // Valid CopyTo tests
  242. HRESULT VCPYTEST_100(int argc, char *argv[]) ;
  243. //Old Name:LegitCopyChildDFToParentDF
  244. HRESULT VCPYTEST_101(int argc, char *argv[]) ;
  245. //Old Name:LegitCopyChildDFwithinParent
  246. HRESULT VCPYTEST_102(int argc, char *argv[]) ;
  247. //Old Name:LegitCopyGrandChildDFToAncestor
  248. HRESULT VCPYTEST_103(int argc, char *argv[]) ;
  249. //Old Name:LegitCopyGrandChildDFWithInAncestor
  250. HRESULT VCPYTEST_104(int argc, char *argv[]) ;//Old Name:LegitCopyDFToRootDF
  251. HRESULT VCPYTEST_105(int argc, char *argv[]) ;//Old Name:LegitCopyDFWithinNewPar
  252. HRESULT VCPYTEST_106(int argc, char *argv[]) ;//Old Name:LegitCopyStream
  253. // Invalid CopyTo tests
  254. HRESULT IVCPYTEST_100(int argc, char *argv[]) ;
  255. //Old Name:IllegitCopyParentInvalid
  256. HRESULT IVCPYTEST_101(int argc, char *argv[]) ;
  257. //Old Name:IllegitCopyParentToChild
  258. // Enumerator tests
  259. HRESULT ENUMTEST_100(int argc, char *argv[]) ; // OldName:LegitInstEnumConvert
  260. HRESULT ENUMTEST_101(int argc, char *argv[]) ; // OldName:LegitInstEnumNext
  261. HRESULT ENUMTEST_102(int argc, char *argv[]) ; // OldName:LegitInstEnumSkip
  262. HRESULT ENUMTEST_103(int argc, char *argv[]) ; // OldName:LegitInstEnumIterMod
  263. HRESULT ENUMTEST_104(int argc, char *argv[]) ; // OldName:LegitInstEnumWalk
  264. // IRootStorage Interface tests
  265. HRESULT IROOTSTGTEST_100(int argc, char *argv[]) ;
  266. //OldName:LegitTransactedSaveAs
  267. HRESULT IROOTSTGTEST_101(int argc, char *argv[]) ;
  268. //OldName:LegitTransactedSaveAsBoth
  269. HRESULT IROOTSTGTEST_102(int argc, char *argv[]) ;
  270. //OldName:LegitTransactedSaveAsNew
  271. HRESULT IROOTSTGTEST_103(int argc, char *argv[]) ;
  272. //OldName:LegitTransactedSaveAsRevert
  273. // HGLOBAL Tests
  274. HRESULT HGLOBALTEST_100 (DWORD dwSeed); // OldName: TestILockBytesOnHGlobal
  275. HRESULT HGLOBALTEST_101 (DWORD dwSeed); // OldName: -none-
  276. HRESULT HGLOBALTEST_110 (DWORD dwSeed); // OldName: TestILockBytesOnHGlobal
  277. HRESULT HGLOBALTEST_120 (DWORD dwSeed); // OldName: TestIStreamOnHGlobal
  278. HRESULT HGLOBALTEST_121 (DWORD dwSeed); // OldName: -none-
  279. HRESULT HGLOBALTEST_130 (DWORD dwSeed); // OldName: TestIStreamOnHGlobal
  280. HRESULT HGLOBALTEST_140 (DWORD dwSeed);
  281. HRESULT HGLOBALTEST_150 (DWORD dwSeed);
  282. // SNB Limited tests
  283. HRESULT SNBTEST_100(int argc, char *argv[]) ;
  284. // OldName:IllegitLimitedInstNormal
  285. HRESULT SNBTEST_101(int argc, char *argv[]) ;
  286. // OldName:LegitLimitedInstNormal
  287. HRESULT SNBTEST_102(int argc, char *argv[]) ;
  288. // OldName:LegitLimitedInstPriority
  289. HRESULT SNBTEST_103(int argc, char *argv[]) ;
  290. // OldName:IllegitLimitedInstPriority
  291. // Miscellaneous Tests
  292. HRESULT MISCTEST_100(int argc, char *argv[]);
  293. // OldName:MiscMemLeak
  294. HRESULT MISCTEST_101(int argc, char *argv[]);
  295. // OldName:MiscWindowsForWorkGroupOpen
  296. HRESULT MISCTEST_102(int argc, char *argv[]);
  297. // OldName:PerformanceTiming
  298. HRESULT MISCTEST_103(int argc, char *argv[]);
  299. HRESULT MISCTEST_104(int argc, char *argv[]);
  300. HRESULT MISCTEST_105(int argc, char *argv[]);
  301. // ILockBytes test
  302. HRESULT ILKBTEST_100(int argc, char *argv[]) ; // OldName:DfSetupOnILockBytes
  303. HRESULT ILKBTEST_101(int argc, char *argv[]) ; // OldName:DfSetupOnILockBytes
  304. // Open Aync DocFile
  305. HRESULT ILKBTEST_102(int argc, char *argv[]) ; // OldName:
  306. // LegitTransactedCommitFail
  307. HRESULT ILKBTEST_103(int argc, char *argv[]) ; // OldName: -none-
  308. HRESULT ILKBTEST_104(int argc, char *argv[]) ; // OldName: -none-
  309. HRESULT ILKBTEST_105(int argc, char *argv[]) ; // OldName: -none-
  310. HRESULT ILKBTEST_106(int argc, char *argv[]) ; // OldName: -none-
  311. HRESULT ILKBTEST_107(int argc, char *argv[]) ; // OldName: -none-
  312. HRESULT ILKBTEST_108(ULONG ulSeed) ; // OldName: -none-
  313. // flatfile tests; NT5 only
  314. HRESULT FLATTEST_100(int argc, char *argv[]) ;
  315. HRESULT FLATTEST_101(int argc, char *argv[]) ;
  316. // Debug object
  317. DH_DECLARE;
  318. // extern globals (yuk)
  319. extern BOOL g_fDeleteTestDF;
  320. extern UINT g_uOpenCreateDF;
  321. // Defines
  322. #define MAX_STG_NAME_LEN (CWCSTORAGENAME * 2)
  323. #define STG_CONVERTED_NAME TEXT("CONTENTS")
  324. #define T TRUE
  325. #define F FALSE
  326. #define WILD_MASK TEXT("~DF*.TMP")
  327. #define MIN_SIZE 394000L
  328. #define RAND_IO_MIN 64000L
  329. #define RAND_IO_MAX 256000L
  330. #define MIN_STMSIZE 1024L
  331. #define MAX_STMSIZE 256000L
  332. #define MAXSIZEOFMINISTM 4096L
  333. #define ORIGINAL 0
  334. #define CLONE 1
  335. #define SEEK 1
  336. #define WRITE 2
  337. #define READ 3
  338. #define NONE 0
  339. #define STORAGE 1
  340. #define STREAM 2
  341. #define SOURCESTM 0
  342. #define DESTSTM 1
  343. #define CLONESTM 2
  344. #define BYTES_BEFORE 0
  345. #define BYTES_COPIED 1
  346. #define BYTES_AFTER 2
  347. #define MAX_SIZE_MULTIPLIER 5
  348. #define MAX_SIZE_ARRAY 14
  349. #define MAX_NAMES_TO_EXCLUDE 32
  350. #define HGLOBAL_PACKET_SIZE 4000 // In Bytes
  351. #define MIN_HGLOBAL_ITERATIONS 2
  352. #define MAX_HGLOBAL_ITERATIONS 4
  353. #define MIN_HGLOBAL_PACKETS 75
  354. #define MAX_HGLOBAL_PACKETS 200
  355. #define dwDefLowDateTime 0xBAD
  356. #define dwDefHighDateTime 0xBADBAD
  357. #define STGM_RW (STGM_READ | STGM_WRITE | STGM_READWRITE)
  358. #define STGM_SHARE (STGM_SHARE_DENY_NONE | STGM_SHARE_DENY_READ |\
  359. STGM_SHARE_DENY_WRITE | STGM_SHARE_EXCLUSIVE)
  360. #define TestUnsupportedInterface(pDocElement, Interface_Name, Interface, hr) \
  361. { \
  362. hr = pDocElement->Interface; \
  363. if(STG_E_INVALIDFUNCTION == hr) \
  364. { \
  365. DH_TRACE(( \
  366. DH_LVL_TRACE1, \
  367. TEXT("STG_E_INVALIDFUNCTION ret as exp for %s"), \
  368. Interface_Name)); \
  369. } \
  370. else \
  371. { \
  372. DH_TRACE(( \
  373. DH_LVL_ERROR, \
  374. TEXT("STG_E_INVALIDFUNCTION not ret as exp for %s, hr=0x%lx "),\
  375. Interface_Name, \
  376. hr)); \
  377. fPass = FALSE; \
  378. } \
  379. hr = S_OK; \
  380. }
  381. #define DoingCreate() ((FL_DISTRIB_CREATE == g_uOpenCreateDF) ? TRUE : FALSE)
  382. #define DoingDistrib() ((FL_DISTRIB_NONE != g_uOpenCreateDF) ? TRUE : FALSE)
  383. #define DeleteTestDF() ((g_fDeleteTestDF == TRUE) ? TRUE : FALSE)
  384. #define DOCFILE 1
  385. #define RUNTIME 2
  386. #define COMMIT 4
  387. #define EXIST 8
  388. #define CREATE 16
  389. #define NONAME 32
  390. #define OPENBOTH 64
  391. #define MAX_DOCFILES 5
  392. #define MAX_PATH_LENGTH 128
  393. enum Timings {
  394. FIRST_TIMING,
  395. CREATE_STREAM_NO_EXIST,
  396. CREATE_STREAM_EXIST,
  397. CREATE_DOCFILE_NO_EXIST,
  398. CREATE_DOCFILE_EXIST,
  399. CREATE_NONAME_DOCFILE,
  400. OPEN_STORAGE_AND_STREAM,
  401. OPEN_STREAM_ONLY,
  402. SEQUENTIAL_WRITE,
  403. SEQUENTIAL_READ,
  404. RANDOM_WRITE,
  405. RANDOM_READ,
  406. LAST_TIMING };
  407. typedef struct timeinfo
  408. {
  409. TCHAR *Text;
  410. USHORT usIndex;
  411. LONG *plDocfileTime;
  412. LONG *plRuntimeTime;
  413. } TIMEINFO;
  414. #define GET_TIME(x) (x = GetTickCount())
  415. #endif //__INIT_HXX__