|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef T_SQLOOM_H |
|
17 #define T_SQLOOM_H |
|
18 |
|
19 #include <e32test.h> |
|
20 #include <bautils.h> |
|
21 #include <sqldb.h> |
|
22 |
|
23 extern RTest TheTest; |
|
24 |
|
25 extern TInt TheHandleCount1B; |
|
26 extern TInt TheHandleCount2B; |
|
27 extern TInt TheAllocatedCellsCountB; |
|
28 |
|
29 const TSecurityPolicy KDefaultPolicy(ECapability_None); |
|
30 const TSecurityPolicy KPolicy1(ECapabilityTrustedUI, ECapabilityDiskAdmin); |
|
31 const TSecurityPolicy KPolicy2(ECapabilityTrustedUI); |
|
32 const TSecurityPolicy KPolicy3(ECapabilityDiskAdmin); |
|
33 |
|
34 // These values have been found by performing each OOM test |
|
35 // with an allocation limit of 1000 and then taking a value |
|
36 // which is just above the allocation failure rate. |
|
37 #if defined __WINS__ || defined __WINSCW__ |
|
38 const TInt KDoCreateDatabaseOomTestAllocLimitClient = 50; |
|
39 const TInt KDoCreateDatabaseOomTestAllocLimitServer = 550; |
|
40 const TInt KDoDbOomTestAllocLimitClient = 50; |
|
41 const TInt KDoDbOomTestAllocLimitServer = 600; |
|
42 const TInt KDoDbOomTest2AllocLimitClient = 50; |
|
43 const TInt KDoDbOomTest2AllocLimitServer = 500; |
|
44 const TInt KBlobOomTestAllocLimitClient = 20; |
|
45 const TInt KBlobOomTestAllocLimitServer = 100; |
|
46 const TInt KStmtOomTestAllocLimitClient = 20; |
|
47 const TInt KStmtOomTestAllocLimitServer = 100; |
|
48 #else //The test running time is above the time limit (2400 sec) set for hardware testing |
|
49 const TInt KDoCreateDatabaseOomTestAllocLimitClient = 50/2; |
|
50 const TInt KDoCreateDatabaseOomTestAllocLimitServer = 550/2; |
|
51 const TInt KDoDbOomTestAllocLimitClient = 50/2; |
|
52 const TInt KDoDbOomTestAllocLimitServer = 600/2; |
|
53 const TInt KDoDbOomTest2AllocLimitClient = 50/2; |
|
54 const TInt KDoDbOomTest2AllocLimitServer = 500/2; |
|
55 const TInt KBlobOomTestAllocLimitClient = 20; |
|
56 const TInt KBlobOomTestAllocLimitServer = 100/2; |
|
57 const TInt KStmtOomTestAllocLimitClient = 20; |
|
58 const TInt KStmtOomTestAllocLimitServer = 100; |
|
59 #endif |
|
60 |
|
61 _LIT(KTestDir, "c:\\test\\"); |
|
62 _LIT(KTestDb, "c:\\test\\t_sqloom_1.db"); |
|
63 _LIT(KSecureTestDb, "c:[21212121]t_sqloom_2.db"); |
|
64 _LIT(KAttachDb, "c:\\test\\t_sqloom_3.db"); |
|
65 _LIT(KSecureAttachDb, "c:[21212121]t_sqloom_4.db"); |
|
66 _LIT(KSecureAttachDb2, "c:[1111CCCC]t_ab.db");//Created outside this test |
|
67 _LIT(KSecureDb2, "C:[21212121]t_sqloom_6.db"); |
|
68 _LIT(KTestDb2, "C:\\TEST\\t_sqloom_7.db"); |
|
69 _LIT(KPrivateTestDb, "c:\\private\\21212121\\t_sqloom_8.db"); |
|
70 |
|
71 _LIT(KTableName1, "A_tbl"); |
|
72 _LIT(KTableName2, "B_table"); |
|
73 _LIT(KTableName3, "T_CCCCCCCCCCCCCC"); |
|
74 |
|
75 /////////////////////////////////////////////////////////////////////////////////////// |
|
76 |
|
77 enum TDbAction |
|
78 { |
|
79 ENotOpenDb, |
|
80 EOpenDb |
|
81 }; |
|
82 |
|
83 enum TDbType |
|
84 { |
|
85 ENonSecureDb, |
|
86 ESecureDb |
|
87 }; |
|
88 |
|
89 enum TOomTestType |
|
90 { |
|
91 EClientSideTest, |
|
92 EServerSideTest |
|
93 }; |
|
94 |
|
95 extern TOomTestType TheOomTestType[2]; |
|
96 |
|
97 /////////////////////////////////////////////////////////////////////////////////////// |
|
98 |
|
99 void DeleteTestFiles(); |
|
100 void CreateTestDir(); |
|
101 void PrepareAttachFromHandle(); |
|
102 |
|
103 void Check(TInt64 aValue, TInt aLine); |
|
104 void Check(TInt64 aValue, TInt64 aExpected, TInt aLine); |
|
105 #define TEST(arg) ::Check((arg), __LINE__) |
|
106 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
|
107 |
|
108 void MarkHandles(); |
|
109 void CheckHandles(); |
|
110 void MarkAllocatedCells(); |
|
111 void CheckAllocatedCells(); |
|
112 |
|
113 void PrintEndOfOomTest(TOomTestType aOomTestType, TInt aFailingAllocationNo); |
|
114 void SetDbHeapFailure(TOomTestType aOomTestType, TInt aFailingAllocationNo, TBool aDelayed = EFalse); |
|
115 void ResetDbHeapFailure(TOomTestType aOomTestType); |
|
116 void SetHeapFailure(TOomTestType aOomTestType, TInt aFailingAllocationNo); |
|
117 void ResetHeapFailure(TOomTestType aOomTestType); |
|
118 |
|
119 typedef void (*TDbFuncPtrL)(RSqlDatabase& aDb, const TDesC& aDbFileName, TDbType aDbType); |
|
120 typedef void (*TStmtFuncPtrL)(RSqlDatabase& aDb, RSqlStatement& aStmt); |
|
121 typedef void (*TStmtFuncPtr2L)(RSqlStatement& aStmt); |
|
122 typedef void (*TScalarFullSelectFuncPtrL)(RSqlDatabase& aDb); |
|
123 typedef void (*TBlobPrepareFuncPtrL)(RSqlDatabase& aDb); |
|
124 typedef void (*TBlobTestFuncPtrL)(RSqlDatabase& aDb, const TDesC& aAttachDbName = KNullDesC); |
|
125 |
|
126 void CreateTestSecurityPolicy(RSqlSecurityPolicy& aSecurityPolicy); |
|
127 void CreateAttachDb(); |
|
128 void DbOomTestsL(TDbType aDbType); |
|
129 |
|
130 #endif//T_SQLOOM_H |