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.

216 lines
7.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996.
  5. //
  6. // File: filttest.hxx
  7. //
  8. // Contents: CFiltTest class declaration
  9. //
  10. // Classes: CFiltTest
  11. //
  12. // Functions: none
  13. //
  14. // Coupling:
  15. //
  16. // Notes: Allocations: This class assumes that a newhandeler
  17. // has been defined to handle failed allocations.
  18. //
  19. // History: 9-16-1996 ericne Created
  20. //
  21. //----------------------------------------------------------------------------
  22. #ifndef _CFILTTEST
  23. #define _CFILTTEST
  24. #include <vquery.hxx> // Prototype for CiShutdown()
  25. #include "filtpars.hxx"
  26. #include "statchnk.hxx"
  27. #include "clog.hxx"
  28. const ULONG BUFFER_SIZE = 4096;
  29. enum Verbosity { MUTE, LOW, NORMAL, HIGH };
  30. //const TCHAR *const szIniFileName = _T("ifilttst.ini");
  31. //+---------------------------------------------------------------------------
  32. //
  33. // Class: CFiltTest ()
  34. //
  35. // Purpose: This class tests an IFilter implementation for compliance
  36. // with the IFilter specification.
  37. //
  38. // Interface: CFiltTest -- Constructor. Default initialization
  39. // ~CFiltTest -- Destructor. Cleans heap. Release OLE.
  40. // Init -- Initializes the test run.
  41. // ExecuteTests -- Perform the tests.
  42. // BindFilter -- Calls LoadIFilter. Returns TRUE/FALSE
  43. // InitializeFilter -- Calls ::Init. Return TRUE/FALSE
  44. // IsCurrentChunkContents -- TRUE if the current chunk is contents
  45. // ReleaseFilter -- Calls ::Release.
  46. // ValidateChunkStats -- Check fields of STAT_CHUNK struct
  47. // ValidatePropspec -- Check that current chunk has a
  48. // requested attribute
  49. // FlushList -- Frees memory of linked list
  50. // LegitimacyTest -- Makes good IFilter calls. Stores
  51. // STAT_CHUNKs in linked list
  52. // ConsistencyTest -- Makes good IFilter calls. Check
  53. // STAT_CHUNKs against those in list
  54. // IllegitimacyTest -- Makes bad IFilter calls.
  55. // GetTextFromTextChunk -- Called from LegitimacyTest
  56. // GetValueFromValueChunk -- Called from LegitimacyTest
  57. // GetTextFromValueChunk -- Called from IllegitimacyTest
  58. // GetValueFromTextChunk -- Called from IllegitimacyTest
  59. // LogConfiguration -- Sends the configuration to the log
  60. // DisplayChunkStats -- Sends chunk stats to the dump file
  61. // LogChunkStats -- Sends chunk stats to the log
  62. // DisplayText -- Sends text to the file stream
  63. // DisplayValue -- Sends a value to the file stream
  64. // m_fIsText -- BOOL which contains current chunk type
  65. // m_fIsInitialized -- BOOL which indicated whether Init
  66. // was called successfully
  67. // m_fSharedLog -- True if the log file is shared with
  68. // other CFiltTest objects
  69. // m_Log -- Object of type CLog
  70. // m_pDumpFile -- FILE* to dump file. Could be stdout
  71. // m_pwcTextBuffer -- Buffer for incomming text
  72. // m_szInputFileName -- Name of file to bind to.
  73. // m_CurrentConfig -- Current Init parameters
  74. // m_ToolBox -- CTools: utility methods.
  75. // m_pIFilter -- Pointer to IFilter interface
  76. // m_ChunkStatsListHead -- First node in linked list
  77. // m_verbosity -- verbosity setting
  78. // m_FiltParse -- CFiltParse: gleans CONFIG structs from
  79. // .ini file.
  80. // m_CurrentChunkStats -- STAT_CHUNK struct returned by GetChunk
  81. // m_fLegitOnly -- true if only the legittimacy
  82. // test should be run
  83. //
  84. // History: 10-03-1996 ericne Created
  85. //
  86. // Notes:
  87. //
  88. //----------------------------------------------------------------------------
  89. class CFiltTest
  90. {
  91. public:
  92. CFiltTest( CLog* = NULL );
  93. ~CFiltTest( );
  94. BOOL Init( const WCHAR *, // Input file
  95. const WCHAR *, // Log file
  96. const WCHAR *, // Dump file
  97. const WCHAR *, // Ini file name
  98. Verbosity, // Verbosity setting
  99. BOOL ); // Legit only?
  100. void ExecuteTests( );
  101. private:
  102. class CListNode
  103. {
  104. public:
  105. CListNode() : ChunkStats(), next( NULL ) {}
  106. ~CListNode() {}
  107. CStatChunk ChunkStats;
  108. CListNode *next;
  109. };
  110. BOOL BindFilter( );
  111. BOOL InitializeFilter( const CONFIG & );
  112. BOOL IsCurrentChunkContents();
  113. void ReleaseFilter( );
  114. void ValidateChunkStats( );
  115. void ValidatePropspec( ); // Called from ValidateChunkStats( )
  116. void FlushList( );
  117. void LegitimacyTest( );
  118. void ConsistencyTest( );
  119. void IllegitimacyTest( );
  120. void GetTextFromTextChunk( ); // called by legitimacy test
  121. void GetValueFromValueChunk( ); // called by legitimacy test
  122. void GetTextFromValueChunk( ); // called by illegitimacy test
  123. void GetValueFromTextChunk( ); // called by illegitimacy test
  124. void LogConfiguration( const CONFIG & );
  125. void LogChunkStats( const STAT_CHUNK & );
  126. void DisplayChunkStats( const STAT_CHUNK &, FILE * );
  127. void DisplayText( const WCHAR *, FILE * );
  128. void DisplayValue( const PROPVARIANT *, FILE * );
  129. BOOL m_fIsText;
  130. BOOL m_fIsInitialized;
  131. BOOL m_fLegitOnly;
  132. BOOL m_fSharedLog;
  133. CLog *m_pLog;
  134. FILE *m_pDumpFile;
  135. WCHAR *m_pwcTextBuffer;
  136. WCHAR *m_szInputFileName;
  137. CONFIG m_CurrentConfig;
  138. IFilter *m_pIFilter;
  139. CListNode m_ChunkStatsListHead;
  140. Verbosity m_verbosity;
  141. CFiltParse m_FiltParse;
  142. STAT_CHUNK m_CurrentChunkStats;
  143. };
  144. // This function is used to convert a verbosity to a logging threshold
  145. inline DWORD VerbosityToLogStyle( const Verbosity verbosity )
  146. {
  147. switch( verbosity )
  148. {
  149. case MUTE:
  150. return( TLS_SEV1 );
  151. break;
  152. case LOW:
  153. return( TLS_WARN );
  154. break;
  155. case NORMAL:
  156. return( TLS_PASS );
  157. break;
  158. case HIGH:
  159. return( TLS_INFO );
  160. break;
  161. default:
  162. return( 0 );
  163. break;
  164. }
  165. }
  166. #endif