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.

121 lines
2.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: preinit.cxx
  7. //
  8. // Contents: Pre-initialization memory allocation tests
  9. //
  10. // Functions: TestPreInit
  11. //
  12. // History: 24-Jan-94 CarlH Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #include "memtest.hxx"
  16. #pragma hdrstop
  17. static char g_szPreInit[] = "preinit";
  18. // WARNING: Do not just start whacking on the elements of this
  19. // array. The third element of each structure may hold
  20. // the index of another entry in the array. If elements
  21. // are inserted, these indices may get hosed!
  22. //
  23. static SMemTask g_amemtskPreInitialize[] =
  24. {
  25. {memopAlloc, 128, 0, S_OK},
  26. {memopFree, 0, 0, S_OK},
  27. {memopAlloc, 12, 0, S_OK},
  28. {memopAlloc, 1423, 0, S_OK},
  29. {memopFree, 0, 2, S_OK},
  30. {memopAlloc, 12, 0, S_OK},
  31. {memopFree, 0, 3, S_OK},
  32. {memopFree, 0, 5, S_OK}
  33. };
  34. static ULONG g_cmemtskPreInitialize =
  35. sizeof(g_amemtskPreInitialize) / sizeof(g_amemtskPreInitialize[0]);
  36. BOOL TestGetAllocator(DWORD grfOptions);
  37. BOOL TestPreInitialize(DWORD grfOptions);
  38. //+-------------------------------------------------------------------------
  39. //
  40. // Function: TestPreInitialize, public
  41. //
  42. // Synopsis: Tests pre-initialization memory allocation functionality
  43. //
  44. // Arguments: [grfOptions] - options for test
  45. //
  46. // Returns: TRUE if successful, FALSE otherwise
  47. //
  48. // History: 24-Jan-94 CarlH Created
  49. //
  50. //--------------------------------------------------------------------------
  51. BOOL TestPreInit(DWORD grfOptions)
  52. {
  53. BOOL fPassed;
  54. PrintHeader(g_szPreInit);
  55. if (!(fPassed = TestGetAllocator(grfOptions)))
  56. goto done;
  57. if (!(fPassed = TestPreInitialize(grfOptions)))
  58. goto done;
  59. done:
  60. PrintResult(g_szPreInit, fPassed);
  61. return (fPassed);
  62. }
  63. BOOL TestGetAllocator(DWORD grfOptions)
  64. {
  65. IMalloc *pmalloc;
  66. HRESULT hr;
  67. BOOL fPassed;
  68. PrintTrace(g_szPreInit, "testing default allocator\n");
  69. hr = CoGetMalloc(MEMCTX_TASK, &pmalloc);
  70. if (fPassed = SUCCEEDED(hr))
  71. {
  72. pmalloc->Release();
  73. }
  74. return (fPassed);
  75. }
  76. //+-------------------------------------------------------------------------
  77. //
  78. // Function: TestPreInitialize, public
  79. //
  80. // Synopsis: Tests standard memory allocation routines
  81. //
  82. // Arguments: [grfOptions] - options for test
  83. //
  84. // Returns: TRUE if successful, FALSE otherwise
  85. //
  86. // History: 24-Jan-94 CarlH Created
  87. //
  88. //--------------------------------------------------------------------------
  89. BOOL TestPreInitialize(DWORD grfOptions)
  90. {
  91. PrintTrace(g_szPreInit, "testing standard allocations\n");
  92. return (
  93. RunMemoryTasks(
  94. g_szPreInit,
  95. g_amemtskPreInitialize,
  96. g_cmemtskPreInitialize));
  97. }