sl@0
|
1 |
// Copyright (c) 2010 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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <e32test.h>
|
sl@0
|
17 |
#include <bautils.h>
|
sl@0
|
18 |
#include "SqlSrvMain.h"
|
sl@0
|
19 |
#include "SqlSrvStartup.h"
|
sl@0
|
20 |
#include "SqlSrvUtil.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
_LIT(KCfgDb1ConfigFilePath, "c:\\private\\10281e17\\cfg[10281E17]t_sqlstartup1.db.02"); // config file version 2 for t_sqlstartup1.db
|
sl@0
|
23 |
_LIT(KCfgDb2ConfigFilePath, "c:\\private\\10281e17\\cfg[10281E17]t_sqlstartup2.db.05"); // config file version 5 for t_sqlstartup2.db
|
sl@0
|
24 |
|
sl@0
|
25 |
//This subdir is created by t_sqlenvcreate app. It should not be returned in the list of files for backup.
|
sl@0
|
26 |
_LIT(KPrivateSubDir, "c:\\private\\10281e17\\TestDir.db");
|
sl@0
|
27 |
|
sl@0
|
28 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
29 |
|
sl@0
|
30 |
RTest TheTest(_L("t_sqlstartup test"));
|
sl@0
|
31 |
|
sl@0
|
32 |
RFs TheFs;
|
sl@0
|
33 |
|
sl@0
|
34 |
static TInt TheProcessHandleCount = 0;
|
sl@0
|
35 |
static TInt TheThreadHandleCount = 0;
|
sl@0
|
36 |
static TInt TheAllocatedCellsCount = 0;
|
sl@0
|
37 |
|
sl@0
|
38 |
#ifdef _DEBUG
|
sl@0
|
39 |
static const TInt KBurstRate = 20;
|
sl@0
|
40 |
#endif
|
sl@0
|
41 |
|
sl@0
|
42 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
43 |
|
sl@0
|
44 |
void DeleteTestFiles()
|
sl@0
|
45 |
{
|
sl@0
|
46 |
(void)TheFs.Delete(KCfgDb2ConfigFilePath);
|
sl@0
|
47 |
(void)TheFs.Delete(KCfgDb1ConfigFilePath);
|
sl@0
|
48 |
TheFs.Close();
|
sl@0
|
49 |
}
|
sl@0
|
50 |
|
sl@0
|
51 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
52 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
53 |
//Test macros and functions
|
sl@0
|
54 |
void Check(TInt aValue, TInt aLine)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
if(!aValue)
|
sl@0
|
57 |
{
|
sl@0
|
58 |
DeleteTestFiles();
|
sl@0
|
59 |
RDebug::Print(_L("*** Expresssion evaluated to false\r\n"));
|
sl@0
|
60 |
TheTest(EFalse, aLine);
|
sl@0
|
61 |
}
|
sl@0
|
62 |
}
|
sl@0
|
63 |
void Check(TInt aValue, TInt aExpected, TInt aLine)
|
sl@0
|
64 |
{
|
sl@0
|
65 |
if(aValue != aExpected)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
DeleteTestFiles();
|
sl@0
|
68 |
RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
|
sl@0
|
69 |
TheTest(EFalse, aLine);
|
sl@0
|
70 |
}
|
sl@0
|
71 |
}
|
sl@0
|
72 |
#define TEST(arg) ::Check((arg), __LINE__)
|
sl@0
|
73 |
#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
|
sl@0
|
74 |
|
sl@0
|
75 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
76 |
|
sl@0
|
77 |
static void MarkHandles()
|
sl@0
|
78 |
{
|
sl@0
|
79 |
RThread().HandleCount(TheProcessHandleCount, TheThreadHandleCount);
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
static void MarkAllocatedCells()
|
sl@0
|
83 |
{
|
sl@0
|
84 |
TheAllocatedCellsCount = User::CountAllocCells();
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
static void CheckAllocatedCells()
|
sl@0
|
88 |
{
|
sl@0
|
89 |
TInt allocatedCellsCount = User::CountAllocCells();
|
sl@0
|
90 |
TEST2(allocatedCellsCount, TheAllocatedCellsCount);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
static void CheckHandles()
|
sl@0
|
94 |
{
|
sl@0
|
95 |
TInt endProcessHandleCount;
|
sl@0
|
96 |
TInt endThreadHandleCount;
|
sl@0
|
97 |
|
sl@0
|
98 |
RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
|
sl@0
|
99 |
|
sl@0
|
100 |
TEST2(TheProcessHandleCount, endProcessHandleCount);
|
sl@0
|
101 |
TEST2(TheThreadHandleCount, endThreadHandleCount);
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
static void OomPreStep(TInt
|
sl@0
|
105 |
#ifdef _DEBUG
|
sl@0
|
106 |
aFailingAllocationNo
|
sl@0
|
107 |
#endif
|
sl@0
|
108 |
)
|
sl@0
|
109 |
{
|
sl@0
|
110 |
MarkHandles();
|
sl@0
|
111 |
MarkAllocatedCells();
|
sl@0
|
112 |
__UHEAP_MARK;
|
sl@0
|
113 |
__UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, aFailingAllocationNo, KBurstRate);
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
static void OomPostStep()
|
sl@0
|
117 |
{
|
sl@0
|
118 |
__UHEAP_RESET;
|
sl@0
|
119 |
__UHEAP_MARKEND;
|
sl@0
|
120 |
CheckAllocatedCells();
|
sl@0
|
121 |
CheckHandles();
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
125 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
126 |
|
sl@0
|
127 |
static void CreateAndDestroySqlServerL()
|
sl@0
|
128 |
{
|
sl@0
|
129 |
CSqlServer* server = CSqlServer::NewLC();
|
sl@0
|
130 |
//Drive C: to the RSqlDriveSpaceCol object. This will allow "reserve drive space" construct/destroy code to be tested.
|
sl@0
|
131 |
RSqlDriveSpaceCol& drvcol = server->DriveSpaceCol();
|
sl@0
|
132 |
drvcol.AddL(EDriveC);
|
sl@0
|
133 |
CleanupStack::PopAndDestroy(server);
|
sl@0
|
134 |
}
|
sl@0
|
135 |
|
sl@0
|
136 |
static CSqlServer* CreateSqlServerL()
|
sl@0
|
137 |
{
|
sl@0
|
138 |
CSqlServer* server = CSqlServer::NewLC();
|
sl@0
|
139 |
CleanupStack::Pop(server);
|
sl@0
|
140 |
return server;
|
sl@0
|
141 |
}
|
sl@0
|
142 |
|
sl@0
|
143 |
/**
|
sl@0
|
144 |
@SYMTestCaseID PDS-SQL-UT-4159
|
sl@0
|
145 |
@SYMTestCaseDesc SQL server startup OOM test
|
sl@0
|
146 |
@SYMTestPriority High
|
sl@0
|
147 |
@SYMTestActions Runs the SQL server startup code in an OOM loop.
|
sl@0
|
148 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
149 |
@SYMDEF DEF144096
|
sl@0
|
150 |
*/
|
sl@0
|
151 |
void SqlServerStartupOomTest()
|
sl@0
|
152 |
{
|
sl@0
|
153 |
TInt err = KErrNoMemory;
|
sl@0
|
154 |
TInt failingAllocationNo = 0;
|
sl@0
|
155 |
TheTest.Printf(_L("Iteration:\r\n"));
|
sl@0
|
156 |
while(err == KErrNoMemory)
|
sl@0
|
157 |
{
|
sl@0
|
158 |
TheTest.Printf(_L(" %d"), ++failingAllocationNo);
|
sl@0
|
159 |
OomPreStep(failingAllocationNo);
|
sl@0
|
160 |
TRAP(err, CreateAndDestroySqlServerL());
|
sl@0
|
161 |
OomPostStep();
|
sl@0
|
162 |
}
|
sl@0
|
163 |
if(err != KErrNoMemory)
|
sl@0
|
164 |
{
|
sl@0
|
165 |
TEST2(err, KErrNone);
|
sl@0
|
166 |
}
|
sl@0
|
167 |
TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
|
sl@0
|
168 |
}
|
sl@0
|
169 |
|
sl@0
|
170 |
/**
|
sl@0
|
171 |
@SYMTestCaseID PDS-SQL-UT-4160
|
sl@0
|
172 |
@SYMTestCaseDesc CSqlServer::GetBackUpListL() OOM test
|
sl@0
|
173 |
@SYMTestPriority High
|
sl@0
|
174 |
@SYMTestActions Calls CSqlServer::GetBackUpListL() in an OOM loop.
|
sl@0
|
175 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
176 |
@SYMDEF DEF144096
|
sl@0
|
177 |
*/
|
sl@0
|
178 |
void GetBackupListOomTest()
|
sl@0
|
179 |
{
|
sl@0
|
180 |
CSqlServer* server = NULL;
|
sl@0
|
181 |
TRAPD(err, server = CreateSqlServerL());
|
sl@0
|
182 |
TEST2(err, KErrNone);
|
sl@0
|
183 |
|
sl@0
|
184 |
TInt fileCnt = 0;
|
sl@0
|
185 |
err = KErrNoMemory;
|
sl@0
|
186 |
TInt failingAllocationNo = 0;
|
sl@0
|
187 |
TheTest.Printf(_L("Iteration:\r\n"));
|
sl@0
|
188 |
while(err == KErrNoMemory)
|
sl@0
|
189 |
{
|
sl@0
|
190 |
TheTest.Printf(_L(" %d"), ++failingAllocationNo);
|
sl@0
|
191 |
OomPreStep(failingAllocationNo);
|
sl@0
|
192 |
const TUid KDbUd = {0x98765432};
|
sl@0
|
193 |
RArray<HBufC*> files;
|
sl@0
|
194 |
TRAP(err, server->GetBackUpListL(KDbUd, EDriveC, files));
|
sl@0
|
195 |
fileCnt = files.Count();
|
sl@0
|
196 |
if(err == KErrNone)
|
sl@0
|
197 |
{
|
sl@0
|
198 |
//No directories should be returned in the list of files for backup
|
sl@0
|
199 |
for(TInt i=0;i<fileCnt;++i)
|
sl@0
|
200 |
{
|
sl@0
|
201 |
TPtrC fname = files[i]->Des();
|
sl@0
|
202 |
TInt rc = KPrivateSubDir().CompareF(fname);
|
sl@0
|
203 |
TEST(rc != 0);
|
sl@0
|
204 |
}
|
sl@0
|
205 |
}
|
sl@0
|
206 |
for(TInt j=0;j<files.Count();++j)
|
sl@0
|
207 |
{
|
sl@0
|
208 |
delete files[j];
|
sl@0
|
209 |
}
|
sl@0
|
210 |
files.Close();
|
sl@0
|
211 |
OomPostStep();
|
sl@0
|
212 |
}
|
sl@0
|
213 |
|
sl@0
|
214 |
delete server;
|
sl@0
|
215 |
|
sl@0
|
216 |
if(err != KErrNoMemory)
|
sl@0
|
217 |
{
|
sl@0
|
218 |
TEST2(err, KErrNone);
|
sl@0
|
219 |
}
|
sl@0
|
220 |
TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\nFile count: %d\r\n"), failingAllocationNo, fileCnt);
|
sl@0
|
221 |
}
|
sl@0
|
222 |
|
sl@0
|
223 |
/**
|
sl@0
|
224 |
@SYMTestCaseID PDS-SQL-UT-4161
|
sl@0
|
225 |
@SYMTestCaseDesc SQL server startup file I/O error simulation test
|
sl@0
|
226 |
@SYMTestPriority High
|
sl@0
|
227 |
@SYMTestActions Runs the SQL server startup code in a file I/O error simulation loop.
|
sl@0
|
228 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
229 |
@SYMDEF DEF144096
|
sl@0
|
230 |
*/
|
sl@0
|
231 |
void SqlServerStartupFileIoErrorTest()
|
sl@0
|
232 |
{
|
sl@0
|
233 |
RFs fs;
|
sl@0
|
234 |
TInt err = fs.Connect();
|
sl@0
|
235 |
TEST2(err, KErrNone);
|
sl@0
|
236 |
|
sl@0
|
237 |
for(TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError)
|
sl@0
|
238 |
{
|
sl@0
|
239 |
TheTest.Printf(_L("===Simulated error: %d\r\nIteration: "), fsError);
|
sl@0
|
240 |
err = KErrNotFound;
|
sl@0
|
241 |
TInt cnt=0;
|
sl@0
|
242 |
while(err<KErrNone)
|
sl@0
|
243 |
{
|
sl@0
|
244 |
TheTest.Printf(_L("%d "), cnt);
|
sl@0
|
245 |
(void)fs.SetErrorCondition(fsError, cnt);
|
sl@0
|
246 |
TRAP(err, CreateAndDestroySqlServerL());
|
sl@0
|
247 |
(void)fs.SetErrorCondition(KErrNone);
|
sl@0
|
248 |
if(err != KErrNone)
|
sl@0
|
249 |
{
|
sl@0
|
250 |
++cnt;
|
sl@0
|
251 |
}
|
sl@0
|
252 |
}
|
sl@0
|
253 |
TEST2(err, KErrNone);
|
sl@0
|
254 |
TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt);
|
sl@0
|
255 |
}
|
sl@0
|
256 |
|
sl@0
|
257 |
fs.Close();
|
sl@0
|
258 |
}
|
sl@0
|
259 |
|
sl@0
|
260 |
/**
|
sl@0
|
261 |
@SYMTestCaseID PDS-SQL-UT-4162
|
sl@0
|
262 |
@SYMTestCaseDesc CSqlServer::GetBackUpListL() file I/O error simulation test
|
sl@0
|
263 |
@SYMTestPriority High
|
sl@0
|
264 |
@SYMTestActions Calls CSqlServer::GetBackUpListL() in a file I/O error simulation loop.
|
sl@0
|
265 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
266 |
@SYMDEF DEF144096
|
sl@0
|
267 |
*/
|
sl@0
|
268 |
void GetBackupListFileIoErrorTest()
|
sl@0
|
269 |
{
|
sl@0
|
270 |
CSqlServer* server = NULL;
|
sl@0
|
271 |
TRAPD(err, server = CreateSqlServerL());
|
sl@0
|
272 |
TEST2(err, KErrNone);
|
sl@0
|
273 |
|
sl@0
|
274 |
for(TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError)
|
sl@0
|
275 |
{
|
sl@0
|
276 |
TheTest.Printf(_L("===Simulated error: %d\r\nIteration: "), fsError);
|
sl@0
|
277 |
err = KErrNotFound;
|
sl@0
|
278 |
TInt fileCnt = 0;
|
sl@0
|
279 |
TInt cnt=0;
|
sl@0
|
280 |
while(err<KErrNone)
|
sl@0
|
281 |
{
|
sl@0
|
282 |
TheTest.Printf(_L("%d "), cnt);
|
sl@0
|
283 |
(void)server->Fs().SetErrorCondition(fsError, cnt);
|
sl@0
|
284 |
const TUid KDbUd = {0x98765432};
|
sl@0
|
285 |
RArray<HBufC*> files;
|
sl@0
|
286 |
TRAP(err, server->GetBackUpListL(KDbUd, EDriveC, files));
|
sl@0
|
287 |
fileCnt = files.Count();
|
sl@0
|
288 |
if(err == KErrNone)
|
sl@0
|
289 |
{
|
sl@0
|
290 |
//No directories should be returned in the list of files for backup
|
sl@0
|
291 |
for(TInt i=0;i<fileCnt;++i)
|
sl@0
|
292 |
{
|
sl@0
|
293 |
TPtrC fname = files[i]->Des();
|
sl@0
|
294 |
TInt rc = KPrivateSubDir().CompareF(fname);
|
sl@0
|
295 |
TEST(rc != 0);
|
sl@0
|
296 |
}
|
sl@0
|
297 |
}
|
sl@0
|
298 |
for(TInt j=0;j<files.Count();++j)
|
sl@0
|
299 |
{
|
sl@0
|
300 |
delete files[j];
|
sl@0
|
301 |
}
|
sl@0
|
302 |
files.Close();
|
sl@0
|
303 |
(void)server->Fs().SetErrorCondition(KErrNone);
|
sl@0
|
304 |
if(err != KErrNone)
|
sl@0
|
305 |
{
|
sl@0
|
306 |
++cnt;
|
sl@0
|
307 |
}
|
sl@0
|
308 |
}
|
sl@0
|
309 |
TEST2(err, KErrNone);
|
sl@0
|
310 |
TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\nFile count: %d\r\n"), cnt, fileCnt);
|
sl@0
|
311 |
}
|
sl@0
|
312 |
|
sl@0
|
313 |
delete server;
|
sl@0
|
314 |
}
|
sl@0
|
315 |
|
sl@0
|
316 |
/**
|
sl@0
|
317 |
@SYMTestCaseID PDS-SQL-UT-4224
|
sl@0
|
318 |
@SYMTestCaseDesc CSqlServer::GetBackUpListL() functional test
|
sl@0
|
319 |
@SYMTestPriority High
|
sl@0
|
320 |
@SYMTestActions Calls CSqlServer::GetBackUpListL() and tests the output, when the drive is read-only,
|
sl@0
|
321 |
when there is a sub-directory which name is matching the search pattern.
|
sl@0
|
322 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
323 |
*/
|
sl@0
|
324 |
void GetBackupListFunctionalTest()
|
sl@0
|
325 |
{
|
sl@0
|
326 |
CSqlServer* server = NULL;
|
sl@0
|
327 |
TRAPD(err, server = CreateSqlServerL());
|
sl@0
|
328 |
TEST2(err, KErrNone);
|
sl@0
|
329 |
//Case 1: database with specified uid bellow do exist (on drive C). There will be one subdirectory matching the search pattern.
|
sl@0
|
330 |
const TDriveNumber KTestDrvNum1 = EDriveC;
|
sl@0
|
331 |
const TUid KDbUid = {0x98765432};
|
sl@0
|
332 |
TDriveUnit testDrive(KTestDrvNum1);
|
sl@0
|
333 |
TDriveName testDriveName = testDrive.Name();
|
sl@0
|
334 |
testDriveName.LowerCase();
|
sl@0
|
335 |
//One test directory will be created, which name will be matching the search pattern.
|
sl@0
|
336 |
//The directory name should not be included in the list with the file names.
|
sl@0
|
337 |
TFileName testFileName;
|
sl@0
|
338 |
err = server->Fs().PrivatePath(testFileName);
|
sl@0
|
339 |
TEST2(err, KErrNone);
|
sl@0
|
340 |
testFileName.Append(KDbUid.Name());
|
sl@0
|
341 |
_LIT(KTestPath, "t_startup\\");
|
sl@0
|
342 |
testFileName.Append(KTestPath);
|
sl@0
|
343 |
testFileName.Append(_L("t_startup.db"));
|
sl@0
|
344 |
TParse parse;
|
sl@0
|
345 |
err = parse.Set(testFileName, &testDriveName, 0);
|
sl@0
|
346 |
TEST2(err, KErrNone);
|
sl@0
|
347 |
err = server->Fs().MkDirAll(parse.FullName());
|
sl@0
|
348 |
TEST(err == KErrNone || err == KErrAlreadyExists);
|
sl@0
|
349 |
//
|
sl@0
|
350 |
RArray<HBufC*> files;
|
sl@0
|
351 |
TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum1, files));
|
sl@0
|
352 |
TEST2(err, KErrNone);
|
sl@0
|
353 |
TInt fileCnt = files.Count();
|
sl@0
|
354 |
for(TInt i=0;i<fileCnt;++i)
|
sl@0
|
355 |
{
|
sl@0
|
356 |
TPtrC fname = files[i]->Des();
|
sl@0
|
357 |
TheTest.Printf(_L("Db: %S\r\n"), &fname);
|
sl@0
|
358 |
TEST(fname.FindF(KTestPath) < 0);
|
sl@0
|
359 |
//The name should include the full path + the drive
|
sl@0
|
360 |
err = parse.Set(fname, 0, 0);
|
sl@0
|
361 |
TEST2(err, KErrNone);
|
sl@0
|
362 |
TEST(parse.DrivePresent());
|
sl@0
|
363 |
TEST(parse.PathPresent());
|
sl@0
|
364 |
TDriveName driveName(parse.Drive());
|
sl@0
|
365 |
driveName.LowerCase();
|
sl@0
|
366 |
delete files[i];
|
sl@0
|
367 |
TEST(driveName == testDriveName);
|
sl@0
|
368 |
}
|
sl@0
|
369 |
files.Close();
|
sl@0
|
370 |
//Case 2: drive Z:. No files should be returned.
|
sl@0
|
371 |
const TDriveNumber KTestDrvNum2 = EDriveZ;
|
sl@0
|
372 |
TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum2, files));
|
sl@0
|
373 |
TEST2(err, KErrNone);
|
sl@0
|
374 |
fileCnt = files.Count();
|
sl@0
|
375 |
TEST2(fileCnt, 0);
|
sl@0
|
376 |
//Case 3: drive A:. The drive does not exist. No files should be returned.
|
sl@0
|
377 |
const TDriveNumber KTestDrvNum3 = EDriveA;
|
sl@0
|
378 |
TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum3, files));
|
sl@0
|
379 |
TheTest.Printf(_L("Drive %d, err=%d\r\n"), KTestDrvNum3, err);
|
sl@0
|
380 |
fileCnt = files.Count();
|
sl@0
|
381 |
TEST2(fileCnt, 0);
|
sl@0
|
382 |
//
|
sl@0
|
383 |
delete server;
|
sl@0
|
384 |
}
|
sl@0
|
385 |
|
sl@0
|
386 |
/**
|
sl@0
|
387 |
@SYMTestCaseID PDS-SQL-UT-4163
|
sl@0
|
388 |
@SYMTestCaseDesc Test for DEF144196: SQL, server code coverage can be improved
|
sl@0
|
389 |
@SYMTestPriority High
|
sl@0
|
390 |
@SYMTestActions Tests the UTF conversion functions implemented in SqlSrvUtil.cpp.
|
sl@0
|
391 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
392 |
@SYMDEF DEF144196
|
sl@0
|
393 |
*/
|
sl@0
|
394 |
void UtfConversionTest()
|
sl@0
|
395 |
{
|
sl@0
|
396 |
///////// UTF16ToUTF8() ///////////////////////
|
sl@0
|
397 |
_LIT(KStr16, "abcd");
|
sl@0
|
398 |
_LIT8(KStr8, "abcd");
|
sl@0
|
399 |
TBuf8<KMaxFileName + 1> bufout;
|
sl@0
|
400 |
TBool rc = UTF16ToUTF8(KStr16, bufout);
|
sl@0
|
401 |
TEST(rc);
|
sl@0
|
402 |
TEST(bufout == KStr8);
|
sl@0
|
403 |
//Test where the input buffer contains non-convertible characters
|
sl@0
|
404 |
TBuf<2> name2;
|
sl@0
|
405 |
name2.SetLength(2);
|
sl@0
|
406 |
name2[0] = TChar(0xD800);
|
sl@0
|
407 |
name2[1] = TChar(0xFC00);
|
sl@0
|
408 |
rc = UTF16ToUTF8(name2, bufout);
|
sl@0
|
409 |
TEST(!rc);
|
sl@0
|
410 |
///////// UTF16ToUTF8Z() ///////////////////////
|
sl@0
|
411 |
_LIT8(KStr8Z, "abcd\x0");
|
sl@0
|
412 |
rc = UTF16ToUTF8Z(KStr16, bufout);
|
sl@0
|
413 |
TEST(rc);
|
sl@0
|
414 |
TEST(bufout == KStr8Z);
|
sl@0
|
415 |
//Test where the input buffer contains non-convertible characters
|
sl@0
|
416 |
rc = UTF16ToUTF8Z(name2, bufout);
|
sl@0
|
417 |
TEST(!rc);
|
sl@0
|
418 |
///////// UTF16ZToUTF8Z() ///////////////////////
|
sl@0
|
419 |
_LIT(KStr16Z, "abcd\x0");
|
sl@0
|
420 |
rc = UTF16ZToUTF8Z(KStr16Z, bufout);
|
sl@0
|
421 |
TEST(rc);
|
sl@0
|
422 |
TEST(bufout == KStr8Z);
|
sl@0
|
423 |
//Test where the input buffer contains non-convertible characters
|
sl@0
|
424 |
TBuf<3> name3;
|
sl@0
|
425 |
name3.SetLength(3);
|
sl@0
|
426 |
name3[0] = TChar(0xD800);
|
sl@0
|
427 |
name3[1] = TChar(0xFC00);
|
sl@0
|
428 |
name3[2] = TChar(0x0000);
|
sl@0
|
429 |
rc = UTF16ZToUTF8Z(name3, bufout);
|
sl@0
|
430 |
TEST(!rc);
|
sl@0
|
431 |
}
|
sl@0
|
432 |
|
sl@0
|
433 |
/**
|
sl@0
|
434 |
@SYMTestCaseID PDS-SQL-UT-4175
|
sl@0
|
435 |
@SYMTestCaseDesc Test for DEF144937: SQL, SQL server, the code coverage can be improved in some areas.
|
sl@0
|
436 |
@SYMTestPriority High
|
sl@0
|
437 |
@SYMTestActions The test creates a SQL server instance and performs some basic operations with
|
sl@0
|
438 |
RSqlDriveSpaceCol object owned by the server, such as: adding a new drive,
|
sl@0
|
439 |
getting an access to the reserved drive space, releasing the access.
|
sl@0
|
440 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
441 |
@SYMDEF DEF144937
|
sl@0
|
442 |
*/
|
sl@0
|
443 |
void ReserveDriveSpaceTest()
|
sl@0
|
444 |
{
|
sl@0
|
445 |
CSqlServer* srv = NULL;
|
sl@0
|
446 |
TRAPD(err, srv = CreateSqlServerL());
|
sl@0
|
447 |
TEST2(err, KErrNone);
|
sl@0
|
448 |
|
sl@0
|
449 |
RSqlDriveSpaceCol& drvcol = srv->DriveSpaceCol();
|
sl@0
|
450 |
TRAP(err, drvcol.AddL(EDriveC));
|
sl@0
|
451 |
TEST2(err, KErrNone);
|
sl@0
|
452 |
|
sl@0
|
453 |
CSqlDriveSpace* drvspace = drvcol.Find(EDriveZ);
|
sl@0
|
454 |
TEST(!drvspace);
|
sl@0
|
455 |
drvspace = drvcol.Find(EDriveC);
|
sl@0
|
456 |
TEST(drvspace != NULL);
|
sl@0
|
457 |
|
sl@0
|
458 |
TDriveNumber drvnum = drvspace->Drive();
|
sl@0
|
459 |
TEST2(drvnum, EDriveC);
|
sl@0
|
460 |
//It is safe to call GetAccessL() more than once. The access is reference counted.
|
sl@0
|
461 |
TRAP(err, drvspace->GetAccessL());
|
sl@0
|
462 |
TEST2(err, KErrNone);
|
sl@0
|
463 |
TRAP(err, drvspace->GetAccessL());
|
sl@0
|
464 |
TEST2(err, KErrNone);
|
sl@0
|
465 |
//It is safe if ReleaseAccess() call count do not match GetAccessL() call count.
|
sl@0
|
466 |
drvspace->ReleaseAccess();
|
sl@0
|
467 |
drvspace->ReleaseAccess();
|
sl@0
|
468 |
drvspace->ReleaseAccess();
|
sl@0
|
469 |
//
|
sl@0
|
470 |
drvcol.ResetAndDestroy();
|
sl@0
|
471 |
delete srv;
|
sl@0
|
472 |
}
|
sl@0
|
473 |
|
sl@0
|
474 |
void DoCreateCfgFile(const TDesC& aFileName, const TDesC8& aData)
|
sl@0
|
475 |
{
|
sl@0
|
476 |
RFile file;
|
sl@0
|
477 |
TInt err = file.Create(TheFs, aFileName, EFileRead | EFileWrite);
|
sl@0
|
478 |
TEST2(err, KErrNone);
|
sl@0
|
479 |
err = file.Write(aData);
|
sl@0
|
480 |
file.Close();
|
sl@0
|
481 |
TEST2(err, KErrNone);
|
sl@0
|
482 |
}
|
sl@0
|
483 |
|
sl@0
|
484 |
void DoTests()
|
sl@0
|
485 |
{
|
sl@0
|
486 |
CActiveScheduler* scheduler = new CActiveScheduler;
|
sl@0
|
487 |
TEST(scheduler != NULL);
|
sl@0
|
488 |
CActiveScheduler::Install(scheduler);
|
sl@0
|
489 |
|
sl@0
|
490 |
//Adding two db config files will allow CDbConfigFiles construct/destroy code also to be tested in the OOM tests.
|
sl@0
|
491 |
TInt err = TheFs.Connect();
|
sl@0
|
492 |
TEST2(err, KErrNone);
|
sl@0
|
493 |
DoCreateCfgFile(KCfgDb1ConfigFilePath, _L8("CREATE INDEX idx ON table1(i1);"));
|
sl@0
|
494 |
DoCreateCfgFile(KCfgDb2ConfigFilePath, _L8("CREATE INDEX idx1 ON table1(i1);CREATE INDEX idx2 ON table2(i2)"));
|
sl@0
|
495 |
|
sl@0
|
496 |
TheTest.Start(_L(" @SYMTestCaseID:PDS-SQL-UT-4159 SQL server startup OOM test"));
|
sl@0
|
497 |
SqlServerStartupOomTest();
|
sl@0
|
498 |
|
sl@0
|
499 |
TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4160 CSqlServer::GetBackUpListL() OOM test"));
|
sl@0
|
500 |
GetBackupListOomTest();
|
sl@0
|
501 |
|
sl@0
|
502 |
TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4161 SQL server startup file I/O error simulation test"));
|
sl@0
|
503 |
SqlServerStartupFileIoErrorTest();
|
sl@0
|
504 |
|
sl@0
|
505 |
TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4162 CSqlServer::GetBackUpListL() file I/O error simulation test"));
|
sl@0
|
506 |
GetBackupListFileIoErrorTest();
|
sl@0
|
507 |
|
sl@0
|
508 |
TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4224 CSqlServer::GetBackUpListL() functional test"));
|
sl@0
|
509 |
GetBackupListFunctionalTest();
|
sl@0
|
510 |
|
sl@0
|
511 |
TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4163 SQL server, UTF conversion test"));
|
sl@0
|
512 |
UtfConversionTest();
|
sl@0
|
513 |
|
sl@0
|
514 |
TheTest.Next (_L(" @SYMTestCaseID:PDS-SQL-UT-4175 Reserve drive space tests"));
|
sl@0
|
515 |
ReserveDriveSpaceTest();
|
sl@0
|
516 |
|
sl@0
|
517 |
delete scheduler;
|
sl@0
|
518 |
}
|
sl@0
|
519 |
|
sl@0
|
520 |
TInt E32Main()
|
sl@0
|
521 |
{
|
sl@0
|
522 |
TheTest.Title();
|
sl@0
|
523 |
|
sl@0
|
524 |
CTrapCleanup* tc = CTrapCleanup::New();
|
sl@0
|
525 |
TheTest(tc != NULL);
|
sl@0
|
526 |
|
sl@0
|
527 |
__UHEAP_MARK;
|
sl@0
|
528 |
|
sl@0
|
529 |
DoTests();
|
sl@0
|
530 |
DeleteTestFiles();
|
sl@0
|
531 |
|
sl@0
|
532 |
__UHEAP_MARKEND;
|
sl@0
|
533 |
|
sl@0
|
534 |
TheTest.End();
|
sl@0
|
535 |
TheTest.Close();
|
sl@0
|
536 |
|
sl@0
|
537 |
delete tc;
|
sl@0
|
538 |
|
sl@0
|
539 |
User::Heap().Check();
|
sl@0
|
540 |
return KErrNone;
|
sl@0
|
541 |
}
|