|
1 // Copyright (c) 2003-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 // EPOC includes |
|
17 #include <e32base.h> |
|
18 |
|
19 // Test system includes |
|
20 #include <networking/log.h> |
|
21 #include <networking/testsuite.h> |
|
22 |
|
23 // Test includes |
|
24 #include "ts_esockutilsteps.h" |
|
25 #include "esockloader.h" |
|
26 #include "esocktestutils.h" |
|
27 |
|
28 class TTruncateOverflow16 : public TDes16Overflow |
|
29 { |
|
30 public: |
|
31 virtual void Overflow(TDes16&) |
|
32 { |
|
33 } |
|
34 }; |
|
35 |
|
36 class TTruncateOverflow8 : public TDes8Overflow |
|
37 { |
|
38 public: |
|
39 virtual void Overflow(TDes8&) |
|
40 { |
|
41 } |
|
42 }; |
|
43 |
|
44 void CTestStepESockUtil::Log(TRefByValue<const TDesC16> aFormat, ...) |
|
45 { |
|
46 VA_LIST vaList; |
|
47 VA_START( vaList, aFormat ); |
|
48 |
|
49 TTruncateOverflow16 truncateOverflow; |
|
50 TBuf<512> buf; |
|
51 buf.AppendFormatList( aFormat, vaList, &truncateOverflow ); |
|
52 |
|
53 // write to the console |
|
54 CTestStep::Log(_L("%S"), &buf); |
|
55 } |
|
56 |
|
57 void CTestStepESockUtil::Log(TRefByValue<const TDesC8> aFormat, ...) |
|
58 { |
|
59 VA_LIST vaList; |
|
60 VA_START( vaList, aFormat ); |
|
61 |
|
62 TTruncateOverflow8 truncateOverflow; |
|
63 TBuf8<512> buf; |
|
64 buf.AppendFormatList( aFormat, vaList, &truncateOverflow ); |
|
65 TBuf<512> dispBuf; |
|
66 dispBuf.Copy(buf); |
|
67 |
|
68 // write to the console |
|
69 CTestStep::Log(_L("%S"), &dispBuf); |
|
70 } |
|
71 |
|
72 CTestStepLoadESock::CTestStepLoadESock() |
|
73 { |
|
74 iTestStepName = _L("ESockUtilLoadESock"); |
|
75 } |
|
76 |
|
77 enum TVerdict CTestStepLoadESock::doTestStepL(void) |
|
78 { |
|
79 TVerdict verdict = EPass; |
|
80 |
|
81 TInt err(ESockLoader::LoadESock(this)); |
|
82 if(err!=KErrNone) |
|
83 { |
|
84 verdict = EFail; |
|
85 Log(_L("LoadESock returned error %d"), err); |
|
86 } |
|
87 return verdict; |
|
88 } |
|
89 |
|
90 CTestStepUnloadESock::CTestStepUnloadESock() |
|
91 { |
|
92 iTestStepName = _L("ESockUtilUnloadESock"); |
|
93 } |
|
94 |
|
95 enum TVerdict CTestStepUnloadESock::doTestStepL(void) |
|
96 { |
|
97 TVerdict verdict = EPass; |
|
98 |
|
99 TInt err(ESockLoader::UnloadESock(EGraceful, this)); |
|
100 if(err!=KErrNone) |
|
101 { |
|
102 verdict = EFail; |
|
103 Log(_L("UnloadESock returned error %d"), err); |
|
104 } |
|
105 return verdict; |
|
106 } |
|
107 |
|
108 CTestStepUnloadESockBase::CTestStepUnloadESockBase(TLeak aLeak) : |
|
109 iLeak(aLeak) |
|
110 { |
|
111 } |
|
112 |
|
113 enum TVerdict CTestStepUnloadESockBase::doTestStepL(void) |
|
114 { |
|
115 TVerdict verdict = EPass; |
|
116 |
|
117 TInt err(ESockLoader::UnloadESock(EImmediate, this)); |
|
118 |
|
119 verdict = EFail; |
|
120 switch (err) |
|
121 { |
|
122 case KErrNone: |
|
123 { |
|
124 if (iLeak == ELeaks) |
|
125 { |
|
126 INFO_PRINTF1(_L("We were expecting a leak and non occurred : check that the leak-detecion machnism is working.")); |
|
127 verdict = EFail; |
|
128 } |
|
129 else |
|
130 { |
|
131 verdict = EPass; |
|
132 } |
|
133 break; |
|
134 } |
|
135 case KErrSessionClosed: |
|
136 { |
|
137 INFO_PRINTF2(_L("UnloadESock returned %d. ESock had still had unclosed sessions when exiting."), err); |
|
138 break; |
|
139 } |
|
140 case ESockLoader::KModuleLeaked: |
|
141 { |
|
142 INFO_PRINTF1(_L("A memory leak was detected on shutdown.")); |
|
143 INFO_PRINTF1(_L("Expect leaks if a panic occurred - Check the epocwind.out.")); |
|
144 if (iLeak == EMayLeak || iLeak == ELeaks) |
|
145 { |
|
146 verdict = EPass; |
|
147 } |
|
148 #ifdef ALWAYS_PASS_UNLOAD |
|
149 verdict = EPass; |
|
150 #endif |
|
151 break; |
|
152 } |
|
153 default: |
|
154 { |
|
155 INFO_PRINTF2(_L("UnloadESock returned error %d"), err); |
|
156 } |
|
157 } |
|
158 return verdict; |
|
159 } |
|
160 |
|
161 CTestStepUnloadESockForced::CTestStepUnloadESockForced() : |
|
162 CTestStepUnloadESockBase(CTestStepUnloadESockBase::ENoLeak) |
|
163 { |
|
164 iTestStepName = _L("ESockUtilUnloadESockForced"); |
|
165 } |
|
166 |
|
167 |
|
168 CTestStepUnloadESockMayLeak::CTestStepUnloadESockMayLeak() : |
|
169 CTestStepUnloadESockBase(CTestStepUnloadESockBase::EMayLeak) |
|
170 { |
|
171 iTestStepName = _L("ESockUtilUnloadESock_MayLeak"); |
|
172 } |
|
173 |
|
174 CTestStepUnloadESockLeaks::CTestStepUnloadESockLeaks() : |
|
175 CTestStepUnloadESockBase(CTestStepUnloadESockBase::ELeaks) |
|
176 { |
|
177 iTestStepName = _L("ESockUtilUnloadESock_Leaks"); |
|
178 } |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 CTestStepStopAllInterfaces::CTestStepStopAllInterfaces() |
|
185 { |
|
186 iTestStepName = _L("StopAllInterfaces"); |
|
187 } |
|
188 |
|
189 enum TVerdict CTestStepStopAllInterfaces::doTestStepL(void) |
|
190 { |
|
191 TVerdict verdict = EPass; |
|
192 |
|
193 TBuf<1000> errDesc; |
|
194 TInt err(ESockTestUtils::StopAllInterfaces(errDesc)); |
|
195 if(err!=KErrNone) |
|
196 { |
|
197 verdict = EFail; |
|
198 Log(_L("StopAllInterfaces returned error %d:\n%S"), err, &errDesc); |
|
199 } |
|
200 return verdict; |
|
201 } |
|
202 |
|
203 CTestStepDefaultToConfig1::CTestStepDefaultToConfig1() |
|
204 { |
|
205 iTestStepName = _L("DefaultToConfig1"); |
|
206 } |
|
207 |
|
208 enum TVerdict CTestStepDefaultToConfig1::doTestStepL(void) |
|
209 { |
|
210 ESockTestUtils::DefaultToConfig1L(); |
|
211 return EPass; |
|
212 } |
|
213 |
|
214 CTestStepAlwaysFail::CTestStepAlwaysFail() |
|
215 { |
|
216 iTestStepName = _L("AlwaysFail"); |
|
217 } |
|
218 |
|
219 enum TVerdict CTestStepAlwaysFail::doTestStepL(void) |
|
220 { |
|
221 return EFail; |
|
222 } |
|
223 |
|
224 |
|
225 |
|
226 |