sl@0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// For testing initialise HAL :
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
@file
|
sl@0
|
20 |
@internalComponent
|
sl@0
|
21 |
@test
|
sl@0
|
22 |
*/
|
sl@0
|
23 |
|
sl@0
|
24 |
#include <e32base.h>
|
sl@0
|
25 |
#include <hal.h>
|
sl@0
|
26 |
#include <f32file.h>
|
sl@0
|
27 |
#include <bautils.h>
|
sl@0
|
28 |
#include <e32test.h>
|
sl@0
|
29 |
|
sl@0
|
30 |
_LIT(KHALSettingsExeName, "HALSettings.exe");
|
sl@0
|
31 |
_LIT(KInitialiseLocaleExeName, "InitialiseLocale.exe");
|
sl@0
|
32 |
|
sl@0
|
33 |
// Symbian VendorID as specified in
|
sl@0
|
34 |
// "Platform security engineering guide" Section 2.1.3.2
|
sl@0
|
35 |
const TVendorId KSymbianVendorId(0x70000001);
|
sl@0
|
36 |
|
sl@0
|
37 |
#define TEST(arg) ::Check((arg), __LINE__)
|
sl@0
|
38 |
#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
|
sl@0
|
39 |
|
sl@0
|
40 |
//Number of sample used
|
sl@0
|
41 |
TInt noSample = 25;
|
sl@0
|
42 |
LOCAL_D RTest TheTest (_L ("T_InitialiseHAL"));
|
sl@0
|
43 |
|
sl@0
|
44 |
LOCAL_C void Check(TInt aValue, TInt aLine)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
if(!aValue)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
TheTest(EFalse, aLine);
|
sl@0
|
49 |
}
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
if(aValue != aExpected)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
|
sl@0
|
57 |
TheTest(EFalse, aLine);
|
sl@0
|
58 |
}
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
/**
|
sl@0
|
62 |
* This function will start HALSettings.exe with invalid argument and wait for finish
|
sl@0
|
63 |
* It is used for base line performance overhead
|
sl@0
|
64 |
*/
|
sl@0
|
65 |
TInt StartEmptyExeL()
|
sl@0
|
66 |
{
|
sl@0
|
67 |
RProcess process;
|
sl@0
|
68 |
//With command line length more than 10 HALSettings.exe returns
|
sl@0
|
69 |
//immediately with error KErrArgument, Used to baseline
|
sl@0
|
70 |
//performance overhead to run an empty exe
|
sl@0
|
71 |
TEST2(process.Create(KHALSettingsExeName,_L("Length is more than ten")),KErrNone);
|
sl@0
|
72 |
TRequestStatus status;
|
sl@0
|
73 |
process.Logon(status);
|
sl@0
|
74 |
process.Resume();
|
sl@0
|
75 |
User::WaitForRequest(status);
|
sl@0
|
76 |
TInt exitReason = process.ExitReason();
|
sl@0
|
77 |
process.Close();
|
sl@0
|
78 |
return exitReason;
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
/**
|
sl@0
|
82 |
* Initialise HAL settings from HAL.DAT
|
sl@0
|
83 |
* This test will start the HALSettings.exe and wait to finish
|
sl@0
|
84 |
*/
|
sl@0
|
85 |
TInt TestInitialiseHALWaitL()
|
sl@0
|
86 |
{
|
sl@0
|
87 |
RProcess process;
|
sl@0
|
88 |
TEST2(process.Create(KHALSettingsExeName, _L("INITIALISE")),KErrNone);
|
sl@0
|
89 |
TRequestStatus status;
|
sl@0
|
90 |
process.Logon(status);
|
sl@0
|
91 |
process.Resume();
|
sl@0
|
92 |
User::WaitForRequest(status);
|
sl@0
|
93 |
TInt exitReason = process.ExitReason();
|
sl@0
|
94 |
process.Close();
|
sl@0
|
95 |
return exitReason;
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
/**
|
sl@0
|
99 |
* Persist HAL settings to HAL.DAT
|
sl@0
|
100 |
* It will create a new HAL.DAT
|
sl@0
|
101 |
*/
|
sl@0
|
102 |
TInt TestPersistHALWaitL()
|
sl@0
|
103 |
{
|
sl@0
|
104 |
RProcess process;
|
sl@0
|
105 |
TEST2(process.Create(KHALSettingsExeName, _L("PERSIST")),KErrNone);
|
sl@0
|
106 |
TRequestStatus status;
|
sl@0
|
107 |
process.Logon(status);
|
sl@0
|
108 |
process.Resume();
|
sl@0
|
109 |
User::WaitForRequest(status);
|
sl@0
|
110 |
TInt exitReason = process.ExitReason();
|
sl@0
|
111 |
process.Close();
|
sl@0
|
112 |
return exitReason;
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|
sl@0
|
115 |
//Tests
|
sl@0
|
116 |
//===================================================================
|
sl@0
|
117 |
/**
|
sl@0
|
118 |
@SYMTestCaseID SYSLIB-HALSETTINGS-CT-1712
|
sl@0
|
119 |
@SYMTestCaseDesc Initialise HAL settings With wrong commandline
|
sl@0
|
120 |
@SYMTestPriority Medium
|
sl@0
|
121 |
@SYMTestActions Start HALSettings.exe and returns KErrArgument
|
sl@0
|
122 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
123 |
@SYMDEF DEF083235: Prop: HAL Attributes (eg screen calibration) lost if the battery is pulled out
|
sl@0
|
124 |
*/
|
sl@0
|
125 |
void TestInitialiseHALWrongParameterL()
|
sl@0
|
126 |
{
|
sl@0
|
127 |
TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-HALSETTINGS-CT-1712 Try to Initialise With wrong commandline "));
|
sl@0
|
128 |
RProcess process;
|
sl@0
|
129 |
TEST2(process.Create(KHALSettingsExeName, _L("ABCD")),KErrNone);
|
sl@0
|
130 |
TRequestStatus status;
|
sl@0
|
131 |
process.Logon(status);
|
sl@0
|
132 |
process.Resume();
|
sl@0
|
133 |
User::WaitForRequest(status);
|
sl@0
|
134 |
TInt exitReason = process.ExitReason();
|
sl@0
|
135 |
process.Close();
|
sl@0
|
136 |
TEST2(exitReason, KErrArgument);
|
sl@0
|
137 |
}
|
sl@0
|
138 |
|
sl@0
|
139 |
/**
|
sl@0
|
140 |
@SYMTestCaseID SYSLIB-HALSETTINGS-CT-1713
|
sl@0
|
141 |
@SYMTestCaseDesc Missing HAL.DAT File
|
sl@0
|
142 |
@SYMTestPriority Medium
|
sl@0
|
143 |
@SYMTestActions This function first delete hal.dat and then try to initialise HAL
|
sl@0
|
144 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
145 |
@SYMDEF DEF083235: Prop: HAL Attributes (eg screen calibration) lost if the battery is pulled out
|
sl@0
|
146 |
*/
|
sl@0
|
147 |
void TestHALFileMissingL()
|
sl@0
|
148 |
{
|
sl@0
|
149 |
TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-HALSETTINGS-CT-1713 HAL.DAT file missing "));
|
sl@0
|
150 |
_LIT(KFileName,"c:\\private\\102825B1\\hal.dat");
|
sl@0
|
151 |
RFs fs;
|
sl@0
|
152 |
fs.Connect();
|
sl@0
|
153 |
TInt err = BaflUtils::DeleteFile(fs,KFileName);
|
sl@0
|
154 |
if(err == KErrNone || err == KErrNotFound )
|
sl@0
|
155 |
{
|
sl@0
|
156 |
TEST2(TestInitialiseHALWaitL(),KErrNotFound);
|
sl@0
|
157 |
}
|
sl@0
|
158 |
fs.Close();
|
sl@0
|
159 |
}
|
sl@0
|
160 |
|
sl@0
|
161 |
/**
|
sl@0
|
162 |
@SYMTestCaseID SYSLIB-HALSETTINGS-CT-1724
|
sl@0
|
163 |
@SYMTestCaseDesc No Access HAL.DAT File
|
sl@0
|
164 |
@SYMTestPriority Medium
|
sl@0
|
165 |
@SYMTestActions This function first open hal.dat and then try to initialise HAL
|
sl@0
|
166 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
167 |
@SYMDEF DEF083235: Prop: HAL Attributes (eg screen calibration) lost if the battery is pulled out
|
sl@0
|
168 |
*/
|
sl@0
|
169 |
void TestHALFileNoAccessL()
|
sl@0
|
170 |
{
|
sl@0
|
171 |
TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-HALSETTINGS-CT-1724 HAL.DAT No Access "));
|
sl@0
|
172 |
//To create hal.dat
|
sl@0
|
173 |
TEST2(TestPersistHALWaitL(),KErrNone);
|
sl@0
|
174 |
_LIT(KFileName,"c:\\private\\102825B1\\hal.dat");
|
sl@0
|
175 |
RFs fs;
|
sl@0
|
176 |
fs.Connect();
|
sl@0
|
177 |
RFile file;
|
sl@0
|
178 |
TInt err = file.Open(fs,KFileName,EFileShareExclusive);
|
sl@0
|
179 |
if(err == KErrNone )
|
sl@0
|
180 |
{
|
sl@0
|
181 |
TEST2(TestInitialiseHALWaitL(),KErrInUse);
|
sl@0
|
182 |
}
|
sl@0
|
183 |
file.Close();
|
sl@0
|
184 |
fs.Close();
|
sl@0
|
185 |
}
|
sl@0
|
186 |
|
sl@0
|
187 |
/**
|
sl@0
|
188 |
@SYMTestCaseID SYSLIB-HALSETTINGS-CT-1714
|
sl@0
|
189 |
@SYMTestCaseDesc HAL.DAT File is Empty
|
sl@0
|
190 |
@SYMTestPriority Medium
|
sl@0
|
191 |
@SYMTestActions This function first create an empty hal.dat and then try to initialise HAL
|
sl@0
|
192 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
193 |
@SYMDEF DEF083235: Prop: HAL Attributes (eg screen calibration) lost if the battery is pulled out
|
sl@0
|
194 |
*/
|
sl@0
|
195 |
void TestHALFileEmptyL()
|
sl@0
|
196 |
{
|
sl@0
|
197 |
TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-HALSETTINGS-CT-1714 HAL.DAT file Empty "));
|
sl@0
|
198 |
_LIT(KFileName,"c:\\private\\102825B1\\hal.dat");
|
sl@0
|
199 |
RFs fs;
|
sl@0
|
200 |
fs.Connect();
|
sl@0
|
201 |
RFile file;
|
sl@0
|
202 |
TInt err = file.Replace(fs,KFileName,EFileRead);
|
sl@0
|
203 |
file.Close();
|
sl@0
|
204 |
|
sl@0
|
205 |
if(err == KErrNone )
|
sl@0
|
206 |
{
|
sl@0
|
207 |
TEST2(TestInitialiseHALWaitL(), KErrCorrupt);
|
sl@0
|
208 |
}
|
sl@0
|
209 |
fs.Close();
|
sl@0
|
210 |
}
|
sl@0
|
211 |
|
sl@0
|
212 |
/**
|
sl@0
|
213 |
@SYMTestCaseID SYSLIB-HALSETTINGS-CT-1715
|
sl@0
|
214 |
@SYMTestCaseDesc Wrong Header
|
sl@0
|
215 |
@SYMTestPriority Medium
|
sl@0
|
216 |
@SYMTestActions This function first corrupt hal.dat by adding wrong header and then
|
sl@0
|
217 |
try to initialise HAL
|
sl@0
|
218 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
219 |
@SYMDEF DEF083235: Prop: HAL Attributes (eg screen calibration) lost if the battery is pulled out
|
sl@0
|
220 |
*/
|
sl@0
|
221 |
void TestHALFileWrongHeaderL()
|
sl@0
|
222 |
{
|
sl@0
|
223 |
TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-HALSETTINGS-CT-1715 HAL.DAT wrong header "));
|
sl@0
|
224 |
_LIT(KFileName,"c:\\private\\102825B1\\hal.dat");
|
sl@0
|
225 |
RFs fs;
|
sl@0
|
226 |
fs.Connect();
|
sl@0
|
227 |
RFile file;
|
sl@0
|
228 |
TInt err = file.Replace(fs,KFileName,EFileRead| EFileWrite);
|
sl@0
|
229 |
|
sl@0
|
230 |
//write data in multiples of 8 otherwise it will not pass the check (size&7) == 0
|
sl@0
|
231 |
file.Write(_L8("abcdefghijklmnop"));
|
sl@0
|
232 |
|
sl@0
|
233 |
file.Close();
|
sl@0
|
234 |
fs.Close();
|
sl@0
|
235 |
|
sl@0
|
236 |
if(err == KErrNone )
|
sl@0
|
237 |
{
|
sl@0
|
238 |
TEST2(TestInitialiseHALWaitL(), KErrCorrupt);
|
sl@0
|
239 |
}
|
sl@0
|
240 |
}
|
sl@0
|
241 |
|
sl@0
|
242 |
//Performance Tests
|
sl@0
|
243 |
//======================================================================================
|
sl@0
|
244 |
/**
|
sl@0
|
245 |
@SYMTestCaseID SYSLIB-HALSETTINGS-CT-1718
|
sl@0
|
246 |
@SYMTestCaseDesc Performance Test Initialise with file
|
sl@0
|
247 |
@SYMTestPriority Medium
|
sl@0
|
248 |
@SYMTestActions Initialise HAL settings with HAL.DAT present
|
sl@0
|
249 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
250 |
@SYMDEF DEF083235: Prop: HAL Attributes (eg screen calibration) lost if the battery is pulled out
|
sl@0
|
251 |
*/
|
sl@0
|
252 |
void TestPerformanceInitialiseWithFileL()
|
sl@0
|
253 |
{
|
sl@0
|
254 |
TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-HALSETTINGS-CT-1718 Performance Test for initialise hal.dat present "));
|
sl@0
|
255 |
|
sl@0
|
256 |
_LIT(KFileName,"c:\\private\\102825B1\\hal.dat");
|
sl@0
|
257 |
RFs fs;
|
sl@0
|
258 |
fs.Connect();
|
sl@0
|
259 |
//to create hal.dat if it is not there
|
sl@0
|
260 |
TEST2(TestPersistHALWaitL(),KErrNone);
|
sl@0
|
261 |
TEST(BaflUtils::FileExists(fs,KFileName));
|
sl@0
|
262 |
TInt fastTimerFreq;
|
sl@0
|
263 |
HAL::Get(HALData::EFastCounterFrequency, fastTimerFreq);
|
sl@0
|
264 |
TReal ticksPerMicroSec = 1.0E-6 * fastTimerFreq;
|
sl@0
|
265 |
TUint prevTime;
|
sl@0
|
266 |
TUint timeDiff;
|
sl@0
|
267 |
|
sl@0
|
268 |
prevTime = User::FastCounter();
|
sl@0
|
269 |
TInt noSuccessfulSamples=0;
|
sl@0
|
270 |
for(;noSuccessfulSamples < noSample; ++noSuccessfulSamples)
|
sl@0
|
271 |
{
|
sl@0
|
272 |
if(TestInitialiseHALWaitL() != KErrNone)
|
sl@0
|
273 |
{
|
sl@0
|
274 |
break; //Stop performing the tests, calculate average with no of successful Samples.
|
sl@0
|
275 |
}
|
sl@0
|
276 |
//else continue;
|
sl@0
|
277 |
}
|
sl@0
|
278 |
TEST(noSuccessfulSamples >0);
|
sl@0
|
279 |
timeDiff = User::FastCounter() - prevTime;
|
sl@0
|
280 |
TReal64 fsSessionMicroSecs = timeDiff / (noSuccessfulSamples * ticksPerMicroSec);
|
sl@0
|
281 |
TheTest.Printf(_L("Time to Initialise HAL (with file) = %10.2lf microseconds\n"), fsSessionMicroSecs);
|
sl@0
|
282 |
fs.Close();
|
sl@0
|
283 |
}
|
sl@0
|
284 |
/**
|
sl@0
|
285 |
@SYMTestCaseID SYSLIB-HALSETTINGS-CT-1719
|
sl@0
|
286 |
@SYMTestCaseDesc Performance Test Initialise with no file
|
sl@0
|
287 |
@SYMTestPriority Medium
|
sl@0
|
288 |
@SYMTestActions Initialise HAL settings with no HAL.DAT present
|
sl@0
|
289 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
290 |
@SYMDEF DEF083235: Prop: HAL Attributes (eg screen calibration) lost if the battery is pulled out
|
sl@0
|
291 |
*/
|
sl@0
|
292 |
void TestPerformanceInitialiseNoFileL()
|
sl@0
|
293 |
{
|
sl@0
|
294 |
TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-HALSETTINGS-CT-1719 Performance Test for initialise with out hal.dat "));
|
sl@0
|
295 |
|
sl@0
|
296 |
_LIT(KFileName,"c:\\private\\102825B1\\hal.dat");
|
sl@0
|
297 |
RFs fs;
|
sl@0
|
298 |
fs.Connect();
|
sl@0
|
299 |
|
sl@0
|
300 |
//Delete the File if it exists
|
sl@0
|
301 |
if(BaflUtils::FileExists(fs,KFileName))
|
sl@0
|
302 |
{
|
sl@0
|
303 |
TEST2(BaflUtils::DeleteFile(fs,KFileName),KErrNone);
|
sl@0
|
304 |
}
|
sl@0
|
305 |
TInt fastTimerFreq;
|
sl@0
|
306 |
HAL::Get(HALData::EFastCounterFrequency, fastTimerFreq);
|
sl@0
|
307 |
TReal ticksPerMicroSec = 1.0E-6 * fastTimerFreq;
|
sl@0
|
308 |
TUint prevTime;
|
sl@0
|
309 |
TUint timeDiff;
|
sl@0
|
310 |
prevTime = User::FastCounter();
|
sl@0
|
311 |
TInt noSuccessfulSamples=0;
|
sl@0
|
312 |
for(;noSuccessfulSamples < noSample; ++noSuccessfulSamples)
|
sl@0
|
313 |
{
|
sl@0
|
314 |
if ( TestInitialiseHALWaitL() !=KErrNotFound)
|
sl@0
|
315 |
{
|
sl@0
|
316 |
break;
|
sl@0
|
317 |
}
|
sl@0
|
318 |
//else continue;
|
sl@0
|
319 |
}
|
sl@0
|
320 |
TEST(noSuccessfulSamples >0);
|
sl@0
|
321 |
timeDiff = User::FastCounter() - prevTime;
|
sl@0
|
322 |
TReal64 fsSessionMicroSecs = timeDiff / (noSuccessfulSamples * ticksPerMicroSec);
|
sl@0
|
323 |
TheTest.Printf(_L("Time to Initialise HAL (no file) = %10.2lf microseconds\n"), fsSessionMicroSecs);
|
sl@0
|
324 |
fs.Close();
|
sl@0
|
325 |
}
|
sl@0
|
326 |
|
sl@0
|
327 |
/**
|
sl@0
|
328 |
@SYMTestCaseID SYSLIB-HALSETTINGS-CT-1720
|
sl@0
|
329 |
@SYMTestCaseDesc Performance Test Base Line
|
sl@0
|
330 |
@SYMTestPriority Medium
|
sl@0
|
331 |
@SYMTestActions Measure the performance to run empty exe
|
sl@0
|
332 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
333 |
@SYMDEF DEF083235: Prop: HAL Attributes (eg screen calibration) lost if the battery is pulled out
|
sl@0
|
334 |
*/
|
sl@0
|
335 |
void PerformanceBaseLineL()
|
sl@0
|
336 |
{
|
sl@0
|
337 |
TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-HALSETTINGS-CT-1720 Performance Test of empty EXE "));
|
sl@0
|
338 |
|
sl@0
|
339 |
TInt fastTimerFreq;
|
sl@0
|
340 |
HAL::Get(HALData::EFastCounterFrequency, fastTimerFreq);
|
sl@0
|
341 |
TReal ticksPerMicroSec = 1.0E-6 * fastTimerFreq;
|
sl@0
|
342 |
TUint prevTime;
|
sl@0
|
343 |
TUint timeDiff;
|
sl@0
|
344 |
|
sl@0
|
345 |
prevTime = User::FastCounter();
|
sl@0
|
346 |
TInt noSuccessfulSamples=0;
|
sl@0
|
347 |
for(;noSuccessfulSamples<noSample; ++noSuccessfulSamples)
|
sl@0
|
348 |
{
|
sl@0
|
349 |
if (StartEmptyExeL() != KErrArgument)
|
sl@0
|
350 |
{
|
sl@0
|
351 |
break;
|
sl@0
|
352 |
}
|
sl@0
|
353 |
//else continue;
|
sl@0
|
354 |
}
|
sl@0
|
355 |
TEST(noSuccessfulSamples >0);
|
sl@0
|
356 |
timeDiff = User::FastCounter() - prevTime;
|
sl@0
|
357 |
TReal64 fsSessionMicroSecs = timeDiff / (noSuccessfulSamples * ticksPerMicroSec);
|
sl@0
|
358 |
TheTest.Printf(_L("Time to run Empty EXE = %10.2lf microseconds\n"), fsSessionMicroSecs);
|
sl@0
|
359 |
}
|
sl@0
|
360 |
|
sl@0
|
361 |
|
sl@0
|
362 |
|
sl@0
|
363 |
/**
|
sl@0
|
364 |
@SYMTestCaseID SYSLIB-SYSAGENT2-UT-3385
|
sl@0
|
365 |
@SYMTestCaseDesc Checking the HAL.DAT filesize is not too big
|
sl@0
|
366 |
@SYMTestPriority Medium
|
sl@0
|
367 |
@SYMTestActions Initialise HAL settings with HAL.DAT padded past the reasonable threshold
|
sl@0
|
368 |
@SYMTestExpectedResults Call to initialise HAL settings should return with KErrCorrupt
|
sl@0
|
369 |
@SYMDEF PDEF101743: A small possibility for halsettings.exe to go infinite loop while initializing
|
sl@0
|
370 |
*/
|
sl@0
|
371 |
|
sl@0
|
372 |
void TestHALDataSizeMismatchL()
|
sl@0
|
373 |
{
|
sl@0
|
374 |
TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-SYSAGENT2-UT-3385 HAL.DAT size mismatch "));
|
sl@0
|
375 |
TInt err = BaflUtils::PersistHAL();
|
sl@0
|
376 |
_LIT(KFileName,"c:\\private\\102825B1\\hal.dat");
|
sl@0
|
377 |
RFs fs;
|
sl@0
|
378 |
if (err == KErrNone)
|
sl@0
|
379 |
{
|
sl@0
|
380 |
fs.Connect();
|
sl@0
|
381 |
RFile file;
|
sl@0
|
382 |
TInt pos = 0;
|
sl@0
|
383 |
err = file.Open(fs,KFileName,EFileRead | EFileWrite);
|
sl@0
|
384 |
// Want to add junk onto the end of the file, preserving the valid header
|
sl@0
|
385 |
err = file.Seek(ESeekEnd, pos);
|
sl@0
|
386 |
|
sl@0
|
387 |
//write data in multiples of 8 otherwise it will not pass the check (size&7) == 0
|
sl@0
|
388 |
for (TInt i = 0; i < 400; i++)
|
sl@0
|
389 |
{
|
sl@0
|
390 |
file.Write(_L8("junkjunkjunkjunk"));
|
sl@0
|
391 |
}
|
sl@0
|
392 |
file.Close();
|
sl@0
|
393 |
}
|
sl@0
|
394 |
|
sl@0
|
395 |
if(err == KErrNone)
|
sl@0
|
396 |
{
|
sl@0
|
397 |
TInt result = TestInitialiseHALWaitL();
|
sl@0
|
398 |
TEST2(result, KErrCorrupt);
|
sl@0
|
399 |
}
|
sl@0
|
400 |
err = fs.Delete(KFileName);
|
sl@0
|
401 |
fs.Close();
|
sl@0
|
402 |
}
|
sl@0
|
403 |
|
sl@0
|
404 |
/**
|
sl@0
|
405 |
@SYMTestCaseID SYSLIB-SYSAGENT2-UT-4001
|
sl@0
|
406 |
@SYMTestCaseDesc system clock change is persisted to hal.dat
|
sl@0
|
407 |
@SYMTestPriority Medium
|
sl@0
|
408 |
@SYMTestActions 1. delete the hal file.
|
sl@0
|
409 |
2. change system time
|
sl@0
|
410 |
3. pause a few seconds and check if the hal file get created.
|
sl@0
|
411 |
@SYMTestExpectedResults At step 1 hal.dat is deleted (or KErrNotFound).
|
sl@0
|
412 |
At step 3 hal.dat is created.
|
sl@0
|
413 |
@SYMDEF DEF115375
|
sl@0
|
414 |
*/
|
sl@0
|
415 |
void TestTimeChangesDEF115375()
|
sl@0
|
416 |
{
|
sl@0
|
417 |
TTime time;
|
sl@0
|
418 |
RProcess process;
|
sl@0
|
419 |
|
sl@0
|
420 |
TheTest.Next (_L ("TestTimeChangesDEF115375"));
|
sl@0
|
421 |
_LIT(KFileName,"c:\\private\\102825B1\\hal.dat");
|
sl@0
|
422 |
|
sl@0
|
423 |
TEST2(process.Create(KInitialiseLocaleExeName, KNullDesC),KErrNone);
|
sl@0
|
424 |
|
sl@0
|
425 |
TRequestStatus stat;
|
sl@0
|
426 |
process.Rendezvous(stat);
|
sl@0
|
427 |
process.Resume(); // Start the process going
|
sl@0
|
428 |
//wait for the locale initialisation to complete first before testing
|
sl@0
|
429 |
User::WaitForRequest(stat);
|
sl@0
|
430 |
TEST2((stat.Int()==KErrNone)||(stat.Int()==KErrAlreadyExists),ETrue);
|
sl@0
|
431 |
|
sl@0
|
432 |
RFs fs;
|
sl@0
|
433 |
fs.Connect();
|
sl@0
|
434 |
|
sl@0
|
435 |
//Delete the File if it exists
|
sl@0
|
436 |
if(BaflUtils::FileExists(fs,KFileName))
|
sl@0
|
437 |
{
|
sl@0
|
438 |
TEST2(BaflUtils::DeleteFile(fs,KFileName),KErrNone);
|
sl@0
|
439 |
}
|
sl@0
|
440 |
|
sl@0
|
441 |
time.UniversalTime();
|
sl@0
|
442 |
time+=TTimeIntervalMinutes(30);
|
sl@0
|
443 |
TInt r=User::SetUTCTime(time);
|
sl@0
|
444 |
TEST2(r, KErrNone);
|
sl@0
|
445 |
|
sl@0
|
446 |
User::After(1000000);
|
sl@0
|
447 |
TEST(BaflUtils::FileExists(fs,KFileName));
|
sl@0
|
448 |
fs.Close();
|
sl@0
|
449 |
|
sl@0
|
450 |
process.Close();
|
sl@0
|
451 |
User::After(1000000);
|
sl@0
|
452 |
}
|
sl@0
|
453 |
|
sl@0
|
454 |
/**
|
sl@0
|
455 |
@SYMTestCaseID SYSLIB-SYSAGENT2-UT-4002
|
sl@0
|
456 |
@SYMTestCaseDesc Check that the VendorID is set to 0x70000001 (Symbian's VendorID)
|
sl@0
|
457 |
@SYMTestPriority Medium
|
sl@0
|
458 |
@SYMTestActions 1. Create a process for HALSettings.exe
|
sl@0
|
459 |
2. Compare the processes VID against the expected VID (0x70000001)
|
sl@0
|
460 |
@SYMTestExpectedResults The VIDs should be identical and so the test will pass.
|
sl@0
|
461 |
@SYMDEF INC121402
|
sl@0
|
462 |
*/
|
sl@0
|
463 |
void TestVendorIdINC121402()
|
sl@0
|
464 |
{
|
sl@0
|
465 |
TheTest.Next (_L ("TestVendorIDINC121402"));
|
sl@0
|
466 |
|
sl@0
|
467 |
RProcess process;
|
sl@0
|
468 |
TEST2(process.Create(KHALSettingsExeName, _L("INITIALISE")), KErrNone);
|
sl@0
|
469 |
|
sl@0
|
470 |
// Test that the VendorID of HALSettings.exe is set to the Symbian VendorID
|
sl@0
|
471 |
TEST2(KSymbianVendorId.iId, process.VendorId().iId);
|
sl@0
|
472 |
|
sl@0
|
473 |
process.Close();
|
sl@0
|
474 |
}
|
sl@0
|
475 |
|
sl@0
|
476 |
LOCAL_C void RunTestsL()
|
sl@0
|
477 |
{
|
sl@0
|
478 |
|
sl@0
|
479 |
//To create hal.dat
|
sl@0
|
480 |
TEST2(TestPersistHALWaitL(),KErrNone);
|
sl@0
|
481 |
//Initialise HAL
|
sl@0
|
482 |
TEST2(TestInitialiseHALWaitL(),KErrNone);
|
sl@0
|
483 |
TestHALFileWrongHeaderL();
|
sl@0
|
484 |
TestHALFileEmptyL();
|
sl@0
|
485 |
TestHALFileMissingL();
|
sl@0
|
486 |
TestInitialiseHALWrongParameterL();
|
sl@0
|
487 |
TestHALFileNoAccessL();
|
sl@0
|
488 |
TestTimeChangesDEF115375();
|
sl@0
|
489 |
TestVendorIdINC121402();
|
sl@0
|
490 |
//Performance Test
|
sl@0
|
491 |
PerformanceBaseLineL();
|
sl@0
|
492 |
TestPerformanceInitialiseWithFileL();
|
sl@0
|
493 |
TestPerformanceInitialiseNoFileL();
|
sl@0
|
494 |
TestHALDataSizeMismatchL();
|
sl@0
|
495 |
}
|
sl@0
|
496 |
|
sl@0
|
497 |
GLDEF_C TInt E32Main()
|
sl@0
|
498 |
{
|
sl@0
|
499 |
__UHEAP_MARK;
|
sl@0
|
500 |
TheTest.Title ();
|
sl@0
|
501 |
TheTest.Start (_L ("HAL Initialise test"));
|
sl@0
|
502 |
CTrapCleanup* tc = CTrapCleanup::New();
|
sl@0
|
503 |
|
sl@0
|
504 |
TRAPD(err, ::RunTestsL());
|
sl@0
|
505 |
|
sl@0
|
506 |
delete tc;
|
sl@0
|
507 |
|
sl@0
|
508 |
TheTest.End ();
|
sl@0
|
509 |
TheTest.Close ();
|
sl@0
|
510 |
|
sl@0
|
511 |
__UHEAP_MARKEND;
|
sl@0
|
512 |
return err;
|
sl@0
|
513 |
}
|