|
1 // Copyright (c) 2001-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 // PsdAgtTestClosure.cpp |
|
15 // This contains PsdAgt TestCase Test 13.1 - 13.2 |
|
16 // |
|
17 // |
|
18 |
|
19 // EPOC includes |
|
20 #include <e32base.h> |
|
21 #include <in_sock.h> |
|
22 |
|
23 // Test system includes |
|
24 #include "networking/log.h" |
|
25 #include "networking/teststep.h" |
|
26 #include "TestStepPsdAgt.h" |
|
27 #include "TestSuitePsdAgt.h" |
|
28 |
|
29 // COMMDB Database Undo |
|
30 #include "DbUndo.h" |
|
31 |
|
32 // RPacketContext |
|
33 #include <etelpckt.h> |
|
34 |
|
35 // EPsdStartingConfiguration |
|
36 #include <psdprog.h> |
|
37 |
|
38 // EConnectionOpen |
|
39 #include <connectprog.h> |
|
40 |
|
41 // Class definitions |
|
42 #include "PsdAgtTestOOM.h" |
|
43 |
|
44 |
|
45 #define MaxAllocationFailures 1000 |
|
46 |
|
47 // Test case 15.1 |
|
48 enum TVerdict CPsdAgtTest15_1::doPsdAgtTestStepL( void ) |
|
49 { |
|
50 TInt failCount=1; |
|
51 TInt ret=-1; |
|
52 |
|
53 TRealAgtNotify agtNotify; |
|
54 |
|
55 agtNotify.SetTestCase(1501); |
|
56 |
|
57 while(failCount < MaxAllocationFailures) |
|
58 { |
|
59 // Mark heap and set allocation to fail |
|
60 __UHEAP_MARK; |
|
61 __UHEAP_FAILNEXT(failCount); |
|
62 |
|
63 Log(_L("Incrementing __HEAP_FAILNEXT() to %d"),failCount); |
|
64 |
|
65 // Connect, most likely fail at some point |
|
66 TRAP(ret,NormalConnectOOML()); |
|
67 |
|
68 User::After(200000); // Allow async libraries to unload |
|
69 |
|
70 // Check all heap is free'd |
|
71 __UHEAP_MARKEND; |
|
72 |
|
73 if(ret == 0) |
|
74 { |
|
75 // Allocation failure has been moved all the way through the test |
|
76 // Succeeded after failCount allocations |
|
77 return iTestStepResult; |
|
78 } |
|
79 else |
|
80 { |
|
81 Log(_L("NormalConnectL : Failed with %d"),ret); |
|
82 |
|
83 // Reset test result to pass since the allocation failure most |
|
84 // likely caused it to fail |
|
85 iTestStepResult = EPass; |
|
86 |
|
87 // Try failing a little further into the process |
|
88 failCount++; |
|
89 } |
|
90 } |
|
91 |
|
92 // We must have reached our maximum number of allocation failures |
|
93 // There must be some other problem within the NormalConnect() function |
|
94 iTestStepResult=EFail; |
|
95 |
|
96 return iTestStepResult; |
|
97 } |
|
98 |
|
99 // Test case 15.2 |
|
100 enum TVerdict CPsdAgtTest15_2::doPsdAgtTestStepL( void ) |
|
101 { |
|
102 TInt failCount=1; |
|
103 TInt ret=-1; |
|
104 |
|
105 TRealAgtNotify agtNotify; |
|
106 agtNotify.SetTestCase(1502); |
|
107 SetGPRSModeL(agtNotify); |
|
108 |
|
109 while(failCount < MaxAllocationFailures) |
|
110 { |
|
111 // Mark heap and set allocation to fail |
|
112 __UHEAP_MARK; |
|
113 __UHEAP_FAILNEXT(failCount); |
|
114 |
|
115 Log(_L("Incrementing __HEAP_FAILNEXT() to %d"),failCount); |
|
116 |
|
117 // Connect, most likely fail at some point |
|
118 TRAP(ret,NormalConnectOOML()); |
|
119 |
|
120 User::After(200000); // Allow async libraries to unload |
|
121 |
|
122 // Check all heap is free'd |
|
123 __UHEAP_MARKEND; |
|
124 |
|
125 |
|
126 if(ret==0) |
|
127 { |
|
128 // Allocation failure has been moved all the way through the test |
|
129 // Succeeded after failCount allocations |
|
130 return iTestStepResult; |
|
131 } |
|
132 else |
|
133 { |
|
134 // Reset test result to pass since the allocation failure most |
|
135 // likely caused it to fail |
|
136 iTestStepResult = EPass; |
|
137 |
|
138 // Try failing a little further into the process |
|
139 failCount++; |
|
140 } |
|
141 } |
|
142 |
|
143 // We must have reached our maximum number of allocation failures |
|
144 // There must be some other problem within the NormalConnect() function |
|
145 iTestStepResult=EFail; |
|
146 |
|
147 return iTestStepResult; |
|
148 } |
|
149 |
|
150 // Test case 15.3 |
|
151 enum TVerdict CPsdAgtTest15_3::doPsdAgtTestStepL( void ) |
|
152 { |
|
153 TInt failCount=1; |
|
154 TInt ret=-1; |
|
155 |
|
156 TRealAgtNotify agtNotify; |
|
157 agtNotify.SetTestCase(1503); |
|
158 |
|
159 while(failCount < MaxAllocationFailures) |
|
160 { |
|
161 // Mark heap and set allocation to fail |
|
162 __UHEAP_MARK; |
|
163 __UHEAP_FAILNEXT(failCount); |
|
164 |
|
165 Log(_L("Incrementing __HEAP_FAILNEXT() to %d"),failCount); |
|
166 |
|
167 // Connect, most likely fail at some point |
|
168 TRAP(ret,ReConnectOOML()); |
|
169 |
|
170 User::After(200000); // Allow async libraries to unload |
|
171 |
|
172 // Check all heap is free'd |
|
173 __UHEAP_MARKEND; |
|
174 |
|
175 |
|
176 if(ret==0) |
|
177 { |
|
178 // Allocation failure has been moved all the way through the test |
|
179 // Succeeded after failCount allocations |
|
180 return iTestStepResult; |
|
181 } |
|
182 else |
|
183 { |
|
184 // Reset test result to pass since the allocation failure most |
|
185 // likely caused it to fail |
|
186 iTestStepResult = EPass; |
|
187 |
|
188 // Try failing a little further into the process |
|
189 failCount++; |
|
190 } |
|
191 } |
|
192 |
|
193 // We must have reached our maximum number of allocation failures |
|
194 // There must be some other problem within the ReConnectL() function |
|
195 iTestStepResult=EFail; |
|
196 |
|
197 return iTestStepResult; |
|
198 } |
|
199 |
|
200 // Test case 15.4 |
|
201 enum TVerdict CPsdAgtTest15_4::doPsdAgtTestStepL( void ) |
|
202 { |
|
203 TInt failCount=1; |
|
204 TInt ret=-1; |
|
205 |
|
206 TRealAgtNotify agtNotify; |
|
207 agtNotify.SetTestCase(1504); |
|
208 SetGPRSModeL(agtNotify); |
|
209 |
|
210 while(failCount < MaxAllocationFailures) |
|
211 { |
|
212 // Mark heap and set allocation to fail |
|
213 __UHEAP_MARK; |
|
214 __UHEAP_FAILNEXT(failCount); |
|
215 |
|
216 Log(_L("Incrementing __HEAP_FAILNEXT()to %d"),failCount); |
|
217 |
|
218 // Connect, most likely fail at some point |
|
219 TRAP(ret,ReConnectOOML()); |
|
220 |
|
221 User::After(200000); // Allow async libraries to unload |
|
222 |
|
223 // Check all heap is free'd |
|
224 __UHEAP_MARKEND; |
|
225 |
|
226 |
|
227 if(ret==0) |
|
228 { |
|
229 // Allocation failure has been moved all the way through the test |
|
230 // Succeeded after failCount allocations |
|
231 return iTestStepResult; |
|
232 } |
|
233 else |
|
234 { |
|
235 // Reset test result to pass since the allocation failure most |
|
236 // likely caused it to fail |
|
237 iTestStepResult = EPass; |
|
238 |
|
239 // Try failing a little further into the process |
|
240 failCount++; |
|
241 } |
|
242 } |
|
243 |
|
244 // We must have reached our maximum number of allocation failures |
|
245 // There must be some other problem within the NormalConnect() function |
|
246 iTestStepResult=EFail; |
|
247 |
|
248 return iTestStepResult; |
|
249 } |