|
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_perfsanity.cpp |
|
21 @internalTechnology |
|
22 */ |
|
23 #include "te_perfsanity.h" |
|
24 #include "te_perfcsvgenerator.h" |
|
25 #include "te_perfresultscollector.h" |
|
26 #include "te_perfapicall.h" |
|
27 #include "te_perfplugin.h" |
|
28 #include "te_ostv2integsuite_defs.h" |
|
29 #include "te_perfsanitytimer.h" |
|
30 #include "te_d32perfdrv.h" |
|
31 |
|
32 CPerformanceSanityWrapper::CPerformanceSanityWrapper() |
|
33 /** |
|
34 * Constructor |
|
35 */ |
|
36 { |
|
37 } |
|
38 |
|
39 CPerformanceSanityWrapper::~CPerformanceSanityWrapper() |
|
40 /** |
|
41 * Destructor |
|
42 */ |
|
43 { |
|
44 } |
|
45 |
|
46 CPerformanceSanityWrapper* CPerformanceSanityWrapper::NewLC() |
|
47 { |
|
48 CPerformanceSanityWrapper* self = new (ELeave)CPerformanceSanityWrapper(); |
|
49 CleanupStack::PushL(self); |
|
50 self->ConstructL(); |
|
51 return self; |
|
52 } |
|
53 |
|
54 CPerformanceSanityWrapper* CPerformanceSanityWrapper::NewL() |
|
55 { |
|
56 CPerformanceSanityWrapper* self=CPerformanceSanityWrapper::NewLC(); |
|
57 CleanupStack::Pop(); // self; |
|
58 return self; |
|
59 } |
|
60 |
|
61 void CPerformanceSanityWrapper::ConstructL() |
|
62 { |
|
63 } |
|
64 |
|
65 TAny* CPerformanceSanityWrapper::GetObject() |
|
66 { |
|
67 return NULL; |
|
68 } |
|
69 |
|
70 TBool CPerformanceSanityWrapper::DoCommandL( const TTEFFunction& /*aCommand*/, |
|
71 const TTEFSectionName& /*aSection*/, |
|
72 const TInt /*aAsyncErrorIndex*/) |
|
73 { |
|
74 if(BlockResult()==EPass) |
|
75 { |
|
76 INFO_PRINTF1(_L("Testing stack usage functions")); |
|
77 //test CApiCallTest class |
|
78 CApiCallTest apicalltest; |
|
79 TInt stackerr=apicalltest.Test(); |
|
80 if(stackerr!=KErrNone) |
|
81 { |
|
82 SetBlockResult(EFail); |
|
83 INFO_PRINTF2(_L("Sanity test failed on Stack usage, with returned stack usage of %d, should be 400"), stackerr); |
|
84 } |
|
85 else |
|
86 INFO_PRINTF1(_L("stack usage test passed")); |
|
87 |
|
88 /* |
|
89 INFO_PRINTF1(_L("Testing CSV generator functions")); |
|
90 //test CUptCsvGenerator class |
|
91 CUptCsvGenerator csvtest; |
|
92 TInt csverr=csvtest.Test(); |
|
93 if(csverr!=KErrNone) |
|
94 { |
|
95 SetBlockResult(EFail); |
|
96 INFO_PRINTF2(_L("Sanity test failed on CSV Generator, with error code %d"), csverr); |
|
97 } |
|
98 else |
|
99 INFO_PRINTF1(_L("CSV Generator Sanity test passed")); |
|
100 */ |
|
101 } |
|
102 |
|
103 if(BlockResult()==EPass) |
|
104 { |
|
105 SetBlockResult(TestTimer()); |
|
106 } |
|
107 |
|
108 //run this no matter if its failed or not..., just to get some statistics out. |
|
109 |
|
110 //temporarily tagged out this test as it is causing a test timeout |
|
111 //can be reinstated as soon as the device driver has been fully implemented |
|
112 |
|
113 //SanityTestTimedUtrace(); |
|
114 |
|
115 |
|
116 return ETrue; |
|
117 } |
|
118 |
|
119 |
|
120 TVerdict CPerformanceSanityWrapper::TestTimer() |
|
121 { |
|
122 INFO_PRINTF1(_L("Testing User side timer functions")); |
|
123 TBool passed = EFalse; |
|
124 TInt error = KErrNone; |
|
125 |
|
126 INFO_PRINTF1(_L("Testing User side timer functions #1")); |
|
127 |
|
128 //test CUptTimer class |
|
129 TTestTimer timer; |
|
130 TUint32 userTime = 0; |
|
131 passed = timer.TestUserTimer(userTime); |
|
132 |
|
133 INFO_PRINTF1(_L("Testing User side timer functions #2")); |
|
134 if(!passed) |
|
135 { |
|
136 SetBlockResult(EFail); |
|
137 INFO_PRINTF2(_L("ERROR: Sanity test failed on User side timer, with time %d"), userTime); |
|
138 } |
|
139 else |
|
140 INFO_PRINTF2(_L("User side timer Sanity test passed with time %d"), userTime); |
|
141 |
|
142 |
|
143 //Kernel side |
|
144 |
|
145 INFO_PRINTF1(_L("Testing Kernel side timer functions")); |
|
146 RUptUTrace utracedriver; |
|
147 error = utracedriver.Open(); |
|
148 TUint32 kernelTime = 0; |
|
149 if(!error) |
|
150 { |
|
151 passed = utracedriver.SanityTestTimer(kernelTime); |
|
152 } |
|
153 utracedriver.Close(); |
|
154 |
|
155 if(!passed) |
|
156 { |
|
157 SetBlockResult(EFail); |
|
158 INFO_PRINTF2(_L("ERROR: Sanity test failed on Kernel side timer, with time %d"), kernelTime); |
|
159 } |
|
160 else |
|
161 { |
|
162 INFO_PRINTF2(_L("Kernel side timer Sanity test passed with time %d"), kernelTime); |
|
163 } |
|
164 |
|
165 if(passed) |
|
166 { |
|
167 //kernel not yet implemented at the moment |
|
168 |
|
169 /* |
|
170 TReal variation = (TReal) userTime / 10; |
|
171 if(kernelTime < userTime - variation || kernelTime > userTime + variation) |
|
172 { |
|
173 SetBlockResult(EFail); |
|
174 INFO_PRINTF1(_L("ERROR: Sanity test failed because the kernel and the user times where too different")); |
|
175 } |
|
176 else |
|
177 INFO_PRINTF1(_L("Sanity test passed, the kernel and the user times where whithin a 10% range")); |
|
178 */ |
|
179 } |
|
180 if(!passed) |
|
181 { |
|
182 INFO_PRINTF3(_L("The times are supposed to be between %d-%d ns"), KMinFooTime, KMaxFooTime); |
|
183 INFO_PRINTF1(_L("This only applies to h4 for reference board, or the equivalent to a duo core PC for emulator, if you run it on any other hardware the range needs to be corrected.")); |
|
184 } |
|
185 |
|
186 return BlockResult(); |
|
187 } |
|
188 |
|
189 TBool CPerformanceSanityWrapper::SanityTestTimedUtrace() |
|
190 { |
|
191 TTestTimer timer; |
|
192 TUint32 userSanityTime = 0; |
|
193 TUint32 userSanityLongTime = 0; |
|
194 TUint32 userUtraceTime = 0; |
|
195 |
|
196 timer.TestUserTimer(userSanityTime); |
|
197 timer.TestUserLongTimer(userSanityLongTime); |
|
198 timer.TestUTraceUserTimer(userUtraceTime); |
|
199 |
|
200 TUint32 kernelSanityTime = 0; |
|
201 // TUint32 kernelSanityLongTime = 0; |
|
202 TUint32 kernelUTraceTime = 0; |
|
203 |
|
204 TInt iters = 10; |
|
205 const TInt min = 10;//just to store fastest time |
|
206 const TInt max = 11;//to store slowes time |
|
207 TUint32 user[max + 1] = {0}; |
|
208 TUint32 kernel[max + 1] = {0}; |
|
209 TUint32 ulong[max + 1] = {0}; |
|
210 TUint32 klong[max + 1] = {0}; |
|
211 user[min] = 0xFFFFFF;//prime it to a large number so we can change it later... |
|
212 kernel[min] = 0xFFFFFF; |
|
213 ulong[min] = 0xFFFFFF; |
|
214 klong[min] = 0xFFFFFF; |
|
215 |
|
216 RUptUTrace utracedriver; |
|
217 TInt error = utracedriver.Open(); |
|
218 if(!error) |
|
219 { |
|
220 utracedriver.SanityTestTimer(kernelSanityTime); |
|
221 //utracedriver.SanityTestLongTimer(kernelSanityLongTime);//Can't do for kernel side as it takes too long and panics the kernel |
|
222 utracedriver.SanityUtraceTestTimer(kernelUTraceTime); |
|
223 |
|
224 |
|
225 //Test for variation between the different foos |
|
226 //I want to find out what the variation is, is it static 0.5us, or is it 10% variable, or what? |
|
227 for(TInt i = 0; i < iters; i++) |
|
228 { |
|
229 timer.TestUserTimer(user[i]); |
|
230 timer.TestUserLongTimer(ulong[i]); |
|
231 utracedriver.SanityTestTimer(kernel[i]); |
|
232 //utracedriver.SanityTestLongTimer(klong[i]); |
|
233 } |
|
234 |
|
235 } |
|
236 utracedriver.Close(); |
|
237 |
|
238 |
|
239 //find fastest/slowest times |
|
240 for(TInt i = 0; i < iters; i++) |
|
241 { |
|
242 //fastest time |
|
243 if(user[i] < user[min]) |
|
244 user[min] = user[i]; |
|
245 if(ulong[i] < ulong[min]) |
|
246 ulong[min] = ulong[i]; |
|
247 if(kernel[i] < kernel[min]) |
|
248 kernel[min] = kernel[i]; |
|
249 if(klong[i] < klong[min]) |
|
250 klong[min] = klong[i]; |
|
251 //slowest time |
|
252 if(user[i] > user[max]) |
|
253 user[max] = user[i]; |
|
254 if(ulong[i] > ulong[max]) |
|
255 ulong[max] = ulong[i]; |
|
256 if(kernel[i] > kernel[max]) |
|
257 kernel[max] = kernel[i]; |
|
258 if(klong[i] > klong[max]) |
|
259 klong[max] = klong[i]; |
|
260 } |
|
261 |
|
262 INFO_PRINTF1(_L("Comparing foo times called from different places")); |
|
263 INFO_PRINTF1(_L("\t\t\tSanity, Sanity long, UPT")); |
|
264 INFO_PRINTF4(_L("User side, ns:\t %d, \t %d, \t%d"), userSanityTime, userSanityLongTime, userUtraceTime); |
|
265 INFO_PRINTF3(_L("Kernel side, ns:\t %d, \tN/A, \t%d"), kernelSanityTime, kernelUTraceTime); |
|
266 INFO_PRINTF3(_L("The time's are supposed to range between %d-%d for h4 for the normal sanity test"), KMinFooTime, KMaxFooTime); |
|
267 INFO_PRINTF2(_L("Number of iterations averaged over: %d"), KNumberOfTraceCallIterations+1); |
|
268 |
|
269 INFO_PRINTF1(_L("Checking what the variation is")); |
|
270 TInt variation = user[max] - user[min]; |
|
271 INFO_PRINTF5(_L("User sanity spans: \t\t%d-%d ns, variation: %d ns, percent: %f2"), user[min], user[max], variation, 100*(TReal)((TReal)variation/((TReal)user[min]+(TReal)variation/(TReal)2))); |
|
272 variation = ulong[max] - ulong[min]; |
|
273 INFO_PRINTF5(_L("User sanity long spans: \t%d-%d ns, variation: %d ns, percent: %f2"), ulong[min], ulong[max], variation, 100*(TReal)((TReal)variation/((TReal)ulong[min]+(TReal)variation/(TReal)2))); |
|
274 variation = kernel[max] - kernel[min]; |
|
275 INFO_PRINTF5(_L("kernel sanity spans: \t\t%d-%d ns, variation: %d ns, percent: %f2"), kernel[min], kernel[max], variation, 100*(TReal)((TReal)variation/((TReal)kernel[min]+(TReal)variation/(TReal)2))); |
|
276 variation = klong[max] - klong[min]; |
|
277 INFO_PRINTF1(_L("kernel sanity long spans: N/A as interrupts in DFCQ causes kernel panic, i.e. call is running for too long.")); |
|
278 INFO_PRINTF2(_L("Number of iterations averaged over: %d"), (iters+1)); |
|
279 |
|
280 //havent actually tested anything... not yet anyway |
|
281 return ETrue; |
|
282 } |
|
283 |
|
284 // eof |
|
285 |
|
286 |
|
287 |