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.

112 lines
3.4 KiB

  1. #ifndef _TESTAUDIT_H_
  2. #define _TESTAUDIT_H_
  3. /*++
  4. Copyright (c) 2001 Microsoft Corporation
  5. Module Name:
  6. testaudit.h
  7. Abstract:
  8. Test Auditing routines. Used by development to document the locations
  9. and reach conditions for code checkpoints that test should be sure to cover.
  10. Used by test to ensure that the test meets the expectations of the developer
  11. and to locate points of interest in the source files.
  12. These routines disappear altogether if the build is not a debug build and
  13. if the symbol TESTAUDIT is not defined. To accomplish this, the command
  14. file buildx.cmd in the tools directory, is modified to provide for setting
  15. this flag.
  16. To use testaudit.h/cpp in your project, you must run the MAKEAUDIT.EXE utility,
  17. which processes files in the current directory, and generates an AUDIT.H file
  18. which is included in testaudit.cpp. This file defines the descriptive strings
  19. for the checkpoints unreached by the code. It should be rebuilt whenever changes
  20. in the source files result in material changes to the line numbers associated
  21. with checkpoints.
  22. Usage examples:
  23. CHECKPOINTINIT; Initializes the test auditing data structure - appears
  24. once in an executable unit
  25. CHECKPOINT(3,"Print page"); Defines checkpoint 3 as "Print page" - Produces an entry
  26. in AUDIT.H with the file, linenumber, and this
  27. description.
  28. CHECKPOINTFINISH; Prints statistics to the debug output and cleans up -
  29. Called when the executable exits. Shows the checkpoint
  30. number, file, line number, and description for all
  31. unreached checkpoints.
  32. Statement blocks can be conditionally compiled in test auditing builds by use of
  33. the preprocessor #if directive and the TESTAUDIT symbol. The usual use is to preface
  34. conditional checkpoints to permit testing for different conditions passing the same
  35. checkpoint, something like this:
  36. #if TESTAUDIT
  37. if (mode_one) CHECKPOINT(3,"Print page portrait mode");
  38. if (Mode_two) CHECKPOINT(4,"Print page landscape mode");
  39. #endif
  40. Author:
  41. georgema Nov., 2001 created
  42. Environment:
  43. Revision History:
  44. --*/
  45. // These macros disappear if the build is not debug or if the symbol TESTAUDIT
  46. // is not defined.
  47. #if DBG
  48. #if TESTAUDIT
  49. typedef struct _AuditData
  50. {
  51. INT iPoint;
  52. WCHAR *pszDescription;
  53. } AUDITDATA;
  54. #define CHECKPOINT(x,y) BranchTouch(x)
  55. #define SEQUENCE(x,y,z) BranchSequence(x,y)
  56. #define RESETSEQUENCE BranchSequence(0,0)
  57. #define FORCESEQUENCE(x) BranchSequence(x,x)
  58. #define CHECKPOINTINIT BranchInit()
  59. #define CHECKPOINTFINISH BranchSummary()
  60. #else
  61. #define CHECKPOINT(x,y)
  62. #define SEQUENCE(x,y,z)
  63. #define RESETSEQUENCE
  64. #define FORCESEQUENCE(x)
  65. #define CHECKPOINTINIT
  66. #define CHECKPOINTFINISH
  67. #endif
  68. #else
  69. #define CHECKPOINT(x,y)
  70. #define SEQUENCE(x,y,z)
  71. #define RESETSEQUENCE
  72. #define FORCESEQUENCE(x)
  73. #define CHECKPOINTINIT
  74. #define CHECKPOINTFINISH
  75. #endif
  76. #define NCHECKPOINT(x,y)
  77. #if defined (__cplusplus)
  78. extern "C" {
  79. #endif
  80. void BranchTouch(INT);
  81. void BranchSequence(INT,INT);
  82. void BranchInit(void);
  83. void BranchSummary(void);
  84. #if defined (__cplusplus)
  85. }
  86. #endif
  87. #endif