author | Shabe Razvi <shaber@symbian.org> |
Tue, 19 Oct 2010 15:57:30 +0100 | |
changeset 54 | a0e1d366428c |
parent 51 | 7d4490026038 |
child 55 | 44f437012c90 |
permissions | -rw-r--r-- |
29 | 1 |
// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
// All rights reserved. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
// This component and the accompanying materials are made available |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
// under the terms of "Eclipse Public License v1.0" |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
// which accompanies this distribution, and is available |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
// Initial Contributors: |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
// Nokia Corporation - initial contribution. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
// Contributors: |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
// Description: |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
#include <e32test.h> |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
#include <bautils.h> |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include <sqldb.h> |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#include <e32math.h> |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include "SqlBur.h" |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#include "t_sqlbur.h" |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
/////////////////////////////////////////////////////////////////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
RTest TheTest(_L("SQL Backup and Restore Test")); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
|
51 | 28 |
_LIT(KPrivateDir, "\\private\\10281e17\\"); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
|
51 | 30 |
//Don't forget to update DeleteBackupFiles() implementation if a new uid is added |
31 |
const TSecureId KClientUid = 0x21212122; // the data owner's UID |
|
32 |
const TSecureId KZeroFileSizeUid = 0xFFFF4321; |
|
33 |
const TSecureId KTestClientUid1 = 0xFFFF4322; |
|
34 |
const TSecureId KTestClientUid2 = 0xFFFF4323; |
|
35 |
const TSecureId KTestClientUid3 = 0xFFFF4324; |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
_LIT(KBackupDir, "C:\\TEST\\"); |
51 | 38 |
_LIT(KBackupFileTemplate, "C:\\TEST\\Backup.bak"); |
39 |
_LIT(KBackupCopy, "C:\\TEST\\Backup2.bak"); |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
_LIT(KBackupFile2Z, "Z:\\TEST\\t_sqlbur_backup_ver0.bak"); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
_LIT(KBackupFile2, "C:\\TEST\\t_sqlbur_backup_ver0.bak"); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
|
51 | 43 |
_LIT(KZeroSizeFile, "C:\\private\\10281e17\\[FFFF4321]t_sqlbur_zero.db"); |
44 |
_LIT(KTestFile1, "C:\\private\\10281e17\\[FFFF4322]t_sqlbur_test1.db"); |
|
45 |
_LIT(KTestFile1NameOnly, "[FFFF4322]t_sqlbur_test1.db"); |
|
46 |
_LIT(KTestFile1Bak, "C:\\private\\10281e17\\bak[FFFF4322]t_sqlbur_test1.db.bak"); |
|
47 |
_LIT(KTestDeleteMask1, "C:\\private\\10281e17\\[FFFF4322]*"); |
|
48 |
_LIT(KTestDeleteMask2, "*bur_test1.db"); |
|
49 |
_LIT(KTestFile2, "\\private\\10281e17\\[FFFF4323]t_sqlbur_test2.db"); |
|
50 |
_LIT(KTestFile3, "c:\\private\\10281e17\\[FFFF4324]t_sqlbur_test3.db"); |
|
51 |
_LIT(KTestFile4, "c:\\private\\10281e17\\[FFFF4324]t_sqlbur_test4.db"); |
|
52 |
||
53 |
const TDriveNumber KTestDrive = EDriveC; |
|
54 |
||
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
55 |
const TUint KBufferSize = 2048; // used for reading backup files for validation |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
static CActiveScheduler* TheScheduler = NULL; |
51 | 58 |
static CSqlSrvTestBurInterface* TheSqlSrvTestBurInterface = NULL; |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
///////////////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
//Test db files |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
_LIT(KTestDbFileName1,"C:[21212122]AADB2.db"); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
64 |
_LIT(KTestDbFileName2,"C:[21212122]BBDB2.db"); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
|
51 | 66 |
//Temp buffers for storing files content, to be compared with what is received after the restore operation. 10 files max. |
67 |
TInt TheFileCount = 0; |
|
68 |
const TInt KMaxDbFileSize = 10 * 1024;//The max test db file size - 10 Kb max. |
|
69 |
static TUint8 TheDbFileData[10][KMaxDbFileSize];//An array where the original db file content will be stored |
|
70 |
static TInt TheDbFileSizes[10];//An array where the real db file size will be stored |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
static TUint8 TheBuf[KMaxDbFileSize]; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
///////////////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
74 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
/////////////////////////////////////////////////////////////////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
76 |
|
51 | 77 |
void DeleteBackupFiles() |
78 |
{ |
|
79 |
TFileName fname; |
|
80 |
||
81 |
fname.Copy(KBackupFileTemplate); |
|
82 |
fname.Append((static_cast <TUid> (KClientUid)).Name()); |
|
83 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(fname); |
|
84 |
||
85 |
fname.Copy(KBackupFileTemplate); |
|
86 |
fname.Append((static_cast <TUid> (KZeroFileSizeUid)).Name()); |
|
87 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(fname); |
|
88 |
||
89 |
fname.Copy(KBackupFileTemplate); |
|
90 |
fname.Append((static_cast <TUid> (KTestClientUid1)).Name()); |
|
91 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(fname); |
|
92 |
||
93 |
fname.Copy(KBackupFileTemplate); |
|
94 |
fname.Append((static_cast <TUid> (KTestClientUid2)).Name()); |
|
95 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(fname); |
|
96 |
||
97 |
fname.Copy(KBackupFileTemplate); |
|
98 |
fname.Append((static_cast <TUid> (KTestClientUid3)).Name()); |
|
99 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(fname); |
|
100 |
} |
|
101 |
||
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
102 |
void TestEnvDestroy() |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
103 |
{ |
51 | 104 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KBackupCopy); |
105 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1); |
|
106 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1Bak); |
|
107 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile3); |
|
108 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile4); |
|
109 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KZeroSizeFile); |
|
110 |
||
111 |
DeleteBackupFiles(); |
|
112 |
||
113 |
delete TheSqlSrvTestBurInterface; |
|
114 |
TheSqlSrvTestBurInterface = NULL; |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
115 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
116 |
delete TheScheduler; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
117 |
TheScheduler = NULL; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
118 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
119 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
120 |
//////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
121 |
// Test macros and functions |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
122 |
//////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
123 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
124 |
void Check(TInt aValue, TInt aLine) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
125 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
126 |
if(!aValue) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
127 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
128 |
TestEnvDestroy(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
129 |
TheTest(EFalse, aLine); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
130 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
131 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
132 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
133 |
void Check(TInt aValue, TInt aExpected, TInt aLine) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
134 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
135 |
if(aValue != aExpected) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
136 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
137 |
TestEnvDestroy(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
138 |
RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
139 |
TheTest(EFalse, aLine); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
140 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
141 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
142 |
#define TEST(arg) ::Check((arg), __LINE__) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
143 |
#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
144 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
145 |
/////////////////////////////////////////////////////////////////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
146 |
|
51 | 147 |
static void DestroyFileList(RArray<HBufC*>& aFileList) |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
148 |
{ |
51 | 149 |
for(TInt i=0;i<aFileList.Count();++i) |
150 |
{ |
|
151 |
delete aFileList[i]; |
|
152 |
} |
|
153 |
aFileList.Close(); |
|
154 |
} |
|
155 |
||
156 |
//CSqlSrvTestBurInterface - test implementation of the MSqlSrvBurInterface, implemented in the production code by the SQL server. |
|
157 |
CSqlSrvTestBurInterface *CSqlSrvTestBurInterface::New() |
|
158 |
{ |
|
159 |
CSqlSrvTestBurInterface* self = new CSqlSrvTestBurInterface; |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
160 |
TEST(self != NULL); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
161 |
self->Construct(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
162 |
return self; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
163 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
164 |
|
51 | 165 |
CSqlSrvTestBurInterface::CSqlSrvTestBurInterface() |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
166 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
167 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
168 |
|
51 | 169 |
void CSqlSrvTestBurInterface::Construct() |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
170 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
171 |
TInt err = iFs.Connect(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
172 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
173 |
err = iFs.MkDir(KBackupDir); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
174 |
TEST(err == KErrNone || err == KErrAlreadyExists); |
51 | 175 |
err = iFs.CreatePrivatePath(KTestDrive); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
176 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
177 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
178 |
|
51 | 179 |
CSqlSrvTestBurInterface::~CSqlSrvTestBurInterface() |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
180 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
181 |
iFs.Close(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
182 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
183 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
184 |
//Called by the backup client ot get a list of database files to backup |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
185 |
//The array is owned by the caller |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
186 |
//The SQL server would have the job to get a list of databases owned by |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
187 |
//the given SID and to determine whether the backup flag is set |
51 | 188 |
//All databases that satisfy this requirement will be added to the array. |
189 |
void CSqlSrvTestBurInterface::GetBackUpListL(TSecureId aUid, TDriveNumber aDrive, RArray<HBufC*>& aFileList) |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
190 |
{ |
29 | 191 |
if(aUid.iId == 0) |
192 |
{//Simulates that there are no databases for backup |
|
51 | 193 |
DestroyFileList(aFileList); |
29 | 194 |
return; |
195 |
} |
|
51 | 196 |
|
197 |
TDriveUnit driveUnit(aDrive); |
|
198 |
TDriveName driveName = driveUnit.Name(); |
|
199 |
TFileName path; |
|
200 |
path.Copy(driveName); |
|
201 |
path.Append(KPrivateDir); |
|
202 |
//Include the aUid and the "*" mask |
|
203 |
TUidName uidName = (static_cast <TUid> (aUid)).Name(); |
|
204 |
_LIT(KMatchAllDbFiles, "*"); |
|
205 |
TBuf<KMaxUidName + sizeof(KMatchAllDbFiles)> fileNameMask(uidName); |
|
206 |
fileNameMask.Append(KMatchAllDbFiles); |
|
207 |
TParse parse; |
|
208 |
TInt err = parse.Set(path, &fileNameMask, NULL); |
|
209 |
User::LeaveIfError(err); |
|
210 |
//Do the search |
|
211 |
TPtrC fullPath(parse.FullName()); |
|
212 |
CDir* fileNameCol = NULL; |
|
213 |
err = TheSqlSrvTestBurInterface->Fs().GetDir(fullPath, KEntryAttNormal, ESortNone, fileNameCol); |
|
214 |
if(err == KErrNotFound) |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
215 |
{ |
51 | 216 |
return; |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
217 |
} |
51 | 218 |
User::LeaveIfError(err); |
219 |
CleanupStack::PushL(fileNameCol); |
|
220 |
TInt fileCount = fileNameCol->Count(); |
|
221 |
err = aFileList.Reserve(fileCount); |
|
222 |
User::LeaveIfError(err); |
|
223 |
//Append the full database file paths to the file names list. |
|
224 |
for(TInt i=0;i<fileCount;++i) |
|
225 |
{ |
|
226 |
const ::TEntry& entry = (*fileNameCol)[i]; |
|
227 |
err = parse.Set(path, &entry.iName, NULL); |
|
228 |
User::LeaveIfError(err); |
|
229 |
TPtrC fname(parse.FullName()); |
|
230 |
HBufC* fnameBuf = fname.AllocL(); |
|
231 |
err = aFileList.Append(fnameBuf); |
|
232 |
User::LeaveIfError(err); |
|
233 |
} |
|
234 |
CleanupStack::PopAndDestroy(fileNameCol); |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
235 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
236 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
237 |
//Returns the file system resource handle to the caller. |
51 | 238 |
RFs& CSqlSrvTestBurInterface::Fs() |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
239 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
240 |
return iFs; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
241 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
242 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
243 |
/////////////////////////////////////////////////////////////////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
244 |
/////////////////////////////////////////////////////////////////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
245 |
/////////////////////////////////////////////////////////////////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
246 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
247 |
TBool FileExists(RFs& aFs, const TDesC& aFileName) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
248 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
249 |
TEntry entry; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
250 |
return aFs.Entry(aFileName, entry) == KErrNone; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
251 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
252 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
253 |
void TestEnvCreate() |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
254 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
255 |
TheScheduler = new CActiveScheduler; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
256 |
TEST(TheScheduler != NULL); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
257 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
258 |
CActiveScheduler::Install(TheScheduler); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
259 |
|
51 | 260 |
TheSqlSrvTestBurInterface = CSqlSrvTestBurInterface::New(); |
261 |
TEST(TheSqlSrvTestBurInterface != NULL); |
|
262 |
} |
|
263 |
||
264 |
void PrepareSearchPath(TDriveNumber aDrive, TDes& aPath) |
|
265 |
{ |
|
266 |
TDriveUnit driveUnit(aDrive); |
|
267 |
TDriveName driveName = driveUnit.Name(); |
|
268 |
aPath.Copy(driveName); |
|
269 |
aPath.Append(KPrivateDir); |
|
270 |
} |
|
271 |
||
272 |
void PrepareSearchPattern(const TDesC& aPath, TSecureId aUid, TParse& aParse) |
|
273 |
{ |
|
274 |
TUidName uidName = (static_cast <TUid> (aUid)).Name(); |
|
275 |
_LIT(KMatchAllDbFiles, "*"); |
|
276 |
TBuf<KMaxUidName + sizeof(KMatchAllDbFiles)> fileNameMask(uidName); |
|
277 |
fileNameMask.Append(KMatchAllDbFiles); |
|
278 |
TInt err = aParse.Set(aPath, &fileNameMask, NULL); |
|
279 |
TEST2(err, KErrNone); |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
280 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
281 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
282 |
//Reads the content of the db files and stores the content to a global memory buffer. |
29 | 283 |
//That buffer content will be used later for verification of the restore process. |
51 | 284 |
void StoreDbContentToBuf(RFs& aFs, TDriveNumber aDrive, TSecureId aUid) |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
285 |
{ |
51 | 286 |
TFileName path; |
287 |
PrepareSearchPath(aDrive, path); |
|
288 |
TParse parse; |
|
289 |
PrepareSearchPattern(path, aUid, parse); |
|
290 |
||
291 |
TheFileCount = -1; |
|
292 |
Mem::FillZ(TheDbFileData, sizeof(TheDbFileData)); |
|
293 |
Mem::FillZ(TheDbFileSizes, sizeof(TheDbFileSizes)); |
|
294 |
||
295 |
CDir* dir = NULL; |
|
296 |
TInt err = aFs.GetDir(parse.FullName(), KEntryAttNormal, ESortByName, dir); |
|
297 |
TEST2(err, KErrNone); |
|
298 |
TheFileCount = dir->Count(); |
|
299 |
for(TInt i=0;i<TheFileCount;++i) |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
300 |
{ |
51 | 301 |
const ::TEntry& entry = (*dir)[i]; |
302 |
err = parse.Set(path, &entry.iName, NULL); |
|
303 |
TEST2(err, KErrNone); |
|
304 |
TPtrC fname(parse.FullName()); |
|
305 |
||
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
306 |
RFile dbFile; |
51 | 307 |
err = dbFile.Open(aFs, fname, EFileRead); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
308 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
309 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
310 |
TInt fileSize = 0; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
311 |
err = dbFile.Size(fileSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
312 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
313 |
TEST(fileSize > 0); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
314 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
315 |
TPtr8 bufptr(TheDbFileData[i], 0, KMaxDbFileSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
316 |
err = dbFile.Read(bufptr, fileSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
317 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
318 |
TEST(fileSize == bufptr.Length()); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
319 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
320 |
TheDbFileSizes[i] = fileSize; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
321 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
322 |
dbFile.Close(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
323 |
} |
51 | 324 |
delete dir; |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
325 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
326 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
327 |
//At the moment when this function is called, the db files content is already restored. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
328 |
//The function will open the restored db files and compare their content against the content |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
329 |
//of the original db files (kept in a global memory buffer). |
51 | 330 |
void CompareDbContentWithBuf(RFs& aFs, TDriveNumber aDrive, TSecureId aUid) |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
331 |
{ |
51 | 332 |
TFileName path; |
333 |
PrepareSearchPath(aDrive, path); |
|
334 |
TParse parse; |
|
335 |
PrepareSearchPattern(path, aUid, parse); |
|
336 |
||
337 |
CDir* dir = NULL; |
|
338 |
TInt err = aFs.GetDir(parse.FullName(), KEntryAttNormal, ESortByName, dir); |
|
339 |
TEST2(err, KErrNone); |
|
340 |
TEST2(TheFileCount, dir->Count()); |
|
341 |
for(TInt i=0;i<TheFileCount;++i) |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
342 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
343 |
TEST(TheDbFileSizes[i] > 0); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
344 |
|
51 | 345 |
const ::TEntry& entry = (*dir)[i]; |
346 |
err = parse.Set(path, &entry.iName, NULL); |
|
347 |
TEST2(err, KErrNone); |
|
348 |
TPtrC fname(parse.FullName()); |
|
349 |
||
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
350 |
RFile dbFile; |
51 | 351 |
TInt err = dbFile.Open(aFs, fname, EFileRead); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
352 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
353 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
354 |
TInt fileSize = 0; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
355 |
err = dbFile.Size(fileSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
356 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
357 |
TEST(fileSize > 0); |
51 | 358 |
TEST2(TheDbFileSizes[i], fileSize); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
359 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
360 |
TPtr8 bufptr(TheBuf, 0, KMaxDbFileSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
361 |
err = dbFile.Read(bufptr, fileSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
362 |
TEST2(err, KErrNone); |
51 | 363 |
TEST2(fileSize, bufptr.Length()); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
364 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
365 |
err = Mem::Compare(TheBuf, fileSize, TheDbFileData[i], TheDbFileSizes[i]); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
366 |
TEST2(err, 0); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
367 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
368 |
dbFile.Close(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
369 |
} |
51 | 370 |
delete dir; |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
371 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
372 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
373 |
//////////////////////////////////////////////////////////////////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
374 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
375 |
//The backup client will return a series of data chunks representing |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
376 |
//one of more databases for the uid of the data owner. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
377 |
//This data is stored in a file on the C drive for the purposes of the test |
51 | 378 |
TInt TestBackupL(CSqlBurCallback &aBackupClient, RFs& aFs, TSecureId aUid, TDriveNumber aDrive, TInt aDataChunkSize = KBufferSize) |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
379 |
{ |
51 | 380 |
TFileName backupFileName; |
381 |
backupFileName.Copy(KBackupFileTemplate); |
|
382 |
backupFileName.Append((static_cast <TUid> (aUid)).Name()); |
|
383 |
||
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
384 |
RFile file; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
385 |
CleanupClosePushL(file); |
51 | 386 |
TInt err = file.Replace(aFs, backupFileName, EFileWrite | EFileStream | EFileShareExclusive); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
387 |
User::LeaveIfError(err); |
51 | 388 |
aBackupClient.InitialiseGetProxyBackupDataL(aUid, aDrive); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
389 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
390 |
TBuf8<KBufferSize> buf; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
391 |
TPtr8 ptr((TUint8*)buf.Ptr(), aDataChunkSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
392 |
TBool finishedFlag = EFalse; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
393 |
TInt count = 0; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
394 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
395 |
do |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
396 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
397 |
aBackupClient.GetBackupDataSectionL(ptr, finishedFlag); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
398 |
count += ptr.Length(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
399 |
err = file.Write(ptr); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
400 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
401 |
ptr.SetLength(0); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
402 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
403 |
while(!finishedFlag); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
404 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
405 |
CleanupStack::PopAndDestroy(&file); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
406 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
407 |
if(count == 0) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
408 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
409 |
User::Leave(KErrEof); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
410 |
} |
51 | 411 |
if(!FileExists(aFs, backupFileName)) |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
412 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
413 |
User::Leave(KErrNotFound); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
414 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
415 |
TheTest.Printf(_L("Backup complete. %d bytes processed.\r\n"), count); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
416 |
return count; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
417 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
418 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
419 |
//This sends the data in chunks form back to the BUR client |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
420 |
//for nupacking and restoration of the original databases files |
51 | 421 |
TInt TestRestoreL(CSqlBurCallback &aRestoreClient, RFs& aFs, TSecureId aUid, TDriveNumber aDrive, TInt aDataChunkSize = KBufferSize) |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
422 |
{ |
51 | 423 |
TFileName backupFileName; |
424 |
backupFileName.Copy(KBackupFileTemplate); |
|
425 |
backupFileName.Append((static_cast <TUid> (aUid)).Name()); |
|
426 |
||
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
427 |
RFile file; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
428 |
CleanupClosePushL(file); |
51 | 429 |
TInt err = file.Open(aFs, backupFileName, EFileRead | EFileShareExclusive); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
430 |
User::LeaveIfError(err); |
51 | 431 |
aRestoreClient.InitialiseRestoreProxyBaseDataL(aUid, aDrive); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
432 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
433 |
TBuf8<KBufferSize> buf; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
434 |
TPtr8 ptr((TUint8*)buf.Ptr(), aDataChunkSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
435 |
TBool finishedFlag = EFalse; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
436 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
437 |
TInt fileSize = 0; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
438 |
err = file.Size(fileSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
439 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
440 |
TInt count = fileSize; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
441 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
442 |
do |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
443 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
444 |
err = file.Read(ptr, aDataChunkSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
445 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
446 |
fileSize -= ptr.Length(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
447 |
finishedFlag = fileSize == 0; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
448 |
aRestoreClient.RestoreBaseDataSectionL(ptr, finishedFlag); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
449 |
ptr.SetLength(0); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
450 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
451 |
while(fileSize > 0); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
452 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
453 |
CleanupStack::PopAndDestroy(&file); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
454 |
|
51 | 455 |
aRestoreClient.RestoreComplete(aDrive); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
456 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
457 |
if(!finishedFlag) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
458 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
459 |
User::Leave(KErrEof); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
460 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
461 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
462 |
TheTest.Printf(_L("Restore complete. %d bytes processed.\r\n"), count); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
463 |
return count; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
464 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
465 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
466 |
//Verifies the integrity of the backup file. |
51 | 467 |
void TestArchiveIntegrityL(CSqlBurCallback &aBackupClient, RFs& aFs, TSecureId aUid) |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
468 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
469 |
RFile bkpFile; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
470 |
CleanupClosePushL(bkpFile); |
51 | 471 |
|
472 |
TFileName backupFileName; |
|
473 |
backupFileName.Copy(KBackupFileTemplate); |
|
474 |
backupFileName.Append((static_cast <TUid> (aUid)).Name()); |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
475 |
|
51 | 476 |
TInt err = bkpFile.Open(aFs, backupFileName, EFileRead | EFileShareExclusive); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
477 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
478 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
479 |
TBuf8<KBufferSize> buf; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
480 |
TPtr8 ptr((TUint8*)buf.Ptr(), buf.MaxLength()); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
481 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
482 |
TInt bkpFileSize = 0; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
483 |
err = bkpFile.Size(bkpFileSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
484 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
485 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
486 |
while(bkpFileSize > 0) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
487 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
488 |
// get the checksum |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
489 |
err = bkpFile.Read(ptr, 16); // 8 UTF-16 characters |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
490 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
491 |
if(ptr.Length() != 16) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
492 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
493 |
User::Leave(KErrCorrupt); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
494 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
495 |
TPtr ptr16((TUint16*) ptr.Ptr(), 8, 8); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
496 |
TLex lex(ptr16); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
497 |
TUint32 checksum; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
498 |
lex.SkipSpace(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
499 |
err = lex.Val(checksum, EHex); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
500 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
501 |
bkpFileSize -= 16; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
502 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
503 |
// get the old file size |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
504 |
err = bkpFile.Read(ptr, 16); // 8 UTF-16 characters |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
505 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
506 |
if(ptr.Length() != 16) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
507 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
508 |
User::Leave(KErrCorrupt); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
509 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
510 |
ptr16.Set((TUint16*) ptr.Ptr(), 8, 8); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
511 |
lex.Assign(ptr16); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
512 |
TUint32 oldFileSize; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
513 |
lex.SkipSpace(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
514 |
err = lex.Val(oldFileSize, EHex); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
515 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
516 |
bkpFileSize -= 16; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
517 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
518 |
// get the backup file header version |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
519 |
err = bkpFile.Read(ptr, 8); // 4 UTF-16 characters |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
520 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
521 |
ptr16.Set((TUint16*)ptr.Ptr(), 4, 4); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
522 |
lex.Assign(ptr16); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
523 |
TUint32 hdrVer; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
524 |
lex.SkipSpace(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
525 |
err = lex.Val(hdrVer, EHex); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
526 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
527 |
bkpFileSize -= 8; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
528 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
529 |
// get the file size |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
530 |
err = bkpFile.Read(ptr, 32); // 16 UTF-16 characters |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
531 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
532 |
if(ptr.Length() != 32) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
533 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
534 |
User::Leave(KErrCorrupt); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
535 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
536 |
ptr16.Set((TUint16*) ptr.Ptr(), 16, 16); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
537 |
lex.Assign(ptr16); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
538 |
TInt64 fileSize; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
539 |
lex.SkipSpace(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
540 |
err = lex.Val(fileSize, EHex); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
541 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
542 |
bkpFileSize -= 32; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
543 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
544 |
// get the filename size |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
545 |
err = bkpFile.Read(ptr, 16); // 8 UTF-16 characters |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
546 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
547 |
ptr16.Set((TUint16*)ptr.Ptr(), 8, 8); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
548 |
lex.Assign(ptr16); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
549 |
TUint32 fileNameSize; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
550 |
lex.SkipSpace(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
551 |
err = lex.Val(fileNameSize, EHex); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
552 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
553 |
bkpFileSize -= 16; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
554 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
555 |
// get the filename |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
556 |
err = bkpFile.Read(ptr, fileNameSize * 2); // fileName UTF-16 characters |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
557 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
558 |
if(ptr.Length() != (fileNameSize * 2)) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
559 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
560 |
User::Leave(KErrCorrupt); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
561 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
562 |
ptr16.Set((TUint16*) ptr.Ptr(), fileNameSize, fileNameSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
563 |
lex.Assign(ptr16); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
564 |
TParse tp; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
565 |
tp.Set(ptr16, NULL, NULL); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
566 |
TPtrC dbFileName = tp.Name(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
567 |
bkpFileSize -= fileNameSize * 2; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
568 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
569 |
// open a local file - replaces any previous one |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
570 |
RFile64 dbFile; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
571 |
CleanupClosePushL(dbFile); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
572 |
err = dbFile.Replace(aFs, dbFileName, EFileWrite | EFileShareExclusive); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
573 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
574 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
575 |
// copy all the data (file size bytes) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
576 |
TInt bytesLeftToRead = fileSize; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
577 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
578 |
while(bytesLeftToRead > 0) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
579 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
580 |
TInt readSize = bytesLeftToRead > KBufferSize ? KBufferSize : bytesLeftToRead; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
581 |
err = bkpFile.Read(ptr, readSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
582 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
583 |
if(ptr.Length() != readSize) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
584 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
585 |
User::Leave(KErrCorrupt); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
586 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
587 |
bytesLeftToRead -= readSize; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
588 |
err = dbFile.Write(ptr, readSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
589 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
590 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
591 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
592 |
bkpFileSize -= fileSize; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
593 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
594 |
// checksum the file |
51 | 595 |
TUint64 checkSum64 = 0; |
596 |
User::LeaveIfError(aBackupClient.CheckSum(dbFile, checkSum64)); |
|
597 |
TUint32 checksum32 = checkSum64 & 0xFFFFFFFF; |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
598 |
|
51 | 599 |
if(checksum != checksum32) |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
600 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
601 |
User::Leave(KErrCorrupt); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
602 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
603 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
604 |
// all done with this file |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
605 |
CleanupStack::PopAndDestroy(&dbFile); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
606 |
err = aFs.Delete(dbFileName); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
607 |
User::LeaveIfError(err); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
608 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
609 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
610 |
CleanupStack::PopAndDestroy(&bkpFile); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
611 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
612 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
613 |
/** |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
614 |
@SYMTestCaseID SYSLIB-SQL-UT-4002 |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
615 |
@SYMTestCaseDesc Test for DEF113598 - "SQL, t_sqlbur unit test needs refactoring" |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
616 |
The test backups 2 test db files, then verifies the backup file integrity, |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
617 |
then restores the test db files content from the backup file. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
618 |
At the end, the test checks that the restored test db files content is the |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
619 |
same as the content of the original test db file. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
620 |
@SYMTestPriority High |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
621 |
@SYMTestActions Test for DEF113598 - "SQL, t_sqlbur unit test needs refactoring" |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
622 |
@SYMTestExpectedResults Test must not fail |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
623 |
@SYMDEF DEF113598 |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
624 |
*/ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
625 |
void FunctionalTest() |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
626 |
{ |
51 | 627 |
CSqlBurCallback* backupClient = NULL; |
628 |
TRAPD(err, backupClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface)); |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
629 |
TEST(backupClient != NULL); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
630 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
631 |
//////////////////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
632 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
633 |
//Virtual functions - with default implementation |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
634 |
|
51 | 635 |
(void)backupClient->GetExpectedDataSize(KTestDrive); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
636 |
|
51 | 637 |
(void)backupClient->GetDataChecksum(KTestDrive); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
638 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
639 |
TBool finished = EFalse; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
640 |
TPtr8 ptr(0, 0, 0); |
51 | 641 |
TRAP(err, backupClient->GetSnapshotDataL(KTestDrive, ptr, finished)); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
642 |
TEST2(err, KErrNotSupported); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
643 |
|
51 | 644 |
TRAP(err, backupClient->InitialiseGetBackupDataL(KTestDrive)); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
645 |
TEST2(err, KErrNotSupported); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
646 |
|
51 | 647 |
TRAP(err, backupClient->InitialiseRestoreBaseDataL(KTestDrive)); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
648 |
TEST2(err, KErrNotSupported); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
649 |
|
51 | 650 |
TRAP(err, backupClient->InitialiseRestoreIncrementDataL(KTestDrive)); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
651 |
TEST2(err, KErrNotSupported); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
652 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
653 |
TPtrC8 ptr2(KNullDesC8); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
654 |
TRAP(err, backupClient->RestoreIncrementDataSectionL(ptr2, finished)); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
655 |
TEST2(err, KErrNotSupported); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
656 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
657 |
TRAP(err, backupClient->AllSnapshotsSuppliedL()); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
658 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
659 |
|
51 | 660 |
TRAP(err, backupClient->ReceiveSnapshotDataL(KTestDrive, ptr2, finished)); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
661 |
TEST2(err, KErrNotSupported); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
662 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
663 |
backupClient->TerminateMultiStageOperation(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
664 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
665 |
//////////////////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
666 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
667 |
TInt bytesStored = 0; |
51 | 668 |
TRAP(err, bytesStored = TestBackupL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KClientUid, KTestDrive)); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
669 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
670 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
671 |
TheTest.Next(_L("Archive integrity test")); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
672 |
|
51 | 673 |
TRAP(err, TestArchiveIntegrityL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KClientUid)); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
674 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
675 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
676 |
delete backupClient; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
677 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
678 |
TheTest.Next(_L("Restore: functional test")); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
679 |
|
51 | 680 |
CSqlBurCallback* restoreClient = NULL; |
681 |
TRAP(err, restoreClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface)); |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
682 |
TEST(restoreClient != NULL); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
683 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
684 |
TInt bytesRestored = 0; |
51 | 685 |
TRAP(err, bytesRestored = TestRestoreL(*restoreClient, TheSqlSrvTestBurInterface->Fs(), KClientUid, KTestDrive)); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
686 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
687 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
688 |
TEST(bytesRestored == bytesStored); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
689 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
690 |
delete restoreClient; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
691 |
|
51 | 692 |
CompareDbContentWithBuf(TheSqlSrvTestBurInterface->Fs(), KTestDrive, KClientUid); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
693 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
694 |
|
51 | 695 |
TInt DoBackupL(TDriveNumber aDrive, TSecureId aUid) |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
696 |
{ |
51 | 697 |
CSqlBurCallback* backupClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface); |
698 |
CleanupStack::PushL(backupClient); |
|
699 |
TInt bytesStored = TestBackupL(*backupClient, TheSqlSrvTestBurInterface->Fs(), aUid, aDrive); |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
700 |
CleanupStack::PopAndDestroy(backupClient); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
701 |
return bytesStored; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
702 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
703 |
|
51 | 704 |
TInt DoRestoreL(TDriveNumber aDrive, TSecureId aUid) |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
705 |
{ |
51 | 706 |
CSqlBurCallback* restoreClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface); |
707 |
CleanupStack::PushL(restoreClient); |
|
708 |
TInt bytesRestored = TestRestoreL(*restoreClient, TheSqlSrvTestBurInterface->Fs(), aUid, aDrive); |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
709 |
CleanupStack::PopAndDestroy(restoreClient); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
710 |
return bytesRestored; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
711 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
712 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
713 |
/** |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
714 |
@SYMTestCaseID SYSLIB-SQL-UT-4003 |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
715 |
@SYMTestCaseDesc Test for DEF113598 - "SQL, t_sqlbur unit test needs refactoring" |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
716 |
Under simulated OOM condition, the test backups 2 test db files, |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
717 |
then restores the test db files content from the backup file. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
718 |
At the end, the test checks that the restored test db files content is the |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
719 |
same as the content of the original test db file. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
720 |
@SYMTestPriority High |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
721 |
@SYMTestActions Test for DEF113598 - "SQL, t_sqlbur unit test needs refactoring" |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
722 |
@SYMTestExpectedResults Test must not fail |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
723 |
@SYMDEF DEF113598 |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
724 |
*/ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
725 |
void OomTest() |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
726 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
727 |
/////////////////////////////////////////////////////////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
728 |
TInt err = KErrNoMemory; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
729 |
TInt bytesStored = 0; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
730 |
TInt count = 0; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
731 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
732 |
for(count=1;err==KErrNoMemory;++count) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
733 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
734 |
TInt startProcessHandleCount; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
735 |
TInt startThreadHandleCount; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
736 |
RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
737 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
738 |
User::__DbgMarkStart(RHeap::EUser); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
739 |
User::__DbgSetAllocFail(RHeap::EUser,RHeap::EFailNext, count); |
51 | 740 |
TRAP(err, bytesStored = DoBackupL(KTestDrive, KClientUid)); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
741 |
User::__DbgMarkEnd(RHeap::EUser, 0); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
742 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
743 |
TInt endProcessHandleCount; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
744 |
TInt endThreadHandleCount; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
745 |
RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
746 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
747 |
TEST(startProcessHandleCount == endProcessHandleCount); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
748 |
TEST(startThreadHandleCount == endThreadHandleCount); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
749 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
750 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
751 |
TheTest.Printf(_L("OOM backup test succeeded at heap failure rate of %d\r\n"), count); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
752 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
753 |
/////////////////////////////////////////////////////////////////////////////// |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
754 |
TheTest.Next(_L("Restore: OOM test")); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
755 |
err = KErrNoMemory; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
756 |
TInt bytesRestored = 0; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
757 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
758 |
for(count=1;err==KErrNoMemory;++count) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
759 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
760 |
TInt startProcessHandleCount; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
761 |
TInt startThreadHandleCount; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
762 |
RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
763 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
764 |
User::__DbgMarkStart(RHeap::EUser); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
765 |
User::__DbgSetAllocFail(RHeap::EUser,RHeap::EFailNext, count); |
51 | 766 |
TRAP(err, bytesRestored = DoRestoreL(KTestDrive, KClientUid)); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
767 |
User::__DbgMarkEnd(RHeap::EUser, 0); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
768 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
769 |
TInt endProcessHandleCount; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
770 |
TInt endThreadHandleCount; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
771 |
RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
772 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
773 |
TEST(startProcessHandleCount == endProcessHandleCount); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
774 |
TEST(startThreadHandleCount == endThreadHandleCount); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
775 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
776 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
777 |
User::__DbgSetAllocFail(RHeap::EUser, RAllocator::ENone, 0); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
778 |
TheTest.Printf(_L("OOM restore test succeeded at heap failure rate of %d\r\n"), count); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
779 |
|
51 | 780 |
TEST2(bytesStored, bytesRestored); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
781 |
|
51 | 782 |
CompareDbContentWithBuf(TheSqlSrvTestBurInterface->Fs(), KTestDrive, KClientUid); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
783 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
784 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
785 |
/** |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
786 |
@SYMTestCaseID PDS-SQL-UT-4143 |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
787 |
@SYMTestCaseDesc SQL Backup&Restore - data chunk size test. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
788 |
The test uses an integer array of 10 elements with randomly generated data chunk sizes. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
789 |
Then the test runs 10 backup iterations using each time different data chunk size. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
790 |
After each backup iteration the test performs a restore operation and checks that the |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
791 |
data has been backup&restored without errors. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
792 |
@SYMTestActions SQL Backup&Restore - data chunk size test. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
793 |
@SYMTestExpectedResults Test must not fail |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
794 |
@SYMTestPriority Medium |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
795 |
@SYMREQ REQ12104 |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
796 |
*/ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
797 |
void FunctionalTest2() |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
798 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
799 |
TTime now; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
800 |
now.UniversalTime(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
801 |
TInt64 seed = now.Int64(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
802 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
803 |
const TInt KArraySize = 10; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
804 |
TInt dataChunks[10] = {2, 6, 0, 0, 0, 0, 0, 0, 0, 0}; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
805 |
const TInt KMaxDataChunkSize = 50; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
806 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
807 |
for(TInt i=2;i<KArraySize;) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
808 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
809 |
TInt dataChunkSize = Math::Rand(seed) % KMaxDataChunkSize; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
810 |
if((dataChunkSize % 2) == 0 && dataChunkSize != 0) //The code works only with data chunks with even sizes!!! |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
811 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
812 |
dataChunks[i++] = dataChunkSize; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
813 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
814 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
815 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
816 |
for(TInt i=0;i<KArraySize;++i) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
817 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
818 |
TheTest.Printf(_L(" === Iteration %d, chunk size %d\r\n"), i + 1, dataChunks[i]); |
51 | 819 |
CSqlBurCallback* backupClient = NULL; |
820 |
TRAPD(err, backupClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface)); |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
821 |
TEST(backupClient != NULL); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
822 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
823 |
TInt bytesStored = 0; |
51 | 824 |
TRAP(err, bytesStored = TestBackupL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KClientUid, KTestDrive, dataChunks[i])); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
825 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
826 |
|
51 | 827 |
TRAP(err, TestArchiveIntegrityL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KClientUid)); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
828 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
829 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
830 |
delete backupClient; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
831 |
|
51 | 832 |
CSqlBurCallback* restoreClient = NULL; |
833 |
TRAP(err, restoreClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface)); |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
834 |
TEST(restoreClient != NULL); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
835 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
836 |
TInt bytesRestored = 0; |
51 | 837 |
TRAP(err, bytesRestored = TestRestoreL(*restoreClient, TheSqlSrvTestBurInterface->Fs(), KClientUid, KTestDrive, dataChunks[i])); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
838 |
TEST2(err, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
839 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
840 |
TEST(bytesRestored == bytesStored); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
841 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
842 |
delete restoreClient; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
843 |
|
51 | 844 |
CompareDbContentWithBuf(TheSqlSrvTestBurInterface->Fs(), KTestDrive, KClientUid); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
845 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
846 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
847 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
848 |
/** |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
849 |
@SYMTestCaseID PDS-SQL-UT-4144 |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
850 |
@SYMTestCaseDesc SQL Backup&Restore - legacy backup file format header test. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
851 |
The 64-bit file system related changes made in the SQL server required some |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
852 |
changes to be made in the format of the backup file header. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
853 |
The test checks that a backup file created with the previous format of the file header |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
854 |
can be restored without errors by the updated Backup&Restore implementation. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
855 |
@SYMTestActions SQL Backup&Restore - legacy backup file format header test. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
856 |
@SYMTestExpectedResults Test must not fail |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
857 |
@SYMTestPriority Medium |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
858 |
@SYMREQ REQ12104 |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
859 |
*/ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
860 |
void LegacyFileFormatTest() |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
861 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
862 |
//KBackupFile2 is a database backup file with header version 0. |
51 | 863 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KBackupFile2); |
864 |
TInt rc = BaflUtils::CopyFile(TheSqlSrvTestBurInterface->Fs(), KBackupFile2Z, KBackupFile2); |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
865 |
TEST2(rc, KErrNone); |
51 | 866 |
(void)TheSqlSrvTestBurInterface->Fs().SetAtt(KBackupFile2, 0, KEntryAttReadOnly); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
867 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
868 |
//Restore the databases from KBackupFile2. |
51 | 869 |
CSqlBurCallback* restoreClient = NULL; |
870 |
TRAP(rc, restoreClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface)); |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
871 |
TEST(restoreClient != NULL); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
872 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
873 |
RFile file; |
51 | 874 |
rc = file.Open(TheSqlSrvTestBurInterface->Fs(), KBackupFile2, EFileRead | EFileShareExclusive); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
875 |
TEST2(rc, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
876 |
|
51 | 877 |
TRAP(rc, restoreClient->InitialiseRestoreProxyBaseDataL(KClientUid, KTestDrive)); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
878 |
TEST2(rc, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
879 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
880 |
TBuf8<KBufferSize> buf; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
881 |
TPtr8 ptr((TUint8*)buf.Ptr(), buf.MaxSize()); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
882 |
TBool finishedFlag = EFalse; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
883 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
884 |
TInt fileSize = 0; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
885 |
rc = file.Size(fileSize); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
886 |
TEST2(rc, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
887 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
888 |
do |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
889 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
890 |
rc = file.Read(ptr); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
891 |
TEST2(rc, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
892 |
fileSize -= ptr.Size(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
893 |
finishedFlag = fileSize == 0; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
894 |
TRAP(rc, restoreClient->RestoreBaseDataSectionL(ptr, finishedFlag)); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
895 |
ptr.SetLength(0); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
896 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
897 |
while(fileSize > 0); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
898 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
899 |
file.Close(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
900 |
|
51 | 901 |
restoreClient->RestoreComplete(KTestDrive); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
902 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
903 |
TEST(finishedFlag); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
904 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
905 |
delete restoreClient; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
906 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
907 |
//At this point we have two restored databases: KTestDbFileName1 and KTestDbFileName2. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
908 |
//The content of the restored file cannot be compared directly, because t_sqlattach uses the same test databases |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
909 |
//and modifies them. The original database content was stored without executing t_sqlattach. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
910 |
//Hence a simple test is made: open the restored database, check if the database content can be accessed. |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
911 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
912 |
RSqlDatabase db; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
913 |
rc = db.Open(KTestDbFileName1); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
914 |
TEST2(rc, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
915 |
//The database contains this table: "TABLE C(A1 INTEGER, B2 BLOB)". |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
916 |
rc = db.Exec(_L("INSERT INTO C VALUES(100, 200)")); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
917 |
TEST2(rc, 1); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
918 |
RSqlStatement stmt; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
919 |
rc = stmt.Prepare(db, _L("SELECT * FROM C")); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
920 |
TEST2(rc, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
921 |
while((rc = stmt.Next()) == KSqlAtRow) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
922 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
923 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
924 |
stmt.Close(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
925 |
TEST2(rc, KSqlAtEnd); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
926 |
db.Close(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
927 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
928 |
rc = db.Open(KTestDbFileName2); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
929 |
TEST2(rc, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
930 |
//The database contains this table: "TABLE A1(F1 INTEGER , F2 INTEGER, B1 BLOB)" |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
931 |
rc = db.Exec(_L("INSERT INTO A1 VALUES(100, 200, NULL)")); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
932 |
TEST2(rc, 1); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
933 |
rc = stmt.Prepare(db, _L("SELECT * FROM A1")); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
934 |
TEST2(rc, KErrNone); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
935 |
while((rc = stmt.Next()) == KSqlAtRow) |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
936 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
937 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
938 |
stmt.Close(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
939 |
TEST2(rc, KSqlAtEnd); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
940 |
db.Close(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
941 |
|
51 | 942 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KBackupFile2); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
943 |
} |
29 | 944 |
|
945 |
/** |
|
946 |
@SYMTestCaseID PDS-SQL-UT-4192 |
|
947 |
@SYMTestCaseDesc SQL Backup&Restore - empty backup file list test. |
|
948 |
The test checks what will happen if the list with the files for backup is empty. |
|
949 |
The GetBackupDataSectionL() should immediatelly set the flag parameter to true and do nothing. |
|
950 |
@SYMTestActions SQL Backup&Restore - empty backup file list test. |
|
951 |
@SYMTestExpectedResults Test must not fail |
|
952 |
@SYMTestPriority High |
|
953 |
@SYMDEF DEF145198 |
|
954 |
*/ |
|
955 |
void EmptyBackupFileListTest() |
|
956 |
{ |
|
51 | 957 |
CSqlBurCallback* backupClient = NULL; |
958 |
TRAPD(err, backupClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface)); |
|
29 | 959 |
TEST(backupClient != NULL); |
960 |
||
51 | 961 |
TRAP(err, backupClient->InitialiseGetProxyBackupDataL(KNullUid, KTestDrive)); |
29 | 962 |
TEST2(err, KErrNone); |
963 |
||
964 |
TBuf8<100> buf; |
|
965 |
TPtr8 ptr((TUint8*)buf.Ptr(), 0, buf.MaxLength()); |
|
966 |
TBool finishedFlag = EFalse; |
|
967 |
TRAP(err, backupClient->GetBackupDataSectionL(ptr, finishedFlag)); |
|
968 |
delete backupClient; |
|
969 |
TEST2(err, KErrNone); |
|
970 |
TEST(finishedFlag); |
|
971 |
TEST2(buf.Length(), 0); |
|
972 |
} |
|
973 |
||
974 |
||
975 |
/** |
|
976 |
@SYMTestCaseID PDS-SQL-UT-4193 |
|
977 |
@SYMTestCaseDesc SQL Backup&Restore - file I/O error simulation test. |
|
978 |
The test executes a backup, followed by a restore operation |
|
979 |
in a file I/O error simulation loop. |
|
980 |
@SYMTestActions SQL Backup&Restore - file I/O error simulation test. |
|
981 |
@SYMTestExpectedResults Test must not fail |
|
982 |
@SYMTestPriority High |
|
983 |
@SYMDEF DEF145198 |
|
984 |
*/ |
|
985 |
void BackupRestoreFileIoErrTest() |
|
986 |
{ |
|
987 |
//Make sure that the database content, just before the backup, will be copied to the test biffers. |
|
988 |
//The buffers will be used during the restore testing for verification of the database content. |
|
51 | 989 |
StoreDbContentToBuf(TheSqlSrvTestBurInterface->Fs(), KTestDrive, KClientUid); |
29 | 990 |
|
991 |
for(TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError) |
|
992 |
{ |
|
993 |
TheTest.Printf(_L("===Backup&Restore, simulated file system error=%d\r\n"), fsError); |
|
994 |
||
995 |
TInt err = KErrGeneral; |
|
996 |
TInt bytesStored = -1; |
|
997 |
TInt it_cnt1 = 0; |
|
998 |
for(;err<KErrNone;++it_cnt1) |
|
999 |
{ |
|
1000 |
__UHEAP_MARK; |
|
51 | 1001 |
(void)TheSqlSrvTestBurInterface->Fs().SetErrorCondition(fsError, it_cnt1); |
1002 |
TRAP(err, bytesStored = DoBackupL(KTestDrive, KClientUid)); |
|
1003 |
(void)TheSqlSrvTestBurInterface->Fs().SetErrorCondition(KErrNone); |
|
29 | 1004 |
__UHEAP_MARKEND; |
1005 |
} |
|
1006 |
TEST2(err, KErrNone); |
|
1007 |
||
1008 |
err = KErrGeneral; |
|
1009 |
TInt bytesRestored = -1; |
|
1010 |
TInt it_cnt2 = 0; |
|
1011 |
for(;err<KErrNone;++it_cnt2) |
|
1012 |
{ |
|
1013 |
__UHEAP_MARK; |
|
51 | 1014 |
(void)TheSqlSrvTestBurInterface->Fs().SetErrorCondition(fsError, it_cnt2); |
1015 |
TRAP(err, bytesRestored = DoRestoreL(KTestDrive, KClientUid)); |
|
1016 |
(void)TheSqlSrvTestBurInterface->Fs().SetErrorCondition(KErrNone); |
|
29 | 1017 |
__UHEAP_MARKEND; |
1018 |
} |
|
1019 |
TEST2(err, KErrNone); |
|
1020 |
||
1021 |
TEST2(bytesStored, bytesRestored); |
|
51 | 1022 |
CompareDbContentWithBuf(TheSqlSrvTestBurInterface->Fs(), KTestDrive, KClientUid); |
29 | 1023 |
|
1024 |
TheTest.Printf(_L("Backup&Restore file I/O error simulation test succeeded at backup iteration %d and restore itreration %d\r\n"), it_cnt1 - 1, it_cnt2 - 1); |
|
1025 |
} |
|
1026 |
} |
|
1027 |
||
51 | 1028 |
/** |
1029 |
@SYMTestCaseID PDS-SQL-UT-4225 |
|
1030 |
@SYMTestCaseDesc SQL Backup - zero size file backup. |
|
1031 |
The test executes a backup on a file with zero size. |
|
1032 |
@SYMTestActions SQL Backup - zero size file backup. |
|
1033 |
@SYMTestExpectedResults Test must not fail |
|
1034 |
@SYMTestPriority High |
|
1035 |
*/ |
|
1036 |
void BackupZeroSizeFileTest() |
|
1037 |
{ |
|
1038 |
CSqlBurCallback* backupClient = NULL; |
|
1039 |
TRAPD(err, backupClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface)); |
|
1040 |
TEST2(err, KErrNone); |
|
1041 |
TEST(backupClient != NULL); |
|
1042 |
// |
|
1043 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KZeroSizeFile); |
|
1044 |
RFile file; |
|
1045 |
err = file.Replace(TheSqlSrvTestBurInterface->Fs(), KZeroSizeFile, EFileRead | EFileWrite); |
|
1046 |
TEST2(err, KErrNone); |
|
1047 |
file.Close(); |
|
1048 |
// |
|
1049 |
TRAP(err, TestBackupL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KZeroFileSizeUid, KTestDrive)); |
|
1050 |
TEST2(err, KErrNone); |
|
1051 |
//Write something to the file |
|
1052 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KZeroSizeFile, EFileRead | EFileWrite); |
|
1053 |
TEST2(err, KErrNone); |
|
1054 |
_LIT8(KData, "123456787989"); |
|
1055 |
err = file.Write(KData); |
|
1056 |
TEST2(err, KErrNone); |
|
1057 |
err = file.Flush(); |
|
1058 |
TEST2(err, KErrNone); |
|
1059 |
file.Close(); |
|
1060 |
//Do the restore. After the restore the file size should be 0. |
|
1061 |
TRAP(err, TestRestoreL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KZeroFileSizeUid, KTestDrive)); |
|
1062 |
TEST2(err, KErrNone); |
|
1063 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KZeroSizeFile, EFileRead | EFileWrite); |
|
1064 |
TEST2(err, KErrNone); |
|
1065 |
TInt size; |
|
1066 |
err = file.Size(size); |
|
1067 |
TEST2(err, KErrNone); |
|
1068 |
file.Close(); |
|
1069 |
TEST2(size, 0); |
|
1070 |
//Write something to the file |
|
1071 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KZeroSizeFile, EFileRead | EFileWrite); |
|
1072 |
TEST2(err, KErrNone); |
|
1073 |
err = file.Write(KData); |
|
1074 |
TEST2(err, KErrNone); |
|
1075 |
err = file.Flush(); |
|
1076 |
TEST2(err, KErrNone); |
|
1077 |
file.Close(); |
|
1078 |
//Call RestoreBaseDataSectionL() with 0 data in the input buffer and finished flag: false. |
|
1079 |
TRAP(err, backupClient->InitialiseRestoreProxyBaseDataL(KZeroFileSizeUid, KTestDrive)); |
|
1080 |
TEST2(err, KErrNone); |
|
1081 |
TPtrC8 zeroBuf; |
|
1082 |
TRAP(err, backupClient->RestoreBaseDataSectionL(zeroBuf, EFalse)); |
|
1083 |
TEST2(err, KErrNone); |
|
1084 |
//No restore in this case, |
|
1085 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KZeroSizeFile, EFileRead | EFileWrite); |
|
1086 |
TEST2(err, KErrNone); |
|
1087 |
err = file.Size(size); |
|
1088 |
TEST2(err, KErrNone); |
|
1089 |
file.Close(); |
|
1090 |
TEST(size > 0); |
|
1091 |
//Call RestoreBaseDataSectionL() with 0 data in the input buffer and finished flag: true. |
|
1092 |
TRAP(err, backupClient->InitialiseRestoreProxyBaseDataL(KZeroFileSizeUid, KTestDrive)); |
|
1093 |
TEST2(err, KErrNone); |
|
1094 |
TRAP(err, backupClient->RestoreBaseDataSectionL(zeroBuf, ETrue)); |
|
1095 |
TEST2(err, KErrNone); |
|
1096 |
//No restore in this case, |
|
1097 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KZeroSizeFile, EFileRead | EFileWrite); |
|
1098 |
TEST2(err, KErrNone); |
|
1099 |
err = file.Size(size); |
|
1100 |
TEST2(err, KErrNone); |
|
1101 |
file.Close(); |
|
1102 |
TEST(size > 0); |
|
1103 |
// |
|
1104 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KZeroSizeFile); |
|
1105 |
delete backupClient; |
|
1106 |
} |
|
1107 |
||
1108 |
/** |
|
1109 |
@SYMTestCaseID PDS-SQL-UT-4226 |
|
1110 |
@SYMTestCaseDesc SQL Restore - corrupted archive 1. |
|
1111 |
The test does a backup of a file with a non-zero size. |
|
1112 |
The the test modifies the archive, simulating a corruption. |
|
1113 |
The the test performs a restore from the archive. The corruption |
|
1114 |
should be detected and reported by SQL B&R code. |
|
1115 |
@SYMTestActions SQL Restore - corrupted archive 1. |
|
1116 |
@SYMTestExpectedResults Test must not fail |
|
1117 |
@SYMTestPriority High |
|
1118 |
*/ |
|
1119 |
void CorruptedArchiveTest1() |
|
1120 |
{ |
|
1121 |
CSqlBurCallback* backupClient = NULL; |
|
1122 |
TRAPD(err, backupClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface)); |
|
1123 |
TEST2(err, KErrNone); |
|
1124 |
TEST(backupClient != NULL); |
|
1125 |
//Create the test file that will be sent for backup |
|
1126 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1); |
|
1127 |
RFile file; |
|
1128 |
err = file.Replace(TheSqlSrvTestBurInterface->Fs(), KTestFile1, EFileRead | EFileWrite); |
|
1129 |
TEST2(err, KErrNone); |
|
1130 |
_LIT8(KData1, "123456787989"); |
|
1131 |
err = file.Write(KData1); |
|
1132 |
TEST2(err, KErrNone); |
|
1133 |
err = file.Flush(); |
|
1134 |
TEST2(err, KErrNone); |
|
1135 |
file.Close(); |
|
1136 |
//Backup the file |
|
1137 |
TRAP(err, TestBackupL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid1, KTestDrive)); |
|
1138 |
TEST2(err, KErrNone); |
|
1139 |
//Modify the file, which was sent for backup |
|
1140 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KTestFile1, EFileRead | EFileWrite); |
|
1141 |
TEST2(err, KErrNone); |
|
1142 |
_LIT8(KData2, "ABCDEFGH"); |
|
1143 |
err = file.Write(KData2); |
|
1144 |
TEST2(err, KErrNone); |
|
1145 |
err = file.SetSize(KData2().Length()); |
|
1146 |
TEST2(err, KErrNone); |
|
1147 |
err = file.Flush(); |
|
1148 |
TEST2(err, KErrNone); |
|
1149 |
file.Close(); |
|
1150 |
//Corrupt the archive |
|
1151 |
TFileName backupFileName; |
|
1152 |
backupFileName.Copy(KBackupFileTemplate); |
|
1153 |
backupFileName.Append((static_cast <TUid> (KTestClientUid1)).Name()); |
|
1154 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), backupFileName, EFileRead | EFileWrite); |
|
1155 |
TEST2(err, KErrNone); |
|
1156 |
TInt pos = -3; |
|
1157 |
err = file.Seek(ESeekEnd, pos); |
|
1158 |
TEST2(err, KErrNone); |
|
1159 |
_LIT8(KData3, "ERR"); |
|
1160 |
err = file.Write(KData3); |
|
1161 |
TEST2(err, KErrNone); |
|
1162 |
err = file.Flush(); |
|
1163 |
TEST2(err, KErrNone); |
|
1164 |
file.Close(); |
|
1165 |
//Try to restore the archive |
|
1166 |
TRAP(err, TestRestoreL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid1, KTestDrive)); |
|
1167 |
TEST2(err, KErrCorrupt); |
|
1168 |
//Check that the file really has not been restored |
|
1169 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KTestFile1, EFileRead | EFileWrite); |
|
1170 |
TEST2(err, KErrNone); |
|
1171 |
TBuf8<50> data; |
|
1172 |
err = file.Read(data); |
|
1173 |
TEST2(err, KErrNone); |
|
1174 |
file.Close(); |
|
1175 |
TEST(data == KData2); |
|
1176 |
// |
|
1177 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1); |
|
1178 |
delete backupClient; |
|
1179 |
} |
|
1180 |
||
1181 |
/** |
|
1182 |
@SYMTestCaseID PDS-SQL-UT-4227 |
|
1183 |
@SYMTestCaseDesc SQL Restore - corrupted archive 2. |
|
1184 |
The test does a backup of a file with a non-zero size. |
|
1185 |
Then the test modifies the archive, byte after byte each step, |
|
1186 |
simulating a corruption. |
|
1187 |
The the test performs a restore from the archive. The corruption |
|
1188 |
should be detected and reported by SQL B&R code. |
|
1189 |
@SYMTestActions SQL Restore - corrupted archive 2. |
|
1190 |
@SYMTestExpectedResults Test must not fail |
|
1191 |
@SYMTestPriority High |
|
1192 |
*/ |
|
1193 |
void CorruptedArchiveTest2() |
|
1194 |
{ |
|
1195 |
CSqlBurCallback* backupClient = NULL; |
|
1196 |
TRAPD(err, backupClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface)); |
|
1197 |
TEST2(err, KErrNone); |
|
1198 |
TEST(backupClient != NULL); |
|
1199 |
//Create the test file that will be sent for backup |
|
1200 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1); |
|
1201 |
RFile file; |
|
1202 |
err = file.Replace(TheSqlSrvTestBurInterface->Fs(), KTestFile1, EFileRead | EFileWrite); |
|
1203 |
TEST2(err, KErrNone); |
|
1204 |
_LIT8(KData1, "123456787989"); |
|
1205 |
err = file.Write(KData1); |
|
1206 |
TEST2(err, KErrNone); |
|
1207 |
err = file.Flush(); |
|
1208 |
TEST2(err, KErrNone); |
|
1209 |
file.Close(); |
|
1210 |
//Backup the file |
|
1211 |
TRAP(err, TestBackupL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid1, KTestDrive)); |
|
1212 |
TEST2(err, KErrNone); |
|
1213 |
//Modify the file, which was sent for backup |
|
1214 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KTestFile1, EFileRead | EFileWrite); |
|
1215 |
TEST2(err, KErrNone); |
|
1216 |
_LIT8(KData2, "ABCDEFGH"); |
|
1217 |
err = file.Write(KData2); |
|
1218 |
TEST2(err, KErrNone); |
|
1219 |
err = file.SetSize(KData2().Length()); |
|
1220 |
TEST2(err, KErrNone); |
|
1221 |
err = file.Flush(); |
|
1222 |
TEST2(err, KErrNone); |
|
1223 |
file.Close(); |
|
1224 |
//Make a copy of the modified file |
|
1225 |
CFileMan* fm = NULL; |
|
1226 |
TRAP(err, fm = CFileMan::NewL(TheSqlSrvTestBurInterface->Fs())); |
|
1227 |
TEST2(err, KErrNone); |
|
1228 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1Bak); |
|
1229 |
err = fm->Copy(KTestFile1, KTestFile1Bak); |
|
1230 |
TEST2(err, KErrNone); |
|
1231 |
//Get the archive size |
|
1232 |
TFileName backupFileName; |
|
1233 |
backupFileName.Copy(KBackupFileTemplate); |
|
1234 |
backupFileName.Append((static_cast <TUid> (KTestClientUid1)).Name()); |
|
1235 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), backupFileName, EFileRead | EFileWrite); |
|
1236 |
TEST2(err, KErrNone); |
|
1237 |
TInt size = 0; |
|
1238 |
err = file.Size(size); |
|
1239 |
TEST2(err, KErrNone); |
|
1240 |
file.Close(); |
|
1241 |
//Save a copy of the archive |
|
1242 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KBackupCopy); |
|
1243 |
err = fm->Copy(backupFileName, KBackupCopy); |
|
1244 |
TEST2(err, KErrNone); |
|
1245 |
//On each iteration step: corrupt the archive and try to do a restore from it. |
|
1246 |
for(TInt i=0;i<size;++i) |
|
1247 |
{ |
|
1248 |
//Change 1 byte in the archive |
|
1249 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), backupFileName, EFileRead | EFileWrite); |
|
1250 |
TEST2(err, KErrNone); |
|
1251 |
TInt pos = i; |
|
1252 |
err = file.Seek(ESeekStart, pos); |
|
1253 |
TEST2(err, KErrNone); |
|
1254 |
TBuf8<1> byte; |
|
1255 |
err = file.Read(byte); |
|
1256 |
TEST2(err, KErrNone); |
|
1257 |
++byte[0]; |
|
1258 |
err = file.Seek(ESeekStart, pos); |
|
1259 |
TEST2(err, KErrNone); |
|
1260 |
err = file.Write(byte); |
|
1261 |
TEST2(err, KErrNone); |
|
1262 |
if(i == (size - 1) && (size & 0x01) == 0) |
|
1263 |
{//Make the file size an odd number, just to test.... |
|
1264 |
err = file.Write(byte); |
|
1265 |
TEST2(err, KErrNone); |
|
1266 |
} |
|
1267 |
err = file.Flush(); |
|
1268 |
TEST2(err, KErrNone); |
|
1269 |
file.Close(); |
|
1270 |
//Restore |
|
1271 |
TRAP(err, TestRestoreL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid1, KTestDrive)); |
|
1272 |
TheTest.Printf(_L("Iteration %d, err=%d\r\n"), i, err); |
|
1273 |
if(err == KErrNone) |
|
1274 |
{ |
|
1275 |
//Delete the restored file. The reason that the restore didn't fail is because only the file data is |
|
1276 |
//protected with checksum. The restore file header - not. The restore completed, the data was restored |
|
1277 |
//to a file with different name. Or even to a file with the same name. Delete created file(s). |
|
1278 |
(void)fm->Delete(KTestDeleteMask1); |
|
1279 |
(void)fm->Delete(KTestDeleteMask2); |
|
1280 |
} |
|
1281 |
else |
|
1282 |
{ |
|
1283 |
//The restore completed with an error. The file content is preserved. |
|
1284 |
//Check that the file content is the same. |
|
1285 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KTestFile1, EFileRead | EFileWrite); |
|
1286 |
TEST2(err, KErrNone); |
|
1287 |
TBuf8<50> data; |
|
1288 |
err = file.Read(data); |
|
1289 |
TEST2(err, KErrNone); |
|
1290 |
file.Close(); |
|
1291 |
TEST(data == KData2); |
|
1292 |
} |
|
1293 |
//Restore the file from the backup copy |
|
1294 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1); |
|
1295 |
err = fm->Copy(KTestFile1Bak, KTestFile1); |
|
1296 |
TEST2(err, KErrNone); |
|
1297 |
//Restore the archive from the good copy. |
|
1298 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(backupFileName); |
|
1299 |
err = fm->Copy(KBackupCopy, backupFileName); |
|
1300 |
TEST2(err, KErrNone); |
|
1301 |
} |
|
1302 |
// |
|
1303 |
delete fm; |
|
1304 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1); |
|
1305 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1Bak); |
|
1306 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KBackupCopy); |
|
1307 |
delete backupClient; |
|
1308 |
} |
|
1309 |
||
1310 |
/** |
|
1311 |
@SYMTestCaseID PDS-SQL-UT-4228 |
|
1312 |
@SYMTestCaseDesc SQL Backup&Restore on a drive different than KTestDrive (C: by default). |
|
1313 |
The test creates one database on KTestDrive and another database |
|
1314 |
with the same name on a drive different than KTestDrive. |
|
1315 |
Then the test backups the "not KTestDrive" drive and restores |
|
1316 |
the data after that. The test verifies that the backup&restore |
|
1317 |
really impacts only the other drive, not KTestDrive. |
|
1318 |
@SYMTestActions SQL Backup&Restore on a drive different than KTestDrive (C: by default). |
|
1319 |
@SYMTestExpectedResults Test must not fail |
|
1320 |
@SYMTestPriority High |
|
1321 |
*/ |
|
1322 |
void DbDriveTest() |
|
1323 |
{ |
|
1324 |
CSqlBurCallback* backupClient = NULL; |
|
1325 |
TRAPD(err, backupClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface)); |
|
1326 |
TEST2(err, KErrNone); |
|
1327 |
TEST(backupClient != NULL); |
|
1328 |
// |
|
1329 |
TDriveUnit driveUnitDefault(KTestDrive); |
|
1330 |
TDriveName driveNameDefault = driveUnitDefault.Name(); |
|
1331 |
//Find a r/w drive, different than KTestDrive |
|
1332 |
TInt drive = EDriveA; |
|
1333 |
for(;drive<=EDriveZ;++drive) |
|
1334 |
{ |
|
1335 |
if(drive == KTestDrive) |
|
1336 |
{ |
|
1337 |
continue; |
|
1338 |
} |
|
1339 |
TDriveInfo driveInfo; |
|
1340 |
err = TheSqlSrvTestBurInterface->Fs().Drive(driveInfo, drive); |
|
1341 |
if(err != KErrNone) |
|
1342 |
{ |
|
1343 |
continue; |
|
1344 |
} |
|
1345 |
if(driveInfo.iDriveAtt & KDriveAttRom) |
|
1346 |
{ |
|
1347 |
continue; |
|
1348 |
} |
|
1349 |
// |
|
1350 |
TDriveUnit driveUnit(drive); |
|
1351 |
TDriveName driveName = driveUnit.Name(); |
|
1352 |
// |
|
1353 |
TVolumeInfo vinfo; |
|
1354 |
err = TheSqlSrvTestBurInterface->Fs().Volume(vinfo, drive); |
|
1355 |
if(err != KErrNone) |
|
1356 |
{ |
|
1357 |
TheTest.Printf(_L("Drive %S, RFs::Volume() err=%d\r\n"), &driveName, err); |
|
1358 |
continue; |
|
1359 |
} |
|
1360 |
//R/W drive found. |
|
1361 |
TheTest.Printf(_L("Test drive: %S\r\n"), &driveName); |
|
1362 |
TParse parse; |
|
1363 |
err = parse.Set(KTestFile2, &driveName, 0); |
|
1364 |
TEST2(err, KErrNone); |
|
1365 |
//Create the test file that will be sent for backup |
|
1366 |
TPtrC fname1(parse.FullName()); |
|
1367 |
TheTest.Printf(_L("Test file 1: %S\r\n"), &fname1); |
|
1368 |
err = TheSqlSrvTestBurInterface->Fs().MkDirAll(parse.FullName()); |
|
1369 |
TEST(err == KErrNone || err == KErrAlreadyExists); |
|
1370 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(parse.FullName()); |
|
1371 |
RFile file; |
|
1372 |
err = file.Replace(TheSqlSrvTestBurInterface->Fs(), parse.FullName(), EFileRead | EFileWrite); |
|
1373 |
TEST2(err, KErrNone); |
|
1374 |
_LIT8(KData1, "123456787989"); |
|
1375 |
err = file.Write(KData1); |
|
1376 |
TEST2(err, KErrNone); |
|
1377 |
err = file.Flush(); |
|
1378 |
TEST2(err, KErrNone); |
|
1379 |
file.Close(); |
|
1380 |
//Create a test file with the same name on drive KTestDrive |
|
1381 |
err = parse.Set(KTestFile2, &driveNameDefault, 0); |
|
1382 |
TEST2(err, KErrNone); |
|
1383 |
TPtrC fname2(parse.FullName()); |
|
1384 |
TheTest.Printf(_L("Test file 2: %S\r\n"), &fname2); |
|
1385 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(parse.FullName()); |
|
1386 |
err = file.Replace(TheSqlSrvTestBurInterface->Fs(), parse.FullName(), EFileRead | EFileWrite); |
|
1387 |
TEST2(err, KErrNone); |
|
1388 |
_LIT8(KData2, "ABCDEFG"); |
|
1389 |
err = file.Write(KData2); |
|
1390 |
TEST2(err, KErrNone); |
|
1391 |
err = file.Flush(); |
|
1392 |
TEST2(err, KErrNone); |
|
1393 |
file.Close(); |
|
1394 |
//Do the backup on "drive" |
|
1395 |
TRAP(err, TestBackupL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid2, (TDriveNumber)drive)); |
|
1396 |
TEST2(err, KErrNone); |
|
1397 |
//Modify the file that was sent for backup |
|
1398 |
err = parse.Set(KTestFile2, &driveName, 0); |
|
1399 |
TEST2(err, KErrNone); |
|
1400 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), parse.FullName(), EFileRead | EFileWrite); |
|
1401 |
TEST2(err, KErrNone); |
|
1402 |
_LIT8(KData3, "ABCDEFGHYYYYYY"); |
|
1403 |
err = file.Write(KData3); |
|
1404 |
TEST2(err, KErrNone); |
|
1405 |
err = file.Flush(); |
|
1406 |
TEST2(err, KErrNone); |
|
1407 |
file.Close(); |
|
1408 |
//Do the restore on "drive" |
|
1409 |
TRAP(err, TestRestoreL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid2, (TDriveNumber)drive)); |
|
1410 |
TEST2(err, KErrNone); |
|
1411 |
//Verify the content of the restored file |
|
1412 |
err = parse.Set(KTestFile2, &driveName, 0); |
|
1413 |
TEST2(err, KErrNone); |
|
1414 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), parse.FullName(), EFileRead | EFileWrite); |
|
1415 |
TEST2(err, KErrNone); |
|
1416 |
TBuf8<50> data; |
|
1417 |
err = file.Read(data); |
|
1418 |
TEST2(err, KErrNone); |
|
1419 |
file.Close(); |
|
1420 |
TEST(data == KData1); |
|
1421 |
//Verify the content of the file on drive KTestDrive. It should be the same as before the backup&restore. |
|
1422 |
err = parse.Set(KTestFile2, &driveNameDefault, 0); |
|
1423 |
TEST2(err, KErrNone); |
|
1424 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), parse.FullName(), EFileRead | EFileWrite); |
|
1425 |
TEST2(err, KErrNone); |
|
1426 |
err = file.Read(data); |
|
1427 |
TEST2(err, KErrNone); |
|
1428 |
file.Close(); |
|
1429 |
TEST(data == KData2); |
|
1430 |
//Cleanup |
|
1431 |
err = parse.Set(KTestFile2, &driveNameDefault, 0); |
|
1432 |
TEST2(err, KErrNone); |
|
1433 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(parse.FullName()); |
|
1434 |
err = parse.Set(KTestFile2, &driveName, 0); |
|
1435 |
TEST2(err, KErrNone); |
|
1436 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(parse.FullName()); |
|
1437 |
break; |
|
1438 |
} |
|
1439 |
delete backupClient; |
|
1440 |
if(drive > EDriveZ) |
|
1441 |
{ |
|
1442 |
TheTest.Printf(_L("No R/W drive has been found, different than %S\r\n"), &driveNameDefault); |
|
1443 |
} |
|
1444 |
} |
|
1445 |
||
1446 |
/** |
|
1447 |
@SYMTestCaseID PDS-SQL-UT-4229 |
|
1448 |
@SYMTestCaseDesc SQL Backup&Restore with locked file. |
|
1449 |
The test creates two test files on the same drive and with the same uid. |
|
1450 |
Then the test backups the databases. After the backup the test simulates that |
|
1451 |
the first file is "in use". Then the test performs a restore. |
|
1452 |
The expected result: the locked file is not restored but the other file is restored. |
|
1453 |
@SYMTestActions SQL Backup&Restore with locked file. |
|
1454 |
@SYMTestExpectedResults Test must not fail |
|
1455 |
@SYMTestPriority High |
|
1456 |
*/ |
|
1457 |
void LockFileTest() |
|
1458 |
{ |
|
1459 |
CSqlBurCallback* backupClient = NULL; |
|
1460 |
TRAPD(err, backupClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface)); |
|
1461 |
TEST2(err, KErrNone); |
|
1462 |
TEST(backupClient != NULL); |
|
1463 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile3); |
|
1464 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile4); |
|
1465 |
//Create the files. File 1. |
|
1466 |
RFile file; |
|
1467 |
err = file.Replace(TheSqlSrvTestBurInterface->Fs(), KTestFile3, EFileRead | EFileWrite); |
|
1468 |
TEST2(err, KErrNone); |
|
1469 |
_LIT8(KData1, "123456787989"); |
|
1470 |
err = file.Write(KData1); |
|
1471 |
TEST2(err, KErrNone); |
|
1472 |
err = file.Flush(); |
|
1473 |
TEST2(err, KErrNone); |
|
1474 |
file.Close(); |
|
1475 |
//...file 2 |
|
1476 |
err = file.Replace(TheSqlSrvTestBurInterface->Fs(), KTestFile4, EFileRead | EFileWrite); |
|
1477 |
TEST2(err, KErrNone); |
|
1478 |
_LIT8(KData2, "ABCDEF"); |
|
1479 |
err = file.Write(KData2); |
|
1480 |
TEST2(err, KErrNone); |
|
1481 |
err = file.Flush(); |
|
1482 |
TEST2(err, KErrNone); |
|
1483 |
file.Close(); |
|
1484 |
//Backup |
|
1485 |
TRAP(err, TestBackupL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid3, KTestDrive)); |
|
1486 |
TEST2(err, KErrNone); |
|
1487 |
//Modify the files. Keep the first file opened. |
|
1488 |
RFile file1; |
|
1489 |
err = file1.Open(TheSqlSrvTestBurInterface->Fs(), KTestFile3, EFileRead | EFileWrite); |
|
1490 |
TEST2(err, KErrNone); |
|
1491 |
_LIT8(KData3, "YYYYYQQQQQQQQQQQ"); |
|
1492 |
err = file1.Write(KData3); |
|
1493 |
TEST2(err, KErrNone); |
|
1494 |
err = file1.Flush(); |
|
1495 |
TEST2(err, KErrNone); |
|
1496 |
//...file 2 |
|
1497 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KTestFile4, EFileRead | EFileWrite); |
|
1498 |
TEST2(err, KErrNone); |
|
1499 |
_LIT8(KData4, "5545495444j32322332234223432"); |
|
1500 |
err = file.Write(KData4); |
|
1501 |
TEST2(err, KErrNone); |
|
1502 |
err = file.Flush(); |
|
1503 |
TEST2(err, KErrNone); |
|
1504 |
file.Close(); |
|
1505 |
//Restore. The reported error should be KErrInUse. |
|
1506 |
TRAP(err, TestRestoreL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid3, KTestDrive)); |
|
1507 |
TEST2(err, KErrInUse); |
|
1508 |
//Close file 1 and check the content. It should be the same as after the backup |
|
1509 |
file1.Close(); |
|
1510 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KTestFile3, EFileRead | EFileWrite); |
|
1511 |
TEST2(err, KErrNone); |
|
1512 |
TBuf8<50> data; |
|
1513 |
err = file.Read(data); |
|
1514 |
TEST2(err, KErrNone); |
|
1515 |
file.Close(); |
|
1516 |
TEST(data == KData3); |
|
1517 |
//File2: check the content. It should be the same as before the backup |
|
1518 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KTestFile4, EFileRead | EFileWrite); |
|
1519 |
TEST2(err, KErrNone); |
|
1520 |
err = file.Read(data); |
|
1521 |
TEST2(err, KErrNone); |
|
1522 |
file.Close(); |
|
1523 |
TEST(data == KData2); |
|
1524 |
// |
|
1525 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile4); |
|
1526 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile3); |
|
1527 |
delete backupClient; |
|
1528 |
} |
|
1529 |
||
1530 |
/** |
|
1531 |
@SYMTestCaseID PDS-SQL-UT-4230 |
|
1532 |
@SYMTestCaseDesc SQL Backup&Restore with locked file - test 2. |
|
1533 |
The test creates two test files on the same drive and with different uids. |
|
1534 |
Then the test backups the databases. After the backup the test simulates that |
|
1535 |
the first file is "in use". Then the test performs a restore. |
|
1536 |
The expected result: the locked file is not restored but the other file is restored. |
|
1537 |
@SYMTestActions SQL Backup&Restore with locked file - test 2. |
|
1538 |
@SYMTestExpectedResults Test must not fail |
|
1539 |
@SYMTestPriority High |
|
1540 |
*/ |
|
1541 |
void LockFileTest2() |
|
1542 |
{ |
|
1543 |
CSqlBurCallback* backupClient = NULL; |
|
1544 |
TRAPD(err, backupClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface)); |
|
1545 |
TEST2(err, KErrNone); |
|
1546 |
TEST(backupClient != NULL); |
|
1547 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1);//KTestClientUid1 used |
|
1548 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile4);//KTestClientUid3 used |
|
1549 |
//Create the files. File 1. |
|
1550 |
RFile file; |
|
1551 |
err = file.Replace(TheSqlSrvTestBurInterface->Fs(), KTestFile1, EFileRead | EFileWrite); |
|
1552 |
TEST2(err, KErrNone); |
|
1553 |
_LIT8(KData1, "123456787989"); |
|
1554 |
err = file.Write(KData1); |
|
1555 |
TEST2(err, KErrNone); |
|
1556 |
err = file.Flush(); |
|
1557 |
TEST2(err, KErrNone); |
|
1558 |
file.Close(); |
|
1559 |
//...file 2 |
|
1560 |
err = file.Replace(TheSqlSrvTestBurInterface->Fs(), KTestFile4, EFileRead | EFileWrite); |
|
1561 |
TEST2(err, KErrNone); |
|
1562 |
_LIT8(KData2, "ABCDEF"); |
|
1563 |
err = file.Write(KData2); |
|
1564 |
TEST2(err, KErrNone); |
|
1565 |
err = file.Flush(); |
|
1566 |
TEST2(err, KErrNone); |
|
1567 |
file.Close(); |
|
1568 |
//Backup |
|
1569 |
TRAP(err, TestBackupL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid1, KTestDrive)); |
|
1570 |
TEST2(err, KErrNone); |
|
1571 |
TRAP(err, TestBackupL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid3, KTestDrive)); |
|
1572 |
TEST2(err, KErrNone); |
|
1573 |
//Modify the files. Keep the first file opened. |
|
1574 |
RFile file1; |
|
1575 |
err = file1.Open(TheSqlSrvTestBurInterface->Fs(), KTestFile1, EFileRead | EFileWrite); |
|
1576 |
TEST2(err, KErrNone); |
|
1577 |
_LIT8(KData3, "YYYYYQQQQQQQQQQQ"); |
|
1578 |
err = file1.Write(KData3); |
|
1579 |
TEST2(err, KErrNone); |
|
1580 |
err = file1.Flush(); |
|
1581 |
TEST2(err, KErrNone); |
|
1582 |
//...file 2 |
|
1583 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KTestFile4, EFileRead | EFileWrite); |
|
1584 |
TEST2(err, KErrNone); |
|
1585 |
_LIT8(KData4, "5545495444j32322332234223432"); |
|
1586 |
err = file.Write(KData4); |
|
1587 |
TEST2(err, KErrNone); |
|
1588 |
err = file.Flush(); |
|
1589 |
TEST2(err, KErrNone); |
|
1590 |
file.Close(); |
|
1591 |
//Restore the first file. The reported error should be KErrInUse. |
|
1592 |
TRAP(err, TestRestoreL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid1, KTestDrive)); |
|
1593 |
TEST2(err, KErrInUse); |
|
1594 |
//Restore the second file. The reported error should be KErrNone. |
|
1595 |
TRAP(err, TestRestoreL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid3, KTestDrive)); |
|
1596 |
TEST2(err, KErrNone); |
|
1597 |
//Close file 1 and check the content. It should be the same as after the backup |
|
1598 |
file1.Close(); |
|
1599 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KTestFile1, EFileRead | EFileWrite); |
|
1600 |
TEST2(err, KErrNone); |
|
1601 |
TBuf8<50> data; |
|
1602 |
err = file.Read(data); |
|
1603 |
TEST2(err, KErrNone); |
|
1604 |
file.Close(); |
|
1605 |
TEST(data == KData3); |
|
1606 |
//File2: check the content. It should be the same as before the backup |
|
1607 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KTestFile4, EFileRead | EFileWrite); |
|
1608 |
TEST2(err, KErrNone); |
|
1609 |
err = file.Read(data); |
|
1610 |
TEST2(err, KErrNone); |
|
1611 |
file.Close(); |
|
1612 |
TEST(data == KData2); |
|
1613 |
// |
|
1614 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile4); |
|
1615 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1); |
|
1616 |
delete backupClient; |
|
1617 |
} |
|
1618 |
||
1619 |
CDir* GetPrivateDirContent(TDriveNumber aDrive) |
|
1620 |
{ |
|
1621 |
TDriveUnit driveUnit(aDrive); |
|
1622 |
TDriveName driveName = driveUnit.Name(); |
|
1623 |
TFileName path; |
|
1624 |
path.Copy(driveName); |
|
1625 |
path.Append(KPrivateDir); |
|
1626 |
_LIT(KMatchAllDbFiles, "*"); |
|
1627 |
path.Append(KMatchAllDbFiles); |
|
1628 |
//Do the search |
|
1629 |
CDir* fileNameCol = NULL; |
|
1630 |
TInt err = TheSqlSrvTestBurInterface->Fs().GetDir(path, KEntryAttNormal, ESortByName, fileNameCol); |
|
1631 |
TEST2(err, KErrNone); |
|
1632 |
return fileNameCol; |
|
1633 |
} |
|
1634 |
||
1635 |
/** |
|
1636 |
@SYMTestCaseID PDS-SQL-UT-4231 |
|
1637 |
@SYMTestCaseDesc SQL Backup&Restore - directory content test. |
|
1638 |
The test stores into an array information regarding all files in |
|
1639 |
SQL private datacage. Then the test backups one of the files and modifies |
|
1640 |
the file after that. Then the test does a restore. Expected result - the only |
|
1641 |
modifed file should be the file which was sent for backup. |
|
1642 |
@SYMTestActions SQL Backup&Restore - directory content test. |
|
1643 |
@SYMTestExpectedResults Test must not fail |
|
1644 |
@SYMTestPriority High |
|
1645 |
*/ |
|
1646 |
void DirectoryContentTest() |
|
1647 |
{ |
|
1648 |
CSqlBurCallback* backupClient = NULL; |
|
1649 |
TRAPD(err, backupClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface)); |
|
1650 |
TEST2(err, KErrNone); |
|
1651 |
TEST(backupClient != NULL); |
|
1652 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1);//KTestClientUid1 used |
|
1653 |
//Create the file |
|
1654 |
RFile file; |
|
1655 |
err = file.Replace(TheSqlSrvTestBurInterface->Fs(), KTestFile1, EFileRead | EFileWrite); |
|
1656 |
TEST2(err, KErrNone); |
|
1657 |
_LIT8(KData1, "123456787989"); |
|
1658 |
err = file.Write(KData1); |
|
1659 |
TEST2(err, KErrNone); |
|
1660 |
err = file.Flush(); |
|
1661 |
TEST2(err, KErrNone); |
|
1662 |
file.Close(); |
|
1663 |
//Store file entries into an array |
|
1664 |
CDir* dirBeforeBackup = GetPrivateDirContent(KTestDrive); |
|
1665 |
//Backup |
|
1666 |
TRAP(err, TestBackupL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid1, KTestDrive)); |
|
1667 |
TEST2(err, KErrNone); |
|
1668 |
//Check dir content |
|
1669 |
CDir* dirAfterBackup = GetPrivateDirContent(KTestDrive); |
|
1670 |
TEST2(dirBeforeBackup->Count(), dirAfterBackup->Count()); |
|
1671 |
for(TInt i=0;i<dirBeforeBackup->Count();++i) |
|
1672 |
{ |
|
1673 |
const TEntry& entry1 = (*dirBeforeBackup)[i]; |
|
1674 |
const TEntry& entry2 = (*dirAfterBackup)[i]; |
|
1675 |
TheTest.Printf(_L("Entry1=%S, Entry2=%S\r\n"), &entry1.iName, &entry2.iName); |
|
1676 |
TBool rc = entry1.iAtt == entry2.iAtt; |
|
1677 |
TEST(rc); |
|
1678 |
rc = entry1.iSize == entry2.iSize; |
|
1679 |
TEST(rc); |
|
1680 |
rc = entry1.iModified == entry2.iModified; |
|
1681 |
TEST(rc); |
|
1682 |
rc = entry1.iType == entry2.iType; |
|
1683 |
TEST(rc); |
|
1684 |
rc = entry1.iName == entry2.iName; |
|
1685 |
TEST(rc); |
|
1686 |
} |
|
1687 |
delete dirAfterBackup; |
|
1688 |
//Modify the file |
|
1689 |
err = file.Replace(TheSqlSrvTestBurInterface->Fs(), KTestFile1, EFileRead | EFileWrite); |
|
1690 |
TEST2(err, KErrNone); |
|
1691 |
_LIT8(KData2, "ABCDEF"); |
|
1692 |
err = file.Write(KData2); |
|
1693 |
TEST2(err, KErrNone); |
|
1694 |
err = file.Flush(); |
|
1695 |
TEST2(err, KErrNone); |
|
1696 |
file.Close(); |
|
1697 |
//Restore |
|
1698 |
User::After(2000000);//To force a change in the file time stamp (the restored file time stamp). |
|
1699 |
TRAP(err, TestRestoreL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid1, KTestDrive)); |
|
1700 |
TEST2(err, KErrNone); |
|
1701 |
//Check dir content |
|
1702 |
CDir* dirAfterRestore = GetPrivateDirContent(KTestDrive); |
|
1703 |
TEST2(dirBeforeBackup->Count(), dirAfterRestore->Count()); |
|
1704 |
for(TInt i=0;i<dirBeforeBackup->Count();++i) |
|
1705 |
{ |
|
1706 |
const TEntry& entry1 = (*dirBeforeBackup)[i]; |
|
1707 |
const TEntry& entry2 = (*dirAfterRestore)[i]; |
|
1708 |
TheTest.Printf(_L("Entry1=%S, Entry2=%S\r\n"), &entry1.iName, &entry2.iName); |
|
1709 |
TBool rc = entry1.iAtt == entry2.iAtt; |
|
1710 |
TEST(rc); |
|
1711 |
rc = entry1.iSize == entry2.iSize; |
|
1712 |
TEST(rc); |
|
1713 |
if(entry1.iName.FindF(KTestFile1NameOnly) >= 0) |
|
1714 |
{ |
|
1715 |
rc = entry1.iModified != entry2.iModified; |
|
1716 |
} |
|
1717 |
else |
|
1718 |
{ |
|
1719 |
rc = entry1.iModified == entry2.iModified; |
|
1720 |
} |
|
1721 |
TEST(rc); |
|
1722 |
rc = entry1.iType == entry2.iType; |
|
1723 |
TEST(rc); |
|
1724 |
rc = entry1.iName == entry2.iName; |
|
1725 |
TEST(rc); |
|
1726 |
} |
|
1727 |
delete dirAfterRestore; |
|
1728 |
// |
|
1729 |
delete dirBeforeBackup; |
|
1730 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1); |
|
1731 |
delete backupClient; |
|
1732 |
} |
|
1733 |
||
1734 |
/** |
|
1735 |
@SYMTestCaseID PDS-SQL-UT-4232 |
|
1736 |
@SYMTestCaseDesc SQL Backup&Restore - large file test. |
|
1737 |
Backup and restore with a file with size bigger than 1 Mb. |
|
1738 |
@SYMTestActions SQL Backup&Restore - large file test. |
|
1739 |
@SYMTestExpectedResults Test must not fail |
|
1740 |
@SYMTestPriority High |
|
1741 |
*/ |
|
1742 |
void LargeFileTest() |
|
1743 |
{ |
|
1744 |
CSqlBurCallback* backupClient = NULL; |
|
1745 |
TRAPD(err, backupClient = CSqlBurCallback::NewL(*TheSqlSrvTestBurInterface)); |
|
1746 |
TEST2(err, KErrNone); |
|
1747 |
TEST(backupClient != NULL); |
|
1748 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1);//KTestClientUid1 used |
|
1749 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile2);//KTestClientUid2 used |
|
1750 |
//Allocate buffer for the data |
|
1751 |
const TInt KDataBufSize = 100000; |
|
1752 |
HBufC8* dataBuf = HBufC8::New(KDataBufSize); |
|
1753 |
TEST(dataBuf != NULL); |
|
1754 |
TPtr8 dataPtr = dataBuf->Des(); |
|
1755 |
//Create file 1 |
|
1756 |
const TInt KFileSize1 = 1201345; |
|
1757 |
RFile file; |
|
1758 |
err = file.Replace(TheSqlSrvTestBurInterface->Fs(), KTestFile1, EFileRead | EFileWrite); |
|
1759 |
TEST2(err, KErrNone); |
|
1760 |
dataPtr.SetLength(dataPtr.MaxLength()); |
|
1761 |
const TChar KChar1(0x5A); |
|
1762 |
dataPtr.Fill(KChar1); |
|
1763 |
TInt len = KFileSize1; |
|
1764 |
while(len > 0) |
|
1765 |
{ |
|
1766 |
TInt blockSize = Min(len, dataPtr.MaxLength()); |
|
1767 |
err = file.Write(dataPtr, blockSize); |
|
1768 |
TEST2(err, KErrNone); |
|
1769 |
len -= blockSize; |
|
1770 |
} |
|
1771 |
err = file.Flush(); |
|
1772 |
TEST2(err, KErrNone); |
|
1773 |
file.Close(); |
|
1774 |
//Create file 2 |
|
1775 |
const TInt KFileSize2 = 1387651; |
|
1776 |
err = file.Replace(TheSqlSrvTestBurInterface->Fs(), KTestFile2, EFileRead | EFileWrite); |
|
1777 |
TEST2(err, KErrNone); |
|
1778 |
dataPtr.SetLength(dataPtr.MaxLength()); |
|
1779 |
const TChar KChar2(0xD5); |
|
1780 |
dataPtr.Fill(KChar2); |
|
1781 |
len = KFileSize2; |
|
1782 |
while(len > 0) |
|
1783 |
{ |
|
1784 |
TInt blockSize = Min(len, dataPtr.MaxLength()); |
|
1785 |
err = file.Write(dataPtr, blockSize); |
|
1786 |
TEST2(err, KErrNone); |
|
1787 |
len -= blockSize; |
|
1788 |
} |
|
1789 |
err = file.Flush(); |
|
1790 |
TEST2(err, KErrNone); |
|
1791 |
file.Close(); |
|
1792 |
//Backup |
|
1793 |
TRAP(err, TestBackupL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid1, KTestDrive)); |
|
1794 |
TEST2(err, KErrNone); |
|
1795 |
TRAP(err, TestBackupL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid2, KTestDrive)); |
|
1796 |
TEST2(err, KErrNone); |
|
1797 |
//Delete the files |
|
1798 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1); |
|
1799 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile2); |
|
1800 |
//Restore |
|
1801 |
TRAP(err, TestRestoreL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid1, KTestDrive)); |
|
1802 |
TEST2(err, KErrNone); |
|
1803 |
TRAP(err, TestRestoreL(*backupClient, TheSqlSrvTestBurInterface->Fs(), KTestClientUid2, KTestDrive)); |
|
1804 |
TEST2(err, KErrNone); |
|
1805 |
//Check restored files content |
|
1806 |
const TPtrC KFileNames[] = {KTestFile1(), KTestFile2()}; |
|
1807 |
const TInt KFileSizes[] = {KFileSize1, KFileSize2}; |
|
1808 |
const TChar KSymbols[] = {KChar1, KChar2}; |
|
1809 |
for(TInt i=0;i<(sizeof(KFileNames)/sizeof(KFileNames[i]));++i) |
|
1810 |
{ |
|
1811 |
err = file.Open(TheSqlSrvTestBurInterface->Fs(), KFileNames[i], EFileRead); |
|
1812 |
TEST2(err, KErrNone); |
|
1813 |
len = 0; |
|
1814 |
err = file.Size(len); |
|
1815 |
TEST2(err, KErrNone); |
|
1816 |
TEST2(len, KFileSizes[i]); |
|
1817 |
while(len > 0) |
|
1818 |
{ |
|
1819 |
TInt blockSize = Min(len, dataPtr.MaxLength()); |
|
1820 |
err = file.Read(dataPtr, blockSize); |
|
1821 |
TEST2(err, KErrNone); |
|
1822 |
len -= blockSize; |
|
1823 |
for(TInt j=0;j<dataPtr.Length();++j) |
|
1824 |
{ |
|
1825 |
TEST(dataPtr[j] == KSymbols[i]); |
|
1826 |
} |
|
1827 |
} |
|
1828 |
file.Close(); |
|
1829 |
} |
|
1830 |
// |
|
1831 |
delete dataBuf; |
|
1832 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile2); |
|
1833 |
(void)TheSqlSrvTestBurInterface->Fs().Delete(KTestFile1); |
|
1834 |
delete backupClient; |
|
1835 |
} |
|
29 | 1836 |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1837 |
void DoMain() |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1838 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1839 |
TestEnvCreate(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1840 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1841 |
TheTest.Start(_L("Store db content to memory buffer")); |
51 | 1842 |
StoreDbContentToBuf(TheSqlSrvTestBurInterface->Fs(), KTestDrive, KClientUid); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1843 |
|
51 | 1844 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4002 Backup: functional test ")); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1845 |
FunctionalTest(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1846 |
|
51 | 1847 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4003 Backup: OOM test ")); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1848 |
OomTest(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1849 |
|
51 | 1850 |
TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4143 Backup&Restore: functional test 2")); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1851 |
FunctionalTest2(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1852 |
|
51 | 1853 |
TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4144 Backup&Restore: legacy file format test")); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1854 |
LegacyFileFormatTest(); |
29 | 1855 |
|
51 | 1856 |
TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4192 Backup&Restore: empty backup file list")); |
29 | 1857 |
EmptyBackupFileListTest(); |
1858 |
||
51 | 1859 |
TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4193 Backup: File I/O error simulation test")); |
29 | 1860 |
BackupRestoreFileIoErrTest(); |
51 | 1861 |
|
1862 |
TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4225 Zero size file - backup test")); |
|
1863 |
BackupZeroSizeFileTest(); |
|
1864 |
||
1865 |
TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4226 Restore test - corrupted archive 1")); |
|
1866 |
CorruptedArchiveTest1(); |
|
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1867 |
|
51 | 1868 |
TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4227 Restore test - corrupted archive 2")); |
1869 |
CorruptedArchiveTest2(); |
|
1870 |
||
1871 |
TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4228 Backup&Restore test on a drive different than KTestDrive (C: by default)")); |
|
1872 |
DbDriveTest(); |
|
1873 |
||
1874 |
TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4229 Backup&Restore test with locked file")); |
|
1875 |
LockFileTest(); |
|
1876 |
||
1877 |
TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4230 Backup&Restore test with locked file 2")); |
|
1878 |
LockFileTest2(); |
|
1879 |
||
1880 |
TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4231 Backup&Restore - directory content test")); |
|
1881 |
DirectoryContentTest(); |
|
1882 |
||
1883 |
TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4232 Backup&Restore - large file test")); |
|
1884 |
LargeFileTest(); |
|
1885 |
||
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1886 |
TestEnvDestroy(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1887 |
} |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1888 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1889 |
TInt E32Main() |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1890 |
{ |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1891 |
TheTest.Title(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1892 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1893 |
CTrapCleanup* tc = CTrapCleanup::New(); |
51 | 1894 |
TheTest(tc != NULL); |
0
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1895 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1896 |
__UHEAP_MARK; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1897 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1898 |
DoMain(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1899 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1900 |
__UHEAP_MARKEND; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1901 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1902 |
TheTest.End(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1903 |
TheTest.Close(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1904 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1905 |
delete tc; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1906 |
|
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1907 |
User::Heap().Check(); |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1908 |
return KErrNone; |
08ec8eefde2f
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1909 |
} |