/*++ Copyright (c) 2001 Microsoft Corporation Module Name: testaudit.cpp Abstract: Test Auditing routines. Used by development to document the locations and reach conditions for code checkpoints that test should be sure to cover. Used by test to ensure that the test meets the expectations of the developer and to locate points of interest in the source files. This file will compile to nothing if TESTAUDIT is not a defined symbol in the build environment. For this purpose, buildx.cmd has been modified to provide for setting this symbol. Author: georgema Nov., 2001 created Environment: Revision History: --*/ #if TESTAUDIT #include #include #include #include #include #include #include #include #include #include "audit.h" // Data structure element for the auditing data typedef struct _touchstruct { INT iPoint; BOOL fTouched; }TOUCHSTRUCT, *PTOUCHSTRUCT; #define TOUCHSIZE sizeof(TOUCHSTRUCT) // Arbitrary limit on point number range, in order to be able to constrain the // size of the runtime point-hit array to manageable size without having to // do anything cute. #define NUMBERLIMIT 500 // Global variable to hold mem allocation for auditing data TOUCHSTRUCT *pTouch = NULL; // Global variable to hold BOOL value for enabling checkpoint hit messages // This way, the initial value is available to manipulate with the debugger #if TESTAUDITHITS BOOL fShowCheckpointHits = TRUE; #else BOOL fShowCheckpointHits = FALSE; #endif /************************************************************************* BranchInit Creates a memory allocation to hold data regarding whether particular checkpoints have been visited. Reads reference numbers from the AuditData structure, and creates pairs of the reference number and a boolean to be set true when the point is hit. arguments: none returns: none errors: May fail due to out of memory. On this case, returns with the pointer NULL. Further calls into these functions with a NULL ptr will do nothing at all. *************************************************************************/ void BranchInit(void) { WCHAR sz[100]; swprintf(sz,L"TEST: %d checkpoints defined\n",CHECKPOINTCOUNT); OutputDebugString(sz); pTouch = (TOUCHSTRUCT *) malloc(CHECKPOINTCOUNT * sizeof(TOUCHSTRUCT)); if (NULL == pTouch) return; // table allocation successful. Initialize using point #s memset(pTouch,0,(CHECKPOINTCOUNT * sizeof(TOUCHSTRUCT))); for (INT i=0;i NUMBERLIMIT) ASSERT(0); if (fShowCheckpointHits) { swprintf(sz,L"TEST: Checkpoint %d touched. \n",iBranch); OutputDebugString(sz); } // look for this point number and set its touched flag for (j=0;j