|
1 // Copyright (c) 2007-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 /** |
|
20 @file te_buffermode.cpp |
|
21 @internalTechnology |
|
22 */ |
|
23 #include "te_buffermode.h" |
|
24 |
|
25 #include <e32cons.h> |
|
26 #include <e32def.h> |
|
27 #include "te_dataparameters.h" |
|
28 #include "te_ostv2integsuite_defs.h" |
|
29 |
|
30 using namespace Ulogger; //CA:added so can use old ulogger api |
|
31 CTCMBufferModeWrapper::~CTCMBufferModeWrapper() |
|
32 /** |
|
33 * Destructor |
|
34 */ |
|
35 { |
|
36 } |
|
37 |
|
38 CTCMBufferModeWrapper::CTCMBufferModeWrapper() |
|
39 /** |
|
40 * Constructor |
|
41 */ |
|
42 { |
|
43 } |
|
44 |
|
45 void CTCMBufferModeWrapper::writeToBuffer(const TPtrC aFileName, TInt aTraceNumber,RULogger* aLogger) |
|
46 { |
|
47 _LIT8(KTextmedia,"uloggerfileplugin"); |
|
48 const TPtrC8 mediaptr(KTextmedia); |
|
49 _LIT(KTextsetting, "output_path"); |
|
50 // test setting the plugin settings |
|
51 TPluginConfiguration setPluginConfigs; |
|
52 setPluginConfigs.SetKey(KTextsetting); |
|
53 setPluginConfigs.SetValue(aFileName); |
|
54 aLogger->SetPluginConfigurations(mediaptr, setPluginConfigs); |
|
55 //empty out logfile before writing to it. |
|
56 #ifdef TE_UPT_TRACE_ENABLED |
|
57 EmptyFile(aFileName); |
|
58 #endif |
|
59 aLogger->Start(); //C.A. previously:aLogger->StartOutputting(); |
|
60 TBool ret=0; |
|
61 TBool OstStatus=0; |
|
62 |
|
63 #ifdef TE_UPT_TRACE_ENABLED |
|
64 OstStatus = 1; |
|
65 INFO_PRINTF1(_L("TRACING HAS BEEN ENABLED!")); |
|
66 #else |
|
67 OstStatus = 0; |
|
68 INFO_PRINTF1(_L("TRACING HAS BEEN DISABLED! All Log files should be empty/not exist")); |
|
69 #endif |
|
70 |
|
71 for(TInt i=0; i!=aTraceNumber; i++) |
|
72 { |
|
73 TTraceContext attrs(KComponentId+i+1, KGroupId, KContextId, KPc); |
|
74 ret = OstTrace(attrs, KInitialClientFormat, KAny16); |
|
75 if (ret == 0 && OstStatus == 1) |
|
76 { |
|
77 INFO_PRINTF2(_L("Trace %d not carried out"), aTraceNumber); |
|
78 SetBlockResult(EFail); |
|
79 } |
|
80 |
|
81 else if (ret == 1 && OstStatus == 0) |
|
82 SetBlockResult(EFail); |
|
83 } |
|
84 |
|
85 TTraceContext attrs1(KComponentId, 192, KContextId, KPc); |
|
86 ret = OstTrace(attrs1, KInitialClientFormat, KAny16); |
|
87 |
|
88 if (ret == 0 && OstStatus == 1) |
|
89 { |
|
90 INFO_PRINTF2(_L("Trace %d not carried out"), aTraceNumber); |
|
91 SetBlockResult(EFail); |
|
92 } |
|
93 |
|
94 else if (ret == 1 && OstStatus == 0) |
|
95 SetBlockResult(EFail); |
|
96 |
|
97 if (ret == 0 && OstStatus == 1) |
|
98 { |
|
99 INFO_PRINTF1(_L("Trace 192 not carried out")); |
|
100 SetBlockResult(EFail); |
|
101 } |
|
102 aLogger->Stop(); |
|
103 |
|
104 } |
|
105 |
|
106 |
|
107 CTCMBufferModeWrapper* CTCMBufferModeWrapper::NewLC() |
|
108 { |
|
109 CTCMBufferModeWrapper* self = new (ELeave)CTCMBufferModeWrapper(); |
|
110 CleanupStack::PushL(self); |
|
111 self->ConstructL(); |
|
112 return self; |
|
113 } |
|
114 |
|
115 CTCMBufferModeWrapper* CTCMBufferModeWrapper::NewL() |
|
116 { |
|
117 CTCMBufferModeWrapper* self=CTCMBufferModeWrapper::NewLC(); |
|
118 CleanupStack::Pop(); // self; |
|
119 return self; |
|
120 } |
|
121 |
|
122 void CTCMBufferModeWrapper::ConstructL() |
|
123 { |
|
124 } |
|
125 |
|
126 TAny* CTCMBufferModeWrapper::GetObject() |
|
127 { |
|
128 return NULL; |
|
129 } |
|
130 |
|
131 TBool CTCMBufferModeWrapper::DoCommandL( const TTEFFunction& /*aCommand*/, |
|
132 const TTEFSectionName& /*aSection*/, |
|
133 const TInt /*aAsyncErrorIndex*/) |
|
134 { |
|
135 if(BlockResult()==EPass) |
|
136 { |
|
137 // ************** Delete the Block, the block start **************** |
|
138 const TInt ECircular=0;//C.A. added because TBuffermode enum doesnt exist in old ulogger api: |
|
139 const TInt EStraight=1;//C.A. as above: |
|
140 TInt result=0; |
|
141 INFO_PRINTF1(_L("About to test buffer Mode")); //Block start |
|
142 RULogger logger; |
|
143 result=logger.Connect(); |
|
144 INFO_PRINTF2(_L("Connection to Ulogger: %d, attempt: 1"), result); |
|
145 if (result!=KErrNone) |
|
146 { |
|
147 INFO_PRINTF1(_L("Connection to Ulogger failed. Will try to connect max. 10 times")); |
|
148 for (TInt i=2; i<12;i++) |
|
149 { |
|
150 User::After(1000); |
|
151 result = logger.Connect(); |
|
152 INFO_PRINTF3(_L("Connection to Ulogger: %d, attempt: %d"), result, i); |
|
153 if (result==KErrNone) |
|
154 { |
|
155 break; |
|
156 } |
|
157 } |
|
158 } |
|
159 CClearConfig configIni; |
|
160 configIni.Clear(logger); |
|
161 logger.SetSecondaryFilteringEnabled(EFalse);//C.A. previously:logger.DisableModuleUidFiltering(); |
|
162 // C.A. previously: |
|
163 /* TBufferMode bufferCircular = ECircular; |
|
164 TBufferMode bufferStraight = EStraight; |
|
165 TBufferMode getBuffer = ECircular; */ |
|
166 TInt bufferCircular = ECircular; |
|
167 TInt bufferStraight = EStraight; |
|
168 TInt getBuffer = ECircular; |
|
169 CArrayFixFlat<TUint8> *setprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1); |
|
170 setprimfilter->AppendL(KGroupId); |
|
171 setprimfilter->AppendL((TGroupId) (192)); |
|
172 RArray<TUint32> setsecondfilter; |
|
173 setsecondfilter.Append((TUint32) KComponentId); |
|
174 logger.SetPrimaryFiltersEnabled(*setprimfilter,ETrue);//C.A. previously:logger.EnableClassifications(*setprimfilter); |
|
175 //logger.EnableModuleUids(setsecondfilter); |
|
176 SetBlockResult(EPass); |
|
177 if(result==0) |
|
178 { |
|
179 INFO_PRINTF1(_L("BTrace to File plugin added")); |
|
180 _LIT8(KTextmedia,"uloggerfileplugin"); |
|
181 const TPtrC8 mediaptr(KTextmedia); |
|
182 result=logger.ActivateOutputPlugin(mediaptr);//C.A. previously:Result=logger.SetActiveOutputPlugin(mediaptr); |
|
183 |
|
184 // write to a small circular buffer with a tight loop |
|
185 logger.SetBufferSize(4); |
|
186 logger.SetNotificationSize(3.9); |
|
187 result=logger.SetBufferMode(bufferCircular); |
|
188 if(result==KErrNone) |
|
189 { |
|
190 INFO_PRINTF1(_L("Buffer mode set without error")); |
|
191 logger.GetBufferMode(getBuffer); |
|
192 if(getBuffer==bufferCircular) |
|
193 INFO_PRINTF1(_L("Circular Buffer mode got correctly")); |
|
194 else |
|
195 { |
|
196 INFO_PRINTF1(_L("get buffer mode different from set circular - FAIL")); |
|
197 SetBlockResult(EFail); |
|
198 } |
|
199 } |
|
200 else |
|
201 { |
|
202 INFO_PRINTF2(_L("Buffer mode set failed with error %d"), result); |
|
203 SetBlockResult(EFail); |
|
204 } |
|
205 _LIT(KTextvalue1, "C:\\logs\\ULoggerBuffer4kDNS4kCircular.utf"); |
|
206 const TPtrC valueptr1(KTextvalue1); |
|
207 INFO_PRINTF3(_L("Writing to buffer... Buffer size: %d, DNS: %d"),4,4); |
|
208 writeToBuffer(valueptr1, Ost_Count, &logger); |
|
209 |
|
210 // write to a small straight buffer with a tight loop |
|
211 result=logger.SetBufferMode(bufferStraight); |
|
212 if(result==KErrNone) |
|
213 { |
|
214 INFO_PRINTF1(_L("Buffer mode set without error")); |
|
215 logger.GetBufferMode(getBuffer); |
|
216 if(getBuffer==bufferStraight) |
|
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 SetBlockResult(EFail); |
|
222 } |
|
223 } |
|
224 else |
|
225 { |
|
226 INFO_PRINTF2(_L("Buffer mode set failed with error %d"), result); |
|
227 SetBlockResult(EFail); |
|
228 } |
|
229 _LIT(KTextvalue2, "C:\\logs\\ULoggerBuffer4kDNS4kStraight.utf"); |
|
230 const TPtrC valueptr2(KTextvalue2); |
|
231 INFO_PRINTF3(_L("Writing to buffer... Buffer size: %d, DNS: %d"),4,4); |
|
232 writeToBuffer(valueptr2, Ost_Count, &logger); |
|
233 |
|
234 // write to a large circular buffer with a tight loop |
|
235 logger.SetBufferSize(100); |
|
236 logger.SetNotificationSize(4); |
|
237 result=logger.SetBufferMode(bufferCircular); |
|
238 if(result==KErrNone) |
|
239 { |
|
240 INFO_PRINTF1(_L("Buffer mode set without error")); |
|
241 logger.GetBufferMode(getBuffer); |
|
242 if(getBuffer==bufferCircular) |
|
243 INFO_PRINTF1(_L("Circular Buffer mode got correctly")); |
|
244 else |
|
245 { |
|
246 INFO_PRINTF1(_L("get buffer mode different from set circular - FAIL")); |
|
247 SetBlockResult(EFail); |
|
248 } |
|
249 } |
|
250 else |
|
251 { |
|
252 INFO_PRINTF2(_L("Buffer mode set failed with error %d"), result); |
|
253 SetBlockResult(EFail); |
|
254 } |
|
255 _LIT(KTextvalue5, "C:\\logs\\ULoggerBuffer100kDNS4kCircular.utf"); |
|
256 const TPtrC valueptr5(KTextvalue5); |
|
257 INFO_PRINTF3(_L("Writing to buffer... Buffer size: %d, DNS: %d"),100,4); |
|
258 writeToBuffer(valueptr5, Ost_Count, &logger); |
|
259 |
|
260 // write to a large straight buffer with a tight loop |
|
261 result=logger.SetBufferMode(bufferStraight); |
|
262 if(result==KErrNone) |
|
263 { |
|
264 INFO_PRINTF1(_L("Buffer mode set without error")); |
|
265 logger.GetBufferMode(getBuffer); |
|
266 if(getBuffer==bufferStraight) |
|
267 INFO_PRINTF1(_L("Straight Buffer mode got correctly")); |
|
268 else |
|
269 { |
|
270 INFO_PRINTF1(_L("get buffer mode different from set Straight - FAIL")); |
|
271 SetBlockResult(EFail); |
|
272 } |
|
273 } |
|
274 else |
|
275 { |
|
276 INFO_PRINTF2(_L("Buffer mode set failed with error %d"), result); |
|
277 SetBlockResult(EFail); |
|
278 } |
|
279 _LIT(KTextvalue6, "C:\\logs\\ULoggerBuffer100kDNS4kStraight.utf"); |
|
280 const TPtrC valueptr6(KTextvalue6); |
|
281 INFO_PRINTF3(_L("Writing to buffer... Buffer size: %d, DNS: %d"),100,4); |
|
282 writeToBuffer(valueptr6, Ost_Count, &logger); |
|
283 |
|
284 } |
|
285 else |
|
286 { |
|
287 INFO_PRINTF1(_L("File Plugin error when added")); |
|
288 SetBlockResult(EFail); |
|
289 } |
|
290 logger.Close(); |
|
291 INFO_PRINTF1(_L("Buffer Mode tests complete!")); |
|
292 |
|
293 // ************** Block end **************** |
|
294 } |
|
295 return ETrue; |
|
296 } |