152 TestKernExtensionTestError = 1; \ |
152 TestKernExtensionTestError = 1; \ |
153 TestKernExtensionTestLine = __LINE__; \ |
153 TestKernExtensionTestLine = __LINE__; \ |
154 } \ |
154 } \ |
155 } |
155 } |
156 |
156 |
|
157 // Invoke some non-fatal calls on the real HCR.dll in the BSP to show |
|
158 // a kernel extension can use the HCR API early in boot. |
157 void KextInitTests() |
159 void KextInitTests() |
158 { |
160 { |
159 TInt r; |
161 TInt r; |
|
162 |
160 // Get last Setting in Reference Compiled Repository |
163 // Get last Setting in Reference Compiled Repository |
161 TUint32 value1; |
164 TUint32 value1; |
162 TSettingId setting1(0xFFFFFFFF, 0xFFFFFFFF); |
165 TSettingId setting1(0xFFFFFFFF, 0xFFFFFFFF); |
163 r = GetUInt(setting1, value1); |
166 r = GetUInt(setting1, value1); |
164 KEXT_TESTKERRNONE(r); |
167 KEXT_TESTKERRNONE(r); |
165 KEXT_TEST(value1==0x4C415354); // 'L', 'A', 'S', 'T' |
168 KEXT_TEST(value1==0x4C415354); // 'L', 'A', 'S', 'T' |
166 |
169 |
167 // Determine what test repositories the HCR has loaded |
170 // Check number of settings in some test categories. |
168 // Make sure we have the file repository |
171 // Most likely these categories are not used in the real HCR.dll |
169 const TRomHeader& romheader = Epoc::RomHeader(); |
|
170 KEXT_TEST(romheader.iHcrFileAddress != NULL); // Assuming this is the test repository (hcr.dat) |
|
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; |
172 TUint i; |
250 for (i = 0; i < sizeof(KTestCategories) / sizeof(TCategoryUid); i++) |
173 for (i = 0; i < sizeof(KTestCategories) / sizeof(TCategoryUid); i++) |
251 { |
174 { |
252 r = FindNumSettingsInCategory(KTestCategories[i]); |
175 r = FindNumSettingsInCategory(KTestCategories[i]); |
253 KEXT_TEST(r >= 0); |
176 KEXT_TEST(r >= 0); |
294 TInt r; |
217 TInt r; |
295 #ifndef HCRTEST_CLIENT_THREAD |
218 #ifndef HCRTEST_CLIENT_THREAD |
296 r = Kern::DynamicDfcQCreate(iDfcQ, KHcrSimTestThreadPriority, KHcrSimTestThread); |
219 r = Kern::DynamicDfcQCreate(iDfcQ, KHcrSimTestThreadPriority, KHcrSimTestThread); |
297 if (r != KErrNone) |
220 if (r != KErrNone) |
298 return r; |
221 return r; |
|
222 // Allow this test DFCQ thread to take page faults should it happen rather |
|
223 // than let the Kernel panic it with 2,61 KERN-EXEC. |
|
224 iDfcQ->SetRealtimeState(ERealtimeStateOff); |
299 #ifdef HCRTEST_USERSIDE_INTERFACE |
225 #ifdef HCRTEST_USERSIDE_INTERFACE |
300 r = SetName(&KTestHcrRealOwn); |
226 r = SetName(&KTestHcrRealOwn); |
301 #else |
227 #else |
302 r = SetName(&KTestHcrSimOwn); |
228 r = SetName(&KTestHcrSimOwn); |
303 #endif // HCRTEST_USERSIDE_INTERFACE |
229 #endif // HCRTEST_USERSIDE_INTERFACE |