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.

138 lines
3.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: memory.cxx
  7. //
  8. // Contents: Memory allocation tests
  9. //
  10. // Functions:
  11. //
  12. // History: 13-Aug-93 CarlH Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #include "memtest.hxx"
  16. #pragma hdrstop
  17. static char g_szMemory[] = "memory";
  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_amemtskStandard[] =
  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_cmemtskStandard =
  35. sizeof(g_amemtskStandard) / sizeof(g_amemtskStandard[0]);
  36. // WARNING: See warning on the above array definition.
  37. //
  38. static SMemTask g_amemtskMIDL[] =
  39. {
  40. {memopMIDLAlloc, 128, 0, S_OK},
  41. {memopMIDLFree, 0, 0, S_OK},
  42. {memopMIDLAlloc, 12, 0, S_OK},
  43. {memopMIDLAlloc, 1423, 0, S_OK},
  44. {memopMIDLFree, 0, 2, S_OK},
  45. {memopMIDLAlloc, 12, 0, S_OK},
  46. {memopMIDLFree, 0, 3, S_OK},
  47. {memopMIDLFree, 0, 5, S_OK}
  48. };
  49. static ULONG g_cmemtskMIDL =
  50. sizeof(g_amemtskMIDL) / sizeof(g_amemtskMIDL[0]);
  51. BOOL TestStandard(DWORD grfOptions);
  52. BOOL TestMIDL(DWORD grfOptions);
  53. //+-------------------------------------------------------------------------
  54. //
  55. // Function: TestMemory, public
  56. //
  57. // Synopsis: Tests simple memory allocation functionality
  58. //
  59. // Arguments: [grfOptions] - options for test
  60. //
  61. // Returns: TRUE if successful, FALSE otherwise
  62. //
  63. // History: 17-Aug-93 CarlH Created
  64. //
  65. //--------------------------------------------------------------------------
  66. BOOL TestMemory(DWORD grfOptions)
  67. {
  68. BOOL fPassed;
  69. PrintHeader(g_szMemory);
  70. if (!(fPassed = TestStandard(grfOptions)))
  71. goto done;
  72. #ifdef TEST_MIDL
  73. if (!(fPassed = TestMIDL(grfOptions)))
  74. goto done;
  75. #endif // TEST_MIDL
  76. done:
  77. PrintResult(g_szMemory, fPassed);
  78. return (fPassed);
  79. }
  80. //+-------------------------------------------------------------------------
  81. //
  82. // Function: TestStandard, public
  83. //
  84. // Synopsis: Tests standard memory allocation routines (not linked)
  85. //
  86. // Arguments: [grfOptions] - options for test
  87. //
  88. // Returns: TRUE if successful, FALSE otherwise
  89. //
  90. // History: 17-Aug-93 CarlH Created
  91. //
  92. //--------------------------------------------------------------------------
  93. BOOL TestStandard(DWORD grfOptions)
  94. {
  95. PrintTrace(g_szMemory, "testing standard allocations\n");
  96. return (RunMemoryTasks(g_szMemory, g_amemtskStandard, g_cmemtskStandard));
  97. }
  98. //+-------------------------------------------------------------------------
  99. //
  100. // Function: TestMIDL, public
  101. //
  102. // Synopsis: Tests RPC memory allocation routines (not linked)
  103. //
  104. // Arguments: [grfOptions] - options for test
  105. //
  106. // Returns: TRUE if successful, FALSE otherwise
  107. //
  108. // History: 17-Aug-93 CarlH Created
  109. //
  110. //--------------------------------------------------------------------------
  111. BOOL TestMIDL(DWORD grfOptions)
  112. {
  113. PrintTrace(g_szMemory, "testing MIDL allocations\n");
  114. return (RunMemoryTasks(g_szMemory, g_amemtskMIDL, g_cmemtskMIDL));
  115. }