|
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 // EFM test steps for characterising feature manager performance. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 @test |
|
22 */ |
|
23 |
|
24 #include <featdiscovery.h> |
|
25 #include <featmgr/featurecontrol.h> |
|
26 #include <hal.h> |
|
27 #include "characterisation_steps.h" |
|
28 #include "efm_teststepbase.h" |
|
29 |
|
30 // This is the base class for some of our characterisation tests. |
|
31 // Creates an RFeatureControl object, finds out what the fast counter |
|
32 // frequency is and gets the timeout for this test. |
|
33 TVerdict CCharacteriseBaseStep :: doTestStepPreambleL() |
|
34 { |
|
35 // First find out the granularity of the system clock.. |
|
36 HAL::Get(HALData::EFastCounterFrequency, icountfreq); |
|
37 INFO_PRINTF2(_L("Counts per sec=%d"), icountfreq); |
|
38 icountperusec = icountfreq/1000000.0; |
|
39 INFO_PRINTF2(_L("Counts per usec=%f"), icountperusec); |
|
40 |
|
41 TInt err = icontrol.Open(); |
|
42 TESTDIAGNOSTICERROR(err==KErrNone, |
|
43 _L("RFeatureControl::Open failed: error = %d"), err); |
|
44 if(err) { return TestStepResult(); } |
|
45 CleanupClosePushL(icontrol); |
|
46 |
|
47 // Get the timeout from the .ini file. The name of the timeout entry |
|
48 // varies depending on what type of build we have. |
|
49 TBuf<20> timeoutini(_L("Timeout")); |
|
50 #ifdef __WINSCW__ |
|
51 timeoutini.Append(_L("_WINSCW")); |
|
52 #endif |
|
53 #ifdef __ARMCC__ |
|
54 timeoutini.Append(_L("_ARM")); |
|
55 TInt muid = 0; |
|
56 HAL::Get(HAL::EMachineUid, muid); |
|
57 switch (muid) |
|
58 { |
|
59 case HAL::EMachineUid_OmapH2: |
|
60 timeoutini.Append(_L("_H2")); |
|
61 break; |
|
62 case HAL::EMachineUid_OmapH4: |
|
63 timeoutini.Append(_L("_H4")); |
|
64 break; |
|
65 case HAL::EMachineUid_OmapH6: |
|
66 timeoutini.Append(_L("_H6")); |
|
67 break; |
|
68 case HAL::EMachineUid_NE1_TB: |
|
69 timeoutini.Append(_L("_NE1")); |
|
70 break; |
|
71 //add any new hardware IDs here |
|
72 default: |
|
73 break; |
|
74 } |
|
75 #endif |
|
76 #ifdef _DEBUG |
|
77 timeoutini.Append(_L("_UDEB")); |
|
78 #else |
|
79 timeoutini.Append(_L("_UREL")); |
|
80 #endif |
|
81 |
|
82 // Get the timeout, which is measured in microseconds. |
|
83 if( !GetIntFromConfig(ConfigSection(), timeoutini, itimeout ) ) |
|
84 { |
|
85 ERR_PRINTF2(_L("Can't find '%S' in .ini file"), |
|
86 &timeoutini ); |
|
87 CleanupStack::PopAndDestroy(&icontrol); |
|
88 SetTestStepResult(EFail); |
|
89 return TestStepResult(); |
|
90 } |
|
91 return TestStepResult(); |
|
92 } |
|
93 |
|
94 TVerdict CCharacteriseBaseStep :: doTestStepPostambleL() |
|
95 { |
|
96 CleanupStack::PopAndDestroy(&icontrol); |
|
97 return TestStepResult(); |
|
98 } |
|
99 |
|
100 CCharacteriseSupportedStep :: CCharacteriseSupportedStep() |
|
101 { |
|
102 SetTestStepName(KCharacteriseSupported); |
|
103 } |
|
104 |
|
105 TVerdict CCharacteriseSupportedStep::doTestStepL() |
|
106 { |
|
107 // The base class 'CCharacteriseBaseStep' has already opened the |
|
108 // RFeatureControl object and read in the timeout number. |
|
109 |
|
110 // Find out how many features we're going to attempt to read, the |
|
111 // minimum uid (that we start on) and the number of supported UIDs |
|
112 // we expect to find in this range. |
|
113 TInt nfeats, minuid, expsup; |
|
114 if(!GetIntFromConfig(ConfigSection(), _L("NumFeaturesToRead"), nfeats) || |
|
115 !GetIntFromConfig(ConfigSection(), _L("MinFeatureUID"), minuid) || |
|
116 !GetIntFromConfig(ConfigSection(), _L("NumSupported"), expsup)) |
|
117 { |
|
118 ERR_PRINTF1(_L("Can't find 'NumFeaturesToRead', 'MinFeatureUID' and 'NumSupported' in .ini file")); |
|
119 SetTestStepResult(EFail); |
|
120 return TestStepResult(); |
|
121 } |
|
122 |
|
123 TInt mintime = 0x7fffffff; |
|
124 TInt maxtime = 0; |
|
125 TInt totaltime = User::FastCounter(); |
|
126 for(TInt i=0 ; i<10 ; i++) |
|
127 { |
|
128 // This is the main part of the test where we perform timing.. |
|
129 TInt nsup=0; |
|
130 TUint prevtime = User::FastCounter(); |
|
131 for(TInt uid=minuid ; uid < minuid + nfeats ; uid++) |
|
132 { |
|
133 TUid tuid = { uid }; |
|
134 if(icontrol.FeatureSupported(tuid) == KFeatureSupported) nsup++; |
|
135 } |
|
136 TUint elapsedtime = User::FastCounter() - prevtime; |
|
137 if(elapsedtime < mintime) mintime = elapsedtime; |
|
138 if(elapsedtime > maxtime) maxtime = elapsedtime; |
|
139 if(nsup != expsup) |
|
140 { |
|
141 ERR_PRINTF3(_L("Expected %d supported features, got %d"), |
|
142 expsup, nsup); |
|
143 SetTestStepResult(EFail); |
|
144 } |
|
145 } |
|
146 totaltime = User::FastCounter() - totaltime; |
|
147 TInt avetime = totaltime/10; |
|
148 |
|
149 TReal us = mintime / icountperusec; |
|
150 INFO_PRINTF2(_L("Minimum time %f us"), us); |
|
151 // This test has been changed to use the minimum timing to check against |
|
152 // the wanted because it suffers from lots of noise - I've seen |
|
153 // max/min ratios of > 10! |
|
154 if(us > itimeout) |
|
155 { |
|
156 ERR_PRINTF3(_L("Test failed timeout. Got '%f' minimum, wanted < '%d'"), |
|
157 us, itimeout); |
|
158 SetTestStepResult(EFail); |
|
159 } |
|
160 us = maxtime / icountperusec; |
|
161 INFO_PRINTF2(_L("Maximum time %f us"), us); |
|
162 us = avetime / icountperusec; |
|
163 INFO_PRINTF2(_L("Average time %f us"), us); |
|
164 return TestStepResult(); |
|
165 } |
|
166 |
|
167 CCharacteriseSupportedArrayStep :: CCharacteriseSupportedArrayStep() |
|
168 { |
|
169 SetTestStepName(KCharacteriseSupportedArray); |
|
170 } |
|
171 |
|
172 TVerdict CCharacteriseSupportedArrayStep::doTestStepL() |
|
173 { |
|
174 // Find out how many features we're going to attempt to read.. |
|
175 TInt nfeats, minuid, expsup; |
|
176 if(!GetIntFromConfig(ConfigSection(), _L("NumFeaturesToRead"), nfeats) || |
|
177 !GetIntFromConfig(ConfigSection(), _L("MinFeatureUID"), minuid) || |
|
178 !GetIntFromConfig(ConfigSection(), _L("NumSupported"), expsup)) |
|
179 { |
|
180 ERR_PRINTF1(_L("Can't find 'NumFeaturesToRead', 'MinFeatureUID' and 'NumSupported' in .ini file")); |
|
181 SetTestStepResult(EFail); |
|
182 return TestStepResult(); |
|
183 } |
|
184 |
|
185 |
|
186 // Set up a loop so we can get average timings. |
|
187 TInt mintime = 0x7fffffff; |
|
188 TInt maxtime = 0; |
|
189 TInt totaltime = User::FastCounter(); |
|
190 for(TInt i=0 ; i<10 ; i++) |
|
191 { |
|
192 // First generate an RFeatureArray containing the features we're interested |
|
193 // in. |
|
194 RFeatureArray rfa; |
|
195 CleanupClosePushL(rfa); |
|
196 for(TInt uid=minuid ; uid < minuid + nfeats ; uid++) |
|
197 { |
|
198 TUid tuid = { uid }; |
|
199 rfa.AppendL(tuid); |
|
200 } |
|
201 // This is the main part of the test where we perform timing.. |
|
202 TUint prevtime = User::FastCounter(); |
|
203 TInt err = icontrol.FeaturesSupported(rfa); |
|
204 TUint elapsedtime = User::FastCounter() - prevtime; |
|
205 TInt nsup = rfa.Count(); // The array may have been pared down.. |
|
206 CleanupStack::PopAndDestroy(&rfa); |
|
207 |
|
208 if(err) |
|
209 { |
|
210 ERR_PRINTF2(_L("FeaturesSupported gave %d, expected KErrNone"), err); |
|
211 SetTestStepResult(EFail); |
|
212 } |
|
213 if(nsup != expsup) |
|
214 { |
|
215 ERR_PRINTF3(_L("Expected %d supported features, got %d"), |
|
216 expsup, nsup); |
|
217 SetTestStepResult(EFail); |
|
218 } |
|
219 if(elapsedtime < mintime) mintime = elapsedtime; |
|
220 if(elapsedtime > maxtime) maxtime = elapsedtime; |
|
221 } |
|
222 totaltime = User::FastCounter() - totaltime; |
|
223 TInt avetime = totaltime/10; |
|
224 TReal us = mintime / icountperusec; |
|
225 INFO_PRINTF2(_L("Minimum time %f us"), us); |
|
226 // This test has been changed to use the minimum timing to check against |
|
227 // the wanted because it suffers from lots of noise - I've seen |
|
228 // max/min ratios of > 10! |
|
229 if(us > itimeout) |
|
230 { |
|
231 ERR_PRINTF3(_L("Test failed timeout. Got '%f' minimum, wanted < '%d'"), |
|
232 us, itimeout); |
|
233 SetTestStepResult(EFail); |
|
234 } |
|
235 us = maxtime / icountperusec; |
|
236 INFO_PRINTF2(_L("Maximum time %f us"), us); |
|
237 us = avetime / icountperusec; |
|
238 INFO_PRINTF2(_L("Average time %f us"), us); |
|
239 |
|
240 return TestStepResult(); |
|
241 } |