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.

115 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. Log.h
  5. Abstract:
  6. This DLL handles the logging for the SMVTest.
  7. Author:
  8. Diaa Fathalla (DiaaF) 27-Nov-2000
  9. Revision History:
  10. --*/
  11. // The following ifdef block is the standard way of creating macros which make exporting
  12. // from a DLL simpler. All files within this DLL are compiled with the LOG_EXPORTS
  13. // symbol defined on the command line. this symbol should not be defined on any project
  14. // that uses this DLL. This way any other project whose source files include this file see
  15. // LOG_API functions as being imported from a DLL, wheras this DLL sees symbols
  16. // defined with this macro as being exported.
  17. #ifndef _LOG_H_
  18. #define _LOG_H_
  19. #ifdef LOG_EXPORTS
  20. #define LOG_API __declspec(dllexport)
  21. #else
  22. #define LOG_API __declspec(dllimport)
  23. #endif
  24. #define SUCCESS 0
  25. #define FAILURE 1
  26. #define NORMAL_SIZE 128*sizeof(TCHAR)
  27. // This class is exported from the Log.dll
  28. class LOG_API CLog {
  29. private:
  30. void SetLogfile(LPCTSTR szLogfile);
  31. void SetLogfileFolder(LPCTSTR szLogfileFolder);
  32. static LPTSTR m_sLogfile;
  33. static LPTSTR m_sLogfileFolder;
  34. static int s_NumberOfTests;
  35. static int s_NumberOfFailures;
  36. static BOOL s_bFirstTime;
  37. void IncNumberOfTests();
  38. void IncNumberOfFailures();
  39. int NumberOfTests();
  40. int NumberOfFailures();
  41. protected:
  42. LPTSTR m_sMachineName;
  43. LPTSTR m_sCSDVersion;
  44. LPTSTR m_sBuildNumber;
  45. LPTSTR m_sProcessor;
  46. int m_iProcessor;
  47. int m_iOperatingSys;
  48. int m_iNTProductType;
  49. BOOL m_bLogFile;
  50. protected:
  51. void DeleteAllLogFiles();
  52. public:
  53. //Logging file routines
  54. //--------------------------------------
  55. CLog(void);
  56. ~CLog();
  57. BOOL InitLogfile(LPCTSTR szLogfile = TEXT("ShimTest.Log"),
  58. LPCTSTR szLogfileFolder = TEXT("TestLogs"));
  59. BOOL InitLogfileInfo(LPCTSTR szLogfile = TEXT("ShimTest.Log"),
  60. LPCTSTR szLogfileFolder = TEXT("TestLogs"));
  61. BOOL EndLogfile();
  62. BOOL LogResults(BOOL bPassed, LPCTSTR szText);
  63. BOOL DoesLogfileExist();
  64. BOOL VerifyFileExists(LPTSTR sPath);
  65. LPTSTR LogInitHeader();
  66. LPTSTR LogCompTail();
  67. void GetLocalComputerInfo();
  68. //--------------------------------------
  69. };
  70. //Using my own new and delete operators because of the MSVCRT dependency
  71. void * __cdecl operator new(size_t size)
  72. {
  73. return HeapAlloc(GetProcessHeap(), 0, size);
  74. }
  75. void __cdecl operator delete(void* memory)
  76. {
  77. if (memory != NULL) {
  78. HeapFree(GetProcessHeap(), 0, memory);
  79. }
  80. }
  81. //explicitly exporting static members because they implicitly linked.
  82. #ifdef LOG_EXPORTS
  83. LOG_API int CLog::s_NumberOfTests;
  84. LOG_API int CLog::s_NumberOfFailures;
  85. LOG_API LPTSTR CLog::m_sLogfile;
  86. LOG_API LPTSTR CLog::m_sLogfileFolder;
  87. LOG_API BOOL CLog::s_bFirstTime;
  88. #endif
  89. #endif