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 // Test22Append.cpp |
|
15 // Contains MBufMgr Test Step 22 for Append() methods |
|
16 // |
|
17 // |
|
18 |
|
19 // EPOC includes |
|
20 #include <e32base.h> |
|
21 |
|
22 // Test system includes |
|
23 #ifdef SYMBIAN_OLD_EXPORT_LOCATION |
|
24 #include "networking/log.h" |
|
25 #include "networking/teststep.h" |
|
26 #else |
|
27 #include <networking/log.h> |
|
28 #include <networking/teststep.h> |
|
29 #endif |
|
30 |
|
31 #include "TestStepCTMbufmgr.h" |
|
32 #include "TestSuiteCTMbufmgr.h" |
|
33 |
|
34 #include "Test22Append.h" |
|
35 |
|
36 // constructor |
|
37 CTest22Append::CTest22Append() |
|
38 { |
|
39 iTestStepName = _L("MBufMgrTest22");// Store the name of this test case |
|
40 } |
|
41 |
|
42 // destructor |
|
43 CTest22Append::~CTest22Append() |
|
44 { |
|
45 } |
|
46 |
|
47 // |
|
48 enum TVerdict CTest22Append::doTestStepL(void) |
|
49 { |
|
50 __UHEAP_MARK; |
|
51 |
|
52 #ifdef __CFLOG_ACTIVE |
|
53 __CFLOG_CREATEL; |
|
54 __CFLOG_OPEN; |
|
55 #endif |
|
56 |
|
57 //-------------- substep 1 -------------------- |
|
58 Log(_L(" 01 Create CMBufManager and install active scheduler:")); |
|
59 CleanupStack::PushL( iActSch = new(ELeave) CActiveScheduler ); |
|
60 CActiveScheduler::Install(iActSch); |
|
61 |
|
62 RArray<TCommsBufPoolCreateInfo> poolInfoArray; |
|
63 TCommsBufPoolCreateInfo createInfo; |
|
64 createInfo.iBufSize = 128; |
|
65 createInfo.iInitialBufs = 128; |
|
66 createInfo.iGrowByBufs = 64; |
|
67 createInfo.iMinFreeBufs = 40; |
|
68 createInfo.iCeiling = (KMBufDefaultHeapSize / 2)/createInfo.iBufSize; |
|
69 poolInfoArray.AppendL(createInfo); |
|
70 CreateInstanceMBufMgrL(poolInfoArray); |
|
71 CleanupClosePushL(iBufPond); |
|
72 poolInfoArray.Close (); |
|
73 |
|
74 TBool firstFail = EFalse; |
|
75 TBool secondFail = EFalse; |
|
76 TInt ret; |
|
77 RMBufChain chain,chain2; |
|
78 |
|
79 //-------------- substep 2 -------------------- |
|
80 Log(_L(" 02 Append 20 bytes to an empty chain")); |
|
81 ret = chain.Append(20); |
|
82 if (ret != KErrNone) |
|
83 { |
|
84 Log(_L("Error: Couldn't append:")); |
|
85 firstFail = ETrue; |
|
86 } |
|
87 else |
|
88 { |
|
89 if(chain.NumBufs() != 1) |
|
90 { |
|
91 Log(_L("Error: Wrong number of MBufs allocated:")); |
|
92 secondFail = ETrue; |
|
93 } |
|
94 if(chain.Length() != 20) |
|
95 { |
|
96 Log(_L("Error: Wrong number of bytes appended:")); |
|
97 secondFail = ETrue; |
|
98 } |
|
99 //-------------- substep 3 -------------------- |
|
100 Log(_L(" 03 Deallocating RMBufChain")); |
|
101 chain.Free(); |
|
102 } |
|
103 |
|
104 //-------------- substep 4 -------------------- |
|
105 Log(_L(" 04 Append 200 bytes to an empty chain")); |
|
106 ret = chain.Append(200); |
|
107 if (ret != KErrNone) |
|
108 { |
|
109 Log(_L("Error: Couldn't append:")); |
|
110 firstFail = ETrue; |
|
111 } |
|
112 else |
|
113 { |
|
114 if(chain.NumBufs() != 2) |
|
115 { |
|
116 Log(_L("Error: Wrong number of MBufs allocated:")); |
|
117 secondFail = ETrue; |
|
118 } |
|
119 if(chain.Length() != 200) |
|
120 { |
|
121 Log(_L("Error: Wrong number of bytes appended:")); |
|
122 secondFail = ETrue; |
|
123 } |
|
124 //-------------- substep 6 -------------------- |
|
125 Log(_L(" 05 Deallocating RMBufChain")); |
|
126 chain.Free(); |
|
127 } |
|
128 //-------------- substep 6 -------------------- |
|
129 Log(_L(" 06 Append 20 bytes to an existing chain")); |
|
130 ret = chain.Alloc(20); |
|
131 if (ret != KErrNone) |
|
132 { |
|
133 Log(_L("Error: Couldn't allocate initial chain:")); |
|
134 firstFail = ETrue; |
|
135 } |
|
136 else |
|
137 { |
|
138 ret = chain.Append(20); |
|
139 if (ret != KErrNone) |
|
140 { |
|
141 Log(_L("Error: Couldn't append:")); |
|
142 firstFail = ETrue; |
|
143 } |
|
144 else |
|
145 { |
|
146 if(chain.NumBufs() != 1) |
|
147 { |
|
148 Log(_L("Error: Wrong number of MBufs allocated:")); |
|
149 secondFail = ETrue; |
|
150 } |
|
151 if(chain.Length() != 40) |
|
152 { |
|
153 Log(_L("Error: Wrong number of bytes:")); |
|
154 secondFail = ETrue; |
|
155 } |
|
156 //-------------- substep 7 -------------------- |
|
157 Log(_L(" 07 Deallocating RMBufChain")); |
|
158 chain.Free(); |
|
159 } |
|
160 } |
|
161 //-------------- substep 8 -------------------- |
|
162 Log(_L(" 08 Append 200 bytes to an existing chain")); |
|
163 ret = chain.Alloc(20); |
|
164 if (ret != KErrNone) |
|
165 { |
|
166 Log(_L("Error: Couldn't allocate initial chain:")); |
|
167 firstFail = ETrue; |
|
168 } |
|
169 else |
|
170 { |
|
171 ret = chain.Append(200); |
|
172 if (ret != KErrNone) |
|
173 { |
|
174 Log(_L("Error: Couldn't append:")); |
|
175 firstFail = ETrue; |
|
176 } |
|
177 else |
|
178 { |
|
179 if(chain.NumBufs() != 2) |
|
180 { |
|
181 Log(_L("Error: Wrong number of MBufs allocated:")); |
|
182 secondFail = ETrue; |
|
183 } |
|
184 if(chain.Length() != 220) |
|
185 { |
|
186 Log(_L("Error: Wrong number of bytes:")); |
|
187 secondFail = ETrue; |
|
188 } |
|
189 //-------------- substep 9 -------------------- |
|
190 Log(_L(" 09 Deallocating RMBufChain")); |
|
191 chain.Free(); |
|
192 } |
|
193 } |
|
194 //-------------- substep 10 -------------------- |
|
195 Log(_L(" 10 Append one chain onto another chain")); |
|
196 ret = chain.Alloc(20); |
|
197 if (ret != KErrNone) |
|
198 { |
|
199 Log(_L("Error: Couldn't allocate initial chain:")); |
|
200 firstFail = ETrue; |
|
201 } |
|
202 else |
|
203 { |
|
204 ret = chain2.Alloc(200); |
|
205 if (ret != KErrNone) |
|
206 { |
|
207 Log(_L("Error: Couldn't allocate second chain:")); |
|
208 firstFail = ETrue; |
|
209 } |
|
210 else |
|
211 { |
|
212 RMBuf* first = chain.First(); |
|
213 chain.Append(chain2); |
|
214 |
|
215 if(chain.NumBufs() != 3) |
|
216 { |
|
217 Log(_L("Error: Wrong number of MBufs in the chain:")); |
|
218 secondFail = ETrue; |
|
219 } |
|
220 if(chain.Length() != 220) |
|
221 { |
|
222 Log(_L("Error: Wrong number of bytes:")); |
|
223 secondFail = ETrue; |
|
224 } |
|
225 if(chain.First() != first) |
|
226 { |
|
227 Log(_L("Error: chain2 not appended correctly:")); |
|
228 secondFail = ETrue; |
|
229 } |
|
230 //-------------- substep 11 -------------------- |
|
231 Log(_L(" 11 Deallocating RMBufChains")); |
|
232 chain2.Free(); |
|
233 } |
|
234 chain.Free(); |
|
235 } |
|
236 //-------------- substep 12 -------------------- |
|
237 Log(_L(" 12 Clean up stack:")); |
|
238 CleanupStack::PopAndDestroy(); // pond |
|
239 CActiveScheduler::Install(NULL); |
|
240 CleanupStack::PopAndDestroy(iActSch); |
|
241 |
|
242 #ifdef __CFLOG_ACTIVE |
|
243 __CFLOG_CLOSE; |
|
244 __CFLOG_DELETE; |
|
245 #endif |
|
246 __UHEAP_MARKEND; |
|
247 |
|
248 if (firstFail || secondFail) |
|
249 { |
|
250 return EFail; |
|
251 } |
|
252 |
|
253 return EPass; |
|
254 } |
|