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