changeset 39 | 5d2844f35677 |
parent 31 | 56f325a607ea |
child 90 | 947f0dc9f7a8 |
36:538db54a451d | 39:5d2844f35677 |
---|---|
15 // |
15 // |
16 |
16 |
17 #include "d_hcrsim.h" |
17 #include "d_hcrsim.h" |
18 #include <kernel/kernel.h> |
18 #include <kernel/kernel.h> |
19 #include <plat_priv.h> |
19 #include <plat_priv.h> |
20 #ifndef HCRTEST_USERSIDE_INTERFACE |
|
21 #include "hcr_debug.h" |
20 #include "hcr_debug.h" |
22 #include "hcr_hai.h" |
21 #include "hcr_uids.h" |
23 #include "hcr_pil.h" |
22 #ifdef HCRTEST_USERSIDE_INTERFACE |
23 #include "d_hcrsim_testdata.h" |
|
24 #endif // HCRTEST_USERSIDE_INTERFACE |
24 #endif // HCRTEST_USERSIDE_INTERFACE |
25 #include "hcr_uids.h" |
|
26 |
25 |
27 #define TEST(a) CheckPoint(a, __LINE__) |
26 #define TEST(a) CheckPoint(a, __LINE__) |
28 #define TEST_KERRNONE(a) CheckPointError(a, __LINE__) |
27 #define TEST_KERRNONE(a) CheckPointError(a, __LINE__) |
29 |
28 |
30 #ifndef HCRTEST_USERSIDE_INTERFACE |
29 #ifndef HCRTEST_USERSIDE_INTERFACE |
105 { |
104 { |
106 Kern::Printf("Device driver error %d (line %d)", aErrorCode, aLine); |
105 Kern::Printf("Device driver error %d (line %d)", aErrorCode, aLine); |
107 } |
106 } |
108 } |
107 } |
109 |
108 |
109 void HasRepositoryInSmr(TBool& aHasSmr, TBool& aHasSmrHcr) |
|
110 { |
|
111 aHasSmr = EFalse; |
|
112 aHasSmrHcr = EFalse; |
|
113 |
|
114 // Note: the SMR feature by which we obtain the address of the override |
|
115 // repository is only supported in the ARM bootstrap, not X86 or WINS so |
|
116 // this test code needs conditional compilation. |
|
117 #if !defined(__WINS__) && !defined(__X86__) |
|
118 const TSuperPage& superpage = Kern::SuperPage(); |
|
119 TUint32* smrib = (TUint32*) superpage.iSmrData; |
|
120 SSmrBank* smrbank = (SSmrBank*) smrib; |
|
121 if((smrib != NULL) && (smrib != (TUint32*)KSuperPageAddressFieldUndefined)) |
|
122 { |
|
123 aHasSmr = ETrue; |
|
124 while (smrbank->iBase) |
|
125 { |
|
126 if (smrbank->iPayloadUID == KHCRUID_SMRPayloadUID) |
|
127 { |
|
128 // We have a HCR repository - assuming it is the test one... |
|
129 aHasSmrHcr = ETrue; |
|
130 break; |
|
131 } |
|
132 ++smrbank; |
|
133 } |
|
134 } |
|
135 #endif // !__WINS__ && !__X86__ |
|
136 } |
|
137 |
|
110 #ifdef HCRTEST_USERSIDE_INTERFACE |
138 #ifdef HCRTEST_USERSIDE_INTERFACE |
111 #define KEXT_TESTKERRNONE(_r) \ |
139 #define KEXT_TESTKERRNONE(_r) \ |
112 { \ |
140 { \ |
113 if ((_r) && !TestKernExtensionTestLine) \ |
141 TInt _s = _r; \ |
142 if ((_s) && !TestKernExtensionTestLine) \ |
|
114 { \ |
143 { \ |
115 TestKernExtensionTestError = (_r); \ |
144 TestKernExtensionTestError = (_r); \ |
116 TestKernExtensionTestLine = __LINE__; \ |
145 TestKernExtensionTestLine = __LINE__; \ |
117 } \ |
146 } \ |
118 } |
147 } |
126 } |
155 } |
127 |
156 |
128 void KextInitTests() |
157 void KextInitTests() |
129 { |
158 { |
130 TInt r; |
159 TInt r; |
131 // Get last Setting in compiled repository |
160 // Get last Setting in Reference Compiled Repository |
132 TUint32 value1; |
161 TUint32 value1; |
133 HCR::TSettingId setting1(0xFFFFFFFF, 0xFFFFFFFF); |
162 TSettingId setting1(0xFFFFFFFF, 0xFFFFFFFF); |
134 r = HCR::GetUInt(setting1, value1); |
163 r = GetUInt(setting1, value1); |
135 KEXT_TESTKERRNONE(r); |
164 KEXT_TESTKERRNONE(r); |
136 KEXT_TEST(value1==0x4C415354); // 'L', 'A', 'S', 'T' |
165 KEXT_TEST(value1==0x4C415354); // 'L', 'A', 'S', 'T' |
137 |
166 |
138 // Get Setting in file repository |
167 // Determine what test repositories the HCR has loaded |
139 TUint32 value2; |
168 // Make sure we have the file repository |
140 HCR::TSettingId setting2(2, 2); |
169 const TRomHeader& romheader = Epoc::RomHeader(); |
141 r = HCR::GetUInt(setting2, value2); |
170 KEXT_TEST(romheader.iHcrFileAddress != NULL); // Assuming this is the test repository (hcr.dat) |
142 KEXT_TESTKERRNONE(r); |
171 // Find the nand repository |
172 TBool smr; |
|
173 TBool smrrep; |
|
174 SSettingC* repos = NULL; |
|
175 TInt nosettings = 0; |
|
176 HasRepositoryInSmr(smr, smrrep); |
|
177 if (smrrep) |
|
178 { |
|
179 repos = SettingsList6; // File+Nand |
|
180 nosettings = sizeof(SettingsList6) / sizeof(SSettingC); |
|
181 } |
|
182 else if (!smr) |
|
183 { |
|
184 repos = SettingsList7; // File Only |
|
185 nosettings = sizeof(SettingsList7) / sizeof(SSettingC); |
|
186 } |
|
187 else |
|
188 { |
|
189 // SMR partitions found but no HCR repository |
|
190 KEXT_TEST(0); |
|
191 return; |
|
192 } |
|
193 |
|
194 // Simple word setting Get |
|
195 for (SSettingC* setting = repos; setting < repos + nosettings; setting++) |
|
196 { |
|
197 // Note: these macros are irrelevant here, it is just so the two test kernel |
|
198 // extensions do something different |
|
199 #ifdef HCRTEST_CLIENT_THREAD |
|
200 if (setting->iName.iType == ETypeInt32) |
|
201 { |
|
202 TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey); |
|
203 TInt32 val; |
|
204 r = GetInt(id, val); |
|
205 KEXT_TESTKERRNONE(r); |
|
206 KEXT_TEST(setting->iValue.iLit.iInt32 == val); |
|
207 } |
|
208 #else // !HCRTEST_CLIENT_THREAD |
|
209 if (setting->iName.iType == ETypeUInt32) |
|
210 { |
|
211 TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey); |
|
212 TUint32 val; |
|
213 r = GetUInt(id, val); |
|
214 KEXT_TESTKERRNONE(r); |
|
215 KEXT_TEST(setting->iValue.iLit.iUInt32 == val); |
|
216 } |
|
217 #endif // !HCRTEST_CLIENT_THREAD |
|
218 } |
|
219 |
|
220 // Large setting Get |
|
221 for (SSettingC* setting = repos; setting < repos + nosettings; setting++) |
|
222 { |
|
223 // Note: these macros are irrelevant here, it is just so the two test kernel |
|
224 // extensions do something different |
|
225 #ifdef HCRTEST_CLIENT_THREAD |
|
226 if (setting->iName.iType == ETypeBinData) |
|
227 { |
|
228 TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey); |
|
229 TBuf8<KMaxSettingLength> val; |
|
230 TPtrC8 aval(setting->iValue.iPtr.iData, setting->iName.iLen); |
|
231 r = GetData(id, val); |
|
232 KEXT_TESTKERRNONE(r); |
|
233 KEXT_TEST(0 == val.Compare(aval)); |
|
234 } |
|
235 #else // !HCRTEST_CLIENT_THREAD |
|
236 if (setting->iName.iType == ETypeText8) |
|
237 { |
|
238 TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey); |
|
239 TBuf8<KMaxSettingLength> val; |
|
240 TPtrC8 aval(setting->iValue.iPtr.iString8, setting->iName.iLen); |
|
241 r = GetString(id, val); |
|
242 KEXT_TESTKERRNONE(r); |
|
243 KEXT_TEST(0 == val.Compare(aval)); |
|
244 } |
|
245 #endif // !HCRTEST_CLIENT_THREAD |
|
246 } |
|
247 |
|
248 // Some other API calls |
|
249 TUint i; |
|
250 for (i = 0; i < sizeof(KTestCategories) / sizeof(TCategoryUid); i++) |
|
251 { |
|
252 r = FindNumSettingsInCategory(KTestCategories[i]); |
|
253 KEXT_TEST(r >= 0); |
|
254 } |
|
143 } |
255 } |
144 |
256 |
145 DECLARE_EXTENSION_WITH_PRIORITY(KExtensionMaximumPriority) |
257 DECLARE_EXTENSION_WITH_PRIORITY(KExtensionMaximumPriority) |
146 { |
258 { |
147 // Set these to 0 so we know we've been here |
259 // Set these to 0 so we know we've been here |
264 TInt r=KErrNotSupported; |
376 TInt r=KErrNotSupported; |
265 switch (aReqNo) |
377 switch (aReqNo) |
266 { |
378 { |
267 case RHcrSimTestChannel::EHcrGetLinAddr: |
379 case RHcrSimTestChannel::EHcrGetLinAddr: |
268 { |
380 { |
269 HCR::TSettingId setting; |
381 TSettingId setting; |
270 TLinAddr value; |
382 TLinAddr value; |
271 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
383 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
272 r = HCR::GetLinAddr(setting, value); |
384 r = GetLinAddr(setting, value); |
273 TEST_MEMPUT(a2, &value, sizeof(value)); |
385 TEST_MEMPUT(a2, &value, sizeof(value)); |
274 break; |
386 break; |
275 } |
387 } |
276 case RHcrSimTestChannel::EHcrFindNumSettingsInCategory: |
388 case RHcrSimTestChannel::EHcrFindNumSettingsInCategory: |
277 { |
389 { |
278 r = HCR::FindNumSettingsInCategory((HCR::TCategoryUid) a1); |
390 r = FindNumSettingsInCategory((TCategoryUid) a1); |
279 break; |
391 break; |
280 } |
392 } |
281 case RHcrSimTestChannel::EHcrFindSettingsCategory: |
393 case RHcrSimTestChannel::EHcrFindSettingsCategory: |
282 { |
394 { |
283 // Get list of pointers |
395 // Get list of pointers |
284 TAny* args[6]; |
396 TAny* args[6]; |
285 TEST_MEMGET(a1, args, sizeof(args)); |
397 TEST_MEMGET(a1, args, sizeof(args)); |
286 TInt aMaxNum = (TInt) args[1]; |
398 TInt aMaxNum = (TInt) args[1]; |
287 // Allocate temporary memory |
399 |
288 |
400 TElementId* ids = NULL; |
289 HCR::TElementId* ids; |
401 TSettingType* types = NULL; |
290 HCR::TSettingType* types = NULL; |
|
291 TUint16* lens = NULL; |
402 TUint16* lens = NULL; |
292 TEST_ENTERCS(); |
403 if(args[3]) |
293 ids = (HCR::TElementId*) Kern::Alloc(aMaxNum * sizeof(HCR::TElementId)); |
404 { |
294 TEST_LEAVECS(); |
405 TEST_ENTERCS(); |
295 if (ids == NULL) |
406 ids = (TElementId*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TElementId)); |
296 { |
407 TEST_LEAVECS(); |
297 r = KErrNoMemory; |
408 } |
298 } |
409 |
299 else |
410 if (args[4]) // aTypes |
300 { |
411 { |
301 if (args[4]) // aTypes |
412 TEST_ENTERCS(); |
302 { |
413 types = (TSettingType*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TSettingType)); |
303 TEST_ENTERCS(); |
414 TEST_LEAVECS(); |
304 types = (HCR::TSettingType*) Kern::Alloc(aMaxNum * sizeof(HCR::TSettingType)); |
415 } |
305 TEST_LEAVECS(); |
416 if (types == NULL && args[4]) |
306 } |
417 { |
307 if (types == NULL && args[4]) |
418 r = KErrNoMemory; |
308 { |
419 } |
309 r = KErrNoMemory; |
420 else |
310 } |
421 { |
311 else |
422 if (args[5]) // aLens |
312 { |
423 { |
313 if (args[5]) // aLens |
424 TEST_ENTERCS(); |
314 { |
425 lens = (TUint16*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TUint16)); |
315 TEST_ENTERCS(); |
426 TEST_LEAVECS(); |
316 lens = (TUint16*) Kern::Alloc(aMaxNum * sizeof(TUint16)); |
427 } |
317 TEST_LEAVECS(); |
428 if (lens == NULL && args[5]) |
318 } |
429 { |
319 if (lens == NULL && args[5]) |
430 r = KErrNoMemory; |
320 { |
431 } |
321 r = KErrNoMemory; |
432 else |
322 } |
433 { |
323 else |
434 // Actual API call |
324 { |
435 r = FindSettings((TCategoryUid) args[0], |
325 // Actual API call |
436 aMaxNum, ids, types, lens); |
326 r = HCR::FindSettings((HCR::TCategoryUid) args[0], |
437 |
327 aMaxNum, ids, types, lens); |
438 // Send values back to client |
328 |
439 if (r >= 0) |
329 // Send values back to client |
440 { |
330 if (r >= 0) |
441 if(args[3]) |
331 { |
442 { |
332 TEST_MEMPUT(args[2], &r, sizeof(TUint32)); |
443 TEST_MEMPUT(args[3], ids, _ABS(aMaxNum) * sizeof(TElementId)); |
333 TEST_MEMPUT(args[3], ids, aMaxNum * sizeof(HCR::TElementId)); |
444 |
334 if (args[4]) |
445 if (args[4]) |
335 { |
446 { |
336 TEST_MEMPUT(args[4], types, aMaxNum * sizeof(HCR::TSettingType)); |
447 TEST_MEMPUT(args[4], types, _ABS(aMaxNum) * sizeof(TSettingType)); |
337 } |
448 } |
338 if (args[5]) |
449 if (args[5]) |
339 { |
450 { |
340 TEST_MEMPUT(args[5], lens, aMaxNum * sizeof(TUint16)); |
451 TEST_MEMPUT(args[5], lens, _ABS(aMaxNum) * sizeof(TUint16)); |
341 } |
452 } |
342 } |
453 } |
343 if (args[5]) |
454 } |
344 { |
455 |
345 TEST_ENTERCS(); |
456 if (args[5]) |
346 Kern::Free(lens); |
457 { |
347 TEST_LEAVECS(); |
458 TEST_ENTERCS(); |
348 } |
459 Kern::Free(lens); |
349 } |
460 TEST_LEAVECS(); |
350 if (args[4]) |
461 } |
351 { |
462 } |
352 TEST_ENTERCS(); |
463 if (args[4]) |
353 Kern::Free(types); |
464 { |
354 TEST_LEAVECS(); |
465 TEST_ENTERCS(); |
355 } |
466 Kern::Free(types); |
356 } |
467 TEST_LEAVECS(); |
357 TEST_ENTERCS(); |
468 } |
358 Kern::Free(ids); |
469 } |
359 TEST_LEAVECS(); |
470 |
360 } |
471 if(args[3]) |
361 break; |
472 { |
362 } |
473 TEST_ENTERCS(); |
474 Kern::Free(ids); |
|
475 TEST_LEAVECS(); |
|
476 } |
|
477 |
|
478 break; |
|
479 } |
|
480 |
|
363 case RHcrSimTestChannel::EHcrFindSettingsPattern: |
481 case RHcrSimTestChannel::EHcrFindSettingsPattern: |
364 { |
482 { |
365 // Get list of pointers |
483 // Get list of pointers |
366 TAny* args[8]; |
484 TAny* args[8]; |
367 TEST_MEMGET(a1, args, sizeof(args)); |
485 TEST_MEMGET(a1, args, sizeof(args)); |
368 TInt aMaxNum = (TInt) args[1]; |
486 TInt aMaxNum = (TInt) args[1]; |
369 // Allocate temporary memory |
487 // Allocate temporary memory |
370 TUint32 numfound; |
488 |
371 HCR::TElementId* ids; |
489 TElementId* ids = NULL; |
372 HCR::TSettingType* types = NULL; |
490 TSettingType* types = NULL; |
373 TUint16* lens = NULL; |
491 TUint16* lens = NULL; |
374 TEST_ENTERCS(); |
492 |
375 ids = (HCR::TElementId*) Kern::Alloc(aMaxNum * sizeof(HCR::TElementId)); |
493 if(args[5]) |
376 TEST_LEAVECS(); |
494 { |
377 if (ids == NULL) |
495 TEST_ENTERCS(); |
378 { |
496 ids = (TElementId*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TElementId)); |
379 r = KErrNoMemory; |
497 if(!ids) |
380 } |
498 return KErrNoMemory; |
381 else |
499 TEST_LEAVECS(); |
382 { |
500 } |
383 if (args[6]) // aTypes |
501 |
384 { |
502 if (args[6]) // aTypes |
385 TEST_ENTERCS(); |
503 { |
386 types = (HCR::TSettingType*) Kern::Alloc(aMaxNum * sizeof(HCR::TSettingType)); |
504 TEST_ENTERCS(); |
387 TEST_LEAVECS(); |
505 types = (TSettingType*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TSettingType)); |
388 } |
506 TEST_LEAVECS(); |
389 if (types == NULL && args[6]) |
507 } |
390 { |
508 |
391 r = KErrNoMemory; |
509 if (types == NULL && args[6]) |
392 } |
510 { |
393 else |
511 r = KErrNoMemory; |
394 { |
512 } |
395 if (args[7]) // aLens |
513 else |
396 { |
514 { |
397 TEST_ENTERCS(); |
515 if (args[7]) // aLens |
398 lens = (TUint16*) Kern::Alloc(aMaxNum * sizeof(TUint16)); |
516 { |
399 TEST_LEAVECS(); |
517 TEST_ENTERCS(); |
400 } |
518 lens = (TUint16*) Kern::Alloc(_ABS(aMaxNum) * sizeof(TUint16)); |
401 if (lens == NULL && args[7]) |
519 TEST_LEAVECS(); |
402 { |
520 } |
403 r = KErrNoMemory; |
521 if (lens == NULL && args[7]) |
404 } |
522 { |
405 else |
523 r = KErrNoMemory; |
406 { |
524 } |
407 // Actual API call |
525 else |
408 r = HCR::FindSettings((HCR::TCategoryUid) args[0], |
526 { |
409 aMaxNum, (TUint32) args[2], (TUint32) args[3], |
527 |
410 ids, types, lens); |
528 // Actual API call |
411 |
529 r = FindSettings((TCategoryUid) args[0], |
412 // Send values back to client |
530 aMaxNum, (TUint32) args[2], (TUint32) args[3], |
413 if (r > 0) |
531 ids, types, lens); |
414 { |
532 |
415 TEST_MEMPUT(args[4], &numfound, sizeof(TUint32)); |
533 // Send values back to client |
416 TEST_MEMPUT(args[5], ids, aMaxNum * sizeof(HCR::TElementId)); |
534 if (r > 0) |
417 if (args[6]) |
535 { |
418 { |
536 |
419 TEST_MEMPUT(args[6], types, aMaxNum * sizeof(HCR::TSettingType)); |
537 TEST_MEMPUT(args[5], ids, _ABS(aMaxNum) * sizeof(TElementId)); |
420 } |
538 if (args[6]) |
421 if (args[7]) |
539 { |
422 { |
540 TEST_MEMPUT(args[6], types, _ABS(aMaxNum) * sizeof(TSettingType)); |
423 TEST_MEMPUT(args[7], lens, aMaxNum * sizeof(TUint16)); |
541 } |
424 } |
542 if (args[7]) |
425 } |
543 { |
426 if (args[7]) |
544 TEST_MEMPUT(args[7], lens, _ABS(aMaxNum) * sizeof(TUint16)); |
427 { |
545 } |
428 TEST_ENTERCS(); |
546 } |
429 Kern::Free(lens); |
547 if (args[7]) |
430 TEST_LEAVECS(); |
548 { |
431 } |
549 TEST_ENTERCS(); |
432 } |
550 Kern::Free(lens); |
433 if (args[6]) |
551 TEST_LEAVECS(); |
434 { |
552 } |
435 TEST_ENTERCS(); |
553 } |
436 Kern::Free(types); |
554 if (args[6]) |
437 TEST_LEAVECS(); |
555 { |
438 } |
556 TEST_ENTERCS(); |
439 } |
557 Kern::Free(types); |
440 TEST_ENTERCS(); |
558 TEST_LEAVECS(); |
441 Kern::Free(ids); |
559 } |
442 TEST_LEAVECS(); |
560 } |
443 } |
561 |
562 if(args[5]) |
|
563 { |
|
564 TEST_ENTERCS(); |
|
565 Kern::Free(ids); |
|
566 TEST_LEAVECS(); |
|
567 } |
|
568 |
|
569 |
|
444 break; |
570 break; |
445 } |
571 } |
446 case RHcrSimTestChannel::EHcrGetTypeAndSize: |
572 case RHcrSimTestChannel::EHcrGetTypeAndSize: |
447 { |
573 { |
448 // Get list of pointers |
574 // Get list of pointers |
449 TAny* args[3]; |
575 TAny* args[3]; |
450 TEST_MEMGET(a1, args, sizeof(args)); |
576 TEST_MEMGET(a1, args, sizeof(args)); |
451 HCR::TSettingId id; |
577 TSettingId id; |
452 TEST_MEMGET(args[0], &id, sizeof(HCR::TSettingId)); |
578 TEST_MEMGET(args[0], &id, sizeof(TSettingId)); |
453 HCR::TSettingType type; |
579 TSettingType type; |
454 TUint16 len; |
580 TUint16 len; |
455 r = HCR::GetTypeAndSize(id, type, len); |
581 r = GetTypeAndSize(id, type, len); |
456 TEST_MEMPUT(args[1], &type, sizeof(HCR::TSettingType)); |
582 TEST_MEMPUT(args[1], &type, sizeof(TSettingType)); |
457 TEST_MEMPUT(args[2], &len, sizeof(TUint16)); |
583 TEST_MEMPUT(args[2], &len, sizeof(TUint16)); |
458 break; |
584 break; |
459 } |
585 } |
460 case RHcrSimTestChannel::EHcrGetWordSettings: |
586 case RHcrSimTestChannel::EHcrGetWordSettings: |
461 { |
587 { |
462 // Get list of pointers |
588 // Get list of pointers |
463 TAny* args[5]; |
589 TAny* args[5]; |
464 TEST_MEMGET(a1, args, sizeof(args)); |
590 TEST_MEMGET(a1, args, sizeof(args)); |
465 TInt aNum = (TInt) args[0]; |
591 TInt aNum = (TInt) args[0]; |
466 // Allocate temporary memory |
592 // Allocate temporary memory |
467 HCR::SSettingId* ids; |
593 SSettingId* ids; |
468 HCR::SSettingId* inIds = (HCR::SSettingId*)args[1]; |
594 SSettingId* inIds = (SSettingId*)args[1]; |
469 TInt32* vals; |
595 TInt32* vals; |
470 HCR::TSettingType* types= NULL; |
596 TSettingType* types= NULL; |
471 TInt* errors = NULL; |
597 TInt* errors = NULL; |
472 |
598 |
473 TEST_ENTERCS(); |
599 TEST_ENTERCS(); |
474 if(inIds) |
600 if(inIds) |
475 { |
601 { |
476 ids = (HCR::SSettingId*) Kern::Alloc((aNum>=0?aNum:-aNum) * sizeof(HCR::SSettingId)); |
602 ids = (SSettingId*) Kern::Alloc((aNum>=0?aNum:-aNum) * sizeof(SSettingId)); |
477 //Read data from the user side |
603 //Read data from the user side |
478 if (ids == NULL) |
604 if (ids == NULL) |
479 { |
605 { |
480 r = KErrNoMemory; |
606 r = KErrNoMemory; |
481 break; |
607 break; |
482 } |
608 } |
483 |
609 |
484 TEST_MEMGET(inIds, ids, (aNum>=0?aNum:-aNum) * sizeof(HCR::SSettingId)); |
610 TEST_MEMGET(inIds, ids, (aNum>=0?aNum:-aNum) * sizeof(SSettingId)); |
485 } |
611 } |
486 else |
612 else |
487 ids = NULL; |
613 ids = NULL; |
488 TEST_LEAVECS(); |
614 TEST_LEAVECS(); |
489 |
615 |
502 vals = NULL; |
628 vals = NULL; |
503 |
629 |
504 if (args[3]) // aTypes |
630 if (args[3]) // aTypes |
505 { |
631 { |
506 TEST_ENTERCS(); |
632 TEST_ENTERCS(); |
507 types = (HCR::TSettingType*) Kern::Alloc((aNum>=0?aNum:-aNum) * |
633 types = (TSettingType*) Kern::Alloc((aNum>=0?aNum:-aNum) * |
508 sizeof(HCR::TSettingType)); |
634 sizeof(TSettingType)); |
509 TEST_LEAVECS(); |
635 TEST_LEAVECS(); |
510 } |
636 } |
511 if (types == NULL && args[3]) |
637 if (types == NULL && args[3]) |
512 { |
638 { |
513 r = KErrNoMemory; |
639 r = KErrNoMemory; |
525 r = KErrNoMemory; |
651 r = KErrNoMemory; |
526 } |
652 } |
527 else |
653 else |
528 { |
654 { |
529 // Actual API call |
655 // Actual API call |
530 r = HCR::GetWordSettings(aNum, ids, vals, types, errors); |
656 r = GetWordSettings(aNum, ids, vals, types, errors); |
531 // Send values back to client |
657 // Send values back to client |
532 if (r >= 0) |
658 if (r >= 0) |
533 { |
659 { |
534 TEST_MEMPUT(args[1], ids, aNum * sizeof(HCR::SSettingId)); |
660 TEST_MEMPUT(args[1], ids, aNum * sizeof(SSettingId)); |
535 TEST_MEMPUT(args[2], vals, aNum * sizeof(TInt32)); |
661 TEST_MEMPUT(args[2], vals, aNum * sizeof(TInt32)); |
536 if (args[3]) |
662 if (args[3]) |
537 { |
663 { |
538 TEST_MEMPUT(args[3], types,(aNum>=0?aNum:-aNum) * sizeof(HCR::TSettingType)); |
664 TEST_MEMPUT(args[3], types,(aNum>=0?aNum:-aNum) * sizeof(TSettingType)); |
539 } |
665 } |
540 if (args[4]) |
666 if (args[4]) |
541 { |
667 { |
542 TEST_MEMPUT(args[4], errors, (aNum>=0?aNum:-aNum) * sizeof(TInt)); |
668 TEST_MEMPUT(args[4], errors, (aNum>=0?aNum:-aNum) * sizeof(TInt)); |
543 } |
669 } |
569 |
695 |
570 break; |
696 break; |
571 } |
697 } |
572 case RHcrSimTestChannel::EHcrGetInt64: |
698 case RHcrSimTestChannel::EHcrGetInt64: |
573 { |
699 { |
574 HCR::TSettingId setting; |
700 TSettingId setting; |
575 TInt64 value; |
701 TInt64 value; |
576 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
702 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
577 r = HCR::GetInt(setting, value); |
703 r = GetInt(setting, value); |
578 TEST_MEMPUT(a2, &value, sizeof(value)); |
704 TEST_MEMPUT(a2, &value, sizeof(value)); |
579 break; |
705 break; |
580 } |
706 } |
581 case RHcrSimTestChannel::EHcrGetInt32: |
707 case RHcrSimTestChannel::EHcrGetInt32: |
582 { |
708 { |
583 HCR::TSettingId setting; |
709 TSettingId setting; |
584 TInt32 value; |
710 TInt32 value; |
585 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
711 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
586 r = HCR::GetInt(setting, value); |
712 r = GetInt(setting, value); |
587 TEST_MEMPUT(a2, &value, sizeof(value)); |
713 TEST_MEMPUT(a2, &value, sizeof(value)); |
588 break; |
714 break; |
589 } |
715 } |
590 case RHcrSimTestChannel::EHcrGetInt16: |
716 case RHcrSimTestChannel::EHcrGetInt16: |
591 { |
717 { |
592 HCR::TSettingId setting; |
718 TSettingId setting; |
593 TInt16 value; |
719 TInt16 value; |
594 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
720 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
595 r = HCR::GetInt(setting, value); |
721 r = GetInt(setting, value); |
596 TEST_MEMPUT(a2, &value, sizeof(value)); |
722 TEST_MEMPUT(a2, &value, sizeof(value)); |
597 break; |
723 break; |
598 } |
724 } |
599 case RHcrSimTestChannel::EHcrGetInt8: |
725 case RHcrSimTestChannel::EHcrGetInt8: |
600 { |
726 { |
601 HCR::TSettingId setting; |
727 TSettingId setting; |
602 TInt8 value; |
728 TInt8 value; |
603 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
729 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
604 r = HCR::GetInt(setting, value); |
730 r = GetInt(setting, value); |
605 TEST_MEMPUT(a2, &value, sizeof(value)); |
731 TEST_MEMPUT(a2, &value, sizeof(value)); |
606 break; |
732 break; |
607 } |
733 } |
608 case RHcrSimTestChannel::EHcrGetBool: |
734 case RHcrSimTestChannel::EHcrGetBool: |
609 { |
735 { |
610 HCR::TSettingId setting; |
736 TSettingId setting; |
611 TBool value; |
737 TBool value; |
612 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
738 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
613 r = HCR::GetBool(setting, value); |
739 r = GetBool(setting, value); |
614 TEST_MEMPUT(a2, &value, sizeof(value)); |
740 TEST_MEMPUT(a2, &value, sizeof(value)); |
615 break; |
741 break; |
616 } |
742 } |
617 case RHcrSimTestChannel::EHcrGetDataArray: |
743 case RHcrSimTestChannel::EHcrGetDataArray: |
618 { |
744 { |
619 // Get list of pointers |
745 // Get list of pointers |
620 TAny* args[4]; |
746 TAny* args[4]; |
621 TEST_MEMGET(a1, args, sizeof(args)); |
747 TEST_MEMGET(a1, args, sizeof(args)); |
622 TUint maxlen = (TUint) args[1]; |
748 TUint maxlen = (TUint) args[1]; |
623 // Retrieve structures from client |
749 // Retrieve structures from client |
624 HCR::TSettingId id; |
750 TSettingId id; |
625 TEST_MEMGET(args[0], &id, sizeof(HCR::TSettingId)); |
751 TEST_MEMGET(args[0], &id, sizeof(TSettingId)); |
626 // Allocate temporary memory |
752 // Allocate temporary memory |
627 TUint16 len; |
753 TUint16 len; |
628 TUint8* value; |
754 TUint8* value; |
629 TEST_ENTERCS(); |
755 TEST_ENTERCS(); |
630 value = (TUint8*) Kern::Alloc(maxlen * sizeof(TUint8)); |
756 value = (TUint8*) Kern::Alloc(maxlen * sizeof(TUint8)); |
634 r = KErrNoMemory; |
760 r = KErrNoMemory; |
635 } |
761 } |
636 else |
762 else |
637 { |
763 { |
638 // Actual API call |
764 // Actual API call |
639 r = HCR::GetData(id, (TUint16) maxlen, |
765 r = GetData(id, (TUint16) maxlen, |
640 value, len); |
766 value, len); |
641 // Send value back to client |
767 // Send value back to client |
642 if (!r) |
768 if (!r) |
643 { |
769 { |
644 TEST_MEMPUT(args[2], value, maxlen * sizeof(TUint8)); |
770 TEST_MEMPUT(args[2], value, maxlen * sizeof(TUint8)); |
650 } |
776 } |
651 break; |
777 break; |
652 } |
778 } |
653 case RHcrSimTestChannel::EHcrGetDataDes: |
779 case RHcrSimTestChannel::EHcrGetDataDes: |
654 { |
780 { |
655 HCR::TSettingId setting; |
781 TSettingId setting; |
656 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
782 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
657 TInt userdes[sizeof(TDes8) / sizeof(TInt) + 1]; |
783 TInt userdes[sizeof(TDes8) / sizeof(TInt) + 1]; |
658 TEST_MEMGET(a2, userdes, sizeof(TDes8)); |
784 TEST_MEMGET(a2, userdes, sizeof(TDes8)); |
659 HBuf8* value; |
785 HBuf8* value; |
660 TEST_ENTERCS(); |
786 TEST_ENTERCS(); |
661 value = HBuf8::New(userdes[1]); |
787 value = HBuf8::New(userdes[1]); |
664 { |
790 { |
665 r = KErrNoMemory; |
791 r = KErrNoMemory; |
666 } |
792 } |
667 else |
793 else |
668 { |
794 { |
669 r = HCR::GetData(setting, *value); |
795 r = GetData(setting, *value); |
670 TEST_DESPUT(a2, *value); |
796 TEST_DESPUT(a2, *value); |
671 TEST_ENTERCS(); |
797 TEST_ENTERCS(); |
672 delete value; |
798 delete value; |
673 TEST_LEAVECS(); |
799 TEST_LEAVECS(); |
674 } |
800 } |
675 break; |
801 break; |
676 } |
802 } |
677 case RHcrSimTestChannel::EHcrGetUInt64: |
803 case RHcrSimTestChannel::EHcrGetUInt64: |
678 { |
804 { |
679 HCR::TSettingId setting; |
805 TSettingId setting; |
680 TUint64 value; |
806 TUint64 value; |
681 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
807 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
682 r = HCR::GetUInt(setting, value); |
808 r = GetUInt(setting, value); |
683 TEST_MEMPUT(a2, &value, sizeof(value)); |
809 TEST_MEMPUT(a2, &value, sizeof(value)); |
684 break; |
810 break; |
685 } |
811 } |
686 case RHcrSimTestChannel::EHcrGetUInt32: |
812 case RHcrSimTestChannel::EHcrGetUInt32: |
687 { |
813 { |
688 HCR::TSettingId setting; |
814 TSettingId setting; |
689 TUint32 value; |
815 TUint32 value; |
690 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
816 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
691 r = HCR::GetUInt(setting, value); |
817 r = GetUInt(setting, value); |
692 TEST_MEMPUT(a2, &value, sizeof(value)); |
818 TEST_MEMPUT(a2, &value, sizeof(value)); |
693 break; |
819 break; |
694 } |
820 } |
695 case RHcrSimTestChannel::EHcrGetUInt16: |
821 case RHcrSimTestChannel::EHcrGetUInt16: |
696 { |
822 { |
697 HCR::TSettingId setting; |
823 TSettingId setting; |
698 TUint16 value; |
824 TUint16 value; |
699 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
825 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
700 r = HCR::GetUInt(setting, value); |
826 r = GetUInt(setting, value); |
701 TEST_MEMPUT(a2, &value, sizeof(value)); |
827 TEST_MEMPUT(a2, &value, sizeof(value)); |
702 break; |
828 break; |
703 } |
829 } |
704 case RHcrSimTestChannel::EHcrGetUInt8: |
830 case RHcrSimTestChannel::EHcrGetUInt8: |
705 { |
831 { |
706 HCR::TSettingId setting; |
832 TSettingId setting; |
707 TUint8 value; |
833 TUint8 value; |
708 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
834 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
709 r = HCR::GetUInt(setting, value); |
835 r = GetUInt(setting, value); |
710 TEST_MEMPUT(a2, &value, sizeof(value)); |
836 TEST_MEMPUT(a2, &value, sizeof(value)); |
711 break; |
837 break; |
712 } |
838 } |
713 case RHcrSimTestChannel::EHcrGetArrayInt: |
839 case RHcrSimTestChannel::EHcrGetArrayInt: |
714 { |
840 { |
715 // Get list of pointers |
841 // Get list of pointers |
716 TAny* args[4]; |
842 TAny* args[4]; |
717 TEST_MEMGET(a1, args, sizeof(args)); |
843 TEST_MEMGET(a1, args, sizeof(args)); |
718 TUint maxlen = (TUint) args[1]; |
844 TUint maxlen = (TUint) args[1]; |
719 // Retrieve structures from client |
845 // Retrieve structures from client |
720 HCR::TSettingId id; |
846 TSettingId id; |
721 TEST_MEMGET(args[0], &id, sizeof(HCR::TSettingId)); |
847 TEST_MEMGET(args[0], &id, sizeof(TSettingId)); |
722 // Allocate temporary memory |
848 // Allocate temporary memory |
723 TUint16 len; |
849 TUint16 len; |
724 TInt32* value; |
850 TInt32* value; |
725 TEST_ENTERCS(); |
851 TEST_ENTERCS(); |
726 value = (TInt32*) Kern::Alloc(maxlen); |
852 value = (TInt32*) Kern::Alloc(maxlen); |
730 r = KErrNoMemory; |
856 r = KErrNoMemory; |
731 } |
857 } |
732 else |
858 else |
733 { |
859 { |
734 // Actual API call |
860 // Actual API call |
735 r = HCR::GetArray(id, (TUint16) maxlen, |
861 r = GetArray(id, (TUint16) maxlen, |
736 value, len); |
862 value, len); |
737 // Send value back to client |
863 // Send value back to client |
738 if (!r) |
864 if (!r) |
739 { |
865 { |
740 TEST_MEMPUT(args[2], value, maxlen); |
866 TEST_MEMPUT(args[2], value, maxlen); |
751 // Get list of pointers |
877 // Get list of pointers |
752 TAny* args[4]; |
878 TAny* args[4]; |
753 TEST_MEMGET(a1, args, sizeof(args)); |
879 TEST_MEMGET(a1, args, sizeof(args)); |
754 TUint maxlen = (TUint) args[1]; |
880 TUint maxlen = (TUint) args[1]; |
755 // Retrieve structures from client |
881 // Retrieve structures from client |
756 HCR::TSettingId id; |
882 TSettingId id; |
757 TEST_MEMGET(args[0], &id, sizeof(HCR::TSettingId)); |
883 TEST_MEMGET(args[0], &id, sizeof(TSettingId)); |
758 // Allocate temporary memory |
884 // Allocate temporary memory |
759 TUint16 len; |
885 TUint16 len; |
760 TUint32* value; |
886 TUint32* value; |
761 TEST_ENTERCS(); |
887 TEST_ENTERCS(); |
762 value = (TUint32*) Kern::Alloc(maxlen); |
888 value = (TUint32*) Kern::Alloc(maxlen); |
766 r = KErrNoMemory; |
892 r = KErrNoMemory; |
767 } |
893 } |
768 else |
894 else |
769 { |
895 { |
770 // Actual API call |
896 // Actual API call |
771 r = HCR::GetArray(id, (TUint16) maxlen, |
897 r = GetArray(id, (TUint16) maxlen, |
772 value, len); |
898 value, len); |
773 // Send value back to client |
899 // Send value back to client |
774 if (!r) |
900 if (!r) |
775 { |
901 { |
776 TEST_MEMPUT(args[2], value, maxlen); |
902 TEST_MEMPUT(args[2], value, maxlen); |
787 // Get list of pointers |
913 // Get list of pointers |
788 TAny* args[4]; |
914 TAny* args[4]; |
789 TEST_MEMGET(a1, args, sizeof(args)); |
915 TEST_MEMGET(a1, args, sizeof(args)); |
790 TUint maxlen = (TUint) args[1]; |
916 TUint maxlen = (TUint) args[1]; |
791 // Retrieve structures from client |
917 // Retrieve structures from client |
792 HCR::TSettingId id; |
918 TSettingId id; |
793 TEST_MEMGET(args[0], &id, sizeof(HCR::TSettingId)); |
919 TEST_MEMGET(args[0], &id, sizeof(TSettingId)); |
794 // Allocate temporary memory |
920 // Allocate temporary memory |
795 TUint16 len; |
921 TUint16 len; |
796 TText8* value; |
922 TText8* value; |
797 TEST_ENTERCS(); |
923 TEST_ENTERCS(); |
798 value = (TText8*) Kern::Alloc(maxlen * sizeof(TText8)); |
924 value = (TText8*) Kern::Alloc(maxlen * sizeof(TText8)); |
802 r = KErrNoMemory; |
928 r = KErrNoMemory; |
803 } |
929 } |
804 else |
930 else |
805 { |
931 { |
806 // Actual API call |
932 // Actual API call |
807 r = HCR::GetString(id, (TUint16) maxlen, |
933 r = GetString(id, (TUint16) maxlen, |
808 value, len); |
934 value, len); |
809 // Send value back to client |
935 // Send value back to client |
810 if (!r) |
936 if (!r) |
811 { |
937 { |
812 TEST_MEMPUT(args[2], value, maxlen * sizeof(TText8)); |
938 TEST_MEMPUT(args[2], value, maxlen * sizeof(TText8)); |
818 } |
944 } |
819 break; |
945 break; |
820 } |
946 } |
821 case RHcrSimTestChannel::EHcrGetStringDes: |
947 case RHcrSimTestChannel::EHcrGetStringDes: |
822 { |
948 { |
823 HCR::TSettingId setting; |
949 TSettingId setting; |
824 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
950 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
825 TInt userdes[sizeof(TDes8) / sizeof(TInt) + 1]; |
951 TInt userdes[sizeof(TDes8) / sizeof(TInt) + 1]; |
826 TEST_MEMGET(a2, userdes, sizeof(TDes8)); |
952 TEST_MEMGET(a2, userdes, sizeof(TDes8)); |
827 HBuf8* value; |
953 HBuf8* value; |
828 TEST_ENTERCS(); |
954 TEST_ENTERCS(); |
829 value = HBuf8::New(userdes[1]); |
955 value = HBuf8::New(userdes[1]); |
832 { |
958 { |
833 r = KErrNoMemory; |
959 r = KErrNoMemory; |
834 } |
960 } |
835 else |
961 else |
836 { |
962 { |
837 r = HCR::GetString(setting, *value); |
963 r = GetString(setting, *value); |
838 TEST_DESPUT(a2, *value); |
964 TEST_DESPUT(a2, *value); |
839 TEST_ENTERCS(); |
965 TEST_ENTERCS(); |
840 delete value; |
966 delete value; |
841 TEST_LEAVECS(); |
967 TEST_LEAVECS(); |
842 } |
968 } |
861 TText8* pfile = filestr; |
987 TText8* pfile = filestr; |
862 if (filename.Length() == 0) |
988 if (filename.Length() == 0) |
863 { |
989 { |
864 pfile = NULL; |
990 pfile = NULL; |
865 } |
991 } |
866 if ((TUint) a2 == HCR::HCRInternal::ECoreRepos) |
992 if ((TUint) a2 == HCRInternal::ECoreRepos) |
867 { |
993 { |
868 r = HCRSingleton->SwitchRepository(pfile, HCR::HCRInternal::ECoreRepos); |
994 r = HCRSingleton->SwitchRepository(pfile, HCRInternal::ECoreRepos); |
869 } |
995 } |
870 else if ((TUint) a2 == HCR::HCRInternal::EOverrideRepos) |
996 else if ((TUint) a2 == HCRInternal::EOverrideRepos) |
871 { |
997 { |
872 r = HCRSingleton->SwitchRepository(pfile, HCR::HCRInternal::EOverrideRepos); |
998 r = HCRSingleton->SwitchRepository(pfile, HCRInternal::EOverrideRepos); |
873 } |
999 } |
874 break; |
1000 break; |
875 } |
1001 } |
876 case RHcrSimTestChannel::EHcrCheckIntegrity: |
1002 case RHcrSimTestChannel::EHcrCheckIntegrity: |
877 { |
1003 { |
884 r = KErrNone; |
1010 r = KErrNone; |
885 TEST_MEMPUT(a1, (TAny*) &TestKernExtensionTestLine, sizeof(TInt)); |
1011 TEST_MEMPUT(a1, (TAny*) &TestKernExtensionTestLine, sizeof(TInt)); |
886 TEST_MEMPUT(a2, (TAny*) &TestKernExtensionTestError, sizeof(TInt)); |
1012 TEST_MEMPUT(a2, (TAny*) &TestKernExtensionTestError, sizeof(TInt)); |
887 } |
1013 } |
888 break; |
1014 break; |
1015 case RHcrSimTestChannel::EHcrHasRepositoryInSmr: |
|
1016 { |
|
1017 r = KErrNone; |
|
1018 TBool smr; |
|
1019 TBool smrrep; |
|
1020 HasRepositoryInSmr(smr, smrrep); |
|
1021 TEST_MEMPUT(a1, (TAny*) &smr, sizeof(TBool)); |
|
1022 TEST_MEMPUT(a2, (TAny*) &smrrep, sizeof(TBool)); |
|
1023 } |
|
1024 break; |
|
889 case RHcrSimTestChannel::EHcrBenchmarkGetSettingInt: |
1025 case RHcrSimTestChannel::EHcrBenchmarkGetSettingInt: |
890 { |
1026 { |
891 r = KErrNone; |
1027 r = KErrNone; |
892 TUint i; |
1028 TUint i; |
893 HCR::TSettingId setting; |
1029 TSettingId setting; |
894 TInt32 value; |
1030 TInt32 value; |
895 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
1031 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
896 // |
1032 // |
897 TUint32 start = NKern::TickCount(); |
1033 TUint32 start = NKern::TickCount(); |
898 for (i = 0; i < KTestBenchmarkIterations; i++) |
1034 for (i = 0; i < KTestBenchmarkIterations; i++) |
899 { |
1035 { |
900 r |= HCR::GetInt(setting, value); |
1036 r |= GetInt(setting, value); |
901 } |
1037 } |
902 TUint32 end = NKern::TickCount(); |
1038 TUint32 end = NKern::TickCount(); |
903 // |
1039 // |
904 TUint32 ms; |
1040 TUint32 ms; |
905 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
1041 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
908 break; |
1044 break; |
909 case RHcrSimTestChannel::EHcrBenchmarkGetSettingArray: |
1045 case RHcrSimTestChannel::EHcrBenchmarkGetSettingArray: |
910 { |
1046 { |
911 r = KErrNone; |
1047 r = KErrNone; |
912 TUint i; |
1048 TUint i; |
913 HCR::TSettingId setting; |
1049 TSettingId setting; |
914 TText8* value; |
1050 TText8* value; |
915 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
1051 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
916 // Allocate temporary memory |
1052 // Allocate temporary memory |
917 TEST_ENTERCS(); |
1053 TEST_ENTERCS(); |
918 value = (TText8*) Kern::Alloc(HCR::KMaxSettingLength); |
1054 value = (TText8*) Kern::Alloc(KMaxSettingLength); |
919 TEST_LEAVECS(); |
1055 TEST_LEAVECS(); |
920 if (value == NULL) |
1056 if (value == NULL) |
921 { |
1057 { |
922 r = KErrNoMemory; |
1058 r = KErrNoMemory; |
923 } |
1059 } |
925 { |
1061 { |
926 TUint16 len; |
1062 TUint16 len; |
927 TUint32 start = NKern::TickCount(); |
1063 TUint32 start = NKern::TickCount(); |
928 for (i = 0; i < KTestBenchmarkIterations; i++) |
1064 for (i = 0; i < KTestBenchmarkIterations; i++) |
929 { |
1065 { |
930 r |= HCR::GetString(setting, (TUint16) HCR::KMaxSettingLength, value, len); |
1066 r |= GetString(setting, (TUint16) KMaxSettingLength, value, len); |
931 } |
1067 } |
932 TUint32 end = NKern::TickCount(); |
1068 TUint32 end = NKern::TickCount(); |
933 // |
1069 // |
934 TUint32 ms; |
1070 TUint32 ms; |
935 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
1071 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
942 break; |
1078 break; |
943 case RHcrSimTestChannel::EHcrBenchmarkGetSettingDes: |
1079 case RHcrSimTestChannel::EHcrBenchmarkGetSettingDes: |
944 { |
1080 { |
945 r = KErrNone; |
1081 r = KErrNone; |
946 TUint i; |
1082 TUint i; |
947 HCR::TSettingId setting; |
1083 TSettingId setting; |
948 TBuf8<HCR::KMaxSettingLength> value; |
1084 TBuf8<KMaxSettingLength> value; |
949 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
1085 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
950 TUint32 start = NKern::TickCount(); |
1086 TUint32 start = NKern::TickCount(); |
951 for (i = 0; i < KTestBenchmarkIterations; i++) |
1087 for (i = 0; i < KTestBenchmarkIterations; i++) |
952 { |
1088 { |
953 r |= HCR::GetString(setting, value); |
1089 r |= GetString(setting, value); |
954 } |
1090 } |
955 TUint32 end = NKern::TickCount(); |
1091 TUint32 end = NKern::TickCount(); |
956 // |
1092 // |
957 TUint32 ms; |
1093 TUint32 ms; |
958 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
1094 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
964 r = 0; |
1100 r = 0; |
965 TUint i; |
1101 TUint i; |
966 TUint32 start = NKern::TickCount(); |
1102 TUint32 start = NKern::TickCount(); |
967 for (i = 0; i < KTestBenchmarkIterations; i++) |
1103 for (i = 0; i < KTestBenchmarkIterations; i++) |
968 { |
1104 { |
969 r |= HCR::FindNumSettingsInCategory((HCR::TCategoryUid) a1); |
1105 r |= FindNumSettingsInCategory((TCategoryUid) a1); |
970 } |
1106 } |
971 TUint32 end = NKern::TickCount(); |
1107 TUint32 end = NKern::TickCount(); |
972 // |
1108 // |
973 TUint32 ms; |
1109 TUint32 ms; |
974 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
1110 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
978 case RHcrSimTestChannel::EHcrBenchmarkFindSettings: |
1114 case RHcrSimTestChannel::EHcrBenchmarkFindSettings: |
979 { |
1115 { |
980 r = 0; |
1116 r = 0; |
981 TUint i; |
1117 TUint i; |
982 |
1118 |
983 HCR::TElementId* ids; |
1119 TElementId* ids; |
984 HCR::TSettingType* types; |
1120 TSettingType* types; |
985 TUint16* lens; |
1121 TUint16* lens; |
986 TEST_ENTERCS(); |
1122 TEST_ENTERCS(); |
987 ids = (HCR::TElementId*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(HCR::TElementId)); |
1123 ids = (TElementId*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(TElementId)); |
988 TEST_LEAVECS(); |
1124 TEST_LEAVECS(); |
989 if (!ids) |
1125 if (!ids) |
990 { |
1126 { |
991 TEST(EFalse); |
1127 TEST(EFalse); |
992 r = KErrNoMemory; |
1128 r = KErrNoMemory; |
993 } |
1129 } |
994 else |
1130 else |
995 { |
1131 { |
996 |
1132 |
997 TEST_ENTERCS(); |
1133 TEST_ENTERCS(); |
998 types = (HCR::TSettingType*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(HCR::TSettingType)); |
1134 types = (TSettingType*) Kern::Alloc(KTestBenchmarkNumberOfSettingsInCategory * sizeof(TSettingType)); |
999 TEST_LEAVECS(); |
1135 TEST_LEAVECS(); |
1000 if (!types) |
1136 if (!types) |
1001 { |
1137 { |
1002 TEST(EFalse); |
1138 TEST(EFalse); |
1003 r = KErrNoMemory; |
1139 r = KErrNoMemory; |
1016 { |
1152 { |
1017 |
1153 |
1018 TUint32 start = NKern::TickCount(); |
1154 TUint32 start = NKern::TickCount(); |
1019 for (i = 0; i < KTestBenchmarkIterations; i++) |
1155 for (i = 0; i < KTestBenchmarkIterations; i++) |
1020 { |
1156 { |
1021 r |= HCR::FindSettings((HCR::TCategoryUid) a1, |
1157 r |= FindSettings((TCategoryUid) a1, |
1022 KTestBenchmarkNumberOfSettingsInCategory, |
1158 KTestBenchmarkNumberOfSettingsInCategory, |
1023 ids, types, lens); |
1159 ids, types, lens); |
1024 } |
1160 } |
1025 TUint32 end = NKern::TickCount(); |
1161 TUint32 end = NKern::TickCount(); |
1026 // |
1162 // |
1044 break; |
1180 break; |
1045 case RHcrSimTestChannel::EHcrBenchmarkGetTypeAndSize: |
1181 case RHcrSimTestChannel::EHcrBenchmarkGetTypeAndSize: |
1046 { |
1182 { |
1047 r = KErrNone; |
1183 r = KErrNone; |
1048 TUint i; |
1184 TUint i; |
1049 HCR::TSettingId setting; |
1185 TSettingId setting; |
1050 HCR::TSettingType type; |
1186 TSettingType type; |
1051 TUint16 len; |
1187 TUint16 len; |
1052 TEST_MEMGET(a1, &setting, sizeof(HCR::TSettingId)); |
1188 TEST_MEMGET(a1, &setting, sizeof(TSettingId)); |
1053 // |
1189 // |
1054 TUint32 start = NKern::TickCount(); |
1190 TUint32 start = NKern::TickCount(); |
1055 for (i = 0; i < KTestBenchmarkIterations; i++) |
1191 for (i = 0; i < KTestBenchmarkIterations; i++) |
1056 { |
1192 { |
1057 r |= HCR::GetTypeAndSize(setting, type, len); |
1193 r |= GetTypeAndSize(setting, type, len); |
1058 } |
1194 } |
1059 TUint32 end = NKern::TickCount(); |
1195 TUint32 end = NKern::TickCount(); |
1060 // |
1196 // |
1061 TUint32 ms; |
1197 TUint32 ms; |
1062 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
1198 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
1065 break; |
1201 break; |
1066 case RHcrSimTestChannel::EHcrBenchmarkGetWordSettings: |
1202 case RHcrSimTestChannel::EHcrBenchmarkGetWordSettings: |
1067 { |
1203 { |
1068 r = 0; |
1204 r = 0; |
1069 TUint i; |
1205 TUint i; |
1070 HCR::SSettingId* ids; |
1206 SSettingId* ids; |
1071 HCR::TSettingType* types; |
1207 TSettingType* types; |
1072 HCR::TCategoryUid catId = (HCR::TCategoryUid)a1; |
1208 TCategoryUid catId = (TCategoryUid)a1; |
1073 TInt32* values; |
1209 TInt32* values; |
1074 TInt* errors; |
1210 TInt* errors; |
1075 TEST_ENTERCS(); |
1211 TEST_ENTERCS(); |
1076 //We allocate here KTestBenchmarkNumberOfSettingsInCategory - 1 because |
1212 //We allocate here KTestBenchmarkNumberOfSettingsInCategory - 1 because |
1077 //last element in the category is a large setting |
1213 //last element in the category is a large setting |
1078 ids = (HCR::SSettingId*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(HCR::SSettingId)); |
1214 ids = (SSettingId*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(SSettingId)); |
1079 TEST_LEAVECS(); |
1215 TEST_LEAVECS(); |
1080 if (!ids) |
1216 if (!ids) |
1081 { |
1217 { |
1082 TEST(EFalse); |
1218 TEST(EFalse); |
1083 r = KErrNoMemory; |
1219 r = KErrNoMemory; |
1089 ids[eId].iCat = catId; |
1225 ids[eId].iCat = catId; |
1090 //First element has value 1, second 2, third 3 and so on |
1226 //First element has value 1, second 2, third 3 and so on |
1091 ids[eId].iKey = eId + 1; |
1227 ids[eId].iKey = eId + 1; |
1092 } |
1228 } |
1093 TEST_ENTERCS(); |
1229 TEST_ENTERCS(); |
1094 types = (HCR::TSettingType*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(HCR::TSettingType)); |
1230 types = (TSettingType*) Kern::Alloc((KTestBenchmarkNumberOfSettingsInCategory - 1) * sizeof(TSettingType)); |
1095 TEST_LEAVECS(); |
1231 TEST_LEAVECS(); |
1096 if (!types) |
1232 if (!types) |
1097 { |
1233 { |
1098 TEST(EFalse); |
1234 TEST(EFalse); |
1099 r = KErrNoMemory; |
1235 r = KErrNoMemory; |
1121 else |
1257 else |
1122 { |
1258 { |
1123 TUint32 start = NKern::TickCount(); |
1259 TUint32 start = NKern::TickCount(); |
1124 for (i = 0; i < KTestGetMultipleBenchmarkIterations; i++) |
1260 for (i = 0; i < KTestGetMultipleBenchmarkIterations; i++) |
1125 { |
1261 { |
1126 r |= HCR::GetWordSettings(KTestBenchmarkNumberOfSettingsInCategory - 1, ids, values, types, errors); |
1262 r |= GetWordSettings(KTestBenchmarkNumberOfSettingsInCategory - 1, ids, values, types, errors); |
1127 } |
1263 } |
1128 TUint32 end = NKern::TickCount(); |
1264 TUint32 end = NKern::TickCount(); |
1129 // |
1265 // |
1130 TUint32 ms; |
1266 TUint32 ms; |
1131 ms = ((end - start) * NKern::TickPeriod()) / 1000; |
1267 ms = ((end - start) * NKern::TickPeriod()) / 1000; |