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.

144 lines
2.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: test.c
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 3-21-95 RichardW Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include <nt.h>
  18. #include <ntrtl.h>
  19. #include <nturtl.h>
  20. #include <windows.h>
  21. #include <string.h>
  22. #include <wchar.h>
  23. #include <stdio.h>
  24. #include <dsysdbg.h>
  25. #include "debugp.h"
  26. DECLARE_DEBUG2(Test);
  27. DECLARE_DEBUG2(Test2);
  28. DEFINE_DEBUG2(Test);
  29. DEFINE_DEBUG2(Test2);
  30. PVOID
  31. DbgpAlloc(
  32. PDebugHeader pHeader,
  33. DWORD cSize);
  34. VOID
  35. DbgpFree(
  36. PDebugHeader pHeader,
  37. PVOID pMemory);
  38. DEBUG_KEY MyKeys[] = { { 1, "Error" },
  39. { 2, "Warning" },
  40. { 4, "Trace" },
  41. { 8, "Yikes" },
  42. { 0, NULL }
  43. };
  44. int
  45. ExceptionFilter(
  46. LPEXCEPTION_POINTERS p)
  47. {
  48. DsysException(p);
  49. return(EXCEPTION_EXECUTE_HANDLER);
  50. }
  51. __cdecl main (int argc, char *argv[])
  52. {
  53. char wait[40];
  54. PUCHAR p;
  55. CHAR c;
  56. DWORD ChunkSize = 1024 ;
  57. PUCHAR Mem[ 16 ];
  58. ULONG i ;
  59. PDebugModule Alloc ;
  60. TestInitDebug(MyKeys);
  61. p = NULL;
  62. TestDebugPrint(1, "This is an error %d\n", 10);
  63. TestDebugPrint(2, "This is a warning!\n");
  64. Test2InitDebug(MyKeys);
  65. Test2DebugPrint(4, "Should be a trace\n");
  66. printf("Waiting...");
  67. gets(wait);
  68. try
  69. {
  70. c = *p;
  71. }
  72. except (ExceptionFilter(GetExceptionInformation()))
  73. {
  74. TestDebugPrint(1, "That AV'd\n");
  75. }
  76. DsysAssert(p);
  77. printf("Waiting...");
  78. gets(wait);
  79. Test2DebugPrint(8, "This is a yikes!\n");
  80. DsysAssertMsg(argc == 1, "Test Assertion");
  81. Test2DebugPrint(4, "yada yada\n");
  82. //
  83. // Load and unload:
  84. //
  85. Test2UnloadDebug();
  86. TestUnloadDebug();
  87. Test2InitDebug( MyKeys );
  88. Test2DebugPrint( 1, "Reload test2\n");
  89. TestInitDebug( MyKeys );
  90. TestDebugPrint( 1, "Reload test\n");
  91. Test2UnloadDebug();
  92. TestUnloadDebug();
  93. Test2DebugPrint(1, "Safe test\n" );
  94. Test2InitDebug( MyKeys );
  95. Test2DebugPrint(1, "Prints now\n" );
  96. //
  97. // Allocation tests:
  98. //
  99. Alloc = (PDebugModule) Test2ControlBlock ;
  100. for ( i = 0 ; i < 16 ; i++ )
  101. {
  102. Mem[ i ] = DbgpAlloc( Alloc->pHeader, ChunkSize );
  103. }
  104. for ( i = 0 ; i < 16 ; i++ )
  105. {
  106. DbgpFree( Alloc->pHeader, Mem[ i ] );
  107. }
  108. return(0);
  109. }