|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file TestExecuteLogger.h |
|
22 */ |
|
23 |
|
24 #if !(defined __TESTEXECUTE_LOGGER_H__) |
|
25 #define __TESTEXECUTE_LOGGER_H__ |
|
26 |
|
27 #include <e32base.h> |
|
28 #include <e32cons.h> |
|
29 #include <f32file.h> |
|
30 #include <test/testexecutelogbase.h> |
|
31 #include <iniparser.h> |
|
32 #include <test/blockitems.h> |
|
33 #include <test/tefscriptutils.h> |
|
34 |
|
35 class CSerialWriter; |
|
36 /** |
|
37 * @internalComponent |
|
38 * @test |
|
39 */ |
|
40 class CTestExecuteIniData : public CBase |
|
41 { |
|
42 public: |
|
43 IMPORT_C CTestExecuteIniData(); |
|
44 IMPORT_C ~CTestExecuteIniData(); |
|
45 IMPORT_C static CTestExecuteIniData* NewL(); |
|
46 IMPORT_C static CTestExecuteIniData* NewLC(); |
|
47 IMPORT_C void ConstructL(); |
|
48 IMPORT_C void ExtractValuesFromIni(); |
|
49 IMPORT_C void GetKeyValueFromIni(const TDesC& aKeyName, TDes& aValue); |
|
50 IMPORT_C void GetKeyValueFromIni(const TDesC& aKeyName, TInt& aValue); |
|
51 IMPORT_C CTestExecuteIniData(TDriveName& aSysDrive); |
|
52 IMPORT_C static CTestExecuteIniData* NewL(TDriveName& aSysDrive); |
|
53 IMPORT_C static CTestExecuteIniData* NewLC(TDriveName& aSysDrive); |
|
54 private: |
|
55 CIniData* iConfigData; |
|
56 TPtrC iHtmlLogPath; |
|
57 TPtrC iXmlLogPath; |
|
58 TPtrC iDefaultScriptDirectory; |
|
59 TInt iLogSeverity; |
|
60 TInt iLoggerOptions; |
|
61 TInt iJustInTime; |
|
62 TInt iRemotePanicDetection; |
|
63 TInt iEnableIniAccessLog; |
|
64 TInt iEnableTestsCountLog; |
|
65 TInt iEnableSystemStarter; |
|
66 TInt iLoggerChannel; |
|
67 TInt iPortNumber; |
|
68 TDriveName iDefaultSysDrive; |
|
69 TPtrC iIniSysDriveName; |
|
70 TInt iWaitForLoggingTime; |
|
71 }; |
|
72 |
|
73 /** |
|
74 * Override of base class virtual for TEF logger implementation |
|
75 * @internalComponent |
|
76 * @test |
|
77 */ |
|
78 class CTestExecuteLogger : public MTestExecuteLogBase |
|
79 { |
|
80 public: |
|
81 IMPORT_C CTestExecuteLogger(TLoggerOptions aLogOptions=ELogHTMLOnly); |
|
82 IMPORT_C ~CTestExecuteLogger(); |
|
83 IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue<const TDesC> aFmt,...); |
|
84 IMPORT_C void LogToXml(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aCommandName, const TInt aNumberOfParams, TExtraLogField* aLogFields); |
|
85 IMPORT_C void LogToXml(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aCommandName); |
|
86 IMPORT_C void InitialiseLoggingL(const TDesC& aScriptFilePath, TBool aSeparateLogFileMode, TInt aLogLevel); |
|
87 |
|
88 IMPORT_C void TerminateLoggingL(const TInt aCommentedCommandsCount, const TInt aRemotePanicsCount, const TInt aRunScriptFailCount); |
|
89 IMPORT_C void LogTestCaseResult(const TDesC& aFile, TInt aLine, TInt aSeverity, const TDesC& aCommand, const TDesC& aTestCaseName, TVerdict aResult = EPass); |
|
90 IMPORT_C void PrintCurrentScriptLine(TDes& aCurrentScriptLine); |
|
91 IMPORT_C void LogResult(TVerdict aResult, const TDesC& aPanicString, TInt aScriptLineNumber,const TDesC& aCommand,const TDesC& aScriptFile,TInt aSeverity); |
|
92 IMPORT_C TVerdict LogBlock( TTEFItemArray* aItemArray, const TInt aScriptLineNumber ); |
|
93 IMPORT_C void SetLoggerOptions(TInt aLogMode); |
|
94 IMPORT_C TInt Connect(); |
|
95 IMPORT_C void Close(); |
|
96 inline RTestExecuteLogServ& HtmlLogger() { return iHtmlLogger; }; |
|
97 inline RTestExecutePIPSLogServ& PIPSLogger() { return iPIPSLogger; }; |
|
98 inline RFileFlogger& XmlLogger() { return iXmlLogger; }; |
|
99 IMPORT_C TInt ShareAuto(); |
|
100 |
|
101 // Legacy methods provided for backwards compatibility |
|
102 // These only log to the html log file |
|
103 IMPORT_C void Write(const TDesC& aLogBuffer); |
|
104 IMPORT_C void WriteFormat(TRefByValue<const TDesC> aFmt,...); |
|
105 IMPORT_C void Write(const TDesC8& aLogBuffer); |
|
106 IMPORT_C void WriteFormat(TRefByValue<const TDesC8> aFmt,...); |
|
107 IMPORT_C static CTestExecuteLogger* NewL(TLoggerOptions aLogOptions=ELogHTMLOnly); |
|
108 IMPORT_C static CTestExecuteLogger* NewLC(TLoggerOptions aLogOptions=ELogHTMLOnly); |
|
109 IMPORT_C void SetLoggerChannel(TInt aLogChannel); |
|
110 IMPORT_C void SetPipeName(TPtrC& aPipeName) ; |
|
111 void OpenSerialPortL(const TInt aPortNumber); |
|
112 protected: |
|
113 // parse the script string(!PanicString) |
|
114 TBool ParsePaincStringFromScriptCommandLine(const TDesC& aCommandStr,TLex& aScriptLineParamLex,TDes& aTEFPanicString); |
|
115 private: |
|
116 // Connects to the HTML log client session and creating the logs with initial tags for logging |
|
117 void InitialiseHTMLLoggingL(const TDesC& aLogFilePath, TInt aLogLevel, const TInt& aEnableCommandCount, CScriptPreProcess& aScriptPreProcess); |
|
118 void InitialisePIPSLoggingL(TInt aLogLevel, const TInt& aEnableCommandCount, CScriptPreProcess& aScriptPreProcess); |
|
119 // Connects to the XML log client session and creates the logs in the path passed in |
|
120 // Also sets in the default threshold for log level |
|
121 void InitialiseXMLLoggingL(const TDesC& aLogFilePath, TInt aLogLevel, const TInt& aEnableCommandCount, CScriptPreProcess& aScriptPreProcess); |
|
122 void TerminateHTMLLoggingL(RFile* aLogFile, const TInt aCommentedCommandsCount, const TInt aRemotePanicsCount, const TInt aRunScriptFailCount); |
|
123 void TerminateXMLLoggingL(const TInt aCommentedCommandsCount, const TInt aRemotePanicsCount, const TInt aRunScriptFailCount); |
|
124 TVerdict LogHTMLBlockL( const TTEFItemArray& aItemArray ); |
|
125 TVerdict LogXMLBlock( const TTEFItemArray& aItemArray, const TInt aScriptLineNumber ); |
|
126 void InitialiseSerialLoggingL(TInt aLogLevel, const TInt& aEnableCommandCount, CScriptPreProcess& aScriptPreProcess, TInt portNumber); |
|
127 void LogTestCaseResultSerialL(const TDesC& aFile, TInt aLine, TInt aSeverity, const TDesC& aCommand, const TDesC& aTestCaseName, TVerdict aResult = EPass); |
|
128 void LogResultSerialL(TVerdict aResult, const TDesC& aPanicString, TInt aScriptLineNumber,const TDesC& aCommand,const TDesC& aScriptFile); |
|
129 void LogResultFileL(TVerdict aResult, const TDesC& aPanicString, TInt aScriptLineNumber,const TDesC& aCommand,const TDesC& aScriptFile, TInt aSeverity); |
|
130 void LoggingTestCaseResultToSummaryResultL( const TDesC &aLogFileDir,const TDesC &aLogFileName,const TDesC8 &aResultBuf); |
|
131 |
|
132 private: |
|
133 // HTML Log client session |
|
134 RTestExecuteLogServ iHtmlLogger; |
|
135 RTestExecutePIPSLogServ iPIPSLogger; |
|
136 // XML Log client session |
|
137 RFileFlogger iXmlLogger; |
|
138 TInt iLoggerOptions; |
|
139 // Member variables to perform TerminateLogging |
|
140 // Set up some vars for the test step result types |
|
141 TInt iPassCount; |
|
142 TInt iFailCount; |
|
143 TInt iAbortCount; |
|
144 TInt iUnknownCount; |
|
145 TInt iInconclusiveCount; |
|
146 TInt iPanicCount; |
|
147 TInt iUnexecutedCount; |
|
148 |
|
149 // Set up some vars for the RUN_PROGRAM result types |
|
150 TBool iRunProgramUsed; |
|
151 TInt iRunProgramPassCount; |
|
152 TInt iRunProgramFailCount; |
|
153 TInt iRunProgramAbortCount; |
|
154 TInt iRunProgramUnknownCount; |
|
155 TInt iRunProgramInconclusiveCount; |
|
156 TInt iRunProgramPanicCount; |
|
157 TInt iRunProgramUnexecutedCount; |
|
158 |
|
159 // Set up some vars for the testcase result types |
|
160 TBool iTestCasesUsed; |
|
161 TInt iTestCasePassCount; |
|
162 TInt iTestCaseFailCount; |
|
163 TInt iTestCaseInconclusiveCount; |
|
164 |
|
165 // Log file paths for HTML & XML |
|
166 TBuf<KMaxTestExecuteNameLength> iHtmlLogPath; |
|
167 TBuf<KMaxTestExecuteNameLength> iXmlLogPath; |
|
168 TInt iRemotePanic; // Flag to retrieve status of Remote Panic Detection from testexecute.ini |
|
169 TInt iRunScriptCommandCount; // Count of number of RUN_SCRIPT commands in the main script executed |
|
170 CSerialWriter *iSerialWriter ; |
|
171 TInt iPortNumber ; |
|
172 TInt iLoggerChannel; |
|
173 TInt iTestCaseSkippedCount; |
|
174 TBool iPIPSExists ; |
|
175 }; |
|
176 |
|
177 #endif |