|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Example CTestStep derived implementation |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file te_uloggerbuffermodestep.cpp |
|
20 @internalTechnology |
|
21 */ |
|
22 #include "te_uloggerbuffermodestep.h" |
|
23 |
|
24 #include <e32cons.h> |
|
25 #include <e32def.h> |
|
26 #include "te_setfilterparameters.h" |
|
27 |
|
28 using namespace Ulogger; |
|
29 |
|
30 CULoggerBufferModeStep::~CULoggerBufferModeStep() |
|
31 /** |
|
32 * Destructor |
|
33 */ |
|
34 { |
|
35 } |
|
36 |
|
37 CULoggerBufferModeStep::CULoggerBufferModeStep() |
|
38 /** |
|
39 * Constructor |
|
40 */ |
|
41 { |
|
42 SetTestStepName(KULoggerBufferModeStep); |
|
43 } |
|
44 |
|
45 TVerdict CULoggerBufferModeStep::doTestStepPreambleL() |
|
46 /** |
|
47 * @return - TVerdict code |
|
48 * Override of base class virtual |
|
49 */ |
|
50 { |
|
51 INFO_PRINTF1(_L("Please delete this line or modify it. I am in Test Step Preamble in Class CULoggerBufferModeStep")); |
|
52 SetTestStepResult(EPass); |
|
53 return TestStepResult(); |
|
54 } |
|
55 |
|
56 void CULoggerBufferModeStep::writeToBuffer(const TPtrC iLit, TInt iTraceNumber,RULogger* iLogger) |
|
57 { |
|
58 _LIT8(KTextmedia,"uloggerfileplugin"); |
|
59 const TPtrC8 mediaptr(KTextmedia); |
|
60 _LIT(KTextsetting, "output_path"); |
|
61 // test setting the plugin settings |
|
62 TPluginConfiguration setPluginConfigs; |
|
63 setPluginConfigs.SetKey(KTextsetting); |
|
64 setPluginConfigs.SetValue(iLit); |
|
65 iLogger->SetPluginConfigurations(mediaptr, setPluginConfigs); |
|
66 CUTraces Testtracer; |
|
67 iLogger->Start(); |
|
68 TBool ret=0; |
|
69 // for(TInt i=0; i!=iTraceNumber/5; i++) |
|
70 // ret = Testtracer.DoTheTrace(0); |
|
71 // for(TInt i=0; i!=iTraceNumber/5; i++) |
|
72 // ret = Testtracer.DoTheTrace(1); |
|
73 // for(TInt i=0; i!=iTraceNumber/5; i++) |
|
74 // ret = Testtracer.DoTheTrace(2); |
|
75 // for(TInt i=0; i!=iTraceNumber/5; i++) |
|
76 // ret = Testtracer.DoTheTrace(3); |
|
77 // for(TInt i=0; i!=iTraceNumber/5; i++) |
|
78 // ret = Testtracer.DoTheTrace(9); |
|
79 for(TInt i=0; i!=iTraceNumber; i++) |
|
80 { |
|
81 // ret = Testtracer.DoTheTrace(0); |
|
82 // ret = Testtracer.DoTheTrace(1); |
|
83 // ret = Testtracer.DoTheTrace(2); |
|
84 ret = Testtracer.DoTheTrace(3); |
|
85 // ret = Testtracer.DoTheTrace(9); |
|
86 } |
|
87 if (ret == 0) |
|
88 { |
|
89 INFO_PRINTF2(_L("Trace %d not carried out"), iTraceNumber); |
|
90 SetTestStepResult(EFail); |
|
91 } |
|
92 ret = TUTrace::Trace((TPrimaryFilter) (192), UTraceSecondary, schema, context, pc); |
|
93 if (ret == 0) |
|
94 { |
|
95 INFO_PRINTF1(_L("Trace 192 not carried out")); |
|
96 SetTestStepResult(EFail); |
|
97 } |
|
98 iLogger->Stop(); |
|
99 } |
|
100 |
|
101 TVerdict CULoggerBufferModeStep::doTestStepL() |
|
102 /** |
|
103 * @return - TVerdict code |
|
104 * Override of base class pure virtual |
|
105 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
106 * not leave. That being the case, the current test result value will be EPass. |
|
107 */ |
|
108 { |
|
109 if(TestStepResult()==EPass) |
|
110 { |
|
111 // ************** Delete the Block, the block start **************** |
|
112 |
|
113 TInt Result=0; |
|
114 INFO_PRINTF1(_L("About to test buffer Mode")); //Block start |
|
115 RULogger logger; |
|
116 logger.Connect(); |
|
117 CClearConfig configIni; |
|
118 configIni.Clear(logger); |
|
119 TInt iBufferCircular = 0; |
|
120 TInt iBufferStraight = 1; |
|
121 TInt iGetBuffer = 2; |
|
122 CArrayFixFlat<TUint8> *setprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1); |
|
123 setprimfilter->AppendL(UTracePrimary); |
|
124 setprimfilter->AppendL((TPrimaryFilter) (192)); |
|
125 RArray<TUint32> setsecondfilter; |
|
126 setsecondfilter.Append((TUint32) UTraceSecondary); |
|
127 logger.SetPrimaryFiltersEnabled(*setprimfilter,ETrue); |
|
128 logger.SetSecondaryFiltersEnabled(setsecondfilter,ETrue); |
|
129 SetTestStepResult(EPass); |
|
130 if(Result==0) |
|
131 { |
|
132 INFO_PRINTF1(_L("BTrace to File plugin added")); |
|
133 _LIT8(KTextmedia,"uloggerfileplugin"); |
|
134 const TPtrC8 mediaptr(KTextmedia); |
|
135 Result=logger.ActivateOutputPlugin(mediaptr); |
|
136 |
|
137 // write to a small circular buffer with a tight loop |
|
138 logger.SetBufferSize(4); |
|
139 logger.SetNotificationSize(3.9); |
|
140 Result=logger.SetBufferMode(iBufferCircular); |
|
141 if(Result==KErrNone) |
|
142 { |
|
143 INFO_PRINTF1(_L("Buffer mode set without error")); |
|
144 logger.GetBufferMode(iGetBuffer); |
|
145 if(iGetBuffer==iBufferCircular) |
|
146 INFO_PRINTF1(_L("Circular Buffer mode got correctly")); |
|
147 else |
|
148 { |
|
149 INFO_PRINTF1(_L("get buffer mode different from set circular - FAIL")); |
|
150 SetTestStepResult(EFail); |
|
151 } |
|
152 } |
|
153 else |
|
154 { |
|
155 INFO_PRINTF2(_L("Buffer mode set failed with error %d"), Result); |
|
156 SetTestStepResult(EFail); |
|
157 } |
|
158 _LIT(KTextvalue1, "C:\\logs\\ULoggerBuffer4kDNS4kCircular.log"); |
|
159 const TPtrC valueptr1(KTextvalue1); |
|
160 writeToBuffer(valueptr1, UTrace_Count, &logger); |
|
161 |
|
162 // write to a small straight buffer with a tight loop |
|
163 Result=logger.SetBufferMode(iBufferStraight); |
|
164 if(Result==KErrNone) |
|
165 { |
|
166 INFO_PRINTF1(_L("Buffer mode set without error")); |
|
167 logger.GetBufferMode(iGetBuffer); |
|
168 if(iGetBuffer==iBufferStraight) |
|
169 INFO_PRINTF1(_L("Straight Buffer mode got correctly")); |
|
170 else |
|
171 { |
|
172 INFO_PRINTF1(_L("get buffer mode different from set straight - FAIL")); |
|
173 SetTestStepResult(EFail); |
|
174 } |
|
175 } |
|
176 else |
|
177 { |
|
178 INFO_PRINTF2(_L("Buffer mode set failed with error %d"), Result); |
|
179 SetTestStepResult(EFail); |
|
180 } |
|
181 _LIT(KTextvalue2, "C:\\logs\\ULoggerBuffer4kDNS4kStraight.log"); |
|
182 const TPtrC valueptr2(KTextvalue2); |
|
183 writeToBuffer(valueptr2, UTrace_Count, &logger); |
|
184 |
|
185 // write to a large circular buffer with a tight loop |
|
186 logger.SetBufferSize(100); |
|
187 logger.SetNotificationSize(4); |
|
188 Result=logger.SetBufferMode(iBufferCircular); |
|
189 if(Result==KErrNone) |
|
190 { |
|
191 INFO_PRINTF1(_L("Buffer mode set without error")); |
|
192 logger.GetBufferMode(iGetBuffer); |
|
193 if(iGetBuffer==iBufferCircular) |
|
194 INFO_PRINTF1(_L("Circular Buffer mode got correctly")); |
|
195 else |
|
196 { |
|
197 INFO_PRINTF1(_L("get buffer mode different from set circular - FAIL")); |
|
198 SetTestStepResult(EFail); |
|
199 } |
|
200 } |
|
201 else |
|
202 { |
|
203 INFO_PRINTF2(_L("Buffer mode set failed with error %d"), Result); |
|
204 SetTestStepResult(EFail); |
|
205 } |
|
206 _LIT(KTextvalue5, "C:\\logs\\ULoggerBuffer100kDNS4kCircular.log"); |
|
207 const TPtrC valueptr5(KTextvalue5); |
|
208 writeToBuffer(valueptr5, UTrace_Count, &logger); |
|
209 |
|
210 // write to a large straight buffer with a tight loop |
|
211 Result=logger.SetBufferMode(iBufferStraight); |
|
212 if(Result==KErrNone) |
|
213 { |
|
214 INFO_PRINTF1(_L("Buffer mode set without error")); |
|
215 logger.GetBufferMode(iGetBuffer); |
|
216 if(iGetBuffer==iBufferStraight) |
|
217 INFO_PRINTF1(_L("Straight Buffer mode got correctly")); |
|
218 else |
|
219 { |
|
220 INFO_PRINTF1(_L("get buffer mode different from set Straight - FAIL")); |
|
221 SetTestStepResult(EFail); |
|
222 } |
|
223 } |
|
224 else |
|
225 { |
|
226 INFO_PRINTF2(_L("Buffer mode set failed with error %d"), Result); |
|
227 SetTestStepResult(EFail); |
|
228 } |
|
229 _LIT(KTextvalue6, "C:\\logs\\ULoggerBuffer100kDNS4kStraight.log"); |
|
230 const TPtrC valueptr6(KTextvalue6); |
|
231 writeToBuffer(valueptr6, UTrace_Count, &logger); |
|
232 |
|
233 } |
|
234 else |
|
235 { |
|
236 INFO_PRINTF1(_L("File Plugin error when added")); |
|
237 SetTestStepResult(EFail); |
|
238 } |
|
239 logger.Close(); |
|
240 INFO_PRINTF1(_L("Buffer Mode tests complete!")); |
|
241 |
|
242 // ************** Block end **************** |
|
243 } |
|
244 return TestStepResult(); |
|
245 } |
|
246 |
|
247 |
|
248 |
|
249 TVerdict CULoggerBufferModeStep::doTestStepPostambleL() |
|
250 /** |
|
251 * @return - TVerdict code |
|
252 * Override of base class virtual |
|
253 */ |
|
254 { |
|
255 INFO_PRINTF1(_L("Please delete this line or modify it. I am in Test Step Postamble in Class CULoggerBufferModeStep")); |
|
256 return TestStepResult(); |
|
257 } |