sl@0
|
1 |
// Copyright (c) 1998-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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
// MSVC++ up to 5.0 has problems with expanding inline functions
|
sl@0
|
17 |
// This disables the mad warnings for the whole project
|
sl@0
|
18 |
#if defined(NDEBUG) && defined(__VC32__) && _MSC_VER<=1100
|
sl@0
|
19 |
#pragma warning(disable : 4710) // function not expanded. MSVC 5.0 is stupid
|
sl@0
|
20 |
#endif
|
sl@0
|
21 |
|
sl@0
|
22 |
#include <d32dbms.h>
|
sl@0
|
23 |
#include <s32file.h>
|
sl@0
|
24 |
#include <e32test.h>
|
sl@0
|
25 |
#include <e32math.h>
|
sl@0
|
26 |
#ifndef __TOOLS2__
|
sl@0
|
27 |
#include <hal.h>
|
sl@0
|
28 |
#endif
|
sl@0
|
29 |
|
sl@0
|
30 |
#include "crccheck.h"
|
sl@0
|
31 |
|
sl@0
|
32 |
#undef __UHEAP_MARK
|
sl@0
|
33 |
#define __UHEAP_MARK
|
sl@0
|
34 |
#undef __UHEAP_MARKEND
|
sl@0
|
35 |
#define __UHEAP_MARKEND
|
sl@0
|
36 |
#undef __UHEAP_CHECK
|
sl@0
|
37 |
#define __UHEAP_CHECK(a)
|
sl@0
|
38 |
#undef __UHEAP_FAILNEXT
|
sl@0
|
39 |
#define __UHEAP_FAILNEXT(a)
|
sl@0
|
40 |
|
sl@0
|
41 |
LOCAL_D TDBMS_CRCChecks TheCrcChecker;
|
sl@0
|
42 |
|
sl@0
|
43 |
#ifndef __linux__ //No CRC test on LINUX
|
sl@0
|
44 |
#ifdef __TOOLS2__
|
sl@0
|
45 |
const TPtrC KCrcRecord=_L("\\epoc32\\winscw\\c\\dbms-tst\\T_BIG.CRC");
|
sl@0
|
46 |
#else
|
sl@0
|
47 |
const TPtrC KCrcRecord=_L("C:\\dbms-tst\\T_BIG.CRC");
|
sl@0
|
48 |
#endif
|
sl@0
|
49 |
#endif
|
sl@0
|
50 |
|
sl@0
|
51 |
class TTimer
|
sl@0
|
52 |
{
|
sl@0
|
53 |
public:
|
sl@0
|
54 |
void Start(const TDesC& aDes);
|
sl@0
|
55 |
void Stop();
|
sl@0
|
56 |
private:
|
sl@0
|
57 |
TUint iTicks;
|
sl@0
|
58 |
};
|
sl@0
|
59 |
|
sl@0
|
60 |
LOCAL_D RTest test(_L("T_BIG - Test Large DBMS objects"));
|
sl@0
|
61 |
LOCAL_D CTrapCleanup* TheTrapCleanup;
|
sl@0
|
62 |
LOCAL_D CFileStore* TheStore;
|
sl@0
|
63 |
LOCAL_D RDbStoreDatabase TheDatabase;
|
sl@0
|
64 |
LOCAL_D RDbTable TheTable;
|
sl@0
|
65 |
LOCAL_D RFs TheFs;
|
sl@0
|
66 |
|
sl@0
|
67 |
const TInt KTestCleanupStack=0x20;
|
sl@0
|
68 |
|
sl@0
|
69 |
#ifdef __TOOLS2__
|
sl@0
|
70 |
const TPtrC KTestDir=_L(".\\dbms-tst\\");
|
sl@0
|
71 |
#else
|
sl@0
|
72 |
const TPtrC KTestDir=_L("C:\\dbms-tst\\");
|
sl@0
|
73 |
#endif
|
sl@0
|
74 |
|
sl@0
|
75 |
const TPtrC KTestFile=_L("T_BIG.DB");
|
sl@0
|
76 |
const TPtrC KTableName(_S("table"));
|
sl@0
|
77 |
const TPtrC KIndexText=_S("text");
|
sl@0
|
78 |
const TPtrC KIndexInt=_S("int");
|
sl@0
|
79 |
const TPtrC KColumnText=_S("text");
|
sl@0
|
80 |
const TPtrC KColumnInt=_S("int");
|
sl@0
|
81 |
const TPtrC KIncFormat=_S("%5d\r");
|
sl@0
|
82 |
const TInt KRecords=1000;
|
sl@0
|
83 |
const TPtrC KOtherTable=_S("extra");
|
sl@0
|
84 |
|
sl@0
|
85 |
#ifndef __TOOLS2__
|
sl@0
|
86 |
static TTimer TheTimer;
|
sl@0
|
87 |
|
sl@0
|
88 |
void TTimer::Start(const TDesC& aDes)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
test.Printf(_L(" %S: "),&aDes);
|
sl@0
|
91 |
iTicks=User::FastCounter();
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|
sl@0
|
94 |
void TTimer::Stop()
|
sl@0
|
95 |
{
|
sl@0
|
96 |
TUint ticks = User::FastCounter() - iTicks;
|
sl@0
|
97 |
TInt freq = 0;
|
sl@0
|
98 |
test(HAL::Get(HAL::EFastCounterFrequency, freq) == KErrNone);
|
sl@0
|
99 |
const TInt KMicroSecIn1Sec = 1000000;
|
sl@0
|
100 |
const TInt KMsIn1Sec = 1000;
|
sl@0
|
101 |
double v = ((double)ticks * KMicroSecIn1Sec) / (double)freq; TInt v2 = (TInt)v;
|
sl@0
|
102 |
test.Printf(_L("%d ms\r\n"),v2/KMsIn1Sec);
|
sl@0
|
103 |
}
|
sl@0
|
104 |
#endif
|
sl@0
|
105 |
|
sl@0
|
106 |
/**
|
sl@0
|
107 |
@SYMTestCaseID SYSLIB-DBMS-CT-1309
|
sl@0
|
108 |
@SYMTestCaseDesc Create the database-in-a-store
|
sl@0
|
109 |
@SYMTestPriority Medium
|
sl@0
|
110 |
@SYMTestActions Calls up RDbStoreDatabase::CreateL() function
|
sl@0
|
111 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
112 |
@SYMREQ REQ0000
|
sl@0
|
113 |
*/
|
sl@0
|
114 |
LOCAL_C void CreateDatabaseL()
|
sl@0
|
115 |
{
|
sl@0
|
116 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1309 "));
|
sl@0
|
117 |
CFileStore* store=CPermanentFileStore::ReplaceLC(TheFs,KTestFile,EFileRead|EFileWrite);
|
sl@0
|
118 |
store->SetTypeL(KPermanentFileStoreLayoutUid);
|
sl@0
|
119 |
TStreamId id;
|
sl@0
|
120 |
id=TheDatabase.CreateL(store);
|
sl@0
|
121 |
store->SetRootL(id);
|
sl@0
|
122 |
store->CommitL();
|
sl@0
|
123 |
CleanupStack::Pop();
|
sl@0
|
124 |
TheStore=store;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
/**
|
sl@0
|
128 |
@SYMTestCaseID SYSLIB-DBMS-CT-1310
|
sl@0
|
129 |
@SYMTestCaseDesc Open the database-in-a-store
|
sl@0
|
130 |
@SYMTestPriority Medium
|
sl@0
|
131 |
@SYMTestActions Call up RDbStoreDatabase::OpenL()
|
sl@0
|
132 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
133 |
@SYMREQ REQ0000
|
sl@0
|
134 |
*/
|
sl@0
|
135 |
LOCAL_C void OpenDatabaseL()
|
sl@0
|
136 |
{
|
sl@0
|
137 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1310 "));
|
sl@0
|
138 |
CFileStore* store=CPermanentFileStore::OpenLC(TheFs,KTestFile,EFileRead|EFileWrite);
|
sl@0
|
139 |
TheDatabase.OpenL(store,store->Root());
|
sl@0
|
140 |
CleanupStack::Pop();
|
sl@0
|
141 |
TheStore=store;
|
sl@0
|
142 |
}
|
sl@0
|
143 |
|
sl@0
|
144 |
/**
|
sl@0
|
145 |
@SYMTestCaseID SYSLIB-DBMS-CT-1311
|
sl@0
|
146 |
@SYMTestCaseDesc Close the database in store
|
sl@0
|
147 |
@SYMTestPriority Medium
|
sl@0
|
148 |
@SYMTestActions Test for RDbStoreDatabase::Close() function
|
sl@0
|
149 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
150 |
@SYMREQ REQ0000
|
sl@0
|
151 |
*/
|
sl@0
|
152 |
LOCAL_C void CloseDatabaseL()
|
sl@0
|
153 |
{
|
sl@0
|
154 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1311 "));
|
sl@0
|
155 |
TheDatabase.Close();
|
sl@0
|
156 |
delete TheStore;
|
sl@0
|
157 |
TInt err = TheCrcChecker.GenerateCrcL(KTestFile);
|
sl@0
|
158 |
test(err == KErrNone);
|
sl@0
|
159 |
}
|
sl@0
|
160 |
|
sl@0
|
161 |
LOCAL_C void CreateTable()
|
sl@0
|
162 |
{
|
sl@0
|
163 |
CDbColSet *cs=CDbColSet::NewLC();
|
sl@0
|
164 |
TDbCol col1(KColumnInt,EDbColInt32);
|
sl@0
|
165 |
col1.iAttributes=TDbCol::ENotNull;
|
sl@0
|
166 |
cs->AddL(col1);
|
sl@0
|
167 |
TDbCol col2(KColumnText,EDbColText,200/sizeof(TText));
|
sl@0
|
168 |
col2.iAttributes=TDbCol::ENotNull;
|
sl@0
|
169 |
cs->AddL(col2);
|
sl@0
|
170 |
test(TheDatabase.CreateTable(KTableName,*cs)==KErrNone);
|
sl@0
|
171 |
CleanupStack::PopAndDestroy();
|
sl@0
|
172 |
}
|
sl@0
|
173 |
|
sl@0
|
174 |
LOCAL_C void WriteRecords(TInt aCount)
|
sl@0
|
175 |
{
|
sl@0
|
176 |
TBuf<10> text;
|
sl@0
|
177 |
TInt jj=0;
|
sl@0
|
178 |
for (TInt ii=0;ii<aCount;++ii)
|
sl@0
|
179 |
{
|
sl@0
|
180 |
TheTable.InsertL();
|
sl@0
|
181 |
jj=(jj+23);
|
sl@0
|
182 |
if (jj>=aCount)
|
sl@0
|
183 |
jj-=aCount;
|
sl@0
|
184 |
TheTable.SetColL(1,jj);
|
sl@0
|
185 |
text.Num(jj);
|
sl@0
|
186 |
TheTable.SetColL(2,text);
|
sl@0
|
187 |
TheTable.PutL();
|
sl@0
|
188 |
}
|
sl@0
|
189 |
}
|
sl@0
|
190 |
|
sl@0
|
191 |
/**
|
sl@0
|
192 |
@SYMTestCaseID SYSLIB-DBMS-CT-1312
|
sl@0
|
193 |
@SYMTestCaseDesc Create a table in database
|
sl@0
|
194 |
@SYMTestPriority Medium
|
sl@0
|
195 |
@SYMTestActions Build a table and write records into the table.Test for commiting the transactions.
|
sl@0
|
196 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
197 |
@SYMREQ REQ0000
|
sl@0
|
198 |
*/
|
sl@0
|
199 |
LOCAL_C void BuildTable(TInt aCount)
|
sl@0
|
200 |
{
|
sl@0
|
201 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1312 "));
|
sl@0
|
202 |
#ifndef __TOOLS2__
|
sl@0
|
203 |
TheTimer.Start(_L("build"));
|
sl@0
|
204 |
#endif
|
sl@0
|
205 |
CreateTable();
|
sl@0
|
206 |
TheDatabase.Begin();
|
sl@0
|
207 |
test(TheTable.Open(TheDatabase,KTableName)==KErrNone);
|
sl@0
|
208 |
WriteRecords(aCount);
|
sl@0
|
209 |
test(TheDatabase.Commit()==KErrNone);
|
sl@0
|
210 |
TheTable.Close();
|
sl@0
|
211 |
#ifndef __TOOLS2__
|
sl@0
|
212 |
TheTimer.Stop();
|
sl@0
|
213 |
#endif
|
sl@0
|
214 |
}
|
sl@0
|
215 |
|
sl@0
|
216 |
/**
|
sl@0
|
217 |
@SYMTestCaseID SYSLIB-DBMS-CT-1313
|
sl@0
|
218 |
@SYMTestCaseDesc Tests for total rows in the rowset
|
sl@0
|
219 |
@SYMTestPriority Medium
|
sl@0
|
220 |
@SYMTestActions Iterate through the table.Test for the total numbers of rows available
|
sl@0
|
221 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
222 |
@SYMREQ REQ0000
|
sl@0
|
223 |
*/
|
sl@0
|
224 |
LOCAL_C void IterateL(RDbTable::TPosition aDirection)
|
sl@0
|
225 |
{
|
sl@0
|
226 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1313 "));
|
sl@0
|
227 |
#ifndef __TOOLS2__
|
sl@0
|
228 |
TheTimer.Start(_L("iterate"));
|
sl@0
|
229 |
#endif
|
sl@0
|
230 |
TInt cc=0;
|
sl@0
|
231 |
while (TheTable.GotoL(aDirection))
|
sl@0
|
232 |
{
|
sl@0
|
233 |
++cc;
|
sl@0
|
234 |
TheTable.GetL();
|
sl@0
|
235 |
}
|
sl@0
|
236 |
#ifndef __TOOLS2__
|
sl@0
|
237 |
TheTimer.Stop();
|
sl@0
|
238 |
#endif
|
sl@0
|
239 |
test(cc=TheTable.CountL());
|
sl@0
|
240 |
}
|
sl@0
|
241 |
|
sl@0
|
242 |
/**
|
sl@0
|
243 |
@SYMTestCaseID SYSLIB-DBMS-CT-0580
|
sl@0
|
244 |
@SYMTestCaseDesc Tests the database definition and enquiry functions
|
sl@0
|
245 |
@SYMTestPriority Medium
|
sl@0
|
246 |
@SYMTestActions Tests by setting an active index for the table.
|
sl@0
|
247 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
248 |
@SYMREQ REQ0000
|
sl@0
|
249 |
*/
|
sl@0
|
250 |
LOCAL_C void TestIndex(const TDesC& aName,const CDbKey& aKey)
|
sl@0
|
251 |
{
|
sl@0
|
252 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0580 "));
|
sl@0
|
253 |
#ifndef __TOOLS2__
|
sl@0
|
254 |
TheTimer.Start(_L("build"));
|
sl@0
|
255 |
#endif
|
sl@0
|
256 |
test(TheDatabase.CreateIndex(aName,KTableName,aKey)==KErrNone);
|
sl@0
|
257 |
#ifndef __TOOLS2__
|
sl@0
|
258 |
TheTimer.Stop();
|
sl@0
|
259 |
#endif
|
sl@0
|
260 |
test(TheTable.Open(TheDatabase,KTableName)==KErrNone);
|
sl@0
|
261 |
test(TheTable.SetIndex(aName)==KErrNone);
|
sl@0
|
262 |
IterateL(TheTable.ENext);
|
sl@0
|
263 |
TheTable.Close();
|
sl@0
|
264 |
}
|
sl@0
|
265 |
|
sl@0
|
266 |
/**
|
sl@0
|
267 |
@SYMTestCaseID SYSLIB-DBMS-CT-0581
|
sl@0
|
268 |
@SYMTestCaseDesc Tests the database definition and enquiry functions
|
sl@0
|
269 |
@SYMTestPriority Medium
|
sl@0
|
270 |
@SYMTestActions Tests for bookmark which saves the current location of a rowset.
|
sl@0
|
271 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
272 |
@SYMREQ REQ0000
|
sl@0
|
273 |
*/
|
sl@0
|
274 |
LOCAL_C void TestBookmark()
|
sl@0
|
275 |
{
|
sl@0
|
276 |
test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0581 creating alien bookmark "));
|
sl@0
|
277 |
CDbColSet* cs=CDbColSet::NewLC();
|
sl@0
|
278 |
TDbCol col(_L("column"),EDbColUint8);
|
sl@0
|
279 |
col.iAttributes=TDbCol::ENotNull+TDbCol::EAutoIncrement;
|
sl@0
|
280 |
cs->AddL(col);
|
sl@0
|
281 |
test (TheDatabase.CreateTable(KOtherTable,*cs)==KErrNone);
|
sl@0
|
282 |
CleanupStack::PopAndDestroy();
|
sl@0
|
283 |
RDbTable extra;
|
sl@0
|
284 |
test (extra.Open(TheDatabase,KOtherTable)==KErrNone);
|
sl@0
|
285 |
extra.InsertL();
|
sl@0
|
286 |
extra.PutL();
|
sl@0
|
287 |
TDbBookmark alien=extra.Bookmark();
|
sl@0
|
288 |
extra.Close();
|
sl@0
|
289 |
//
|
sl@0
|
290 |
test.Next(_L("Alien bookmark"));
|
sl@0
|
291 |
test (TheTable.Open(TheDatabase,KTableName)==KErrNone);
|
sl@0
|
292 |
TRAPD(r,TheTable.GotoL(alien));
|
sl@0
|
293 |
test (r==KErrNotFound);
|
sl@0
|
294 |
test (TheTable.SetIndex(KIndexInt)==KErrNone);
|
sl@0
|
295 |
TRAP(r,TheTable.GotoL(alien));
|
sl@0
|
296 |
test (r==KErrNotFound);
|
sl@0
|
297 |
test (TheTable.SetIndex(KIndexText)==KErrNone);
|
sl@0
|
298 |
TRAP(r,TheTable.GotoL(alien));
|
sl@0
|
299 |
test (r==KErrNotFound);
|
sl@0
|
300 |
//
|
sl@0
|
301 |
test.Next(_L("Cross-view bookmarks"));
|
sl@0
|
302 |
TheTable.LastL(); // indexed view
|
sl@0
|
303 |
TheTable.PreviousL();
|
sl@0
|
304 |
TDbBookmark mark=TheTable.Bookmark();
|
sl@0
|
305 |
test (extra.Open(TheDatabase,KTableName)==KErrNone);
|
sl@0
|
306 |
TRAP(r,extra.GotoL(mark));
|
sl@0
|
307 |
test (r==KErrNone);
|
sl@0
|
308 |
test (extra.PreviousL());
|
sl@0
|
309 |
TRAP(r,TheTable.GotoL(extra.Bookmark()));
|
sl@0
|
310 |
test (r==KErrNone);
|
sl@0
|
311 |
extra.Close();
|
sl@0
|
312 |
//
|
sl@0
|
313 |
test.Next(_L("Bookmark persistence"));
|
sl@0
|
314 |
TheTable.Close();
|
sl@0
|
315 |
test (TheTable.Open(TheDatabase,KTableName)==KErrNone);
|
sl@0
|
316 |
TRAP(r,TheTable.GotoL(mark));
|
sl@0
|
317 |
test (r==KErrNone);
|
sl@0
|
318 |
TheTable.Close();
|
sl@0
|
319 |
//
|
sl@0
|
320 |
test.Next(_L("Delete alien record"));
|
sl@0
|
321 |
test (extra.Open(TheDatabase,KOtherTable)==KErrNone);
|
sl@0
|
322 |
TRAP(r, extra.GotoL(mark));
|
sl@0
|
323 |
test (r==KErrNotFound);
|
sl@0
|
324 |
TRAP(r,extra.GotoL(alien));
|
sl@0
|
325 |
test (r==KErrNone);
|
sl@0
|
326 |
extra.DeleteL();
|
sl@0
|
327 |
TRAP(r,extra.GotoL(alien));
|
sl@0
|
328 |
test (r==KErrNotFound);
|
sl@0
|
329 |
extra.Close();
|
sl@0
|
330 |
//
|
sl@0
|
331 |
test.Next(_L("Delete extra table"));
|
sl@0
|
332 |
test (TheDatabase.DropTable(KOtherTable)==KErrNone);
|
sl@0
|
333 |
test (TheTable.Open(TheDatabase,KTableName)==KErrNone);
|
sl@0
|
334 |
TRAP(r,TheTable.GotoL(alien));
|
sl@0
|
335 |
test (r==KErrNotFound);
|
sl@0
|
336 |
TheTable.Close();
|
sl@0
|
337 |
//
|
sl@0
|
338 |
test.End();
|
sl@0
|
339 |
}
|
sl@0
|
340 |
|
sl@0
|
341 |
/**
|
sl@0
|
342 |
@SYMTestCaseID SYSLIB-DBMS-CT-1314
|
sl@0
|
343 |
@SYMTestCaseDesc Discarding indexes belonging to the table on database
|
sl@0
|
344 |
@SYMTestPriority Medium
|
sl@0
|
345 |
@SYMTestActions Tests for RDbIncremental::DropTable(),RDbIncremental::Next() function.
|
sl@0
|
346 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
347 |
@SYMREQ REQ0000
|
sl@0
|
348 |
*/
|
sl@0
|
349 |
LOCAL_C void BreakIndex()
|
sl@0
|
350 |
{
|
sl@0
|
351 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1314 "));
|
sl@0
|
352 |
#ifndef __TOOLS2__
|
sl@0
|
353 |
TheTimer.Start(_L("break"));
|
sl@0
|
354 |
#endif
|
sl@0
|
355 |
TInt step;
|
sl@0
|
356 |
RDbIncremental drop;
|
sl@0
|
357 |
test(drop.DropTable(TheDatabase,KTableName,step)==KErrNone);
|
sl@0
|
358 |
test(drop.Next(step)==KErrNone);
|
sl@0
|
359 |
test(step>0);
|
sl@0
|
360 |
drop.Close(); // abort the drop
|
sl@0
|
361 |
test(TheDatabase.IsDamaged());
|
sl@0
|
362 |
#ifndef __TOOLS2__
|
sl@0
|
363 |
TheTimer.Stop();
|
sl@0
|
364 |
#endif
|
sl@0
|
365 |
}
|
sl@0
|
366 |
|
sl@0
|
367 |
/**
|
sl@0
|
368 |
@SYMTestCaseID SYSLIB-DBMS-CT-1315
|
sl@0
|
369 |
@SYMTestCaseDesc Database recovery test
|
sl@0
|
370 |
@SYMTestPriority Medium
|
sl@0
|
371 |
@SYMTestActions Calls up RDbStoreDatabase::Recover() function
|
sl@0
|
372 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
373 |
@SYMREQ REQ0000
|
sl@0
|
374 |
*/
|
sl@0
|
375 |
LOCAL_C void Recover()
|
sl@0
|
376 |
{
|
sl@0
|
377 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1315 "));
|
sl@0
|
378 |
#ifndef __TOOLS2__
|
sl@0
|
379 |
TheTimer.Start(_L("recover"));
|
sl@0
|
380 |
#endif
|
sl@0
|
381 |
test(TheDatabase.Recover()==KErrNone);
|
sl@0
|
382 |
#ifndef __TOOLS2__
|
sl@0
|
383 |
TheTimer.Stop();
|
sl@0
|
384 |
#endif
|
sl@0
|
385 |
test(!TheDatabase.IsDamaged());
|
sl@0
|
386 |
}
|
sl@0
|
387 |
|
sl@0
|
388 |
/**
|
sl@0
|
389 |
@SYMTestCaseID SYSLIB-DBMS-CT-1316
|
sl@0
|
390 |
@SYMTestCaseDesc Tests for dropping an index
|
sl@0
|
391 |
@SYMTestPriority Medium
|
sl@0
|
392 |
@SYMTestActions Drop an integer and text index from the table. Test for damage of database
|
sl@0
|
393 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
394 |
@SYMREQ REQ0000
|
sl@0
|
395 |
*/
|
sl@0
|
396 |
LOCAL_C void DropIndexes()
|
sl@0
|
397 |
{
|
sl@0
|
398 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1316 "));
|
sl@0
|
399 |
#ifndef __TOOLS2__
|
sl@0
|
400 |
TheTimer.Start(_L("drop Int[32]"));
|
sl@0
|
401 |
#endif
|
sl@0
|
402 |
test(TheDatabase.DropIndex(KIndexInt,KTableName)==KErrNone);
|
sl@0
|
403 |
#ifndef __TOOLS2__
|
sl@0
|
404 |
TheTimer.Stop();
|
sl@0
|
405 |
TheTimer.Start(_L("drop Text[200]"));
|
sl@0
|
406 |
#endif
|
sl@0
|
407 |
test(TheDatabase.DropIndex(KIndexText,KTableName)==KErrNone);
|
sl@0
|
408 |
#ifndef __TOOLS2__
|
sl@0
|
409 |
TheTimer.Stop();
|
sl@0
|
410 |
#endif
|
sl@0
|
411 |
test(!TheDatabase.IsDamaged());
|
sl@0
|
412 |
}
|
sl@0
|
413 |
|
sl@0
|
414 |
/**
|
sl@0
|
415 |
@SYMTestCaseID SYSLIB-DBMS-CT-1317
|
sl@0
|
416 |
@SYMTestCaseDesc Deleting a table from the database
|
sl@0
|
417 |
@SYMTestPriority Medium
|
sl@0
|
418 |
@SYMTestActions Delete the rows from the rowset.Check for empty rows in the rowset.
|
sl@0
|
419 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
420 |
@SYMREQ REQ0000
|
sl@0
|
421 |
*/
|
sl@0
|
422 |
LOCAL_C void DeleteTable()
|
sl@0
|
423 |
{
|
sl@0
|
424 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-1317 "));
|
sl@0
|
425 |
const TInt KTenthRecords=KRecords/10;
|
sl@0
|
426 |
|
sl@0
|
427 |
test (TheTable.Open(TheDatabase,KTableName)==KErrNone);
|
sl@0
|
428 |
TheDatabase.Begin();
|
sl@0
|
429 |
TInt ii;
|
sl@0
|
430 |
for (ii=0;ii<15;++ii)
|
sl@0
|
431 |
{
|
sl@0
|
432 |
TheTable.NextL();
|
sl@0
|
433 |
TheTable.DeleteL();
|
sl@0
|
434 |
}
|
sl@0
|
435 |
TheTable.NextL();
|
sl@0
|
436 |
TDbBookmark mark=TheTable.Bookmark();
|
sl@0
|
437 |
TheTable.Close();
|
sl@0
|
438 |
TheDatabase.Commit();
|
sl@0
|
439 |
CloseDatabaseL();
|
sl@0
|
440 |
OpenDatabaseL();
|
sl@0
|
441 |
#ifndef __TOOLS2__
|
sl@0
|
442 |
TheTimer.Start(_L("delete table"));
|
sl@0
|
443 |
#endif
|
sl@0
|
444 |
test (TheTable.Open(TheDatabase,KTableName)==KErrNone);
|
sl@0
|
445 |
TheDatabase.Begin();
|
sl@0
|
446 |
TheTable.GotoL(mark);
|
sl@0
|
447 |
TheTable.DeleteL();
|
sl@0
|
448 |
for (ii=0;ii<KTenthRecords*2-16;++ii)
|
sl@0
|
449 |
{
|
sl@0
|
450 |
TheTable.NextL();
|
sl@0
|
451 |
TheTable.DeleteL();
|
sl@0
|
452 |
}
|
sl@0
|
453 |
TheTable.EndL();
|
sl@0
|
454 |
for (ii=0;ii<KTenthRecords*2;++ii)
|
sl@0
|
455 |
{
|
sl@0
|
456 |
TheTable.PreviousL();
|
sl@0
|
457 |
TheTable.DeleteL();
|
sl@0
|
458 |
}
|
sl@0
|
459 |
TheTable.BeginningL();
|
sl@0
|
460 |
for (ii=0;ii<KTenthRecords*3;++ii)
|
sl@0
|
461 |
TheTable.NextL();
|
sl@0
|
462 |
for (ii=0;ii<KTenthRecords*2;++ii)
|
sl@0
|
463 |
{
|
sl@0
|
464 |
TheTable.NextL();
|
sl@0
|
465 |
TheTable.DeleteL();
|
sl@0
|
466 |
}
|
sl@0
|
467 |
for (ii=0;ii<KTenthRecords*2;++ii)
|
sl@0
|
468 |
{
|
sl@0
|
469 |
TheTable.PreviousL();
|
sl@0
|
470 |
TheTable.DeleteL();
|
sl@0
|
471 |
}
|
sl@0
|
472 |
for (ii=0;ii<KTenthRecords;++ii)
|
sl@0
|
473 |
{
|
sl@0
|
474 |
TheTable.NextL();
|
sl@0
|
475 |
TheTable.DeleteL();
|
sl@0
|
476 |
}
|
sl@0
|
477 |
for (ii=0;ii<KTenthRecords;++ii)
|
sl@0
|
478 |
{
|
sl@0
|
479 |
TheTable.PreviousL();
|
sl@0
|
480 |
TheTable.DeleteL();
|
sl@0
|
481 |
}
|
sl@0
|
482 |
test (TheTable.CountL()==0);
|
sl@0
|
483 |
test (!TheTable.NextL());
|
sl@0
|
484 |
test (!TheTable.PreviousL());
|
sl@0
|
485 |
test (TheDatabase.Commit()==KErrNone);
|
sl@0
|
486 |
TheTable.Close();
|
sl@0
|
487 |
#ifndef __TOOLS2__
|
sl@0
|
488 |
TheTimer.Stop();
|
sl@0
|
489 |
#endif
|
sl@0
|
490 |
}
|
sl@0
|
491 |
|
sl@0
|
492 |
/**
|
sl@0
|
493 |
@SYMTestCaseID SYSLIB-DBMS-CT-0579
|
sl@0
|
494 |
@SYMTestCaseDesc Tests the database definition and enquiry functions
|
sl@0
|
495 |
@SYMTestPriority Medium
|
sl@0
|
496 |
@SYMTestActions Executes the index and bookmark tests
|
sl@0
|
497 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
498 |
@SYMREQ REQ0000
|
sl@0
|
499 |
*/
|
sl@0
|
500 |
LOCAL_C void BigTestL()
|
sl@0
|
501 |
{
|
sl@0
|
502 |
test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0579 Table "));
|
sl@0
|
503 |
CreateDatabaseL();
|
sl@0
|
504 |
BuildTable(KRecords);
|
sl@0
|
505 |
test(TheTable.Open(TheDatabase,KTableName)==KErrNone);
|
sl@0
|
506 |
TheTable.EndL();
|
sl@0
|
507 |
IterateL(TheTable.EPrevious);
|
sl@0
|
508 |
TheTable.BeginningL();
|
sl@0
|
509 |
IterateL(TheTable.ENext);
|
sl@0
|
510 |
TheTable.EndL();
|
sl@0
|
511 |
IterateL(TheTable.EPrevious);
|
sl@0
|
512 |
TheTable.Close();
|
sl@0
|
513 |
test.Next(_L("Int32 Index"));
|
sl@0
|
514 |
CDbKey *key=CDbKey::NewLC();
|
sl@0
|
515 |
key->AddL(KColumnInt);
|
sl@0
|
516 |
key->MakeUnique();
|
sl@0
|
517 |
TestIndex(KIndexInt,*key);
|
sl@0
|
518 |
test.Next(_L("Text[200] Index"));
|
sl@0
|
519 |
key->Clear();
|
sl@0
|
520 |
key->AddL(KColumnText);
|
sl@0
|
521 |
key->MakeUnique();
|
sl@0
|
522 |
TestIndex(KIndexText,*key);
|
sl@0
|
523 |
test.Next(_L("Bookmarks"));
|
sl@0
|
524 |
TestBookmark();
|
sl@0
|
525 |
test.Next(_L("Int32 Index"));
|
sl@0
|
526 |
#ifndef __TOOLS2__
|
sl@0
|
527 |
TheTimer.Start(_L("drop"));
|
sl@0
|
528 |
#endif
|
sl@0
|
529 |
test(TheDatabase.DropIndex(KIndexInt,KTableName)==KErrNone);
|
sl@0
|
530 |
#ifndef __TOOLS2__
|
sl@0
|
531 |
TheTimer.Stop();
|
sl@0
|
532 |
#endif
|
sl@0
|
533 |
key->Clear();
|
sl@0
|
534 |
key->AddL(KColumnInt);
|
sl@0
|
535 |
key->MakeUnique();
|
sl@0
|
536 |
TestIndex(KIndexInt,*key);
|
sl@0
|
537 |
CleanupStack::PopAndDestroy();
|
sl@0
|
538 |
test.Next(_L("Break & Recover"));
|
sl@0
|
539 |
BreakIndex();
|
sl@0
|
540 |
Recover();
|
sl@0
|
541 |
test.Next(_L("Drop Indexes"));
|
sl@0
|
542 |
DropIndexes();
|
sl@0
|
543 |
test.Next(_L("Delete all records"));
|
sl@0
|
544 |
DeleteTable();
|
sl@0
|
545 |
CloseDatabaseL();
|
sl@0
|
546 |
test.End();
|
sl@0
|
547 |
}
|
sl@0
|
548 |
|
sl@0
|
549 |
//
|
sl@0
|
550 |
// Prepare the test directory.
|
sl@0
|
551 |
//
|
sl@0
|
552 |
LOCAL_C void setupTestDirectory()
|
sl@0
|
553 |
{
|
sl@0
|
554 |
TInt r=TheFs.Connect();
|
sl@0
|
555 |
test(r==KErrNone);
|
sl@0
|
556 |
r=TheFs.MkDir(KTestDir);
|
sl@0
|
557 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
558 |
r=TheFs.SetSessionPath(KTestDir);
|
sl@0
|
559 |
test(r==KErrNone);
|
sl@0
|
560 |
|
sl@0
|
561 |
// On TOOLS2 - RFs::SetSessionPath() will affect all RFs Sessions,
|
sl@0
|
562 |
// the two RFs need same session path anyway
|
sl@0
|
563 |
#ifdef __WINSCW__
|
sl@0
|
564 |
r=TheCrcChecker.SetSessionPath(KTestDir);
|
sl@0
|
565 |
test(r==KErrNone);
|
sl@0
|
566 |
#endif
|
sl@0
|
567 |
}
|
sl@0
|
568 |
|
sl@0
|
569 |
//
|
sl@0
|
570 |
// Initialise the cleanup stack.
|
sl@0
|
571 |
//
|
sl@0
|
572 |
LOCAL_C void setupCleanup()
|
sl@0
|
573 |
{
|
sl@0
|
574 |
TheTrapCleanup=CTrapCleanup::New();
|
sl@0
|
575 |
test(TheTrapCleanup!=NULL);
|
sl@0
|
576 |
TRAPD(r,\
|
sl@0
|
577 |
{\
|
sl@0
|
578 |
for (TInt i=KTestCleanupStack;i>0;i--)\
|
sl@0
|
579 |
CleanupStack::PushL((TAny*)0);\
|
sl@0
|
580 |
CleanupStack::Pop(KTestCleanupStack);\
|
sl@0
|
581 |
});
|
sl@0
|
582 |
test(r==KErrNone);
|
sl@0
|
583 |
}
|
sl@0
|
584 |
|
sl@0
|
585 |
LOCAL_C void DeleteDataFile(const TDesC& aFullName)
|
sl@0
|
586 |
{
|
sl@0
|
587 |
RFs fsSession;
|
sl@0
|
588 |
TInt err = fsSession.Connect();
|
sl@0
|
589 |
if(err == KErrNone)
|
sl@0
|
590 |
{
|
sl@0
|
591 |
TEntry entry;
|
sl@0
|
592 |
if(fsSession.Entry(aFullName, entry) == KErrNone)
|
sl@0
|
593 |
{
|
sl@0
|
594 |
RDebug::Print(_L("Deleting \"%S\" file.\n"), &aFullName);
|
sl@0
|
595 |
err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly);
|
sl@0
|
596 |
if(err != KErrNone)
|
sl@0
|
597 |
{
|
sl@0
|
598 |
RDebug::Print(_L("Error %d changing \"%S\" file attributes.\n"), err, &aFullName);
|
sl@0
|
599 |
}
|
sl@0
|
600 |
err = fsSession.Delete(aFullName);
|
sl@0
|
601 |
if(err != KErrNone)
|
sl@0
|
602 |
{
|
sl@0
|
603 |
RDebug::Print(_L("Error %d deleting \"%S\" file.\n"), err, &aFullName);
|
sl@0
|
604 |
}
|
sl@0
|
605 |
}
|
sl@0
|
606 |
fsSession.Close();
|
sl@0
|
607 |
}
|
sl@0
|
608 |
else
|
sl@0
|
609 |
{
|
sl@0
|
610 |
RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
|
sl@0
|
611 |
}
|
sl@0
|
612 |
}
|
sl@0
|
613 |
|
sl@0
|
614 |
GLDEF_C TInt E32Main()
|
sl@0
|
615 |
{
|
sl@0
|
616 |
test.Title();
|
sl@0
|
617 |
setupTestDirectory();
|
sl@0
|
618 |
setupCleanup();
|
sl@0
|
619 |
__UHEAP_MARK;
|
sl@0
|
620 |
//
|
sl@0
|
621 |
test.Start(_L("Standard database"));
|
sl@0
|
622 |
TRAPD(r,BigTestL();)
|
sl@0
|
623 |
test(r==KErrNone);
|
sl@0
|
624 |
test.Next(_L("Secure database"));
|
sl@0
|
625 |
TRAP(r,BigTestL();)
|
sl@0
|
626 |
test(r==KErrNone);
|
sl@0
|
627 |
|
sl@0
|
628 |
// clean up data files used by this test - must be done before call to End() - DEF047652
|
sl@0
|
629 |
#ifndef __TOOLS2__
|
sl@0
|
630 |
_LIT(KTestDbName, "C:\\dbms-tst\\T_BIG.DB");
|
sl@0
|
631 |
#else
|
sl@0
|
632 |
_LIT(KTestDbName, "T_BIG.DB");
|
sl@0
|
633 |
#endif
|
sl@0
|
634 |
::DeleteDataFile(KTestDbName);
|
sl@0
|
635 |
|
sl@0
|
636 |
#ifndef __linux__
|
sl@0
|
637 |
TInt err;
|
sl@0
|
638 |
#ifndef __TOOLS2__
|
sl@0
|
639 |
TRAPD(lc, err = TheCrcChecker.DumpCrcRecordsL(KCrcRecord));
|
sl@0
|
640 |
test(err==KErrNone);
|
sl@0
|
641 |
test(lc==KErrNone);
|
sl@0
|
642 |
#else
|
sl@0
|
643 |
TRAPD(lc, err = TheCrcChecker.ValidateCrcRecordsL(KCrcRecord));
|
sl@0
|
644 |
TPtrC errmsg;
|
sl@0
|
645 |
TheCrcChecker.ErrorReportL(err, errmsg);
|
sl@0
|
646 |
RDebug::Print(errmsg);
|
sl@0
|
647 |
test(err==KErrNone || err==TDBMS_CRCChecks::ECrcCheckOk);
|
sl@0
|
648 |
#endif
|
sl@0
|
649 |
#endif
|
sl@0
|
650 |
|
sl@0
|
651 |
test.End();
|
sl@0
|
652 |
|
sl@0
|
653 |
__UHEAP_MARKEND;
|
sl@0
|
654 |
delete TheTrapCleanup;
|
sl@0
|
655 |
|
sl@0
|
656 |
TheFs.Close();
|
sl@0
|
657 |
test.Close();
|
sl@0
|
658 |
return 0;
|
sl@0
|
659 |
}
|