|
1 // Copyright (c) 2005-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 #include "ptestcases.h" |
|
17 |
|
18 #ifdef SYMBIAN_OLD_EXPORT_LOCATION |
|
19 #include "es_dummy.h" |
|
20 #else |
|
21 #include <test/es_dummy.h> |
|
22 #endif |
|
23 #include "es_ptestinternalsocket.h" |
|
24 #include <es_mbuf.h> |
|
25 #include <es_sock_internal.h> |
|
26 #include "agregate.h" |
|
27 #include "ss_eintsock_msgs.h" |
|
28 #include <elements/nm_address_internal.h> |
|
29 |
|
30 #ifdef _DEBUG |
|
31 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
32 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
33 _LIT(KSpecAssert_ESockTestptstcs, "ESockTestptstcs."); |
|
34 #endif |
|
35 |
|
36 |
|
37 //------------------------------------------------------------------------------------------------- |
|
38 // CEIntSockTestBase |
|
39 //------------------------------------------------------------------------------------------------- |
|
40 |
|
41 /** This is a static method that is called to get a given test running |
|
42 @param aTestName The name of the test to be run |
|
43 @the name of the provider starting the test |
|
44 */ |
|
45 |
|
46 //static const TInt KWaitInterval = 10000; //Wait 10 milliseconds before doing checks; |
|
47 //static const TInt KMaxNumWait = 100; // Wait KWaitIntercal 100 times; |
|
48 |
|
49 #define BEGIN_TESTLIST |
|
50 |
|
51 #define ADD_TEST(name) \ |
|
52 if (aTestName == _L(#name))\ |
|
53 {\ |
|
54 return CEIntSock ## name::NewL(aProvd);\ |
|
55 } |
|
56 |
|
57 #define END_TESTLIST \ |
|
58 User::Leave(KErrNotSupported);\ |
|
59 return NULL; |
|
60 |
|
61 CEIntSockTestBase* CEIntSockTestBase::CreateTestL(const TDesC& aTestName, CProxyProvd* aProvd) |
|
62 { |
|
63 BEGIN_TESTLIST |
|
64 ADD_TEST(Test1) |
|
65 ADD_TEST(Test2) |
|
66 ADD_TEST(Test3) |
|
67 ADD_TEST(Test4) |
|
68 ADD_TEST(Test5) |
|
69 ADD_TEST(Test6) |
|
70 ADD_TEST(Test7) |
|
71 ADD_TEST(Test8) |
|
72 ADD_TEST(Test9) |
|
73 ADD_TEST(Test10) |
|
74 ADD_TEST(Test11) |
|
75 ADD_TEST(Test12) |
|
76 ADD_TEST(Test13) |
|
77 ADD_TEST(Test14) |
|
78 ADD_TEST(Test15) |
|
79 ADD_TEST(Test16) |
|
80 ADD_TEST(Test17) |
|
81 ADD_TEST(Test18) |
|
82 ADD_TEST(Test19) |
|
83 ADD_TEST(Test20) |
|
84 ADD_TEST(Test21) |
|
85 ADD_TEST(Test22) |
|
86 ADD_TEST(Test23) |
|
87 ADD_TEST(Test25A) |
|
88 ADD_TEST(Test25B) |
|
89 ADD_TEST(Test25C) |
|
90 ADD_TEST(Test26) |
|
91 ADD_TEST(Test27) |
|
92 ADD_TEST(Test28A) |
|
93 ADD_TEST(Test28B) |
|
94 ADD_TEST(Test29) |
|
95 ADD_TEST(Test30) |
|
96 ADD_TEST(Test31) |
|
97 ADD_TEST(Test32) |
|
98 ADD_TEST(Test33) |
|
99 ADD_TEST(Test34) |
|
100 ADD_TEST(Test35) |
|
101 ADD_TEST(Test36) |
|
102 ADD_TEST(Test37) |
|
103 ADD_TEST(Test38) |
|
104 ADD_TEST(Test39) |
|
105 ADD_TEST(Test40) |
|
106 ADD_TEST(Test41) |
|
107 ADD_TEST(Test42) |
|
108 ADD_TEST(Test43) |
|
109 ADD_TEST(Test44) |
|
110 ADD_TEST(Test45) |
|
111 ADD_TEST(Test46) |
|
112 ADD_TEST(Test47) |
|
113 ADD_TEST(Test48) |
|
114 ADD_TEST(Test49) |
|
115 ADD_TEST(Test50) |
|
116 ADD_TEST(Test51) |
|
117 ADD_TEST(Test52) |
|
118 ADD_TEST(Test53) |
|
119 ADD_TEST(Test54) |
|
120 ADD_TEST(Test55) |
|
121 ADD_TEST(Test56) |
|
122 ADD_TEST(Test57) |
|
123 ADD_TEST(Test58) |
|
124 ADD_TEST(Test59) |
|
125 ADD_TEST(Test60) |
|
126 ADD_TEST(Test61) |
|
127 END_TESTLIST |
|
128 } |
|
129 |
|
130 |
|
131 void CEIntSockTestBase::StartTestL(const TDesC& aTestName, CProxyProvd* aProvd) |
|
132 { |
|
133 CEIntSockTestBase* test = CreateTestL(aTestName,aProvd); |
|
134 CleanupStack::PushL(test); |
|
135 test->CEIntSockTestBase::ConstructL(); |
|
136 CActiveScheduler::Add(test); |
|
137 CleanupStack::Pop(test); |
|
138 TRequestStatus* stat = &test->iStatus; |
|
139 test->SetActive(); |
|
140 User::RequestComplete(stat,KErrNone); |
|
141 } |
|
142 |
|
143 CEIntSockTestBase::CEIntSockTestBase(CProxyProvd* aProvd) : |
|
144 CActive(EPriorityNormal), |
|
145 iProvd(aProvd) |
|
146 { |
|
147 iProvd->SetTestStepNotify(this); |
|
148 } |
|
149 |
|
150 void CEIntSockTestBase::ConstructL() |
|
151 { |
|
152 SetLoggerL(); |
|
153 } |
|
154 |
|
155 CEIntSockTestBase::~CEIntSockTestBase() |
|
156 { |
|
157 if(iProvd) |
|
158 { |
|
159 iProvd->SetTestStepNotify(NULL); |
|
160 } |
|
161 iLogger.Close(); |
|
162 } |
|
163 |
|
164 /** Override this function if you want cleanup to happen before the completion of |
|
165 the test case. This function is called before the test is completed |
|
166 */ |
|
167 void CEIntSockTestBase::Cleanup() |
|
168 {} |
|
169 |
|
170 /** Sets the test case as active again and prevents the object from being destroyed |
|
171 when the RunL completes. |
|
172 |
|
173 Note: The active object is not complete the request again automatically, if this behaviour is |
|
174 desired the user must call User::RequestComplete |
|
175 */ |
|
176 void CEIntSockTestBase::Reschedule() |
|
177 { |
|
178 SetActive(); |
|
179 iReschedule = TRUE; |
|
180 } |
|
181 |
|
182 /** Attaches the iLogger variable to the TestExecute Log Server. This enable this prt to write to |
|
183 the testexecute logs as if it were running directly from TestExecute |
|
184 */ |
|
185 // SetLoggerL() is taken directly from CTestServer::StartLoggerL() in the TEF src TestServerBase.Cpp |
|
186 |
|
187 |
|
188 void CEIntSockTestBase::SetLoggerL() |
|
189 { |
|
190 // Create a cinidata object for parsing the testexecute.ini |
|
191 CTestExecuteIniData* parseTestExecuteIni = NULL; |
|
192 TBuf<KMaxTestExecuteNameLength> resultFilePath; |
|
193 TBuf<KMaxTestExecuteNameLength> xmlFilePath; |
|
194 TInt logMode; |
|
195 TInt logLevel; |
|
196 |
|
197 TRAPD(err,parseTestExecuteIni = CTestExecuteIniData::NewL()); |
|
198 if (err == KErrNone) |
|
199 { |
|
200 CleanupStack::PushL(parseTestExecuteIni); |
|
201 parseTestExecuteIni->ExtractValuesFromIni(); |
|
202 parseTestExecuteIni->GetKeyValueFromIni(KTEFHtmlKey, resultFilePath); |
|
203 parseTestExecuteIni->GetKeyValueFromIni(KTEFXmlKey, xmlFilePath); |
|
204 parseTestExecuteIni->GetKeyValueFromIni(KTEFLogMode, logMode); |
|
205 parseTestExecuteIni->GetKeyValueFromIni(KTEFLogSeverityKey, logLevel); |
|
206 } |
|
207 else |
|
208 { |
|
209 resultFilePath.Copy(KTestExecuteLogPath); |
|
210 xmlFilePath.Copy(KTestExecuteLogPath); |
|
211 logMode = TLoggerOptions(ELogHTMLOnly); |
|
212 logLevel = RFileFlogger::TLogSeverity(ESevrAll); |
|
213 } |
|
214 Logger().SetLoggerOptions(logMode); |
|
215 |
|
216 // Initialise a handle to the file logger |
|
217 User::LeaveIfError(Logger().Connect()); |
|
218 RFs fS; |
|
219 User::LeaveIfError(fS.Connect()); |
|
220 CleanupClosePushL(fS); |
|
221 RFile file; |
|
222 TBuf<KMaxTestExecuteNameLength> xmlLogFile(xmlFilePath); |
|
223 TBuf<KMaxTestExecuteNameLength> logFile; |
|
224 TBuf<KMaxTestExecuteNameLength> logFileNameFile(resultFilePath); |
|
225 logFileNameFile.Append(KTestExecuteScheduleTestLogCompatibilityNameFile); |
|
226 if(file.Open(fS,logFileNameFile,EFileRead | EFileShareAny) != KErrNone) |
|
227 { |
|
228 // For the old flogger we have to create an individual file |
|
229 _LIT(KTxtLog,"TEIntSock.txt"); |
|
230 logFile.Copy(KTxtLog); |
|
231 logMode = TLoggerOptions(0); |
|
232 Logger().SetLoggerOptions(logMode); |
|
233 } |
|
234 else |
|
235 { |
|
236 CleanupClosePushL(file); |
|
237 TBuf8<KMaxTestExecuteNameLength> logFile8; |
|
238 TInt fileSize; |
|
239 User::LeaveIfError(file.Size(fileSize)); |
|
240 User::LeaveIfError(file.Read(logFile8,fileSize)); |
|
241 logFile.Copy(logFile8); |
|
242 xmlLogFile.Append(logFile); |
|
243 _LIT(KXmlExtension,".xml"); |
|
244 xmlLogFile.Append(KXmlExtension); |
|
245 _LIT(KHtmExtension,".htm"); |
|
246 logFile.Append(KHtmExtension); |
|
247 CleanupStack::Pop(&file); |
|
248 file.Close(); |
|
249 } |
|
250 TBuf<KMaxTestExecuteLogFilePath> logFilePath(resultFilePath); |
|
251 logFilePath.Append(logFile); |
|
252 CleanupStack::Pop(&fS); |
|
253 fS.Close(); |
|
254 |
|
255 if (logMode == 0 || logMode == 2) |
|
256 { |
|
257 User::LeaveIfError(Logger().HtmlLogger().CreateLog(logFilePath, RTestExecuteLogServ::ELogModeAppend)); |
|
258 } |
|
259 if (logMode == 1 || logMode == 2) |
|
260 { |
|
261 User::LeaveIfError(Logger().XmlLogger().CreateLog(xmlLogFile,RFileFlogger::ELogModeAppend)); |
|
262 Logger().XmlLogger().SetLogLevel(RFileFlogger::TLogSeverity(logLevel)); |
|
263 } |
|
264 if (parseTestExecuteIni != NULL) |
|
265 { |
|
266 CleanupStack::PopAndDestroy(parseTestExecuteIni); |
|
267 } |
|
268 } |
|
269 |
|
270 |
|
271 |
|
272 /** Called by the active scheduler in order to run the test |
|
273 */ |
|
274 void CEIntSockTestBase::RunL() |
|
275 { |
|
276 iReschedule = EFalse; |
|
277 TVerdict res = RunTestL(); |
|
278 if (!iReschedule) |
|
279 { |
|
280 Cleanup(); |
|
281 FinishTest(res); |
|
282 delete this; |
|
283 return; |
|
284 } |
|
285 } |
|
286 |
|
287 void CEIntSockTestBase::AboutToShutdown() |
|
288 { |
|
289 // Complete the client before the provider is deleted. |
|
290 FinishTest(EPass); |
|
291 iProvd = NULL; |
|
292 } |
|
293 |
|
294 void CEIntSockTestBase::FinishTest(TVerdict aResult) |
|
295 { |
|
296 if(iProvd) |
|
297 { |
|
298 iProvd->TestComplete(aResult); |
|
299 } |
|
300 } |
|
301 |
|
302 void CEIntSockTestBase::DoCancel() |
|
303 { |
|
304 Cleanup(); |
|
305 } |
|
306 |
|
307 //------------------------------------------------------------------------------------------------- |
|
308 // CEIntSockTest1 |
|
309 //------------------------------------------------------------------------------------------------- |
|
310 |
|
311 CEIntSockTestBase* CEIntSockTest1::NewL(CProxyProvd* aProvd) |
|
312 { |
|
313 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest1(aProvd); |
|
314 return ret; |
|
315 } |
|
316 |
|
317 CEIntSockTest1::CEIntSockTest1(CProxyProvd* aProvd) : |
|
318 CEIntSockTestBase(aProvd) |
|
319 {} |
|
320 |
|
321 TVerdict CEIntSockTest1::RunTestL() |
|
322 { |
|
323 |
|
324 TInt err; |
|
325 _LIT(KDescSillyProtocol, "trifle"); |
|
326 iLogger.WriteFormat(_L("<i>Test 1 - Open and close socket to non-existent protocol</i>")); |
|
327 |
|
328 iLogger.WriteFormat(_L("<i>Open socket to protocol - name passed as parameter does not exist</i>")); |
|
329 err = iSocket.Open(KDescSillyProtocol); |
|
330 if (err != KErrNotFound) |
|
331 { |
|
332 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
333 return EFail; |
|
334 } |
|
335 |
|
336 iLogger.WriteFormat(_L("<i>Open socket to protocol - address family does not exist</i>")); |
|
337 err = iSocket.Open(KDummyAddrFamily, KSockDatagram, 123411); //Some arbitary number |
|
338 if (err != KErrBadName) |
|
339 { |
|
340 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
341 return EFail; |
|
342 } |
|
343 return EPass; |
|
344 } |
|
345 |
|
346 void CEIntSockTest1::Cleanup() |
|
347 { |
|
348 iSocket.Close(); |
|
349 } |
|
350 |
|
351 //------------------------------------------------------------------------------------------------- |
|
352 // CEIntSockTest2 |
|
353 //------------------------------------------------------------------------------------------------- |
|
354 |
|
355 CEIntSockTestBase* CEIntSockTest2::NewL(CProxyProvd* aProvd) |
|
356 { |
|
357 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest2(aProvd); |
|
358 return ret; |
|
359 } |
|
360 |
|
361 CEIntSockTest2::CEIntSockTest2(CProxyProvd* aProvd) : |
|
362 CEIntSockTestBase(aProvd) |
|
363 {} |
|
364 |
|
365 TVerdict CEIntSockTest2::RunTestL() |
|
366 { |
|
367 TInt err; |
|
368 iLogger.WriteFormat(_L("<i>Test 2 - Open and close socket</i>")); |
|
369 iLogger.WriteFormat(_L("<i>Open socket to protocol by name</i>")); |
|
370 err = iSocket.Open(KDummyTwoName); |
|
371 if (err != KErrNone) |
|
372 { |
|
373 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
374 return EFail; |
|
375 } |
|
376 iSocket.Close(); |
|
377 iLogger.WriteFormat(_L("<i>Open socket to protocol supplying address family</i>")); |
|
378 err = iSocket.Open(KDummyAddrFamily, KSockDatagram, KDummyOne); |
|
379 if (err != KErrNone) |
|
380 { |
|
381 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
382 return EFail; |
|
383 } |
|
384 |
|
385 iSocket.Close(); |
|
386 // this is a null socket for use with accept, can't specify protocol as no parameters |
|
387 iLogger.WriteFormat(_L("<i>Open null socket</i>")); |
|
388 err = iSocket.Open(); |
|
389 if (err != KErrNone) |
|
390 { |
|
391 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
392 return EFail; |
|
393 } |
|
394 return EPass; |
|
395 } |
|
396 |
|
397 void CEIntSockTest2::Cleanup() |
|
398 { |
|
399 iSocket.Close(); |
|
400 } |
|
401 |
|
402 //------------------------------------------------------------------------------------------------- |
|
403 // CEIntSockTest3 |
|
404 //------------------------------------------------------------------------------------------------- |
|
405 |
|
406 CEIntSockTestBase* CEIntSockTest3::NewL(CProxyProvd* aProvd) |
|
407 { |
|
408 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest3(aProvd); |
|
409 return ret; |
|
410 } |
|
411 |
|
412 CEIntSockTest3::CEIntSockTest3(CProxyProvd* aProvd) : |
|
413 CEIntSockTestBase(aProvd) |
|
414 {} |
|
415 |
|
416 TVerdict CEIntSockTest3::RunTestL() |
|
417 { |
|
418 TSockAddr localAddr(KProxyAddrFamily); |
|
419 TInt err; |
|
420 iLogger.WriteFormat(_L("<i>Test 3 - Binding</i>")); |
|
421 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 2</i>")); |
|
422 err = iSocket.Open(KDummyTwoName); |
|
423 if (err != KErrNone) |
|
424 { |
|
425 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
426 return EFail; |
|
427 } |
|
428 |
|
429 iLogger.WriteFormat(_L("<i>Binding socket to TSockAddr</i>")); |
|
430 err = iSocket.Bind(localAddr); |
|
431 if (err != KErrNone) |
|
432 { |
|
433 iLogger.WriteFormat(_L("<i>Bind() failed with %d</i>"),err); |
|
434 return EFail; |
|
435 } |
|
436 |
|
437 iLogger.WriteFormat(_L("<i>Checking LocalName() returns the correct address following the bind</i>")); |
|
438 TSockAddr actualAddr; |
|
439 iSocket.LocalName(actualAddr); |
|
440 if (actualAddr != localAddr) |
|
441 { |
|
442 iLogger.WriteFormat(_L("<i>Name didn't match the one passed to Bind()</i>")); |
|
443 return EFail; |
|
444 } |
|
445 |
|
446 iLogger.WriteFormat(_L("<i>Closing the socket</i>")); |
|
447 iSocket.Close(); |
|
448 |
|
449 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 2</i>")); |
|
450 err = iSocket.Open(KDummyTwoName); |
|
451 if (err != KErrNone) |
|
452 { |
|
453 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
454 return EFail; |
|
455 } |
|
456 iLogger.WriteFormat(_L("<i>Setting local port of socket</i>")); |
|
457 TUint localPort = 7; |
|
458 err = iSocket.SetLocalPort(localPort); |
|
459 if (err != KErrNone) |
|
460 { |
|
461 iLogger.WriteFormat(_L("<i>SetLocalPort() failed with %d</i>"),err); |
|
462 return EFail; |
|
463 } |
|
464 |
|
465 iLogger.WriteFormat(_L("<i>Checking LocalPort() returns the correct port number following the bind</i>")); |
|
466 TUint actualPort; |
|
467 actualPort = iSocket.LocalPort(); |
|
468 if (actualPort != localPort) |
|
469 { |
|
470 iLogger.WriteFormat(_L("<i>Port didn't match the one passed to SetLocalPort()</i>")); |
|
471 return EFail; |
|
472 } |
|
473 return EPass; |
|
474 } |
|
475 |
|
476 void CEIntSockTest3::Cleanup() |
|
477 { |
|
478 iSocket.Close(); |
|
479 } |
|
480 |
|
481 |
|
482 //------------------------------------------------------------------------------------------------- |
|
483 // CEIntSockTest4 |
|
484 //------------------------------------------------------------------------------------------------- |
|
485 |
|
486 CEIntSockTestBase* CEIntSockTest4::NewL(CProxyProvd* aProvd) |
|
487 { |
|
488 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest4(aProvd); |
|
489 return ret; |
|
490 } |
|
491 |
|
492 CEIntSockTest4::CEIntSockTest4(CProxyProvd* aProvd) : |
|
493 CEIntSockTestBase(aProvd) |
|
494 {} |
|
495 |
|
496 TVerdict CEIntSockTest4::RunTestL() |
|
497 { |
|
498 TInt err; |
|
499 TProtocolDesc info; |
|
500 |
|
501 iLogger.WriteFormat(_L("<i>Test 4 - ProtocolInfo </i>")); |
|
502 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 2</i>")); |
|
503 err = iSocket.Open(KDummyTwoName); |
|
504 if (err != KErrNone) |
|
505 { |
|
506 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
507 return EFail; |
|
508 } |
|
509 |
|
510 iLogger.WriteFormat(_L("<i>Getting info about the protocol</i>")); |
|
511 err = iSocket.Info(info); |
|
512 if (err != KErrNone) |
|
513 { |
|
514 iLogger.WriteFormat(_L("<i>Info() failed with %d</i>"),err); |
|
515 return EFail; |
|
516 } |
|
517 |
|
518 iLogger.WriteFormat(_L("<i>Checking that the address is of type PDummyAddrFamily</i>")); |
|
519 if (info.iAddrFamily != KDummyAddrFamily) |
|
520 { |
|
521 iLogger.WriteFormat(_L("<i>Address family in return unexpectedly was %X</i>"),info.iAddrFamily); |
|
522 return EFail; |
|
523 } |
|
524 return EPass; |
|
525 } |
|
526 |
|
527 void CEIntSockTest4::Cleanup() |
|
528 { |
|
529 iSocket.Close(); |
|
530 } |
|
531 |
|
532 |
|
533 //------------------------------------------------------------------------------------------------- |
|
534 // CEIntSockTest5 |
|
535 //------------------------------------------------------------------------------------------------- |
|
536 |
|
537 CEIntSockTestBase* CEIntSockTest5::NewL(CProxyProvd* aProvd) |
|
538 { |
|
539 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest5(aProvd); |
|
540 return ret; |
|
541 } |
|
542 |
|
543 CEIntSockTest5::CEIntSockTest5(CProxyProvd* aProvd) : |
|
544 CEIntSockTestBase(aProvd), |
|
545 iState(EState1), iRecvBufPtr(NULL, 0) |
|
546 {} |
|
547 |
|
548 TVerdict CEIntSockTest5::RunTestL() |
|
549 { |
|
550 |
|
551 TInt err; |
|
552 _LIT8(KSendData,"1234567890"); |
|
553 switch (iState) |
|
554 { |
|
555 case EState1: |
|
556 { |
|
557 iLogger.WriteFormat(_L("<i>Test 5 - Send to and receive from a stream protocol (Descriptor API) </i>")); |
|
558 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 2</i>")); |
|
559 err = iSocket.Open(KDummyTwoName); |
|
560 if (err != KErrNone) |
|
561 { |
|
562 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
563 return EFail; |
|
564 } |
|
565 |
|
566 iLogger.WriteFormat(_L("<i>Opening an internal socket (stream protocol)</i>")); |
|
567 |
|
568 iAddress.SetFamily(KProxyAddrFamily); |
|
569 iSocket.Connect(iAddress, iStatus); |
|
570 |
|
571 iState = EState2; |
|
572 Reschedule(); |
|
573 return EPass; |
|
574 } |
|
575 case EState2: |
|
576 { |
|
577 if (iStatus != KErrNone) |
|
578 { |
|
579 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
580 return EFail; |
|
581 } |
|
582 iBuf.Copy ( KSendData() ); |
|
583 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the descriptor API</i>")); |
|
584 iSocket.Send(iBuf,0,iStatus); |
|
585 |
|
586 iState = EState3; |
|
587 Reschedule(); |
|
588 return EPass; |
|
589 } |
|
590 case EState3: |
|
591 { |
|
592 if (iStatus != KErrNone) |
|
593 { |
|
594 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iStatus.Int()); |
|
595 return EFail; |
|
596 } |
|
597 |
|
598 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the descriptor API</i>")); |
|
599 iBuf.Zero(); |
|
600 iBuf.SetLength(KSendData().Length()); |
|
601 iRecvBufPtr.Set(( TUint8* )iBuf.PtrZ(), KSendData().Length(), KSendData().Length()); |
|
602 iSocket.Recv(iRecvBufPtr,0,iStatus); |
|
603 |
|
604 iState = EState4; |
|
605 Reschedule(); |
|
606 return EPass; |
|
607 } |
|
608 case EState4: |
|
609 { |
|
610 if (iStatus != KErrNone) |
|
611 { |
|
612 iLogger.WriteFormat(_L("<i>Recv() didn't return KErrNotSupported (returned %d)</i>"),iStatus.Int()); |
|
613 return EFail; |
|
614 } |
|
615 |
|
616 iLogger.WriteFormat(_L("<i>Checking that the data was read into the buffer</i>")); |
|
617 if (iBuf != KSendData) |
|
618 { |
|
619 iLogger.WriteFormat(_L("<i>Incorrect data to recved</i>")); |
|
620 return EFail; |
|
621 } |
|
622 |
|
623 return EPass; |
|
624 } |
|
625 default: |
|
626 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 1)); |
|
627 return EFail; |
|
628 } |
|
629 } |
|
630 |
|
631 void CEIntSockTest5::Cleanup() |
|
632 { |
|
633 iSocket.Close(); |
|
634 } |
|
635 |
|
636 |
|
637 //------------------------------------------------------------------------------------------------- |
|
638 // CEIntSockTest6 |
|
639 //------------------------------------------------------------------------------------------------- |
|
640 |
|
641 CEIntSockTestBase* CEIntSockTest6::NewL(CProxyProvd* aProvd) |
|
642 { |
|
643 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest6(aProvd); |
|
644 return ret; |
|
645 } |
|
646 |
|
647 CEIntSockTest6::CEIntSockTest6(CProxyProvd* aProvd) : |
|
648 CEIntSockTestBase(aProvd), |
|
649 iState(EState1) |
|
650 {} |
|
651 |
|
652 TVerdict CEIntSockTest6::RunTestL() |
|
653 { |
|
654 TInt err; |
|
655 _LIT8(KSendData,"1234567890"); |
|
656 switch (iState) |
|
657 { |
|
658 case EState1: |
|
659 { |
|
660 iLogger.WriteFormat(_L("<i>Test 6 - Send to and receive from a datagram protocol (Descriptor API)</i>")); |
|
661 |
|
662 iLogger.WriteFormat(_L("<i>Opening PDummy 1</i>")); |
|
663 err = iSocket.Open(KDummyOneName); |
|
664 if (err != KErrNone) |
|
665 { |
|
666 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
667 return EFail; |
|
668 } |
|
669 |
|
670 iAddress.SetFamily (KProxyAddrFamily); |
|
671 iLogger.WriteFormat(_L("<i>Opening an internal socket (datagram protocol)</i>")); |
|
672 iSocket.Connect(iAddress, iStatus); |
|
673 |
|
674 iState = EState2; |
|
675 Reschedule(); |
|
676 return EPass; |
|
677 } |
|
678 case EState2: |
|
679 { |
|
680 if (iStatus != KErrNone) |
|
681 { |
|
682 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
683 return EFail; |
|
684 } |
|
685 |
|
686 iBuf.Copy ( KSendData() ); |
|
687 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the descriptor API</i>")); |
|
688 iSocket.Send(iBuf,0,iStatus); |
|
689 |
|
690 iState = EState3; |
|
691 Reschedule(); |
|
692 return EPass; |
|
693 } |
|
694 case EState3: |
|
695 { |
|
696 if (iStatus != KErrNone) |
|
697 { |
|
698 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iStatus.Int()); |
|
699 return EFail; |
|
700 } |
|
701 |
|
702 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the descriptor API</i>")); |
|
703 iBuf.Zero(); |
|
704 iBuf.SetLength(KSendData().Length()); |
|
705 iSocket.Recv(iBuf,0,iStatus); |
|
706 |
|
707 iState = EState4; |
|
708 Reschedule(); |
|
709 return EPass; |
|
710 } |
|
711 case EState4: |
|
712 { |
|
713 if (iStatus != KErrNone) |
|
714 { |
|
715 iLogger.WriteFormat(_L("<i>Recv() failed with %d</i>"),iStatus.Int()); |
|
716 return EFail; |
|
717 } |
|
718 |
|
719 iLogger.WriteFormat(_L("<i>Checking that the data was read into the buffer</i>")); |
|
720 if (iBuf != KSendData) |
|
721 { |
|
722 iLogger.WriteFormat(_L("<i>Incorrect data to recved</i>")); |
|
723 return EFail; |
|
724 } |
|
725 return EPass; |
|
726 } |
|
727 default: |
|
728 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 2)); |
|
729 return EFail; |
|
730 } |
|
731 } |
|
732 |
|
733 void CEIntSockTest6::Cleanup() |
|
734 { |
|
735 iSocket.Close(); |
|
736 } |
|
737 |
|
738 |
|
739 |
|
740 //------------------------------------------------------------------------------------------------- |
|
741 // CEIntSockTest7 |
|
742 //------------------------------------------------------------------------------------------------- |
|
743 |
|
744 CEIntSockTestBase* CEIntSockTest7::NewL(CProxyProvd* aProvd) |
|
745 { |
|
746 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest7(aProvd); |
|
747 return ret; |
|
748 } |
|
749 |
|
750 CEIntSockTest7::CEIntSockTest7(CProxyProvd* aProvd) : |
|
751 CEIntSockTestBase(aProvd), |
|
752 iState(EState1) |
|
753 {} |
|
754 |
|
755 TVerdict CEIntSockTest7::RunTestL() |
|
756 { |
|
757 TInt err; |
|
758 _LIT8(KSendData,"1234567890"); |
|
759 switch (iState) |
|
760 { |
|
761 case EState1: |
|
762 { |
|
763 iLogger.WriteFormat(_L("<i> Test 7 - Send to and receive from a stream protocol (RMBufChain API)</i>")); |
|
764 iLogger.WriteFormat(_L("<i>Opening PDummy 2</i>")); |
|
765 err = iSocket.Open(KDummyTwoName); |
|
766 if (err != KErrNone) |
|
767 { |
|
768 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
769 return EFail; |
|
770 } |
|
771 |
|
772 iAddress.SetFamily(KProxyAddrFamily); |
|
773 iLogger.WriteFormat(_L("<i>Opening an internal socket (stream protocol)</i>")); |
|
774 iSocket.Connect(iAddress, iStatus); |
|
775 |
|
776 iState = EState2; |
|
777 Reschedule(); |
|
778 return EPass; |
|
779 } |
|
780 case EState2: |
|
781 { |
|
782 if (iStatus != KErrNone) |
|
783 { |
|
784 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
785 return EFail; |
|
786 } |
|
787 |
|
788 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the RMBufChain API</i>")); |
|
789 |
|
790 iSendChain.CreateL(KSendData()); |
|
791 iSocket.Send(iSendChain,0,iStatus); |
|
792 |
|
793 |
|
794 iState = EState3; |
|
795 Reschedule(); |
|
796 return EPass; |
|
797 } |
|
798 case EState3: |
|
799 { |
|
800 if (iStatus != KErrNone) |
|
801 { |
|
802 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iStatus.Int()); |
|
803 return EFail; |
|
804 } |
|
805 // dummy prt won't take ownership of this chain. we have still this data. but when we |
|
806 // do a receive we will get the "same" chain back. so we have to remove the chain that we sent. |
|
807 // Now data is sent. |
|
808 iSendChain.Remove (); |
|
809 |
|
810 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the RMBufChain API</i>")); |
|
811 |
|
812 iBuf.SetLength(KSendData().Length()); |
|
813 iSocket.Recv(iRecvChain,0,iStatus); |
|
814 |
|
815 iState = EState4; |
|
816 Reschedule(); |
|
817 return EPass; |
|
818 } |
|
819 case EState4: |
|
820 { |
|
821 if (iStatus != KErrNone) |
|
822 { |
|
823 iLogger.WriteFormat(_L("<i>Recv() failed returning %d</i>"),iStatus.Int()); |
|
824 return EFail; |
|
825 } |
|
826 iRecvChain.CopyOut(iBuf); |
|
827 |
|
828 iRecvChain.Free(); |
|
829 |
|
830 iLogger.WriteFormat(_L("<i>Checking that the data was read into the buffer</i>")); |
|
831 if (iBuf != KSendData) |
|
832 { |
|
833 iLogger.WriteFormat(_L("<i>Incorrect data recieved</i>")); |
|
834 return EFail; |
|
835 } |
|
836 |
|
837 return EPass; |
|
838 } |
|
839 |
|
840 |
|
841 default: |
|
842 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 3)); |
|
843 return EFail; |
|
844 } |
|
845 } |
|
846 |
|
847 void CEIntSockTest7::Cleanup() |
|
848 { |
|
849 iSocket.Close(); |
|
850 __ASSERT_DEBUG(iSendChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 4)); |
|
851 __ASSERT_DEBUG(iRecvChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 5)); |
|
852 } |
|
853 |
|
854 //------------------------------------------------------------------------------------------------- |
|
855 // CEIntSockTest8 |
|
856 //------------------------------------------------------------------------------------------------- |
|
857 |
|
858 CEIntSockTestBase* CEIntSockTest8::NewL(CProxyProvd* aProvd) |
|
859 { |
|
860 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest8(aProvd); |
|
861 return ret; |
|
862 } |
|
863 |
|
864 CEIntSockTest8::CEIntSockTest8(CProxyProvd* aProvd) : |
|
865 CEIntSockTestBase(aProvd), |
|
866 iState(EState1) |
|
867 {} |
|
868 |
|
869 TVerdict CEIntSockTest8::RunTestL() |
|
870 { |
|
871 TInt err; |
|
872 _LIT8(KSendData,"1234567890"); |
|
873 switch (iState) |
|
874 { |
|
875 case EState1: |
|
876 { |
|
877 iLogger.WriteFormat(_L("<i> Test 8 - Send to and receive from a datagram protocol (RMBufChain API)</i>")); |
|
878 iLogger.WriteFormat(_L("<i>Opening PDummy 1</i>")); |
|
879 err = iSocket.Open(KDummyOneName); |
|
880 if (err != KErrNone) |
|
881 { |
|
882 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
883 return EFail; |
|
884 } |
|
885 |
|
886 iAddress.SetFamily(KProxyAddrFamily); |
|
887 iLogger.WriteFormat(_L("<i>Opening an internal socket (datagram protocol)</i>")); |
|
888 iSocket.Connect(iAddress, iStatus); |
|
889 |
|
890 iState = EState2; |
|
891 Reschedule(); |
|
892 return EPass; |
|
893 } |
|
894 case EState2: |
|
895 { |
|
896 if (iStatus != KErrNone) |
|
897 { |
|
898 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
899 return EFail; |
|
900 } |
|
901 |
|
902 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the RMBufChain API</i>")); |
|
903 |
|
904 iSendChain.CreateL(KSendData()); |
|
905 iSocket.Send(iSendChain,0,iStatus); |
|
906 |
|
907 iState = EState3; |
|
908 Reschedule(); |
|
909 return EPass; |
|
910 } |
|
911 case EState3: |
|
912 { |
|
913 if (iStatus != KErrNone) |
|
914 { |
|
915 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iStatus.Int()); |
|
916 return EFail; |
|
917 } |
|
918 // dummy prt won't take ownership of this chain. we have still this data. but when we |
|
919 // do a receive we will get the "same" chain back. so we have to remove the chain that we sent. |
|
920 // Now we sent |
|
921 iSendChain.Remove (); |
|
922 |
|
923 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the RMBufChain API</i>")); |
|
924 iSocket.Recv(iRecvChain,0,iStatus); |
|
925 |
|
926 iState = EState4; |
|
927 Reschedule(); |
|
928 return EPass; |
|
929 } |
|
930 case EState4: |
|
931 { |
|
932 if (iStatus != KErrNone) |
|
933 { |
|
934 iLogger.WriteFormat(_L("<i>Recv() failed with %d</i>"),iStatus.Int()); |
|
935 return EFail; |
|
936 } |
|
937 iLogger.WriteFormat(_L("<i>Checking that the data was read into the buffer</i>")); |
|
938 iBuf.SetLength(KSendData().Length()); |
|
939 iRecvChain.CopyOut(iBuf); |
|
940 iRecvChain.Free(); |
|
941 if(iBuf.Compare(KSendData()) == 0) |
|
942 { |
|
943 iLogger.WriteFormat(_L("<i>Recv() data matched that sent</i>")); |
|
944 } |
|
945 else |
|
946 { |
|
947 iLogger.WriteFormat(_L("<i>Recv() data != that send (%S recvd vs %S)</i>"), &iBuf, &KSendData()); |
|
948 return EFail; |
|
949 } |
|
950 |
|
951 return EPass; |
|
952 } |
|
953 |
|
954 default: |
|
955 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 6)); |
|
956 return EFail; |
|
957 } |
|
958 } |
|
959 |
|
960 void CEIntSockTest8::Cleanup() |
|
961 { |
|
962 iSocket.Close(); |
|
963 __ASSERT_DEBUG(iSendChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 7)); |
|
964 __ASSERT_DEBUG(iRecvChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 8)); |
|
965 } |
|
966 |
|
967 //------------------------------------------------------------------------------------------------- |
|
968 // CEIntSockTest9 |
|
969 //------------------------------------------------------------------------------------------------- |
|
970 |
|
971 CEIntSockTestBase* CEIntSockTest9::NewL(CProxyProvd* aProvd) |
|
972 { |
|
973 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest9(aProvd); |
|
974 return ret; |
|
975 } |
|
976 |
|
977 CEIntSockTest9::CEIntSockTest9(CProxyProvd* aProvd) : |
|
978 CEIntSockTestBase(aProvd) |
|
979 {} |
|
980 |
|
981 TVerdict CEIntSockTest9::RunTestL() |
|
982 { |
|
983 TInt err; |
|
984 iLogger.WriteFormat(_L("<i>Test 9 - Get and Set Options</i>")); |
|
985 iLogger.WriteFormat(_L("<i>Opening to PDummy 1</i>")); |
|
986 err = iSocket.Open(KDummyOneName); |
|
987 if (err != KErrNone) |
|
988 { |
|
989 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
990 return EFail; |
|
991 } |
|
992 iLogger.WriteFormat(_L("<i>Setting Blocked connect to TRUE</i>")); |
|
993 err = iSocket.SetOpt(KDummyOptionSetBlockConnect,28,TRUE); |
|
994 if (err != KErrNone) |
|
995 { |
|
996 iLogger.WriteFormat(_L("<i>SetOpt() failed with %d</i>"),err); |
|
997 return EFail; |
|
998 } |
|
999 TPckgBuf<TBool> boolean; |
|
1000 iLogger.WriteFormat(_L("<i>Getting Blocked connect Sock opt</i>")); |
|
1001 err = iSocket.GetOpt(KDummyOptionSetBlockConnect,28, boolean); |
|
1002 if (err != KErrNone) |
|
1003 { |
|
1004 iLogger.WriteFormat(_L("<i>SetOpt() failed with %d</i>"),err); |
|
1005 return EFail; |
|
1006 } |
|
1007 iLogger.WriteFormat(_L("<i>Checking that Blocked connect Sock opt returns true</i>")); |
|
1008 if (boolean() != TRUE) |
|
1009 { |
|
1010 iLogger.WriteFormat(_L("GetOpt did not return true - looks like the opt was not set")); |
|
1011 return EFail; |
|
1012 } |
|
1013 iLogger.WriteFormat(_L("<i>Setting Blocked connect to FALSE</i>")); |
|
1014 err = iSocket.SetOpt(KDummyOptionSetBlockConnect,28,FALSE); |
|
1015 if (err != KErrNone) |
|
1016 { |
|
1017 iLogger.WriteFormat(_L("<i>SetOpt() failed with %d</i>"),err); |
|
1018 return EFail; |
|
1019 } |
|
1020 iLogger.WriteFormat(_L("<i>Getting Blocked connect Sock opt</i>")); |
|
1021 err = iSocket.GetOpt(KDummyOptionSetBlockConnect,28, boolean); |
|
1022 if (err != KErrNone) |
|
1023 { |
|
1024 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
1025 return EFail; |
|
1026 } |
|
1027 iLogger.WriteFormat(_L("<i>Checking Blocked connect is FALSE</i>")); |
|
1028 if (boolean() != FALSE) |
|
1029 { |
|
1030 iLogger.WriteFormat(_L("GetOpt did not return false - looks like the opt was not set")); |
|
1031 return EFail; |
|
1032 } |
|
1033 return EPass; |
|
1034 } |
|
1035 |
|
1036 void CEIntSockTest9::Cleanup() |
|
1037 { |
|
1038 iSocket.Close(); |
|
1039 } |
|
1040 |
|
1041 //------------------------------------------------------------------------------------------------- |
|
1042 // CEIntSockTest10 |
|
1043 //------------------------------------------------------------------------------------------------- |
|
1044 |
|
1045 CEIntSockTestBase* CEIntSockTest10::NewL(CProxyProvd* aProvd) |
|
1046 { |
|
1047 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest10(aProvd); |
|
1048 return ret; |
|
1049 } |
|
1050 |
|
1051 CEIntSockTest10::CEIntSockTest10(CProxyProvd* aProvd) : |
|
1052 CEIntSockTestBase(aProvd), |
|
1053 iState(EState1) |
|
1054 {} |
|
1055 |
|
1056 TVerdict CEIntSockTest10::RunTestL() |
|
1057 { |
|
1058 TInt err; |
|
1059 switch(iState) |
|
1060 { |
|
1061 case EState1: |
|
1062 { |
|
1063 iLogger.WriteFormat(_L("<i>Test 10 - Ioctl</i>")); |
|
1064 iLogger.WriteFormat(_L("<i>Opening PDummy 3</i>")); |
|
1065 err = iSocket.Open(KDummyThreeName); |
|
1066 if (err != KErrNone) |
|
1067 { |
|
1068 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
1069 return EFail; |
|
1070 } |
|
1071 iLogger.WriteFormat(_L("<i>Sending an ioctl that does nothing</i>")); |
|
1072 iSocket.Ioctl(KDummyIocltJustComplete, iStatus); |
|
1073 |
|
1074 iState = EState2; |
|
1075 Reschedule(); |
|
1076 return EPass; |
|
1077 } |
|
1078 case EState2: |
|
1079 { |
|
1080 iLogger.WriteFormat(_L("<i>Checking that the Ioctl() completes</i>")); |
|
1081 if (iStatus != KErrNone) |
|
1082 { |
|
1083 iLogger.WriteFormat(_L("<i>Ioctl() failed with %d</i>"),iStatus.Int()); |
|
1084 return EFail; |
|
1085 } |
|
1086 return EPass; |
|
1087 } |
|
1088 default: |
|
1089 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 9)); |
|
1090 return EFail; |
|
1091 } |
|
1092 } |
|
1093 |
|
1094 void CEIntSockTest10::Cleanup() |
|
1095 { |
|
1096 iSocket.Close(); |
|
1097 } |
|
1098 |
|
1099 //------------------------------------------------------------------------------------------------- |
|
1100 // CEIntSockTest11 |
|
1101 //------------------------------------------------------------------------------------------------- |
|
1102 |
|
1103 CEIntSockTestBase* CEIntSockTest11::NewL(CProxyProvd* aProvd) |
|
1104 { |
|
1105 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest11(aProvd); |
|
1106 return ret; |
|
1107 } |
|
1108 |
|
1109 CEIntSockTest11::CEIntSockTest11(CProxyProvd* aProvd) : |
|
1110 CEIntSockTestBase(aProvd), |
|
1111 iState(EState1) |
|
1112 {} |
|
1113 |
|
1114 TVerdict CEIntSockTest11::RunTestL() |
|
1115 { |
|
1116 TInt err; |
|
1117 switch(iState) |
|
1118 { |
|
1119 case EState1: |
|
1120 { |
|
1121 iLogger.WriteFormat(_L("<i>Test 11 - Cancel Ioctls</i>")); |
|
1122 iLogger.WriteFormat(_L("<i>Opening PDummy 1</i>")); |
|
1123 err = iSocket.Open(KDummyOneName); |
|
1124 if (err != KErrNone) |
|
1125 { |
|
1126 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
1127 return EFail; |
|
1128 } |
|
1129 iLogger.WriteFormat(_L("<i>Sending an ioclt that does not complete</i>")); |
|
1130 iSocket.Ioctl(KDummyIocltNonCompleting, iStatus); |
|
1131 if (iStatus != KRequestPending) |
|
1132 { |
|
1133 iLogger.WriteFormat(_L("<i>Ioclt() failed with %d</i>"),iStatus.Int()); |
|
1134 return EFail; |
|
1135 } |
|
1136 iLogger.WriteFormat(_L("<i>Completing the ioctl with a SocketOpt</i>")); |
|
1137 err = iSocket.SetOpt(KDummyOptionSetIocltComplete,28); |
|
1138 if (err != KErrNone) |
|
1139 { |
|
1140 iLogger.WriteFormat(_L("<i>SetOpt() failed with %d</i>"),err); |
|
1141 return EFail; |
|
1142 } |
|
1143 iState = EState2; |
|
1144 Reschedule(); |
|
1145 return EPass; |
|
1146 } |
|
1147 case EState2: |
|
1148 { |
|
1149 iLogger.WriteFormat(_L("<i>Checking the completion code for the ioclt</i>")); |
|
1150 if (iStatus != KErrNone) |
|
1151 { |
|
1152 iLogger.WriteFormat(_L("<i>Ioctl() failed with %d</i>"),iStatus.Int()); |
|
1153 return EFail; |
|
1154 } |
|
1155 iLogger.WriteFormat(_L("<i>Sending an ioclt that does not complete</i>")); |
|
1156 iSocket.Ioctl(KDummyIocltNonCompleting, iStatus); |
|
1157 iLogger.WriteFormat(_L("<i>Cancelling the Ioclt</i>")); |
|
1158 iSocket.CancelIoctl(); |
|
1159 iState = EState3; |
|
1160 Reschedule(); |
|
1161 return EPass; |
|
1162 } |
|
1163 case EState3: |
|
1164 { |
|
1165 iLogger.WriteFormat(_L("<i>Checking the completion code for the ioclt in KErrCancel</i>")); |
|
1166 if (iStatus != KErrCancel) |
|
1167 { |
|
1168 iLogger.WriteFormat(_L("<i>Ioclt() failed with %d</i>"),iStatus.Int()); |
|
1169 return EFail; |
|
1170 } |
|
1171 iLogger.WriteFormat(_L("<i>Completing the ioctl with a SocketOpt</i>")); |
|
1172 err = iSocket.SetOpt(KDummyOptionSetIocltComplete,28); |
|
1173 if (err != KErrNone) |
|
1174 { |
|
1175 iLogger.WriteFormat(_L("<i>SetOpt() failed with %d</i>"),err); |
|
1176 return EFail; |
|
1177 } |
|
1178 iLogger.WriteFormat(_L("<i>Checking the completion code for the ioclt in KErrCancel</i>")); |
|
1179 if (iStatus != KErrCancel) |
|
1180 { |
|
1181 iLogger.WriteFormat(_L("<i>Ioclt() failed with %d</i>"),iStatus.Int()); |
|
1182 return EFail; |
|
1183 } |
|
1184 return EPass; |
|
1185 } |
|
1186 default: |
|
1187 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 10)); |
|
1188 return EFail; |
|
1189 } |
|
1190 } |
|
1191 |
|
1192 void CEIntSockTest11::Cleanup() |
|
1193 { |
|
1194 iSocket.Close(); |
|
1195 } |
|
1196 |
|
1197 //------------------------------------------------------------------------------------------------- |
|
1198 // CEIntSockTest12 |
|
1199 //------------------------------------------------------------------------------------------------- |
|
1200 |
|
1201 CEIntSockTestBase* CEIntSockTest12::NewL(CProxyProvd* aProvd) |
|
1202 { |
|
1203 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest12(aProvd); |
|
1204 return ret; |
|
1205 } |
|
1206 |
|
1207 CEIntSockTest12::CEIntSockTest12(CProxyProvd* aProvd) : |
|
1208 CEIntSockTestBase(aProvd), |
|
1209 iState(EState1) |
|
1210 {} |
|
1211 |
|
1212 TVerdict CEIntSockTest12::RunTestL() |
|
1213 { |
|
1214 TInt err; |
|
1215 switch(iState) |
|
1216 { |
|
1217 case EState1: |
|
1218 { |
|
1219 iLogger.WriteFormat(_L("<i>Test 12 - Cancel Accept</i>")); |
|
1220 iLogger.WriteFormat(_L("<i>Opening PDummy 3</i>")); |
|
1221 err = iSocket.Open(KDummyThreeName); |
|
1222 if (err != KErrNone) |
|
1223 { |
|
1224 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
1225 return EFail; |
|
1226 } |
|
1227 TSockAddr addr; |
|
1228 iLogger.WriteFormat(_L("<i>Performing Bind</i>")); |
|
1229 err =iSocket.Bind(addr); |
|
1230 if (err != KErrNone) |
|
1231 { |
|
1232 iLogger.WriteFormat(_L("<i>Bind() failed with %d</i>"),err); |
|
1233 return EFail; |
|
1234 } |
|
1235 iLogger.WriteFormat(_L("<i>Performing Listen</i>")); |
|
1236 err = iSocket.Listen(5); |
|
1237 if (err != KErrNone) |
|
1238 { |
|
1239 iLogger.WriteFormat(_L("<i>Listen() failed with %d</i>"),err); |
|
1240 return EFail; |
|
1241 } |
|
1242 iLogger.WriteFormat(_L("<i>Opening a NULL socket</i>")); |
|
1243 err = iNewSock.Open(); |
|
1244 if (err != KErrNone) |
|
1245 { |
|
1246 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
1247 return EFail; |
|
1248 } |
|
1249 |
|
1250 iLogger.WriteFormat(_L("<i>Accepting a connection</i>")); |
|
1251 iSocket.Accept(iNewSock,iStatus); |
|
1252 |
|
1253 iLogger.WriteFormat(_L("<i>Setting a sockopt to simulate a connect</i>")); |
|
1254 err = iSocket.SetOpt(KDummyOptionSetConnectComplete,27); |
|
1255 if (err != KErrNone) |
|
1256 { |
|
1257 iLogger.WriteFormat(_L("<i>SetOpt() failed with %d</i>"),err); |
|
1258 return EFail; |
|
1259 } |
|
1260 iState = EState2; |
|
1261 Reschedule(); |
|
1262 return EPass; |
|
1263 } |
|
1264 |
|
1265 case EState2: |
|
1266 { |
|
1267 iLogger.WriteFormat(_L("<i>Checking that the accept completes</i>")); |
|
1268 if (iStatus != KErrNone) |
|
1269 { |
|
1270 iLogger.WriteFormat(_L("<i>Accept() failed with %d</i>"),iStatus.Int()); |
|
1271 return EFail; |
|
1272 } |
|
1273 iLogger.WriteFormat(_L("<i>Closing and then reopenning the new socket</i>")); |
|
1274 iNewSock.Close(); |
|
1275 err = iNewSock.Open(); |
|
1276 if(err != KErrNone) |
|
1277 { |
|
1278 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),iStatus.Int()); |
|
1279 return EFail; |
|
1280 } |
|
1281 |
|
1282 iLogger.WriteFormat(_L("<i>Accepting a connection</i>")); |
|
1283 iSocket.Accept(iNewSock,iStatus); |
|
1284 |
|
1285 iLogger.WriteFormat(_L("<i>Cancelling the accept</i>")); |
|
1286 iSocket.CancelAccept(); |
|
1287 iState = EState3; |
|
1288 Reschedule(); |
|
1289 return EPass; |
|
1290 } |
|
1291 case EState3: |
|
1292 { |
|
1293 iLogger.WriteFormat(_L("<i>Checking that the accept completes with KErrCancel</i>")); |
|
1294 if (iStatus != KErrCancel) |
|
1295 { |
|
1296 iLogger.WriteFormat(_L("<i>Accept() failed with %d</i>"),iStatus.Int()); |
|
1297 return EFail; |
|
1298 } |
|
1299 iLogger.WriteFormat(_L("<i>Setting a sockopt to simulate a connect</i>")); |
|
1300 err = iSocket.SetOpt(KDummyOptionSetConnectComplete,27); |
|
1301 if (err != KErrNone) |
|
1302 { |
|
1303 iLogger.WriteFormat(_L("<i>SetOpt() failed with %d</i>"),err); |
|
1304 return EFail; |
|
1305 } |
|
1306 iLogger.WriteFormat(_L("<i>Checking that the status code is still KErrCancel</i>")); |
|
1307 if (iStatus != KErrCancel) |
|
1308 { |
|
1309 iLogger.WriteFormat(_L("<i>Accept() failed with %d</i>"),iStatus.Int()); |
|
1310 return EFail; |
|
1311 } |
|
1312 return EPass; |
|
1313 } |
|
1314 default: |
|
1315 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 11)); |
|
1316 return EFail; |
|
1317 } |
|
1318 } |
|
1319 |
|
1320 void CEIntSockTest12::Cleanup() |
|
1321 { |
|
1322 iSocket.Close(); |
|
1323 iNewSock.Close(); |
|
1324 } |
|
1325 |
|
1326 //------------------------------------------------------------------------------------------------- |
|
1327 // CEIntSockTest13 |
|
1328 //------------------------------------------------------------------------------------------------- |
|
1329 |
|
1330 CEIntSockTestBase* CEIntSockTest13::NewL(CProxyProvd* aProvd) |
|
1331 { |
|
1332 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest13(aProvd); |
|
1333 return ret; |
|
1334 } |
|
1335 |
|
1336 CEIntSockTest13::CEIntSockTest13(CProxyProvd* aProvd) : |
|
1337 CEIntSockTestBase(aProvd), |
|
1338 iState(EState1) |
|
1339 {} |
|
1340 |
|
1341 TVerdict CEIntSockTest13::RunTestL() |
|
1342 { |
|
1343 TInt err; |
|
1344 switch(iState) |
|
1345 { |
|
1346 case EState1: |
|
1347 { |
|
1348 iLogger.WriteFormat(_L("<i>Test 13 - Cancel Connect</i>")); |
|
1349 iLogger.WriteFormat(_L("<i>Opening PDummy 3</i>")); |
|
1350 err = iSocket.Open(KDummyThreeName); |
|
1351 if (err != KErrNone) |
|
1352 { |
|
1353 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
1354 return EFail; |
|
1355 } |
|
1356 iLogger.WriteFormat(_L("<i>Setting sockopt not to complete connect</i>")); |
|
1357 err = iSocket.SetOpt(KDummyOptionSetBlockConnect,28,TRUE); //Block connect |
|
1358 if (err != KErrNone) |
|
1359 { |
|
1360 iLogger.WriteFormat(_L("<i>SetOpt() failed with %d</i>"),err); |
|
1361 return EFail; |
|
1362 } |
|
1363 iLogger.WriteFormat(_L("<i>Performing connect</i>")); |
|
1364 iSocket.Connect(iAddress, iStatus); |
|
1365 if (iStatus != KRequestPending) |
|
1366 { |
|
1367 iLogger.WriteFormat(_L("<i>Ioclt() failed with %d</i>"),iStatus.Int()); |
|
1368 return EFail; |
|
1369 } |
|
1370 |
|
1371 iLogger.WriteFormat(_L("<i>Setting sockopt to now complete the connect</i>")); |
|
1372 err = iSocket.SetOpt(KDummyOptionSetBlockConnect,28,FALSE); //Unblock Connect |
|
1373 if (err != KErrNone) |
|
1374 { |
|
1375 iLogger.WriteFormat(_L("<i>SetOpt() failed with %d</i>"),err); |
|
1376 return EFail; |
|
1377 } |
|
1378 |
|
1379 iState = EState2; |
|
1380 Reschedule(); |
|
1381 return EPass; |
|
1382 } |
|
1383 case EState2: |
|
1384 { |
|
1385 iLogger.WriteFormat(_L("<i>Checking that the connect completes</i>")); |
|
1386 if (iStatus != KErrNone) |
|
1387 { |
|
1388 iLogger.WriteFormat(_L("<i>Ioclt() failed with %d</i>"),iStatus.Int()); |
|
1389 return EFail; |
|
1390 } |
|
1391 iLogger.WriteFormat(_L("<i>Closing and Reopening socket</i>")); |
|
1392 iSocket.Close(); |
|
1393 err = iSocket.Open(KDummyTwoName); |
|
1394 if (err != KErrNone) |
|
1395 { |
|
1396 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
1397 return EFail; |
|
1398 } |
|
1399 iLogger.WriteFormat(_L("<i>Setting sockopt not to complete connect</i>")); |
|
1400 err = iSocket.SetOpt(KDummyOptionSetBlockConnect,28,TRUE); //Block connect |
|
1401 if (err != KErrNone) |
|
1402 { |
|
1403 iLogger.WriteFormat(_L("<i>SetOpt() failed with %d</i>"),err); |
|
1404 return EFail; |
|
1405 } |
|
1406 iLogger.WriteFormat(_L("<i>Performing connect</i>")); |
|
1407 iSocket.Connect(iAddress, iStatus); |
|
1408 if (iStatus != KRequestPending) |
|
1409 { |
|
1410 iLogger.WriteFormat(_L("<i>Ioclt() failed with %d</i>"),iStatus.Int()); |
|
1411 return EFail; |
|
1412 } |
|
1413 |
|
1414 iLogger.WriteFormat(_L("<i>Cancelling connect</i>")); |
|
1415 iSocket.CancelConnect(); |
|
1416 |
|
1417 iState = EState3; |
|
1418 Reschedule(); |
|
1419 return EPass; |
|
1420 } |
|
1421 case EState3: |
|
1422 { |
|
1423 iLogger.WriteFormat(_L("<i>Checking that connect completes with KErrCancel</i>")); |
|
1424 if (iStatus != KErrCancel) |
|
1425 { |
|
1426 iLogger.WriteFormat(_L("<i>Cancel() failed with %d</i>"),iStatus.Int()); |
|
1427 return EFail; |
|
1428 } |
|
1429 |
|
1430 iLogger.WriteFormat(_L("<i>Attepting to simulate the completion of the connection</i>")); |
|
1431 err = iSocket.SetOpt(KDummyOptionSetBlockConnect,28,FALSE); //Unblock Connect |
|
1432 if (err != KErrNone) |
|
1433 { |
|
1434 iLogger.WriteFormat(_L("<i>SetOpt() failed with %d</i>"),err); |
|
1435 return EFail; |
|
1436 } |
|
1437 |
|
1438 iLogger.WriteFormat(_L("<i>Checking that the status remains KErrCancel</i>")); |
|
1439 if (iStatus != KErrCancel) |
|
1440 { |
|
1441 iLogger.WriteFormat(_L("<i>iStatus is now %d</i>"),iStatus.Int()); |
|
1442 return EFail; |
|
1443 } |
|
1444 |
|
1445 return EPass; |
|
1446 } |
|
1447 default: |
|
1448 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 12)); |
|
1449 return EFail; |
|
1450 } |
|
1451 } |
|
1452 |
|
1453 void CEIntSockTest13::Cleanup() |
|
1454 { |
|
1455 iSocket.Close(); |
|
1456 } |
|
1457 |
|
1458 //------------------------------------------------------------------------------------------------- |
|
1459 // CEIntSockTest14 |
|
1460 //------------------------------------------------------------------------------------------------- |
|
1461 |
|
1462 CEIntSockTestBase* CEIntSockTest14::NewL(CProxyProvd* aProvd) |
|
1463 { |
|
1464 CEIntSockTest14* ret = new(ELeave) CEIntSockTest14(aProvd); |
|
1465 CleanupStack::PushL(ret); |
|
1466 ret->ConstructL(); |
|
1467 CleanupStack::Pop(ret); |
|
1468 return ret; |
|
1469 } |
|
1470 |
|
1471 CEIntSockTest14::CEIntSockTest14(CProxyProvd* aProvd) : |
|
1472 CEIntSockTestBase(aProvd), |
|
1473 iState(EState1) |
|
1474 {} |
|
1475 |
|
1476 CEIntSockTest14::~CEIntSockTest14() |
|
1477 { |
|
1478 delete iColl; |
|
1479 } |
|
1480 |
|
1481 void CEIntSockTest14::ConstructL() |
|
1482 { |
|
1483 iColl = CAggregateCollection::NewL(iStatus,CAggregateCollection::EAny); |
|
1484 iSendItem = iColl->GetNewItemL(); |
|
1485 iIoctlItem = iColl->GetNewItemL(); |
|
1486 iConnectItem = iColl->GetNewItemL(); |
|
1487 } |
|
1488 |
|
1489 TVerdict CEIntSockTest14::RunTestL() |
|
1490 { |
|
1491 _LIT8(KSendData,"1234567890"); |
|
1492 TInt err; |
|
1493 switch(iState) |
|
1494 { |
|
1495 case EState1: |
|
1496 { |
|
1497 iLogger.WriteFormat(_L("<i> Test 14 - Transfer Socket</i>")); |
|
1498 iLogger.WriteFormat(_L("<i> Opening PDummy 1</i>")); |
|
1499 err = iSocket.Open(KDummyOneName); |
|
1500 if (err != KErrNone) |
|
1501 { |
|
1502 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
1503 return EFail; |
|
1504 } |
|
1505 iLogger.WriteFormat(_L("<i>Sending through a non completing ioctl</i>")); |
|
1506 iIoctlItem->Start(); |
|
1507 iSocket.Ioctl(KDummyIocltNonCompleting, iIoctlItem->iStatus); |
|
1508 iLogger.WriteFormat(_L("<i>Attempting to transfer the socket from one to another</i>")); |
|
1509 err = iNewSock.Transfer(iSocket); |
|
1510 if (err != KErrNone) |
|
1511 { |
|
1512 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
1513 return EFail; |
|
1514 } |
|
1515 iSocket.CancelIoctl(); |
|
1516 if (iStatus == KErrCancel) |
|
1517 { |
|
1518 iLogger.WriteFormat(_L("<i>Ioclt() from parent socket returned %d</i>"),iStatus.Int()); |
|
1519 return EFail; |
|
1520 } |
|
1521 iLogger.WriteFormat(_L("<i>Connecting...</i>")); |
|
1522 iConnectItem->Start(); |
|
1523 iNewSock.Connect(iAddress, iConnectItem->iStatus); |
|
1524 iState = EState2; |
|
1525 Reschedule(); |
|
1526 iColl->Kick(); |
|
1527 return EPass; |
|
1528 } |
|
1529 case EState2: |
|
1530 { |
|
1531 if (iIoctlItem->ReturnCode() != KRequestPending) //Since the socket was tranferred cancel should do nothing |
|
1532 { |
|
1533 iLogger.WriteFormat(_L("<i>Cancel) from parent socket returned %d</i>"),iIoctlItem->ReturnCode()); |
|
1534 return EFail; |
|
1535 } |
|
1536 if(iConnectItem->iStatus != KErrNone) |
|
1537 { |
|
1538 iLogger.WriteFormat(_L("<i>Connect() failed with error code %d</i>"),iStatus.Int()); |
|
1539 return EFail; |
|
1540 } |
|
1541 iSendItem->Start(); |
|
1542 iNewSock.Send(KSendData(),0,iSendItem->iStatus); |
|
1543 iState = EState3; |
|
1544 Reschedule(); |
|
1545 iColl->Kick(); |
|
1546 return EPass; |
|
1547 } |
|
1548 case EState3: |
|
1549 { |
|
1550 if (iSendItem->ReturnCode() != KErrNone) |
|
1551 { |
|
1552 iLogger.WriteFormat(_L("<i>Send() from new socket returned %d</i>"),iSendItem->iStatus.Int()); |
|
1553 return EFail; |
|
1554 } |
|
1555 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the descriptor API</i>")); |
|
1556 iBuf.Zero(); |
|
1557 iNewSock.Recv(iBuf,0,iStatus); |
|
1558 iState = EState4; |
|
1559 Reschedule(); |
|
1560 return EPass; |
|
1561 } |
|
1562 case EState4: |
|
1563 { |
|
1564 if (iStatus != KErrNone) |
|
1565 { |
|
1566 iLogger.WriteFormat(_L("<i>Recv() from new socket returned %d</i>"),iStatus.Int()); |
|
1567 return EFail; |
|
1568 } |
|
1569 iLogger.WriteFormat(_L("<i>Checking that the data is recieved correctly</i>")); |
|
1570 if (iBuf != KSendData()) |
|
1571 { |
|
1572 iLogger.WriteFormat(_L("<i>Recv() did not return any data </i>")); |
|
1573 return EFail; |
|
1574 } |
|
1575 iNewSock.CancelIoctl(); |
|
1576 iState = EState5; |
|
1577 iColl->Kick(); |
|
1578 Reschedule(); |
|
1579 return EPass; |
|
1580 } |
|
1581 case EState5: |
|
1582 { |
|
1583 if (iIoctlItem->ReturnCode() != KErrCancel) |
|
1584 { |
|
1585 iLogger.WriteFormat(_L("<i>Ioclt() from new socket returned %d</i>"),iIoctlItem->iStatus.Int()); |
|
1586 return EFail; |
|
1587 } |
|
1588 return EPass; |
|
1589 } |
|
1590 default: |
|
1591 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 13)); |
|
1592 return EFail; |
|
1593 } |
|
1594 } |
|
1595 |
|
1596 void CEIntSockTest14::Cleanup() |
|
1597 { |
|
1598 iSocket.Close(); |
|
1599 iNewSock.Close(); |
|
1600 } |
|
1601 |
|
1602 //------------------------------------------------------------------------------------------------- |
|
1603 // CEIntSockTest15 |
|
1604 //------------------------------------------------------------------------------------------------- |
|
1605 |
|
1606 CEIntSockTestBase* CEIntSockTest15::NewL(CProxyProvd* aProvd) |
|
1607 { |
|
1608 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest15(aProvd); |
|
1609 return ret; |
|
1610 } |
|
1611 |
|
1612 CEIntSockTest15::CEIntSockTest15(CProxyProvd* aProvd) : |
|
1613 CEIntSockTestBase(aProvd), |
|
1614 iState(EState1) |
|
1615 {} |
|
1616 |
|
1617 TVerdict CEIntSockTest15::RunTestL() |
|
1618 { |
|
1619 TInt err; |
|
1620 switch(iState) |
|
1621 { |
|
1622 case EState1: |
|
1623 { |
|
1624 iLogger.WriteFormat(_L("<i> Test 15 - Connect socket and close before completion</i>")); |
|
1625 iLogger.WriteFormat(_L("<i>Opening socket to PDummy Two (stream protocol)</i>")); |
|
1626 err = iSocket.Open(KDummyTwoName); |
|
1627 if (err != KErrNone) |
|
1628 { |
|
1629 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
1630 return EFail; |
|
1631 } |
|
1632 |
|
1633 iLogger.WriteFormat(_L("<i>Connecting an internal socket (stream protocol)</i>")); |
|
1634 iAddress.SetFamily(KProxyAddrFamily); |
|
1635 iSocket.Connect(iAddress, iStatus); |
|
1636 |
|
1637 iLogger.WriteFormat(_L("<i>Closing the socket without waiting for Connect() to complete</i>")); |
|
1638 // actually it probably is complete as it is pretty much synchronous with this protocol |
|
1639 iSocket.Close(); |
|
1640 |
|
1641 iState = EState2; |
|
1642 Reschedule(); |
|
1643 return EPass; |
|
1644 } |
|
1645 case EState2: |
|
1646 { |
|
1647 iLogger.WriteFormat(_L("<i>Checking the status of the Connect()</i>")); |
|
1648 if (iStatus != KErrNone) |
|
1649 { |
|
1650 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
1651 return EFail; |
|
1652 } |
|
1653 |
|
1654 iLogger.WriteFormat(_L("<i>Opening socket to PDummy One (datagram protocol)</i>")); |
|
1655 err = iSocket.Open(KDummyOneName); |
|
1656 if (err != KErrNone) |
|
1657 { |
|
1658 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
1659 return EFail; |
|
1660 } |
|
1661 |
|
1662 iLogger.WriteFormat(_L("<i>Connecting an internal socket (datagram protocol)</i>")); |
|
1663 iAddress.SetFamily(KProxyAddrFamily); |
|
1664 iSocket.Connect(iAddress, iStatus); |
|
1665 |
|
1666 iLogger.WriteFormat(_L("<i>Closing the socket without waiting for Connect() to complete</i>")); |
|
1667 // actually it probably is complete as it is pretty much synchronous with this protocol |
|
1668 iSocket.Close(); |
|
1669 |
|
1670 iState = EState3; |
|
1671 Reschedule(); |
|
1672 return EPass; |
|
1673 } |
|
1674 case EState3: |
|
1675 { |
|
1676 iLogger.WriteFormat(_L("<i>Checking the status of the Connect()</i>")); |
|
1677 if (iStatus != KErrNone) |
|
1678 { |
|
1679 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
1680 return EFail; |
|
1681 } |
|
1682 return EPass; |
|
1683 } |
|
1684 default: |
|
1685 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 14)); |
|
1686 return EFail; |
|
1687 } |
|
1688 } |
|
1689 |
|
1690 void CEIntSockTest15::Cleanup() |
|
1691 { |
|
1692 iSocket.Close(); |
|
1693 } |
|
1694 |
|
1695 |
|
1696 //------------------------------------------------------------------------------------------------- |
|
1697 // CEIntSockTest16 |
|
1698 //------------------------------------------------------------------------------------------------- |
|
1699 |
|
1700 CEIntSockTestBase* CEIntSockTest16::NewL(CProxyProvd* aProvd) |
|
1701 { |
|
1702 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest16(aProvd); |
|
1703 return ret; |
|
1704 } |
|
1705 |
|
1706 CEIntSockTest16::CEIntSockTest16(CProxyProvd* aProvd) : |
|
1707 CEIntSockTestBase(aProvd), |
|
1708 iState(EState1) |
|
1709 {} |
|
1710 |
|
1711 TVerdict CEIntSockTest16::RunTestL() |
|
1712 { |
|
1713 TInt err; |
|
1714 switch(iState) |
|
1715 { |
|
1716 case EState1: |
|
1717 { |
|
1718 iLogger.WriteFormat(_L("<i> Test 16 - Send data and close socket without waiting for Send to complete</i>")); |
|
1719 iLogger.WriteFormat(_L("<i>Opening socket to PDummy One (datagram protocol)</i>")); |
|
1720 err = iSocket.Open(KDummyOneName); |
|
1721 if (err != KErrNone) |
|
1722 { |
|
1723 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
1724 return EFail; |
|
1725 } |
|
1726 |
|
1727 iLogger.WriteFormat(_L("<i>Connecting an internal socket (stream protocol)</i>")); |
|
1728 iAddress.SetFamily(KProxyAddrFamily); |
|
1729 iSocket.Connect(iAddress, iStatus); |
|
1730 |
|
1731 iState = EState2; |
|
1732 Reschedule(); |
|
1733 return EPass; |
|
1734 } |
|
1735 case EState2: |
|
1736 { |
|
1737 iLogger.WriteFormat(_L("<i>Checking the status of the Connect()</i>")); |
|
1738 if (iStatus != KErrNone) |
|
1739 { |
|
1740 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
1741 return EFail; |
|
1742 } |
|
1743 |
|
1744 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the descriptor API</i>")); |
|
1745 TBuf8<20> buf = _L8("pancake"); |
|
1746 iSocket.Send(buf,0,iStatus); |
|
1747 |
|
1748 iLogger.WriteFormat(_L("<i>Close socket before Send() completes</i>")); |
|
1749 iSocket.Close(); |
|
1750 |
|
1751 iState = EState3; |
|
1752 Reschedule(); |
|
1753 return EPass; |
|
1754 } |
|
1755 case EState3: |
|
1756 { |
|
1757 iLogger.WriteFormat(_L("<i>Checking the status of the Send()</i>")); |
|
1758 if (iStatus != KErrNone) |
|
1759 { |
|
1760 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iStatus.Int()); |
|
1761 return EFail; |
|
1762 } |
|
1763 return EPass; |
|
1764 } |
|
1765 default: |
|
1766 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 15)); |
|
1767 return EFail; |
|
1768 } |
|
1769 } |
|
1770 |
|
1771 void CEIntSockTest16::Cleanup() |
|
1772 { |
|
1773 iSocket.Close(); |
|
1774 } |
|
1775 |
|
1776 //------------------------------------------------------------------------------------------------- |
|
1777 // CEIntSockTest17 |
|
1778 //------------------------------------------------------------------------------------------------- |
|
1779 |
|
1780 CEIntSockTestBase* CEIntSockTest17::NewL(CProxyProvd* aProvd) |
|
1781 { |
|
1782 CEIntSockTest17* ret = new(ELeave) CEIntSockTest17(aProvd); |
|
1783 CleanupStack::PushL(ret); |
|
1784 ret->ConstructL(); |
|
1785 CleanupStack::Pop(ret); |
|
1786 return ret; |
|
1787 } |
|
1788 |
|
1789 void CEIntSockTest17::ConstructL() |
|
1790 { |
|
1791 iColl = CAggregateCollection::NewL(iStatus,CAggregateCollection::EAny); |
|
1792 iSendItem = iColl->GetNewItemL(); |
|
1793 iRecvItem = iColl->GetNewItemL(); |
|
1794 } |
|
1795 |
|
1796 CEIntSockTest17::CEIntSockTest17(CProxyProvd* aProvd) : |
|
1797 CEIntSockTestBase(aProvd), |
|
1798 iState(EState1) |
|
1799 {} |
|
1800 |
|
1801 CEIntSockTest17::~CEIntSockTest17() |
|
1802 { |
|
1803 delete iColl; |
|
1804 } |
|
1805 |
|
1806 TVerdict CEIntSockTest17::RunTestL() |
|
1807 { |
|
1808 TInt err; |
|
1809 _LIT8(KSendData,"1234567890"); |
|
1810 switch(iState) |
|
1811 { |
|
1812 case EState1: |
|
1813 { |
|
1814 iLogger.WriteFormat(_L("<i>Test 17 - Cancel Recv</i>")); |
|
1815 iLogger.WriteFormat(_L("<i>Attempting to open socket on PDummy1</i>")); |
|
1816 err = iSocket.Open(KDummyOneName); |
|
1817 if (err != KErrNone) |
|
1818 { |
|
1819 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
1820 return EFail; |
|
1821 } |
|
1822 iLogger.WriteFormat(_L("<i>Attempting to perform a connect on PDummy1</i>")); |
|
1823 iSocket.Connect(iAddress,iStatus); |
|
1824 iState = EState2; |
|
1825 Reschedule(); |
|
1826 return EPass; |
|
1827 } |
|
1828 case EState2: |
|
1829 { |
|
1830 if (iStatus != KErrNone) |
|
1831 { |
|
1832 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
1833 return EFail; |
|
1834 } |
|
1835 iLogger.WriteFormat(_L("<i>Attempting to perform a recv</i>")); |
|
1836 iRecvItem->Start(); |
|
1837 TInt size = iBuf.MaxLength (); |
|
1838 iBuf.Zero (); |
|
1839 iSocket.Recv(iBuf,0,iRecvItem->iStatus); |
|
1840 |
|
1841 iLogger.WriteFormat(_L("<i>Attempting to perform a send</i>")); |
|
1842 iSendItem->Start(); |
|
1843 iSocket.Send(KSendData(),0,iSendItem->iStatus); |
|
1844 iState = EState3; |
|
1845 iColl->Kick(); |
|
1846 Reschedule(); |
|
1847 return EPass; |
|
1848 } |
|
1849 case EState3: |
|
1850 { |
|
1851 if (iSendItem->ReturnCode() != KRequestPending && iRecvItem->ReturnCode() != KRequestPending) |
|
1852 { |
|
1853 if(iSendItem->ReturnCode()!= KErrNone) |
|
1854 { |
|
1855 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iSendItem->ReturnCode()); |
|
1856 return EFail; |
|
1857 } |
|
1858 iLogger.WriteFormat(_L("<i>Checking that the recv returned correctly</i>")); |
|
1859 if(iRecvItem->ReturnCode() != KErrNone) |
|
1860 { |
|
1861 iLogger.WriteFormat(_L("<i>Recv() failed with %d</i>"),iRecvItem->ReturnCode()); |
|
1862 return EFail; |
|
1863 } |
|
1864 if (iBuf != KSendData) |
|
1865 { |
|
1866 iLogger.WriteFormat(_L("<i>Recv did not return expected data</i>")); |
|
1867 return EFail; |
|
1868 } |
|
1869 iLogger.WriteFormat(_L("<i>Attempting to perform a another recv</i>")); |
|
1870 iBuf.Zero(); |
|
1871 iRecvItem->Start(); |
|
1872 iSocket.Recv(iBuf,0,iRecvItem->iStatus); |
|
1873 |
|
1874 iLogger.WriteFormat(_L("<i>Attempting to cancel the recv</i>")); |
|
1875 iSocket.CancelRecv(); |
|
1876 |
|
1877 iState =EState4; |
|
1878 } |
|
1879 //Else reschedule and wait for soemthing to come in |
|
1880 iColl->Kick(); |
|
1881 Reschedule(); |
|
1882 return EPass; |
|
1883 } |
|
1884 case EState4: |
|
1885 { |
|
1886 iLogger.WriteFormat(_L("<i>Checking that the recv is cancelled</i>")); |
|
1887 if(iRecvItem->ReturnCode() != KErrCancel) |
|
1888 { |
|
1889 iLogger.WriteFormat(_L("<i>Recv() failed with %d</i>"),iStatus.Int()); |
|
1890 return EFail; |
|
1891 } |
|
1892 |
|
1893 iLogger.WriteFormat(_L("<i>Attempting to perform a send</i>")); |
|
1894 iSendItem->Start(); |
|
1895 iSocket.Send(KSendData,0,iSendItem->iStatus); |
|
1896 |
|
1897 iState = EState5; |
|
1898 iColl->Kick(); |
|
1899 Reschedule(); |
|
1900 return EPass; |
|
1901 } |
|
1902 case EState5: |
|
1903 { |
|
1904 if (iSendItem->ReturnCode() == KRequestPending || iRecvItem->ReturnCode() == KRequestPending) |
|
1905 { |
|
1906 //go back to active scheduler and wait for reschedule |
|
1907 iColl->Kick(); |
|
1908 Reschedule(); |
|
1909 return EFail; |
|
1910 } |
|
1911 if(iSendItem->ReturnCode() != KErrNone) |
|
1912 { |
|
1913 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iSendItem->ReturnCode()); |
|
1914 return EFail; |
|
1915 } |
|
1916 |
|
1917 iLogger.WriteFormat(_L("<i>Checking that the recv is still cancelled</i>")); |
|
1918 if(iRecvItem->ReturnCode() != KErrCancel) |
|
1919 { |
|
1920 iLogger.WriteFormat(_L("<i>Recv() failed with %d</i>"),iStatus.Int()); |
|
1921 return EFail; |
|
1922 } |
|
1923 |
|
1924 return EPass; |
|
1925 } |
|
1926 default: |
|
1927 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 16)); |
|
1928 return EFail; |
|
1929 } |
|
1930 } |
|
1931 |
|
1932 void CEIntSockTest17::Cleanup() |
|
1933 { |
|
1934 iSocket.Close(); |
|
1935 } |
|
1936 |
|
1937 //------------------------------------------------------------------------------------------------- |
|
1938 // CEIntSockTest18 |
|
1939 //------------------------------------------------------------------------------------------------- |
|
1940 |
|
1941 CEIntSockTestBase* CEIntSockTest18::NewL(CProxyProvd* aProvd) |
|
1942 { |
|
1943 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest18(aProvd); |
|
1944 return ret; |
|
1945 } |
|
1946 |
|
1947 CEIntSockTest18::CEIntSockTest18(CProxyProvd* aProvd) : |
|
1948 CEIntSockTestBase(aProvd) |
|
1949 {} |
|
1950 |
|
1951 TVerdict CEIntSockTest18::RunTestL() |
|
1952 { |
|
1953 TInt err; |
|
1954 iLogger.WriteFormat(_L("<i>Test 18 - Multiple opens and closes to a single protocol</i>")); |
|
1955 |
|
1956 TInt i; |
|
1957 for (i=0; i<KTest18NumSockets; i++) |
|
1958 { |
|
1959 iLogger.WriteFormat(_L("<i>Opening socket %d to pdummy 2</i>"),i); |
|
1960 err = iSockets[i].Open(KDummyTwoName); |
|
1961 if (err != KErrNone) |
|
1962 { |
|
1963 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
1964 return EFail; |
|
1965 } |
|
1966 } |
|
1967 |
|
1968 for (i=(KTest18NumSockets-1); i>=0; i--) |
|
1969 { |
|
1970 iLogger.WriteFormat(_L("<i>Closing socket %d</i>"),i); |
|
1971 iSockets[i].Close(); |
|
1972 } |
|
1973 |
|
1974 return EPass; |
|
1975 } |
|
1976 |
|
1977 void CEIntSockTest18::Cleanup() |
|
1978 { |
|
1979 for (TInt i=0; i<KTest18NumSockets; i++) |
|
1980 { |
|
1981 iSockets[i].Close(); |
|
1982 } |
|
1983 } |
|
1984 |
|
1985 //------------------------------------------------------------------------------------------------- |
|
1986 // CEIntSockTest19 |
|
1987 //------------------------------------------------------------------------------------------------- |
|
1988 |
|
1989 CEIntSockTestBase* CEIntSockTest19::NewL(CProxyProvd* aProvd) |
|
1990 { |
|
1991 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest19(aProvd); |
|
1992 return ret; |
|
1993 } |
|
1994 |
|
1995 CEIntSockTest19::CEIntSockTest19(CProxyProvd* aProvd) : |
|
1996 CEIntSockTestBase(aProvd) |
|
1997 {} |
|
1998 |
|
1999 TVerdict CEIntSockTest19::RunTestL() |
|
2000 { |
|
2001 TInt err; |
|
2002 |
|
2003 iLogger.WriteFormat(_L("<i>Test 19 - Multiple opens and closes to various protocols</i>")); |
|
2004 |
|
2005 iLogger.WriteFormat(_L("<i>Opening socket 0 (PDummyOne)</i>")); |
|
2006 err = iSockets[0].Open(KDummyOneName); |
|
2007 if (err != KErrNone) |
|
2008 { |
|
2009 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2010 return EFail; |
|
2011 } |
|
2012 |
|
2013 iLogger.WriteFormat(_L("<i>Opening socket 1 (PDummyTwo)</i>")); |
|
2014 err = iSockets[1].Open(KDummyTwoName); |
|
2015 if (err != KErrNone) |
|
2016 { |
|
2017 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2018 return EFail; |
|
2019 } |
|
2020 |
|
2021 iLogger.WriteFormat(_L("<i>Opening socket 2 (PDummyThree)</i>")); |
|
2022 err = iSockets[2].Open(KDummyTwoName); |
|
2023 if (err != KErrNone) |
|
2024 { |
|
2025 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2026 return EFail; |
|
2027 } |
|
2028 |
|
2029 for (TInt i=(KTest18NumSockets-1); i>=0; i--) |
|
2030 { |
|
2031 iLogger.WriteFormat(_L("<i>Closing socket %d</i>"),i); |
|
2032 iSockets[i].Close(); |
|
2033 } |
|
2034 |
|
2035 return EPass; |
|
2036 } |
|
2037 |
|
2038 void CEIntSockTest19::Cleanup() |
|
2039 { |
|
2040 for (TInt i=0; i<KTest18NumSockets; i++) |
|
2041 { |
|
2042 iSockets[i].Close(); |
|
2043 } |
|
2044 } |
|
2045 |
|
2046 //------------------------------------------------------------------------------------------------- |
|
2047 // CEIntSockTest20 |
|
2048 //------------------------------------------------------------------------------------------------- |
|
2049 |
|
2050 CEIntSockTestBase* CEIntSockTest20::NewL(CProxyProvd* aProvd) |
|
2051 { |
|
2052 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest20(aProvd); |
|
2053 return ret; |
|
2054 } |
|
2055 |
|
2056 CEIntSockTest20::CEIntSockTest20(CProxyProvd* aProvd) : |
|
2057 CEIntSockTestBase(aProvd) |
|
2058 {} |
|
2059 |
|
2060 TVerdict CEIntSockTest20::RunTestL() |
|
2061 { |
|
2062 TInt err; |
|
2063 |
|
2064 iLogger.WriteFormat(_L("<i>Test 20 - Repeated closes</i>")); |
|
2065 |
|
2066 iLogger.WriteFormat(_L("<i>Opening socket by name (PDummyOne)</i>")); |
|
2067 err = iSocket.Open(KDummyOneName); |
|
2068 if (err != KErrNone) |
|
2069 { |
|
2070 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2071 return EFail; |
|
2072 } |
|
2073 |
|
2074 TInt i; |
|
2075 for (i=0; i<KTest20NumCloses; i++) |
|
2076 { |
|
2077 iLogger.WriteFormat(_L("<i>Closing socket - iteration %d</i>"),i+1); |
|
2078 iSocket.Close(); |
|
2079 } |
|
2080 |
|
2081 iLogger.WriteFormat(_L("<i>Reopening socket - using protocol family etc (PDummyOne)</i>")); |
|
2082 err = iSocket.Open(KDummyAddrFamily, KSockDatagram, KDummyOne); |
|
2083 if (err != KErrNone) |
|
2084 { |
|
2085 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2086 return EFail; |
|
2087 } |
|
2088 |
|
2089 for (i=0; i<KTest20NumCloses; i++) |
|
2090 { |
|
2091 iLogger.WriteFormat(_L("<i>Closing socket - iteration %d</i>"),i+1); |
|
2092 iSocket.Close(); |
|
2093 } |
|
2094 |
|
2095 return EPass; |
|
2096 } |
|
2097 |
|
2098 void CEIntSockTest20::Cleanup() |
|
2099 { |
|
2100 iSocket.Close(); |
|
2101 } |
|
2102 |
|
2103 //------------------------------------------------------------------------------------------------- |
|
2104 // CEIntSockTest21 |
|
2105 //------------------------------------------------------------------------------------------------- |
|
2106 |
|
2107 CEIntSockTestBase* CEIntSockTest21::NewL(CProxyProvd* aProvd) |
|
2108 { |
|
2109 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest21(aProvd); |
|
2110 return ret; |
|
2111 } |
|
2112 |
|
2113 CEIntSockTest21::CEIntSockTest21(CProxyProvd* aProvd) : |
|
2114 CEIntSockTestBase(aProvd) |
|
2115 {} |
|
2116 |
|
2117 TVerdict CEIntSockTest21::RunTestL() |
|
2118 { |
|
2119 TInt err; |
|
2120 iLogger.WriteFormat(_L("<i>Test 21 - Repeated opens</i>")); |
|
2121 |
|
2122 iLogger.WriteFormat(_L("<i>Attempting to open a socket on pdummy 1</i>")); |
|
2123 err = iSocket.Open(KDummyOneName); |
|
2124 if (err != KErrNone) |
|
2125 { |
|
2126 iLogger.WriteFormat(_L("Open failed with %d"),err); |
|
2127 return EFail; |
|
2128 } |
|
2129 |
|
2130 iLogger.WriteFormat(_L("<i>Attempting to open a socket on the same protocol - Should Panic</i>")); |
|
2131 err = iSocket.Open(KDummyOneName); |
|
2132 // Everything below here should never be run due to the panic, but has been left for completeness |
|
2133 iLogger.WriteFormat(_L("Open returned %d"),err); |
|
2134 if (err == KErrNone) |
|
2135 { |
|
2136 return EFail; |
|
2137 } |
|
2138 |
|
2139 iSocket.Close(); |
|
2140 return EPass; |
|
2141 } |
|
2142 |
|
2143 void CEIntSockTest21::Cleanup() |
|
2144 { |
|
2145 iSocket.Close(); |
|
2146 } |
|
2147 |
|
2148 |
|
2149 //------------------------------------------------------------------------------------------------- |
|
2150 // CEIntSockTest22 |
|
2151 //------------------------------------------------------------------------------------------------- |
|
2152 |
|
2153 CEIntSockTestBase* CEIntSockTest22::NewL(CProxyProvd* aProvd) |
|
2154 { |
|
2155 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest22(aProvd); |
|
2156 return ret; |
|
2157 } |
|
2158 |
|
2159 CEIntSockTest22::CEIntSockTest22(CProxyProvd* aProvd) : |
|
2160 CEIntSockTestBase(aProvd) |
|
2161 {} |
|
2162 |
|
2163 TVerdict CEIntSockTest22::RunTestL() |
|
2164 { |
|
2165 iLogger.WriteFormat(_L("<i>Test 22 - Close without Open</i>")); |
|
2166 |
|
2167 iLogger.WriteFormat(_L("<i>Attempting to close a socket before openning it</i>")); |
|
2168 iSocket.Close(); |
|
2169 return EPass; |
|
2170 } |
|
2171 |
|
2172 void CEIntSockTest22::Cleanup() |
|
2173 { |
|
2174 } |
|
2175 |
|
2176 //------------------------------------------------------------------------------------------------- |
|
2177 // CEIntSockTest23 |
|
2178 //------------------------------------------------------------------------------------------------- |
|
2179 |
|
2180 CEIntSockTestBase* CEIntSockTest23::NewL(CProxyProvd* aProvd) |
|
2181 { |
|
2182 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest23(aProvd); |
|
2183 return ret; |
|
2184 } |
|
2185 |
|
2186 CEIntSockTest23::CEIntSockTest23(CProxyProvd* aProvd) : |
|
2187 CEIntSockTestBase(aProvd), |
|
2188 iState(EState1) |
|
2189 { |
|
2190 } |
|
2191 |
|
2192 TVerdict CEIntSockTest23::RunTestL() |
|
2193 { |
|
2194 TInt err; |
|
2195 _LIT8(KSendData,"1234567890"); |
|
2196 iOut = KSendData; |
|
2197 |
|
2198 switch (iState) |
|
2199 { |
|
2200 case EState1: |
|
2201 { |
|
2202 iLogger.WriteFormat(_L("<i>Test 23 Connect with connectData</i>")); |
|
2203 |
|
2204 iLogger.WriteFormat(_L("<i>Opening socket to a datagram protocol (PDummyOne)</i>")); |
|
2205 err = iSocket.Open(KDummyThreeName); |
|
2206 if (err != KErrNone) |
|
2207 { |
|
2208 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2209 return EFail; |
|
2210 } |
|
2211 |
|
2212 iLogger.WriteFormat(_L("<i>Connecting the internal socket (datagram protocol) with the data in/data out overload</i>")); |
|
2213 iAddress.SetFamily(KProxyAddrFamily); |
|
2214 iOut.Copy (KSendData); |
|
2215 iSocket.Connect(iAddress, iOut, iIn, iStatus); |
|
2216 |
|
2217 iState = EState2; |
|
2218 Reschedule(); |
|
2219 return EPass; |
|
2220 } |
|
2221 case EState2: |
|
2222 { |
|
2223 if (iStatus != KErrNone) |
|
2224 { |
|
2225 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
2226 return EFail; |
|
2227 } |
|
2228 |
|
2229 iLogger.WriteFormat(_L("<i>Connect() completed with %d</i>"),iStatus.Int()); // KErrNone presumably |
|
2230 |
|
2231 if (iIn.Compare(KSendData) == 0) |
|
2232 { |
|
2233 iLogger.WriteFormat(_L("<i>Data received matched data sent - pass!</i>")); |
|
2234 } |
|
2235 else |
|
2236 { |
|
2237 iLogger.WriteFormat(_L("<i>Data received did not match data sent - fail!</i>")); |
|
2238 return EFail; |
|
2239 } |
|
2240 |
|
2241 iSocket.Close(); |
|
2242 |
|
2243 return EPass; |
|
2244 } |
|
2245 default: |
|
2246 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 17)); |
|
2247 return EFail; |
|
2248 } |
|
2249 } |
|
2250 |
|
2251 void CEIntSockTest23::Cleanup() |
|
2252 { |
|
2253 iSocket.Close(); |
|
2254 } |
|
2255 |
|
2256 //------------------------------------------------------------------------------------------------- |
|
2257 // CEIntSockTest25A |
|
2258 //------------------------------------------------------------------------------------------------- |
|
2259 |
|
2260 CEIntSockTestBase* CEIntSockTest25A::NewL(CProxyProvd* aProvd) |
|
2261 { |
|
2262 CEIntSockTest25A* ret = new(ELeave) CEIntSockTest25A(aProvd); |
|
2263 CleanupStack::PushL(ret); |
|
2264 ret->ConstructL(); |
|
2265 CleanupStack::Pop(ret); |
|
2266 return ret; |
|
2267 } |
|
2268 |
|
2269 CEIntSockTest25A::CEIntSockTest25A(CProxyProvd* aProvd) : |
|
2270 CEIntSockTestBase(aProvd), |
|
2271 iState(EState1) |
|
2272 {} |
|
2273 |
|
2274 CEIntSockTest25A::~CEIntSockTest25A() |
|
2275 { |
|
2276 delete iColl; |
|
2277 } |
|
2278 |
|
2279 void CEIntSockTest25A::ConstructL() |
|
2280 { |
|
2281 iColl = CAggregateCollection::NewL(iStatus,CAggregateCollection::EAny); |
|
2282 iConnectItem = iColl->GetNewItemL(); |
|
2283 iIoctlItem = iColl->GetNewItemL(); |
|
2284 } |
|
2285 |
|
2286 TVerdict CEIntSockTest25A::RunTestL() |
|
2287 { |
|
2288 TInt err; |
|
2289 |
|
2290 switch (iState) |
|
2291 { |
|
2292 case EState1: |
|
2293 { |
|
2294 iLogger.WriteFormat(_L("<i>Test 25 CancelAll (Connect & Ioclt)</i>")); |
|
2295 |
|
2296 iLogger.WriteFormat(_L("<i>Opening socket to a datagram protocol (PDummyOne)</i>")); |
|
2297 err = iSocket.Open(KDummyThreeName); |
|
2298 if (err != KErrNone) |
|
2299 { |
|
2300 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2301 return EFail; |
|
2302 } |
|
2303 |
|
2304 iLogger.WriteFormat(_L("<i>Setting option to block connect</i>")); |
|
2305 err = iSocket.SetOpt(KDummyOptionSetBlockConnect,28,TRUE); |
|
2306 if (err != KErrNone) |
|
2307 { |
|
2308 iLogger.WriteFormat(_L("<i>SetOpt() failed with %d</i>"),err); |
|
2309 return EFail; |
|
2310 } |
|
2311 iLogger.WriteFormat(_L("<i>Connecting the internal socket (datagram protocol) with the data in/data out overload</i>")); |
|
2312 iAddress.SetFamily(KProxyAddrFamily); |
|
2313 iConnectItem->Start(); |
|
2314 iSocket.Connect(iAddress, iConnectItem->iStatus); |
|
2315 iLogger.WriteFormat(_L("<i>Sending through a non completing ioclt</i>")); |
|
2316 iIoctlItem->Start(); |
|
2317 iSocket.Ioctl(KDummyIocltNonCompleting, iIoctlItem->iStatus); |
|
2318 iLogger.WriteFormat(_L("<i>Performing CancelAll</i>")); |
|
2319 iSocket.CancelAll(); |
|
2320 iState = EState2; |
|
2321 iColl->Kick(); |
|
2322 Reschedule(); |
|
2323 return EPass; |
|
2324 } |
|
2325 case EState2: |
|
2326 { |
|
2327 if(iConnectItem->ReturnCode() == KRequestPending || iIoctlItem->ReturnCode() == KRequestPending) |
|
2328 { |
|
2329 iColl->Kick(); |
|
2330 Reschedule(); |
|
2331 return EFail; |
|
2332 } |
|
2333 if (iConnectItem->ReturnCode() != KErrCancel) |
|
2334 { |
|
2335 iLogger.WriteFormat(_L("<i>Connect returned with %d (KErrCancel Expected)</i>"), iConnectItem->ReturnCode()); |
|
2336 return EFail; |
|
2337 } |
|
2338 if (iIoctlItem->ReturnCode() != KErrCancel) |
|
2339 { |
|
2340 iLogger.WriteFormat(_L("<i>Ioctl returned with %d (KErrCancel Expected)</i>"), iIoctlItem->ReturnCode()); |
|
2341 return EFail; |
|
2342 } |
|
2343 return EPass; |
|
2344 } |
|
2345 default: |
|
2346 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 18)); |
|
2347 return EFail; |
|
2348 } |
|
2349 } |
|
2350 |
|
2351 void CEIntSockTest25A::Cleanup() |
|
2352 { |
|
2353 iSocket.Close(); |
|
2354 } |
|
2355 |
|
2356 //------------------------------------------------------------------------------------------------- |
|
2357 // CEIntSockTest25B |
|
2358 //------------------------------------------------------------------------------------------------- |
|
2359 |
|
2360 CEIntSockTestBase* CEIntSockTest25B::NewL(CProxyProvd* aProvd) |
|
2361 { |
|
2362 CEIntSockTest25B* ret = new(ELeave) CEIntSockTest25B(aProvd); |
|
2363 CleanupStack::PushL(ret); |
|
2364 ret->ConstructL(); |
|
2365 CleanupStack::Pop(ret); |
|
2366 return ret; |
|
2367 } |
|
2368 |
|
2369 CEIntSockTest25B::CEIntSockTest25B(CProxyProvd* aProvd) : |
|
2370 CEIntSockTestBase(aProvd), |
|
2371 iState(EState1) |
|
2372 {} |
|
2373 |
|
2374 CEIntSockTest25B::~CEIntSockTest25B() |
|
2375 { |
|
2376 delete iColl; |
|
2377 } |
|
2378 |
|
2379 void CEIntSockTest25B::ConstructL() |
|
2380 { |
|
2381 iColl = CAggregateCollection::NewL(iStatus,CAggregateCollection::EAny); |
|
2382 iAcceptItem = iColl->GetNewItemL(); |
|
2383 iIoctlItem = iColl->GetNewItemL(); |
|
2384 } |
|
2385 |
|
2386 TVerdict CEIntSockTest25B::RunTestL() |
|
2387 { |
|
2388 TInt err; |
|
2389 |
|
2390 switch (iState) |
|
2391 { |
|
2392 case EState1: |
|
2393 { |
|
2394 iLogger.WriteFormat(_L("<i>Test 25 CancelAll (Accept & Ioclt)</i>")); |
|
2395 |
|
2396 iLogger.WriteFormat(_L("<i>Opening socket to a datagram protocol (PDummyThree)</i>")); |
|
2397 |
|
2398 err = iSocket.Open(KDummyThreeName); |
|
2399 if (err != KErrNone) |
|
2400 { |
|
2401 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2402 return EFail; |
|
2403 } |
|
2404 TSockAddr addr; |
|
2405 iLogger.WriteFormat(_L("<i>Performing Bind</i>")); |
|
2406 err =iSocket.Bind(addr); |
|
2407 if (err != KErrNone) |
|
2408 { |
|
2409 iLogger.WriteFormat(_L("<i>Bind() failed with %d</i>"),err); |
|
2410 return EFail; |
|
2411 } |
|
2412 iLogger.WriteFormat(_L("<i>Performing Listen</i>")); |
|
2413 err = iSocket.Listen(5); |
|
2414 if (err != KErrNone) |
|
2415 { |
|
2416 iLogger.WriteFormat(_L("<i>Listen() failed with %d</i>"),err); |
|
2417 return EFail; |
|
2418 } |
|
2419 iLogger.WriteFormat(_L("<i>Opening a NULL socket</i>")); |
|
2420 err = iNewSock.Open(); |
|
2421 if (err != KErrNone) |
|
2422 { |
|
2423 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2424 return EFail; |
|
2425 } |
|
2426 |
|
2427 iLogger.WriteFormat(_L("<i>Accepting a connection</i>")); |
|
2428 iAcceptItem->Start(); |
|
2429 iSocket.Accept(iNewSock,iAcceptItem->iStatus); |
|
2430 iLogger.WriteFormat(_L("<i>Sending through a non completing ioclt</i>")); |
|
2431 iIoctlItem->Start(); |
|
2432 iSocket.Ioctl(KDummyIocltNonCompleting, iIoctlItem->iStatus); |
|
2433 iLogger.WriteFormat(_L("<i>Performing CancelAll</i>")); |
|
2434 iSocket.CancelAll(); |
|
2435 |
|
2436 iState = EState2; |
|
2437 iColl->Kick(); |
|
2438 Reschedule(); |
|
2439 return EPass; |
|
2440 } |
|
2441 case EState2: |
|
2442 { |
|
2443 if (iAcceptItem->ReturnCode() == KRequestPending || iIoctlItem->ReturnCode() == KRequestPending) |
|
2444 { |
|
2445 Reschedule(); //No change of status b/c we are waiting for a timeout |
|
2446 iColl->Kick(); |
|
2447 return EFail; |
|
2448 } |
|
2449 if (iAcceptItem->ReturnCode() != KErrCancel) |
|
2450 { |
|
2451 iLogger.WriteFormat(_L("<i>Accept returned with %d (KErrCancel Expected)</i>"), iAcceptItem->ReturnCode()); |
|
2452 return EFail; |
|
2453 } |
|
2454 if (iIoctlItem->ReturnCode() != KErrCancel) |
|
2455 { |
|
2456 iLogger.WriteFormat(_L("<i>Ioctl returned with %d (KErrCancel Expected)</i>"), iIoctlItem->ReturnCode()); |
|
2457 return EFail; |
|
2458 } |
|
2459 return EPass; |
|
2460 } |
|
2461 default: |
|
2462 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 19)); |
|
2463 return EFail; |
|
2464 |
|
2465 } |
|
2466 } |
|
2467 |
|
2468 void CEIntSockTest25B::Cleanup() |
|
2469 { |
|
2470 iSocket.Close(); |
|
2471 } |
|
2472 |
|
2473 //------------------------------------------------------------------------------------------------- |
|
2474 // CEIntSockTest25C |
|
2475 //------------------------------------------------------------------------------------------------- |
|
2476 |
|
2477 CEIntSockTestBase* CEIntSockTest25C::NewL(CProxyProvd* aProvd) |
|
2478 { |
|
2479 CEIntSockTest25C* ret = new(ELeave) CEIntSockTest25C(aProvd); |
|
2480 CleanupStack::PushL(ret); |
|
2481 ret->ConstructL(); |
|
2482 CleanupStack::Pop(ret); |
|
2483 return ret; |
|
2484 } |
|
2485 |
|
2486 CEIntSockTest25C::CEIntSockTest25C(CProxyProvd* aProvd) : |
|
2487 CEIntSockTestBase(aProvd), |
|
2488 iState(EState1) |
|
2489 {} |
|
2490 |
|
2491 CEIntSockTest25C::~CEIntSockTest25C() |
|
2492 { |
|
2493 delete iColl; |
|
2494 } |
|
2495 |
|
2496 void CEIntSockTest25C::ConstructL() |
|
2497 { |
|
2498 iColl = CAggregateCollection::NewL(iStatus,CAggregateCollection::EAny); |
|
2499 iRecvItem = iColl->GetNewItemL(); |
|
2500 iIoctlItem = iColl->GetNewItemL(); |
|
2501 } |
|
2502 |
|
2503 TVerdict CEIntSockTest25C::RunTestL() |
|
2504 { |
|
2505 TInt err; |
|
2506 switch (iState) |
|
2507 { |
|
2508 case EState1: |
|
2509 { |
|
2510 iLogger.WriteFormat(_L("<i>Test 25 CancelAll (Recv & Ioclt)</i>")); |
|
2511 |
|
2512 iLogger.WriteFormat(_L("<i>Opening socket to a datagram protocol (PDummyOne)</i>")); |
|
2513 err = iSocket.Open(KDummyOneName); |
|
2514 if (err != KErrNone) |
|
2515 { |
|
2516 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2517 return EFail; |
|
2518 } |
|
2519 |
|
2520 iLogger.WriteFormat(_L("<i>Peforming Connect</i>")); |
|
2521 iAddress.SetFamily(KProxyAddrFamily); |
|
2522 iSocket.Connect(iAddress, iStatus); |
|
2523 iState = EState2; |
|
2524 Reschedule(); |
|
2525 return EPass; |
|
2526 } |
|
2527 case EState2: |
|
2528 { |
|
2529 if (iStatus != KErrNone) |
|
2530 { |
|
2531 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
2532 return EFail; |
|
2533 } |
|
2534 iLogger.WriteFormat(_L("<i>Performing Recv that will not return</i>")); |
|
2535 iRecvItem->Start(); |
|
2536 iSocket.Recv(iRecvBuf,0,iRecvItem->iStatus); |
|
2537 iLogger.WriteFormat(_L("<i>Sending through a non completing ioclt</i>")); |
|
2538 iIoctlItem->Start(); |
|
2539 iSocket.Ioctl(KDummyIocltNonCompleting, iIoctlItem->iStatus); |
|
2540 iLogger.WriteFormat(_L("<i>Performing CancelAll</i>")); |
|
2541 iSocket.CancelAll(); |
|
2542 iState = EState3; |
|
2543 iColl->Kick(); |
|
2544 Reschedule(); |
|
2545 return EPass; |
|
2546 } |
|
2547 case EState3: |
|
2548 { |
|
2549 if (iRecvItem->ReturnCode() == KRequestPending || iIoctlItem->ReturnCode() == KRequestPending) |
|
2550 { |
|
2551 iColl->Kick(); |
|
2552 Reschedule(); //No change of status b/c we are waiting for a timeout |
|
2553 return EFail; |
|
2554 } |
|
2555 |
|
2556 if (iRecvItem->ReturnCode() != KErrCancel) |
|
2557 { |
|
2558 iLogger.WriteFormat(_L("<i>Connect returned with %d (KErrCancel Expected)</i>"), iRecvItem->ReturnCode()); |
|
2559 return EFail; |
|
2560 } |
|
2561 if (iIoctlItem->ReturnCode() != KErrCancel) |
|
2562 { |
|
2563 iLogger.WriteFormat(_L("<i>Ioctl returned with %d (KErrCancel Expected)</i>"), iIoctlItem->ReturnCode()); |
|
2564 return EFail; |
|
2565 } |
|
2566 return EPass; |
|
2567 } |
|
2568 default: |
|
2569 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 20)); |
|
2570 return EFail; |
|
2571 } |
|
2572 } |
|
2573 |
|
2574 void CEIntSockTest25C::Cleanup() |
|
2575 { |
|
2576 iSocket.Close(); |
|
2577 } |
|
2578 |
|
2579 //------------------------------------------------------------------------------------------------- |
|
2580 // CEIntSockTest26 |
|
2581 //------------------------------------------------------------------------------------------------- |
|
2582 |
|
2583 CEIntSockTestBase* CEIntSockTest26::NewL(CProxyProvd* aProvd) |
|
2584 { |
|
2585 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest26(aProvd); |
|
2586 return ret; |
|
2587 } |
|
2588 |
|
2589 CEIntSockTest26::CEIntSockTest26(CProxyProvd* aProvd) : |
|
2590 CEIntSockTestBase(aProvd), |
|
2591 iState(EState1) |
|
2592 { |
|
2593 } |
|
2594 |
|
2595 TVerdict CEIntSockTest26::RunTestL() |
|
2596 { |
|
2597 TInt err; |
|
2598 _LIT8(KSendData,"1234567890"); |
|
2599 |
|
2600 switch (iState) |
|
2601 { |
|
2602 case EState1: |
|
2603 { |
|
2604 iLogger.WriteFormat(_L("<i>Test 26 - GetDisconnectData Where there is no disconnect data</i>")); |
|
2605 |
|
2606 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 3</i>")); |
|
2607 err = iSocket.Open(KDummyThreeName); |
|
2608 if (err != KErrNone) |
|
2609 { |
|
2610 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2611 return EFail; |
|
2612 } |
|
2613 |
|
2614 iLogger.WriteFormat(_L("<i>Opening an internal socket (datagram protocol)</i>")); |
|
2615 iAddress.SetFamily(KProxyAddrFamily); |
|
2616 iSocket.Connect(iAddress, iStatus); |
|
2617 |
|
2618 iState = EState2; |
|
2619 Reschedule(); |
|
2620 return EPass; |
|
2621 } |
|
2622 case EState2: |
|
2623 { |
|
2624 if (iStatus != KErrNone) |
|
2625 { |
|
2626 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
2627 return EFail; |
|
2628 } |
|
2629 |
|
2630 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the descriptor API and requesting amount sent</i>")); |
|
2631 iSocket.Send(KSendData,0,iStatus); |
|
2632 |
|
2633 iState = EState3; |
|
2634 Reschedule(); |
|
2635 return EPass; |
|
2636 } |
|
2637 case EState3: |
|
2638 { |
|
2639 if (iStatus != KErrNone) |
|
2640 { |
|
2641 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iStatus.Int()); |
|
2642 return EFail; |
|
2643 } |
|
2644 |
|
2645 iLogger.WriteFormat(_L("<i>Sending an Ioctl that simulates a remote disconnect</i>")); |
|
2646 iSocket.Ioctl(KDummyIocltRemoteDisconnect,iStatus,NULL); |
|
2647 |
|
2648 iState = EState4; |
|
2649 Reschedule(); |
|
2650 return EPass; |
|
2651 } |
|
2652 case EState4: |
|
2653 { |
|
2654 if (iStatus != KErrNone) |
|
2655 { |
|
2656 iLogger.WriteFormat(_L("<i>Ioctl() failed with %d</i>"),iStatus.Int()); |
|
2657 return EFail; |
|
2658 } |
|
2659 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the descriptor API</i>")); |
|
2660 iBuf.Zero(); |
|
2661 iBuf.SetLength(KSendData().Length()); |
|
2662 iSocket.Recv(iBuf,0,iStatus); |
|
2663 |
|
2664 iState = EState5; |
|
2665 Reschedule(); |
|
2666 return EPass; |
|
2667 } |
|
2668 case EState5: |
|
2669 { |
|
2670 iLogger.WriteFormat(_L("<i>Recv() returned with %d</i>"),iStatus.Int()); |
|
2671 if (iStatus == KErrNone) |
|
2672 { |
|
2673 iLogger.WriteFormat(_L("<i>Recv() failed with %d</i>"),iStatus.Int()); |
|
2674 return EFail; |
|
2675 } |
|
2676 iLogger.WriteFormat(_L("<i>Getting Disconnect Data for the socket</i>")); |
|
2677 |
|
2678 TBuf8<40> disconnectData; |
|
2679 err = iSocket.GetDisconnectData(disconnectData); |
|
2680 if (err != KErrNotFound) |
|
2681 { |
|
2682 iLogger.WriteFormat(_L("<i>GetDisconnectData() failed with %d</i>"),iStatus.Int()); |
|
2683 return EFail; |
|
2684 } |
|
2685 return EPass; |
|
2686 } |
|
2687 default: |
|
2688 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 21)); |
|
2689 return EFail; |
|
2690 } |
|
2691 } |
|
2692 |
|
2693 void CEIntSockTest26::Cleanup() |
|
2694 { |
|
2695 iSocket.Close(); |
|
2696 } |
|
2697 |
|
2698 //------------------------------------------------------------------------------------------------- |
|
2699 // CEIntSockTest27 |
|
2700 //------------------------------------------------------------------------------------------------- |
|
2701 |
|
2702 CEIntSockTestBase* CEIntSockTest27::NewL(CProxyProvd* aProvd) |
|
2703 { |
|
2704 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest27(aProvd); |
|
2705 return ret; |
|
2706 } |
|
2707 |
|
2708 CEIntSockTest27::CEIntSockTest27(CProxyProvd* aProvd) : |
|
2709 CEIntSockTestBase(aProvd), |
|
2710 iState(EState1) |
|
2711 { |
|
2712 } |
|
2713 |
|
2714 TVerdict CEIntSockTest27::RunTestL() |
|
2715 { |
|
2716 TInt err; |
|
2717 _LIT8(KSendData,"1234567890"); |
|
2718 _LIT8(KDisconnectData,"Socket has been disconnected"); |
|
2719 |
|
2720 switch (iState) |
|
2721 { |
|
2722 case EState1: |
|
2723 { |
|
2724 iLogger.WriteFormat(_L("<i>Test 27 - GetDisconnectData Where there is disconnect data</i>")); |
|
2725 |
|
2726 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 3</i>")); |
|
2727 err = iSocket.Open(KDummyThreeName); |
|
2728 if (err != KErrNone) |
|
2729 { |
|
2730 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2731 return EFail; |
|
2732 } |
|
2733 |
|
2734 iLogger.WriteFormat(_L("<i>Opening an internal socket (datagram protocol)</i>")); |
|
2735 iAddress.SetFamily(KProxyAddrFamily); |
|
2736 iSocket.Connect(iAddress, iStatus); |
|
2737 |
|
2738 iState = EState2; |
|
2739 Reschedule(); |
|
2740 return EPass; |
|
2741 } |
|
2742 case EState2: |
|
2743 { |
|
2744 if (iStatus != KErrNone) |
|
2745 { |
|
2746 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
2747 return EFail; |
|
2748 } |
|
2749 |
|
2750 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the descriptor API and requesting amount sent</i>")); |
|
2751 iSocket.Send(KSendData,0,iStatus); |
|
2752 |
|
2753 iState = EState3; |
|
2754 Reschedule(); |
|
2755 return EPass; |
|
2756 } |
|
2757 case EState3: |
|
2758 { |
|
2759 if (iStatus != KErrNone) |
|
2760 { |
|
2761 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iStatus.Int()); |
|
2762 return EFail; |
|
2763 } |
|
2764 |
|
2765 iLogger.WriteFormat(_L("<i>Sending an Ioctl that simulates a remote disconnect</i>")); |
|
2766 iDisconnectBuf = KDisconnectData; |
|
2767 iSocket.Ioctl(KDummyIocltRemoteDisconnect,iStatus,&iDisconnectBuf); |
|
2768 |
|
2769 iState = EState4; |
|
2770 Reschedule(); |
|
2771 return EPass; |
|
2772 } |
|
2773 case EState4: |
|
2774 { |
|
2775 if (iStatus != KErrNone) |
|
2776 { |
|
2777 iLogger.WriteFormat(_L("<i>Ioctl() failed with %d</i>"),iStatus.Int()); |
|
2778 return EFail; |
|
2779 } |
|
2780 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the descriptor API</i>")); |
|
2781 iBuf.Zero(); |
|
2782 iBuf.SetLength(KSendData().Length()); |
|
2783 iSocket.Recv(iBuf,0,iStatus); |
|
2784 |
|
2785 iState = EState5; |
|
2786 Reschedule(); |
|
2787 return EPass; |
|
2788 } |
|
2789 case EState5: |
|
2790 { |
|
2791 iLogger.WriteFormat(_L("<i>Recv() returned with %d</i>"),iStatus.Int()); |
|
2792 if (iStatus == KErrNone) |
|
2793 { |
|
2794 iLogger.WriteFormat(_L("<i>Recv() failed with %d</i>"),iStatus.Int()); |
|
2795 return EFail; |
|
2796 } |
|
2797 iLogger.WriteFormat(_L("<i>Getting Disconnect Data for the socket</i>")); |
|
2798 TBuf8<1> tooShort; |
|
2799 err = iSocket.GetDisconnectData(tooShort); |
|
2800 if (err != KErrOverflow) |
|
2801 { |
|
2802 iLogger.WriteFormat(_L("<i>GetDisconnectData() failed with %d</i>"),iStatus.Int()); |
|
2803 return EFail; |
|
2804 } |
|
2805 TBuf8<40> disconnectData; |
|
2806 err = iSocket.GetDisconnectData(disconnectData); |
|
2807 if (err != KErrNone) |
|
2808 { |
|
2809 iLogger.WriteFormat(_L("<i>GetDisconnectData() failed with %d</i>"),iStatus.Int()); |
|
2810 return EFail; |
|
2811 } |
|
2812 if (disconnectData != KDisconnectData) |
|
2813 { |
|
2814 iLogger.WriteFormat(_L("<i>GetDisconnectData() returned %S. Should have returned %S</i>"), |
|
2815 &disconnectData,&(KDisconnectData())); |
|
2816 return EFail; |
|
2817 } |
|
2818 return EPass; |
|
2819 } |
|
2820 default: |
|
2821 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 22)); |
|
2822 return EFail; |
|
2823 } |
|
2824 } |
|
2825 |
|
2826 void CEIntSockTest27::Cleanup() |
|
2827 { |
|
2828 iSocket.Close(); |
|
2829 } |
|
2830 |
|
2831 //------------------------------------------------------------------------------------------------- |
|
2832 // CEIntSockTest28A |
|
2833 //------------------------------------------------------------------------------------------------- |
|
2834 |
|
2835 CEIntSockTestBase* CEIntSockTest28A::NewL(CProxyProvd* aProvd) |
|
2836 { |
|
2837 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest28A(aProvd); |
|
2838 return ret; |
|
2839 } |
|
2840 |
|
2841 CEIntSockTest28A::CEIntSockTest28A(CProxyProvd* aProvd) : |
|
2842 CEIntSockTestBase(aProvd), |
|
2843 iState(EState1) |
|
2844 { |
|
2845 } |
|
2846 |
|
2847 TVerdict CEIntSockTest28A::RunTestL() |
|
2848 { |
|
2849 TInt err; |
|
2850 _LIT8(KConnectData,"1234567890"); |
|
2851 |
|
2852 switch (iState) |
|
2853 { |
|
2854 case EState1: |
|
2855 { |
|
2856 iLogger.WriteFormat(_L("<i>Test 29 - Connect with connect data</i>")); |
|
2857 |
|
2858 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 3</i>")); |
|
2859 err = iSocket.Open(KDummyThreeName); |
|
2860 if (err != KErrNone) |
|
2861 { |
|
2862 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2863 return EFail; |
|
2864 } |
|
2865 |
|
2866 iLogger.WriteFormat(_L("<i>Performing a connect with connect data</i>")); |
|
2867 iAddress.SetFamily(KProxyAddrFamily); |
|
2868 iSocket.Connect(iAddress,KConnectData(),iBuf,iStatus); |
|
2869 |
|
2870 iState = EState2; |
|
2871 Reschedule(); |
|
2872 return EPass; |
|
2873 } |
|
2874 case EState2: |
|
2875 { |
|
2876 if (iStatus != KErrNone) |
|
2877 { |
|
2878 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
2879 return EFail; |
|
2880 } |
|
2881 |
|
2882 if (iBuf != KConnectData) |
|
2883 { |
|
2884 iLogger.WriteFormat(_L("<i>Connect out is not equal to connect in. Connect in =%S</i>"),&iBuf); |
|
2885 return EFail; |
|
2886 } |
|
2887 return EPass; |
|
2888 } |
|
2889 default: |
|
2890 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 23)); |
|
2891 return EFail; |
|
2892 } |
|
2893 } |
|
2894 |
|
2895 void CEIntSockTest28A::Cleanup() |
|
2896 { |
|
2897 iSocket.Close(); |
|
2898 } |
|
2899 |
|
2900 //------------------------------------------------------------------------------------------------- |
|
2901 // CEIntSockTest28B |
|
2902 //------------------------------------------------------------------------------------------------- |
|
2903 |
|
2904 CEIntSockTestBase* CEIntSockTest28B::NewL(CProxyProvd* aProvd) |
|
2905 { |
|
2906 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest28B(aProvd); |
|
2907 return ret; |
|
2908 } |
|
2909 |
|
2910 CEIntSockTest28B::CEIntSockTest28B(CProxyProvd* aProvd) : |
|
2911 CEIntSockTestBase(aProvd), |
|
2912 iState(EState1) |
|
2913 { |
|
2914 } |
|
2915 |
|
2916 TVerdict CEIntSockTest28B::RunTestL() |
|
2917 { |
|
2918 TInt err; |
|
2919 _LIT8(KConnectData,"1234567890"); |
|
2920 switch(iState) |
|
2921 { |
|
2922 case EState1: |
|
2923 { |
|
2924 iLogger.WriteFormat(_L("<i>Test 28B - Listen and Accept with connectdata</i>")); |
|
2925 iLogger.WriteFormat(_L("<i>Opening PDummy 3</i>")); |
|
2926 err = iSocket.Open(KDummyThreeName); |
|
2927 if (err != KErrNone) |
|
2928 { |
|
2929 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2930 return EFail; |
|
2931 } |
|
2932 TSockAddr addr; |
|
2933 iLogger.WriteFormat(_L("<i>Performing Bind</i>")); |
|
2934 err =iSocket.Bind(addr); |
|
2935 if (err != KErrNone) |
|
2936 { |
|
2937 iLogger.WriteFormat(_L("<i>Bind() failed with %d</i>"),err); |
|
2938 return EFail; |
|
2939 } |
|
2940 iLogger.WriteFormat(_L("<i>Performing Listen with connect data</i>")); |
|
2941 err = iSocket.Listen(5,KConnectData); |
|
2942 if (err != KErrNone) |
|
2943 { |
|
2944 iLogger.WriteFormat(_L("<i>Listen() failed with %d</i>"),err); |
|
2945 return EFail; |
|
2946 } |
|
2947 iLogger.WriteFormat(_L("<i>Opening a NULL socket</i>")); |
|
2948 err = iNewSock.Open(); |
|
2949 if (err != KErrNone) |
|
2950 { |
|
2951 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
2952 return EFail; |
|
2953 } |
|
2954 |
|
2955 iLogger.WriteFormat(_L("<i>Accepting a connection</i>")); |
|
2956 iSocket.Accept(iNewSock, iBuf, iStatus); |
|
2957 |
|
2958 iLogger.WriteFormat(_L("<i>Setting a sockopt to simulate a connect</i>")); |
|
2959 err = iSocket.SetOpt(KDummyOptionSetConnectComplete,27); |
|
2960 if (err != KErrNone) |
|
2961 { |
|
2962 iLogger.WriteFormat(_L("<i>SetOpt() failed with %d</i>"),err); |
|
2963 return EFail; |
|
2964 } |
|
2965 iState = EState2; |
|
2966 Reschedule(); |
|
2967 return EPass; |
|
2968 } |
|
2969 |
|
2970 case EState2: |
|
2971 { |
|
2972 iLogger.WriteFormat(_L("<i>Checking that the accept completes</i>")); |
|
2973 if (iStatus != KErrNone) |
|
2974 { |
|
2975 iLogger.WriteFormat(_L("<i>Accept() failed with %d</i>"),iStatus.Int()); |
|
2976 return EFail; |
|
2977 } |
|
2978 if (iBuf != KConnectData) |
|
2979 { |
|
2980 iLogger.WriteFormat(_L("<i>Connect out is not equal to connect in. Connect in =%S</i>"), &iBuf); |
|
2981 return EFail; |
|
2982 } |
|
2983 return EPass; |
|
2984 } |
|
2985 default: |
|
2986 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 24)); |
|
2987 return EFail; |
|
2988 } |
|
2989 } |
|
2990 |
|
2991 void CEIntSockTest28B::Cleanup() |
|
2992 { |
|
2993 iSocket.Close(); |
|
2994 } |
|
2995 // CEIntSockTest29 |
|
2996 //------------------------------------------------------------------------------------------------- |
|
2997 |
|
2998 CEIntSockTestBase* CEIntSockTest29::NewL(CProxyProvd* aProvd) |
|
2999 { |
|
3000 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest29(aProvd); |
|
3001 return ret; |
|
3002 } |
|
3003 |
|
3004 CEIntSockTest29::CEIntSockTest29(CProxyProvd* aProvd) : |
|
3005 CEIntSockTestBase(aProvd), |
|
3006 iState(EState1) |
|
3007 { |
|
3008 } |
|
3009 |
|
3010 TVerdict CEIntSockTest29::RunTestL() |
|
3011 { |
|
3012 TInt err; |
|
3013 _LIT8(KSendData,"1234567890"); |
|
3014 |
|
3015 switch (iState) |
|
3016 { |
|
3017 case EState1: |
|
3018 { |
|
3019 iLogger.WriteFormat(_L("<i>Test 29 - Send() with volume of data returned to client (datagram protocol, descriptor API)</i>")); |
|
3020 |
|
3021 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 1</i>")); |
|
3022 err = iSocket.Open(KDummyOneName); |
|
3023 if (err != KErrNone) |
|
3024 { |
|
3025 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
3026 return EFail; |
|
3027 } |
|
3028 |
|
3029 iLogger.WriteFormat(_L("<i>Performing a connect</i>")); |
|
3030 iAddress.SetFamily(KProxyAddrFamily); |
|
3031 iSocket.Connect(iAddress, iStatus); |
|
3032 |
|
3033 iState = EState2; |
|
3034 Reschedule(); |
|
3035 return EPass; |
|
3036 } |
|
3037 case EState2: |
|
3038 { |
|
3039 if (iStatus != KErrNone) |
|
3040 { |
|
3041 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
3042 return EFail; |
|
3043 } |
|
3044 |
|
3045 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the descriptor API and requesting amount sent</i>")); |
|
3046 iSocket.Send(KSendData,0,iStatus,iVolume); |
|
3047 |
|
3048 iState = EState3; |
|
3049 Reschedule(); |
|
3050 return EPass; |
|
3051 } |
|
3052 case EState3: |
|
3053 { |
|
3054 if (iStatus != KErrNone) |
|
3055 { |
|
3056 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iStatus.Int()); |
|
3057 return EFail; |
|
3058 } |
|
3059 if (iVolume() != KSendData().Length()) |
|
3060 { |
|
3061 iLogger.WriteFormat(_L("<i>Volume of datagrams sent was actually %d instead of 1</i>"),iVolume()); |
|
3062 return EFail; |
|
3063 } |
|
3064 |
|
3065 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the descriptor API</i>")); |
|
3066 iBuf.Zero(); |
|
3067 iBuf.SetLength(KSendData().Length()); |
|
3068 iSocket.Recv(iBuf,0,iStatus); |
|
3069 |
|
3070 iState = EState4; |
|
3071 Reschedule(); |
|
3072 return EPass; |
|
3073 } |
|
3074 case EState4: |
|
3075 { |
|
3076 if (iStatus != KErrNone) |
|
3077 { |
|
3078 iLogger.WriteFormat(_L("<i>Recv() failed with %d</i>"),iStatus.Int()); |
|
3079 return EFail; |
|
3080 } |
|
3081 |
|
3082 iLogger.WriteFormat(_L("<i>Checking that the data was read into the buffer</i>")); |
|
3083 if (iBuf != KSendData) |
|
3084 { |
|
3085 iLogger.WriteFormat(_L("<i>Incorrect data to recved</i>")); |
|
3086 return EFail; |
|
3087 } |
|
3088 return EPass; |
|
3089 } |
|
3090 default: |
|
3091 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 25)); |
|
3092 return EFail; |
|
3093 } |
|
3094 } |
|
3095 |
|
3096 void CEIntSockTest29::Cleanup() |
|
3097 { |
|
3098 iSocket.Close(); |
|
3099 } |
|
3100 |
|
3101 //------------------------------------------------------------------------------------------------- |
|
3102 // CEIntSockTest30 |
|
3103 //------------------------------------------------------------------------------------------------- |
|
3104 |
|
3105 CEIntSockTestBase* CEIntSockTest30::NewL(CProxyProvd* aProvd) |
|
3106 { |
|
3107 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest30(aProvd); |
|
3108 return ret; |
|
3109 } |
|
3110 |
|
3111 CEIntSockTest30::CEIntSockTest30(CProxyProvd* aProvd) : |
|
3112 CEIntSockTestBase(aProvd), |
|
3113 iState(EState1), iRecvBufPtr(NULL, 0) |
|
3114 { |
|
3115 } |
|
3116 |
|
3117 TVerdict CEIntSockTest30::RunTestL() |
|
3118 { |
|
3119 TInt err; |
|
3120 _LIT8(KSendData,"1234567890"); |
|
3121 |
|
3122 switch (iState) |
|
3123 { |
|
3124 case EState1: |
|
3125 { |
|
3126 iLogger.WriteFormat(_L("<i>Test 30 - Send() with volume of data returned to client (stream protocol, descriptor API)</i>")); |
|
3127 |
|
3128 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 2</i>")); |
|
3129 err = iSocket.Open(KDummyTwoName); |
|
3130 if (err != KErrNone) |
|
3131 { |
|
3132 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
3133 return EFail; |
|
3134 } |
|
3135 |
|
3136 iLogger.WriteFormat(_L("<i>Opening an internal socket (datagram protocol)</i>")); |
|
3137 iAddress.SetFamily(KProxyAddrFamily); |
|
3138 iSocket.Connect(iAddress, iStatus); |
|
3139 |
|
3140 iState = EState2; |
|
3141 Reschedule(); |
|
3142 return EPass; |
|
3143 } |
|
3144 case EState2: |
|
3145 { |
|
3146 if (iStatus != KErrNone) |
|
3147 { |
|
3148 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
3149 return EFail; |
|
3150 } |
|
3151 |
|
3152 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the descriptor API and requesting amount sent</i>")); |
|
3153 iSocket.Send(KSendData,0,iStatus,iVolume); |
|
3154 |
|
3155 iState = EState3; |
|
3156 Reschedule(); |
|
3157 return EPass; |
|
3158 } |
|
3159 case EState3: |
|
3160 { |
|
3161 if (iStatus != KErrNone) |
|
3162 { |
|
3163 iLogger.WriteFormat(_L("<i>Send() didn't return KErrNone (returned %d)</i>"),iStatus.Int()); |
|
3164 return EFail; |
|
3165 } |
|
3166 |
|
3167 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the descriptor API</i>")); |
|
3168 iBuf.Zero(); |
|
3169 iBuf.SetLength(KSendData().Length()); |
|
3170 iRecvBufPtr.Set( (TUint8*)iBuf.PtrZ(), KSendData().Length(), KSendData().Length() ); |
|
3171 iSocket.Recv(iRecvBufPtr,0,iStatus); |
|
3172 |
|
3173 iState = EState4; |
|
3174 Reschedule(); |
|
3175 return EPass; |
|
3176 } |
|
3177 case EState4: |
|
3178 { |
|
3179 if (iStatus != KErrNone) |
|
3180 { |
|
3181 iLogger.WriteFormat(_L("<i>Recv() didn't return KErrNone (returned %d)</i>"),iStatus.Int()); |
|
3182 return EFail; |
|
3183 } |
|
3184 return EPass; |
|
3185 } |
|
3186 default: |
|
3187 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 26)); |
|
3188 return EFail; |
|
3189 } |
|
3190 } |
|
3191 |
|
3192 void CEIntSockTest30::Cleanup() |
|
3193 { |
|
3194 iSocket.Close(); |
|
3195 } |
|
3196 |
|
3197 //------------------------------------------------------------------------------------------------- |
|
3198 // CEIntSockTest31 |
|
3199 //------------------------------------------------------------------------------------------------- |
|
3200 |
|
3201 CEIntSockTestBase* CEIntSockTest31::NewL(CProxyProvd* aProvd) |
|
3202 { |
|
3203 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest31(aProvd); |
|
3204 return ret; |
|
3205 } |
|
3206 |
|
3207 CEIntSockTest31::CEIntSockTest31(CProxyProvd* aProvd) : |
|
3208 CEIntSockTestBase(aProvd), |
|
3209 iState(EState1) |
|
3210 { |
|
3211 } |
|
3212 |
|
3213 TVerdict CEIntSockTest31::RunTestL() |
|
3214 { |
|
3215 TInt err; |
|
3216 _LIT8(KSendData,"1234567890"); |
|
3217 |
|
3218 switch (iState) |
|
3219 { |
|
3220 case EState1: |
|
3221 { |
|
3222 iLogger.WriteFormat(_L("<i>Test 31 - Send() with volume of data returned to client (datagram protocol, RMBufChain API)</i>")); |
|
3223 |
|
3224 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 1</i>")); |
|
3225 err = iSocket.Open(KDummyOneName); |
|
3226 if (err != KErrNone) |
|
3227 { |
|
3228 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
3229 return EFail; |
|
3230 } |
|
3231 |
|
3232 iLogger.WriteFormat(_L("<i>Opening an internal socket (datagram protocol)</i>")); |
|
3233 iAddress.SetFamily(KProxyAddrFamily); |
|
3234 iSocket.Connect(iAddress, iStatus); |
|
3235 |
|
3236 iState = EState2; |
|
3237 Reschedule(); |
|
3238 return EPass; |
|
3239 } |
|
3240 case EState2: |
|
3241 { |
|
3242 if (iStatus != KErrNone) |
|
3243 { |
|
3244 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
3245 return EFail; |
|
3246 } |
|
3247 |
|
3248 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the RMBufChain API and requesting amount sent</i>")); |
|
3249 iSendChain.CreateL(KSendData()); |
|
3250 iSocket.Send(iSendChain,0,iStatus,iVolume); |
|
3251 |
|
3252 |
|
3253 iState = EState3; |
|
3254 Reschedule(); |
|
3255 return EPass; |
|
3256 } |
|
3257 case EState3: |
|
3258 { |
|
3259 if (iStatus != KErrNone) |
|
3260 { |
|
3261 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iStatus.Int()); |
|
3262 return EFail; |
|
3263 } |
|
3264 if (iVolume() != KSendData().Length()) |
|
3265 { |
|
3266 iLogger.WriteFormat(_L("<i>Volume of data sent was actually %d instead of 1</i>"),iVolume()); |
|
3267 return EFail; |
|
3268 } |
|
3269 |
|
3270 iSendChain.Remove (); |
|
3271 |
|
3272 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the RMBufChain API</i>")); |
|
3273 iBuf.Zero(); |
|
3274 |
|
3275 iBuf.SetLength(KSendData().Length()); |
|
3276 iSocket.Recv(iRecvChain,0,iStatus); |
|
3277 |
|
3278 iState = EState4; |
|
3279 Reschedule(); |
|
3280 return EPass; |
|
3281 } |
|
3282 case EState4: |
|
3283 { |
|
3284 if (iStatus != KErrNone) |
|
3285 { |
|
3286 iLogger.WriteFormat(_L("<i>Recv() failed with %d</i>"),iStatus.Int()); |
|
3287 return EFail; |
|
3288 } |
|
3289 |
|
3290 iRecvChain.CopyOut(iBuf); |
|
3291 iRecvChain.Free(); |
|
3292 |
|
3293 |
|
3294 iLogger.WriteFormat(_L("<i>Checking that the data was read into the buffer</i>")); |
|
3295 if (iBuf != KSendData) |
|
3296 { |
|
3297 iLogger.WriteFormat(_L("<i>Incorrect data to recved</i>")); |
|
3298 return EFail; |
|
3299 } |
|
3300 return EPass; |
|
3301 } |
|
3302 default: |
|
3303 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 27)); |
|
3304 return EFail; |
|
3305 } |
|
3306 } |
|
3307 |
|
3308 void CEIntSockTest31::Cleanup() |
|
3309 { |
|
3310 iSocket.Close(); |
|
3311 __ASSERT_DEBUG(iRecvChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 28)); |
|
3312 __ASSERT_DEBUG(iSendChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 29)); |
|
3313 } |
|
3314 |
|
3315 //------------------------------------------------------------------------------------------------- |
|
3316 // CEIntSockTest32 |
|
3317 //------------------------------------------------------------------------------------------------- |
|
3318 |
|
3319 CEIntSockTestBase* CEIntSockTest32::NewL(CProxyProvd* aProvd) |
|
3320 { |
|
3321 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest32(aProvd); |
|
3322 return ret; |
|
3323 } |
|
3324 |
|
3325 CEIntSockTest32::CEIntSockTest32(CProxyProvd* aProvd) : |
|
3326 CEIntSockTestBase(aProvd), |
|
3327 iState(EState1) |
|
3328 { |
|
3329 } |
|
3330 |
|
3331 TVerdict CEIntSockTest32::RunTestL() |
|
3332 { |
|
3333 TInt err; |
|
3334 _LIT8(KSendData,"1234567890"); |
|
3335 |
|
3336 |
|
3337 switch (iState) |
|
3338 { |
|
3339 case EState1: |
|
3340 { |
|
3341 iLogger.WriteFormat(_L("<i>Test 32 - Send() with volume of data returned to client (stream protocol, RMBufChain API)</i>")); |
|
3342 |
|
3343 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 2</i>")); |
|
3344 err = iSocket.Open(KDummyTwoName); |
|
3345 if (err != KErrNone) |
|
3346 { |
|
3347 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
3348 return EFail; |
|
3349 } |
|
3350 |
|
3351 iLogger.WriteFormat(_L("<i>Opening an internal socket (datagram protocol)</i>")); |
|
3352 iAddress.SetFamily(KProxyAddrFamily); |
|
3353 iSocket.Connect(iAddress, iStatus); |
|
3354 |
|
3355 iState = EState2; |
|
3356 Reschedule(); |
|
3357 return EPass; |
|
3358 } |
|
3359 case EState2: |
|
3360 { |
|
3361 if (iStatus != KErrNone) |
|
3362 { |
|
3363 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
3364 return EFail; |
|
3365 } |
|
3366 |
|
3367 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the descriptor API and requesting amount sent</i>")); |
|
3368 iSendChain.CreateL(KSendData()); |
|
3369 iSocket.Send(iSendChain,0,iStatus,iVolume); |
|
3370 |
|
3371 |
|
3372 iState = EState3; |
|
3373 Reschedule(); |
|
3374 return EPass; |
|
3375 } |
|
3376 case EState3: |
|
3377 { |
|
3378 if (iStatus != KErrNone) |
|
3379 { |
|
3380 iLogger.WriteFormat(_L("<i>Send() didn't return KErrNone (returned %d)</i>"),iStatus.Int()); |
|
3381 return EFail; |
|
3382 } |
|
3383 |
|
3384 iSendChain.Remove (); |
|
3385 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the descriptor API</i>")); |
|
3386 iBuf.Zero(); |
|
3387 iBuf.SetLength(KSendData().Length()); |
|
3388 iSocket.Recv(iRecvChain,0,iStatus); |
|
3389 |
|
3390 iState = EState4; |
|
3391 Reschedule(); |
|
3392 return EPass; |
|
3393 } |
|
3394 case EState4: |
|
3395 { |
|
3396 iRecvChain.CopyOut(iBuf); |
|
3397 iRecvChain.Free(); |
|
3398 |
|
3399 if (iStatus != KErrNone) |
|
3400 { |
|
3401 iLogger.WriteFormat(_L("<i>Recv() didn't return KErrNone (returned %d)</i>"),iStatus.Int()); |
|
3402 return EFail; |
|
3403 } |
|
3404 return EPass; |
|
3405 } |
|
3406 default: |
|
3407 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 30)); |
|
3408 return EFail; |
|
3409 } |
|
3410 |
|
3411 } |
|
3412 |
|
3413 void CEIntSockTest32::Cleanup() |
|
3414 { |
|
3415 iSocket.Close(); |
|
3416 __ASSERT_DEBUG(iSendChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 31)); |
|
3417 __ASSERT_DEBUG(iRecvChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 32)); |
|
3418 } |
|
3419 |
|
3420 //------------------------------------------------------------------------------------------------- |
|
3421 // CEIntSockTest33 |
|
3422 //------------------------------------------------------------------------------------------------- |
|
3423 |
|
3424 CEIntSockTestBase* CEIntSockTest33::NewL(CProxyProvd* aProvd) |
|
3425 { |
|
3426 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest33(aProvd); |
|
3427 return ret; |
|
3428 } |
|
3429 |
|
3430 CEIntSockTest33::CEIntSockTest33(CProxyProvd* aProvd) : |
|
3431 CEIntSockTestBase(aProvd), |
|
3432 iState(EState1), iReadBufPtr(NULL, 0) |
|
3433 {} |
|
3434 |
|
3435 TVerdict CEIntSockTest33::RunTestL() |
|
3436 |
|
3437 { |
|
3438 TInt err; |
|
3439 _LIT8(KWriteData,"1234567890"); |
|
3440 switch (iState) |
|
3441 { |
|
3442 case EState1: |
|
3443 { |
|
3444 iLogger.WriteFormat(_L("<i>Test 33 - Write to and read from a stream protocol (Descriptor API)</i>")); |
|
3445 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 2</i>")); |
|
3446 err = iSocket.Open(KDummyTwoName); |
|
3447 if (err != KErrNone) |
|
3448 { |
|
3449 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
3450 return EFail; |
|
3451 } |
|
3452 |
|
3453 iLogger.WriteFormat(_L("<i>Opening an internal socket (stream protocol)</i>")); |
|
3454 iAddress.SetFamily(KProxyAddrFamily); |
|
3455 iSocket.Connect(iAddress, iStatus); |
|
3456 |
|
3457 iState = EState2; |
|
3458 Reschedule(); |
|
3459 return EPass; |
|
3460 } |
|
3461 case EState2: |
|
3462 { |
|
3463 if (iStatus != KErrNone) |
|
3464 { |
|
3465 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
3466 return EFail; |
|
3467 } |
|
3468 |
|
3469 iLogger.WriteFormat(_L("<i>Writing data to an internal socket using the descriptor API</i>")); |
|
3470 iSocket.Write(KWriteData,iStatus); |
|
3471 |
|
3472 iState = EState3; |
|
3473 Reschedule(); |
|
3474 return EPass; |
|
3475 } |
|
3476 case EState3: |
|
3477 { |
|
3478 if (iStatus != KErrNone) |
|
3479 { |
|
3480 iLogger.WriteFormat(_L("<i>Write() failed with %d</i>"),iStatus.Int()); |
|
3481 return EFail; |
|
3482 } |
|
3483 |
|
3484 iLogger.WriteFormat(_L("<i>Reading data from an internal socket using the descriptor API</i>")); |
|
3485 iBuf.Zero(); |
|
3486 iBuf.SetLength(KWriteData().Length()); |
|
3487 iReadBufPtr.Set( (TUint8*)iBuf.PtrZ(), KWriteData().Length(), KWriteData().Length() ); |
|
3488 iSocket.Read(iReadBufPtr,iStatus); |
|
3489 |
|
3490 iState = EState4; |
|
3491 Reschedule(); |
|
3492 return EPass; |
|
3493 } |
|
3494 case EState4: |
|
3495 { |
|
3496 if (iStatus != KErrNone) |
|
3497 { |
|
3498 iLogger.WriteFormat(_L("<i>Read() didn't return KErrNone (returned %d)</i>"),iStatus.Int()); |
|
3499 return EFail; |
|
3500 } |
|
3501 return EPass; |
|
3502 } |
|
3503 default: __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 33)); |
|
3504 return EFail; |
|
3505 } |
|
3506 } |
|
3507 |
|
3508 void CEIntSockTest33::Cleanup() |
|
3509 { |
|
3510 iSocket.Close(); |
|
3511 } |
|
3512 |
|
3513 //------------------------------------------------------------------------------------------------- |
|
3514 // CEIntSockTest34 |
|
3515 //------------------------------------------------------------------------------------------------- |
|
3516 |
|
3517 CEIntSockTestBase* CEIntSockTest34::NewL(CProxyProvd* aProvd) |
|
3518 { |
|
3519 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest34(aProvd); |
|
3520 return ret; |
|
3521 } |
|
3522 |
|
3523 CEIntSockTest34::CEIntSockTest34(CProxyProvd* aProvd) : |
|
3524 CEIntSockTestBase(aProvd), |
|
3525 iState(EState1) |
|
3526 {} |
|
3527 |
|
3528 TVerdict CEIntSockTest34::RunTestL() |
|
3529 |
|
3530 { |
|
3531 TInt err; |
|
3532 switch (iState) |
|
3533 { |
|
3534 case EState1: |
|
3535 { |
|
3536 iLogger.WriteFormat(_L("<i>Test 34 - Shutdown without disconnect data</i>")); |
|
3537 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 1</i>")); |
|
3538 err = iSocket.Open(KDummyOneName); |
|
3539 if (err != KErrNone) |
|
3540 { |
|
3541 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
3542 return EFail; |
|
3543 } |
|
3544 iLogger.WriteFormat(_L("<i>Performing a Connect</i>")); |
|
3545 iAddress.SetFamily(KProxyAddrFamily); |
|
3546 iSocket.Connect(iAddress, iStatus); |
|
3547 |
|
3548 iState = EState2; |
|
3549 Reschedule(); |
|
3550 return EPass; |
|
3551 } |
|
3552 case EState2: |
|
3553 { |
|
3554 if (iStatus != KErrNone) |
|
3555 { |
|
3556 iLogger.WriteFormat(_L("<i>Connect failed with</i>"),iStatus.Int()); |
|
3557 return EFail; |
|
3558 } |
|
3559 iLogger.WriteFormat(_L("<i>Performing a Shutdown</i>")); |
|
3560 iSocket.Shutdown(RSocket::ENormal,iStatus); |
|
3561 iState = EState3; |
|
3562 Reschedule(); |
|
3563 return EPass; |
|
3564 } |
|
3565 case EState3: |
|
3566 { |
|
3567 if (iStatus != KErrNone) |
|
3568 { |
|
3569 iLogger.WriteFormat(_L("<i>Shutdown failed with</i>"),iStatus.Int()); |
|
3570 return EFail; |
|
3571 } |
|
3572 return EPass; |
|
3573 } |
|
3574 default: __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 34)); |
|
3575 return EFail; |
|
3576 } |
|
3577 } |
|
3578 |
|
3579 void CEIntSockTest34::Cleanup() |
|
3580 { |
|
3581 iSocket.Close(); |
|
3582 } |
|
3583 |
|
3584 |
|
3585 //------------------------------------------------------------------------------------------------- |
|
3586 // CEIntSockTest35 |
|
3587 //------------------------------------------------------------------------------------------------- |
|
3588 |
|
3589 CEIntSockTestBase* CEIntSockTest35::NewL(CProxyProvd* aProvd) |
|
3590 { |
|
3591 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest35(aProvd); |
|
3592 return ret; |
|
3593 } |
|
3594 |
|
3595 CEIntSockTest35::CEIntSockTest35(CProxyProvd* aProvd) : |
|
3596 CEIntSockTestBase(aProvd), |
|
3597 iState(EState1) |
|
3598 {} |
|
3599 |
|
3600 TVerdict CEIntSockTest35::RunTestL() |
|
3601 |
|
3602 { |
|
3603 TInt err; |
|
3604 switch (iState) |
|
3605 { |
|
3606 case EState1: |
|
3607 { |
|
3608 iLogger.WriteFormat(_L("<i>Test 35 - Error during connect</i>")); |
|
3609 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 3</i>")); |
|
3610 err = iSocket.Open(KDummyThreeName); |
|
3611 if (err != KErrNone) |
|
3612 { |
|
3613 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
3614 return EFail; |
|
3615 } |
|
3616 iLogger.WriteFormat(_L("Set connect error code to %d"), KExpectedError); |
|
3617 err=iSocket.SetOpt(KDummyOptionSetErrorNextConnect, 0, KExpectedError); |
|
3618 if (err != KErrNone) |
|
3619 { |
|
3620 iLogger.WriteFormat(_L("<i>Setopt() failed with %d</i>"),err); |
|
3621 return EFail; |
|
3622 } |
|
3623 iLogger.WriteFormat(_L("Performing Connect")); |
|
3624 iSocket.Connect(iAddress,iStatus); |
|
3625 iState = EState2; |
|
3626 Reschedule(); |
|
3627 return EPass; |
|
3628 } |
|
3629 case EState2: |
|
3630 { |
|
3631 if (iStatus != KExpectedError) |
|
3632 { |
|
3633 iLogger.WriteFormat(_L("<i>Connect failed with %d should have returned %d</i>"),iStatus.Int(), KExpectedError); |
|
3634 return EFail; |
|
3635 } |
|
3636 iLogger.WriteFormat(_L("Set blocked connect")); |
|
3637 err=iSocket.SetOpt(KDummyOptionSetBlockConnect, 0, TRUE); |
|
3638 if (err != KErrNone) |
|
3639 { |
|
3640 iLogger.WriteFormat(_L("<i>Setopt() failed with %d</i>"),err); |
|
3641 return EFail; |
|
3642 } |
|
3643 iLogger.WriteFormat(_L("Set connect error code to %d"), KExpectedError); |
|
3644 err=iSocket.SetOpt(KDummyOptionSetErrorNextConnect, 0, KExpectedError); |
|
3645 if (err != KErrNone) |
|
3646 { |
|
3647 iLogger.WriteFormat(_L("<i>Setopt() failed with %d</i>"),err); |
|
3648 return EFail; |
|
3649 } |
|
3650 iLogger.WriteFormat(_L("Performing Connect")); |
|
3651 iSocket.Connect(iAddress,iStatus); |
|
3652 |
|
3653 iState = EState3; |
|
3654 Reschedule(); |
|
3655 return EPass; |
|
3656 } |
|
3657 case EState3: |
|
3658 { |
|
3659 if (iStatus != KExpectedError) |
|
3660 { |
|
3661 iLogger.WriteFormat(_L("<i>Connect failed with %d should have returned %d</i>"),iStatus.Int(), KExpectedError); |
|
3662 return EFail; |
|
3663 } |
|
3664 iLogger.WriteFormat(_L("Set blocked connect")); |
|
3665 err=iSocket.SetOpt(KDummyOptionSetBlockConnect, 0, TRUE); |
|
3666 if (err != KErrNone) |
|
3667 { |
|
3668 iLogger.WriteFormat(_L("<i>Setopt() failed with %d</i>"),err); |
|
3669 return EFail; |
|
3670 } |
|
3671 iLogger.WriteFormat(_L("Performing Connect")); |
|
3672 iSocket.Connect(iAddress,iStatus); |
|
3673 |
|
3674 iLogger.WriteFormat(_L("Set connect error code to %d"), KExpectedError); |
|
3675 err=iSocket.SetOpt(KDummyOptionSetErrorNextConnect, 0, KExpectedError); |
|
3676 if (err != KErrNone) |
|
3677 { |
|
3678 iLogger.WriteFormat(_L("<i>Setopt() failed with %d</i>"),err); |
|
3679 return EFail; |
|
3680 } |
|
3681 iLogger.WriteFormat(_L("Unblock connect")); |
|
3682 err=iSocket.SetOpt(KDummyOptionSetBlockConnect, 0, FALSE); |
|
3683 if (err != KErrNone) |
|
3684 { |
|
3685 iLogger.WriteFormat(_L("<i>Setopt() failed with %d</i>"),err); |
|
3686 return EFail; |
|
3687 } |
|
3688 iState = EState4; |
|
3689 Reschedule(); |
|
3690 return EPass; |
|
3691 } |
|
3692 case EState4: |
|
3693 { |
|
3694 if (iStatus != KExpectedError) |
|
3695 { |
|
3696 iLogger.WriteFormat(_L("<i>Connect failed with %d should have returned %d</i>"),iStatus.Int(), KExpectedError); |
|
3697 return EFail; |
|
3698 } |
|
3699 return EPass; |
|
3700 } |
|
3701 default: __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 35)); |
|
3702 return EFail; |
|
3703 } |
|
3704 } |
|
3705 |
|
3706 void CEIntSockTest35::Cleanup() |
|
3707 { |
|
3708 iSocket.Close(); |
|
3709 } |
|
3710 |
|
3711 |
|
3712 //------------------------------------------------------------------------------------------------- |
|
3713 // CEIntSockTest36 |
|
3714 //------------------------------------------------------------------------------------------------- |
|
3715 |
|
3716 CEIntSockTestBase* CEIntSockTest36::NewL(CProxyProvd* aProvd) |
|
3717 { |
|
3718 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest36(aProvd); |
|
3719 return ret; |
|
3720 } |
|
3721 |
|
3722 CEIntSockTest36::CEIntSockTest36(CProxyProvd* aProvd) |
|
3723 : CEIntSockTestBase(aProvd), |
|
3724 iState(EState1) |
|
3725 {} |
|
3726 |
|
3727 TVerdict CEIntSockTest36::RunTestL() |
|
3728 { |
|
3729 TInt err; |
|
3730 _LIT8(KSendData,"1234567890"); |
|
3731 |
|
3732 switch (iState) |
|
3733 { |
|
3734 case EState1: |
|
3735 { |
|
3736 iLogger.WriteFormat(_L("<i>Test 36 - Send to and receive from a datagram protocol that temporarily flows control off (Descriptor API)</i>")); |
|
3737 |
|
3738 iLogger.WriteFormat(_L("<i>Opening PDummy 1</i>")); |
|
3739 err = iSocket.Open(KDummyOneName); |
|
3740 if (err != KErrNone) |
|
3741 { |
|
3742 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
3743 return EFail; |
|
3744 } |
|
3745 |
|
3746 iLogger.WriteFormat(_L("<i>Opening an internal socket (datagram protocol)</i>")); |
|
3747 iAddress.SetFamily(KProxyAddrFamily); |
|
3748 iSocket.Connect(iAddress, iStatus); |
|
3749 |
|
3750 iState = EState2; |
|
3751 Reschedule(); |
|
3752 return EPass; |
|
3753 } |
|
3754 |
|
3755 case EState2: |
|
3756 { |
|
3757 if (iStatus != KErrNone) |
|
3758 { |
|
3759 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
3760 return EFail; |
|
3761 } |
|
3762 |
|
3763 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the descriptor API - temporarily flowing control off</i>")); |
|
3764 iSocket.SetOpt(KDummyOptionSetTimedFlowOffWrite, 0, KDummyWriteFlowOffTimeout); |
|
3765 iSocket.Send(KSendData,0,iStatus); |
|
3766 iState = EState3; |
|
3767 Reschedule(); |
|
3768 return EPass; |
|
3769 } |
|
3770 |
|
3771 case EState3: |
|
3772 { |
|
3773 if (iStatus != KErrNone) |
|
3774 { |
|
3775 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iStatus.Int()); |
|
3776 iSocket.SetOpt(KDummyOptionSetTimedFlowOffWrite, 0, 0); |
|
3777 return EFail; |
|
3778 } |
|
3779 |
|
3780 iSocket.SetOpt(KDummyOptionSetTimedFlowOffWrite, 0, 0); |
|
3781 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the descriptor API</i>")); |
|
3782 iBuf.Zero(); |
|
3783 iBuf.SetLength(KSendData().Length()); |
|
3784 iSocket.Recv(iBuf,0,iStatus); |
|
3785 |
|
3786 iState = EState4; |
|
3787 Reschedule(); |
|
3788 return EPass; |
|
3789 } |
|
3790 |
|
3791 case EState4: |
|
3792 { |
|
3793 if (iStatus != KErrNone) |
|
3794 { |
|
3795 iLogger.WriteFormat(_L("<i>Recv() failed with %d</i>"),iStatus.Int()); |
|
3796 return EFail; |
|
3797 } |
|
3798 |
|
3799 iLogger.WriteFormat(_L("<i>Checking that the data was read into the buffer</i>")); |
|
3800 if (iBuf != KSendData) |
|
3801 { |
|
3802 iLogger.WriteFormat(_L("<i>Incorrect data to recved</i>")); |
|
3803 return EFail; |
|
3804 } |
|
3805 return EPass; |
|
3806 } |
|
3807 |
|
3808 default: |
|
3809 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 36)); |
|
3810 return EFail; |
|
3811 } |
|
3812 } |
|
3813 |
|
3814 void CEIntSockTest36::Cleanup() |
|
3815 { |
|
3816 iSocket.Close(); |
|
3817 } |
|
3818 |
|
3819 |
|
3820 //------------------------------------------------------------------------------------------------- |
|
3821 // CEIntSockTest37 |
|
3822 //------------------------------------------------------------------------------------------------- |
|
3823 |
|
3824 CEIntSockTestBase* CEIntSockTest37::NewL(CProxyProvd* aProvd) |
|
3825 { |
|
3826 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest37(aProvd); |
|
3827 return ret; |
|
3828 } |
|
3829 |
|
3830 CEIntSockTest37::CEIntSockTest37(CProxyProvd* aProvd) |
|
3831 : CEIntSockTestBase(aProvd), |
|
3832 iState(EState1) |
|
3833 {} |
|
3834 |
|
3835 TVerdict CEIntSockTest37::RunTestL() |
|
3836 { |
|
3837 TInt err; |
|
3838 _LIT8(KSendData,"1234567890"); |
|
3839 |
|
3840 switch (iState) |
|
3841 { |
|
3842 case EState1: |
|
3843 { |
|
3844 iLogger.WriteFormat(_L("<i>Test 37 - Send to and receive from a datagram protocol that temporarily flows control off (RMBufChain API)</i>")); |
|
3845 |
|
3846 iLogger.WriteFormat(_L("<i>Opening PDummy 1</i>")); |
|
3847 err = iSocket.Open(KDummyOneName); |
|
3848 if (err != KErrNone) |
|
3849 { |
|
3850 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
3851 return EFail; |
|
3852 } |
|
3853 |
|
3854 iLogger.WriteFormat(_L("<i>Opening an internal socket (datagram protocol)</i>")); |
|
3855 iAddress.SetFamily(KProxyAddrFamily); |
|
3856 iSocket.Connect(iAddress, iStatus); |
|
3857 |
|
3858 iState = EState2; |
|
3859 Reschedule(); |
|
3860 return EPass; |
|
3861 } |
|
3862 |
|
3863 case EState2: |
|
3864 { |
|
3865 if (iStatus != KErrNone) |
|
3866 { |
|
3867 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
3868 return EFail; |
|
3869 } |
|
3870 |
|
3871 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the RMBufChain API - temporarily flowing control off</i>")); |
|
3872 |
|
3873 iSendChain.CreateL(KSendData()); |
|
3874 |
|
3875 iSocket.SetOpt(KDummyOptionSetTimedFlowOffWrite, 0, KDummyWriteFlowOffTimeout); |
|
3876 iSocket.Send(iSendChain,0,iStatus); |
|
3877 |
|
3878 iState = EState3; |
|
3879 Reschedule(); |
|
3880 return EPass; |
|
3881 } |
|
3882 |
|
3883 case EState3: |
|
3884 { |
|
3885 if (iStatus != KErrNone) |
|
3886 { |
|
3887 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iStatus.Int()); |
|
3888 iSocket.SetOpt(KDummyOptionSetTimedFlowOffWrite, 0, 0); |
|
3889 return EFail; |
|
3890 } |
|
3891 iSendChain.Remove(); |
|
3892 |
|
3893 iSocket.SetOpt(KDummyOptionSetTimedFlowOffWrite, 0, 0); |
|
3894 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the RMBufChain API</i>")); |
|
3895 |
|
3896 iSocket.Recv(iRecvChain, 0, iStatus); |
|
3897 |
|
3898 iState = EState4; |
|
3899 Reschedule(); |
|
3900 return EPass; |
|
3901 } |
|
3902 |
|
3903 case EState4: |
|
3904 { |
|
3905 if (iStatus != KErrNone) |
|
3906 { |
|
3907 iLogger.WriteFormat(_L("<i>Recv() failed with %d</i>"),iStatus.Int()); |
|
3908 return EFail; |
|
3909 } |
|
3910 |
|
3911 iLogger.WriteFormat(_L("<i>Checking that the data was read into the buffer</i>")); |
|
3912 iBuf.SetLength(KSendData().Length()); |
|
3913 iRecvChain.CopyOut(iBuf); |
|
3914 iRecvChain.Free(); |
|
3915 |
|
3916 if (iBuf.Compare(KSendData()) != 0) |
|
3917 { |
|
3918 iLogger.WriteFormat(_L("<i>Recv() data != that send (%S recvd vs %S)</i>"), &iBuf, &KSendData()); |
|
3919 return EFail; |
|
3920 } |
|
3921 |
|
3922 iLogger.WriteFormat(_L("<i>Recv() data matched that sent</i>")); |
|
3923 return EPass; |
|
3924 } |
|
3925 |
|
3926 default: |
|
3927 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 37)); |
|
3928 return EFail; |
|
3929 } |
|
3930 } |
|
3931 |
|
3932 void CEIntSockTest37::Cleanup() |
|
3933 { |
|
3934 iSocket.Close(); |
|
3935 __ASSERT_DEBUG(iSendChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 38)); |
|
3936 __ASSERT_DEBUG(iRecvChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 39)); |
|
3937 } |
|
3938 |
|
3939 |
|
3940 //------------------------------------------------------------------------------------------------- |
|
3941 // CEIntSockTest38 |
|
3942 //------------------------------------------------------------------------------------------------- |
|
3943 |
|
3944 CEIntSockTestBase* CEIntSockTest38::NewL(CProxyProvd* aProvd) |
|
3945 { |
|
3946 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest38(aProvd); |
|
3947 return ret; |
|
3948 } |
|
3949 |
|
3950 CEIntSockTest38::CEIntSockTest38(CProxyProvd* aProvd) |
|
3951 : CEIntSockTestBase(aProvd), |
|
3952 iState(EState1) |
|
3953 {} |
|
3954 |
|
3955 TVerdict CEIntSockTest38::RunTestL() |
|
3956 { |
|
3957 TInt err; |
|
3958 _LIT8(KSendData,"1234567890"); |
|
3959 |
|
3960 switch (iState) |
|
3961 { |
|
3962 case EState1: |
|
3963 { |
|
3964 iLogger.WriteFormat(_L("<i>Test 38 - Send to and receive from a datagram protocol that temporarily flows control off (Descriptor API)</i>")); |
|
3965 |
|
3966 iLogger.WriteFormat(_L("<i>Opening PDummy 1</i>")); |
|
3967 err = iSocket.Open(KDummyOneName); |
|
3968 if (err != KErrNone) |
|
3969 { |
|
3970 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
3971 return EFail; |
|
3972 } |
|
3973 |
|
3974 iLogger.WriteFormat(_L("<i>Opening an internal socket (datagram protocol)</i>")); |
|
3975 iAddress.SetFamily(KProxyAddrFamily); |
|
3976 iSocket.Connect(iAddress, iStatus); |
|
3977 |
|
3978 iState = EState2; |
|
3979 Reschedule(); |
|
3980 return EPass; |
|
3981 } |
|
3982 |
|
3983 case EState2: |
|
3984 { |
|
3985 if (iStatus != KErrNone) |
|
3986 { |
|
3987 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
3988 return EFail; |
|
3989 } |
|
3990 |
|
3991 iSocket.SetOpt(KDummyOptionSetFlowOffWrite, 0, ETrue); |
|
3992 |
|
3993 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the descriptor API - flowing control off</i>")); |
|
3994 |
|
3995 iSocket.Send(KSendData, 0, iStatus); |
|
3996 |
|
3997 iLogger.WriteFormat(_L("<i>Cancelling the Send request</i>")); |
|
3998 iSocket.CancelSend(); |
|
3999 |
|
4000 iState = EState3; |
|
4001 Reschedule(); |
|
4002 return EPass; |
|
4003 } |
|
4004 |
|
4005 case EState3: |
|
4006 { |
|
4007 |
|
4008 iLogger.WriteFormat(_L("<i>Checking that the completion code for Send is KErrCancel</i>")); |
|
4009 if (iStatus != KErrCancel) |
|
4010 { |
|
4011 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iStatus.Int()); |
|
4012 return EFail; |
|
4013 } |
|
4014 |
|
4015 iSocket.SetOpt(KDummyOptionSetFlowOffWrite, 0, EFalse); |
|
4016 |
|
4017 iLogger.WriteFormat(_L("<i>Resending data over an internal socket using the descriptor API - will not flow control off</i>")); |
|
4018 |
|
4019 iSocket.Send(KSendData, 0, iStatus); |
|
4020 |
|
4021 iState = EState4; |
|
4022 Reschedule(); |
|
4023 return EPass; |
|
4024 } |
|
4025 |
|
4026 case EState4: |
|
4027 { |
|
4028 if (iStatus != KErrNone) |
|
4029 { |
|
4030 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"), iStatus.Int()); |
|
4031 return EFail; |
|
4032 } |
|
4033 |
|
4034 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the descriptor API</i>")); |
|
4035 iBuf.Zero(); |
|
4036 iBuf.SetLength(KSendData().Length()); |
|
4037 iSocket.Recv(iBuf, 0, iStatus); |
|
4038 |
|
4039 iState = EState5; |
|
4040 Reschedule(); |
|
4041 return EPass; |
|
4042 } |
|
4043 |
|
4044 case EState5: |
|
4045 { |
|
4046 if (iStatus != KErrNone) |
|
4047 { |
|
4048 iLogger.WriteFormat(_L("<i>Recv() failed with %d</i>"),iStatus.Int()); |
|
4049 return EFail; |
|
4050 } |
|
4051 |
|
4052 iLogger.WriteFormat(_L("<i>Checking that the data was read into the buffer</i>")); |
|
4053 if (iBuf != KSendData) |
|
4054 { |
|
4055 iLogger.WriteFormat(_L("<i>Incorrect data to recved</i>")); |
|
4056 return EFail; |
|
4057 } |
|
4058 return EPass; |
|
4059 } |
|
4060 |
|
4061 default: |
|
4062 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 40)); |
|
4063 return EFail; |
|
4064 } |
|
4065 } |
|
4066 |
|
4067 void CEIntSockTest38::Cleanup() |
|
4068 { |
|
4069 iSocket.Close(); |
|
4070 } |
|
4071 |
|
4072 //------------------------------------------------------------------------------------------------- |
|
4073 // CEIntSockTest39 |
|
4074 //------------------------------------------------------------------------------------------------- |
|
4075 |
|
4076 CEIntSockTestBase* CEIntSockTest39::NewL( CProxyProvd* aProvd ) |
|
4077 { |
|
4078 CEIntSockTestBase* ret = new ( ELeave ) CEIntSockTest39( aProvd ); |
|
4079 return ret; |
|
4080 } |
|
4081 |
|
4082 CEIntSockTest39::CEIntSockTest39( CProxyProvd* aProvd ) |
|
4083 : CEIntSockTestBase(aProvd), |
|
4084 iState ( EState1 ) |
|
4085 |
|
4086 { |
|
4087 |
|
4088 } |
|
4089 |
|
4090 TVerdict CEIntSockTest39::RunTestL() |
|
4091 { |
|
4092 iLogger.WriteFormat(_L("<i>Test 39 - Open (asynchronous) and close socket</i>")); |
|
4093 iLogger.WriteFormat(_L("<i>Open socket to protocol by name</i>")); |
|
4094 switch ( iState ) |
|
4095 { |
|
4096 case EState1: |
|
4097 { |
|
4098 iLogger.WriteFormat(_L("<i>Open socket by name</i>")); |
|
4099 |
|
4100 iSocket.Open(KDummyTwoName, iStatus); |
|
4101 iState = EState2; |
|
4102 Reschedule (); |
|
4103 return EPass; |
|
4104 } |
|
4105 case EState2: |
|
4106 { |
|
4107 iLogger.WriteFormat(_L("<i>Open return with status code %d</i>"), iStatus.Int() ); |
|
4108 if (iStatus != KErrNone) |
|
4109 { |
|
4110 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),iStatus.Int()); |
|
4111 return EFail; |
|
4112 } |
|
4113 iLogger.WriteFormat(_L("<i>Close the socket</i>")); |
|
4114 iSocket.Close (); |
|
4115 iLogger.WriteFormat(_L("<i>Open socket to protocol supplying address family</i>")); |
|
4116 iSocket.Open(KDummyAddrFamily, KSockDatagram, KDummyOne, iStatus); |
|
4117 iState = EState3; |
|
4118 Reschedule (); |
|
4119 return EPass; |
|
4120 } |
|
4121 case EState3: |
|
4122 { |
|
4123 iLogger.WriteFormat(_L("<i>Open with address family return with status code %d</i>"), iStatus.Int() ); |
|
4124 if (iStatus != KErrNone) |
|
4125 { |
|
4126 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),iStatus.Int()); |
|
4127 return EFail; |
|
4128 } |
|
4129 return EPass; |
|
4130 } |
|
4131 default: |
|
4132 { |
|
4133 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 41)); |
|
4134 return EFail; |
|
4135 } |
|
4136 } |
|
4137 } |
|
4138 |
|
4139 void CEIntSockTest39::Cleanup() |
|
4140 { |
|
4141 iSocket.Close (); |
|
4142 } |
|
4143 |
|
4144 //------------------------------------------------------------------------------------------------- |
|
4145 // CEIntSockTest40 |
|
4146 //------------------------------------------------------------------------------------------------- |
|
4147 CEIntSockTestBase* CEIntSockTest40::NewL(CProxyProvd* aProvd) |
|
4148 { |
|
4149 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest40(aProvd); |
|
4150 return ret; |
|
4151 } |
|
4152 |
|
4153 CEIntSockTest40::CEIntSockTest40(CProxyProvd* aProvd) : |
|
4154 CEIntSockTestBase(aProvd), |
|
4155 iState(EState1) |
|
4156 {} |
|
4157 |
|
4158 TVerdict CEIntSockTest40::RunTestL() |
|
4159 { |
|
4160 TInt err; |
|
4161 switch(iState) |
|
4162 { |
|
4163 case EState1: |
|
4164 iLogger.WriteFormat(_L("<i>Test 40 - Asyn Open and cancel/close socket</i>")); |
|
4165 iLogger.WriteFormat(_L("<i>Asyn Open socket to protocol by name</i>")); |
|
4166 iSocket.Open(KDummyTwoName, iStatus); |
|
4167 iState = EState2; |
|
4168 Reschedule(); |
|
4169 return EPass; |
|
4170 case EState2: |
|
4171 if (iStatus != KErrNone) |
|
4172 { |
|
4173 iLogger.WriteFormat(_L("<i>Async Open() failed with %d</i>"),iStatus.Int()); |
|
4174 return EFail; |
|
4175 } |
|
4176 iSocket.Close(); |
|
4177 |
|
4178 iLogger.WriteFormat(_L("<i>Async Open socket to protocol supplying address family</i>")); |
|
4179 iSocket.Open(KDummyAddrFamily, KSockDatagram, KDummyOne, iStatus); |
|
4180 |
|
4181 iLogger.WriteFormat(_L("<i>Cancelling/Closing Async Open() </i>")); |
|
4182 iSocket.Close(); |
|
4183 |
|
4184 iState = EState3; |
|
4185 Reschedule(); |
|
4186 return EPass; |
|
4187 case EState3: |
|
4188 if(iStatus == KErrNone) |
|
4189 { |
|
4190 iSocket.Close(); |
|
4191 } |
|
4192 else if(iStatus != KErrAbort) |
|
4193 { |
|
4194 iLogger.WriteFormat(_L("<i>Cancelling Async Open failed with %d </i>"), iStatus.Int()); |
|
4195 return EFail; |
|
4196 } |
|
4197 |
|
4198 iLogger.WriteFormat(_L("<i>Open socket to protocol supplying address family</i>")); |
|
4199 err = iSocket.Open(KDummyAddrFamily, KSockDatagram, KDummyOne); |
|
4200 |
|
4201 if (err != KErrNone) |
|
4202 { |
|
4203 iLogger.WriteFormat(_L("<i>Async Open() failed with %d</i>"),err); |
|
4204 return EFail; |
|
4205 } |
|
4206 iSocket.Close(); |
|
4207 return EPass; |
|
4208 default: |
|
4209 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 42)); |
|
4210 return EFail; |
|
4211 } |
|
4212 } |
|
4213 |
|
4214 void CEIntSockTest40::Cleanup() |
|
4215 { |
|
4216 iSocket.Close(); |
|
4217 } |
|
4218 |
|
4219 |
|
4220 //------------------------------------------------------------------------------------------------- |
|
4221 // CEIntSockTest41 |
|
4222 //------------------------------------------------------------------------------------------------- |
|
4223 CEIntSockTestBase* CEIntSockTest41::NewL(CProxyProvd* aProvd) |
|
4224 { |
|
4225 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest41(aProvd); |
|
4226 return ret; |
|
4227 } |
|
4228 |
|
4229 CEIntSockTest41::CEIntSockTest41(CProxyProvd* aProvd) : |
|
4230 CEIntSockTestBase(aProvd), |
|
4231 iState(EState1) |
|
4232 {} |
|
4233 |
|
4234 TVerdict CEIntSockTest41::RunTestL() |
|
4235 { |
|
4236 _LIT8(KSendData,"1234567890"); |
|
4237 TInt err; |
|
4238 switch(iState) |
|
4239 { |
|
4240 case EState1: |
|
4241 iLogger.WriteFormat(_L("<i>Test 41 - SendTo/RecvFrom with descriptior (datagram protocol)</i>")); |
|
4242 iLogger.WriteFormat(_L("<i>Opening a datagram socket.</i>")); |
|
4243 err = iSocket.Open (KDummyOneName); |
|
4244 if ( err != KErrNone ) |
|
4245 { |
|
4246 iLogger.WriteFormat(_L("<i>Opening of datagram socket failed.</i>")); |
|
4247 return EFail; |
|
4248 } |
|
4249 iDestAddr.SetFamily(KProxyAddrFamily); |
|
4250 iBuf.Copy (KSendData()); |
|
4251 iSocket.SendTo(iBuf, iDestAddr, 0, iStatus); |
|
4252 iState = EState2; |
|
4253 Reschedule(); |
|
4254 return EPass; |
|
4255 case EState2: |
|
4256 if(iStatus != KErrNone) |
|
4257 { |
|
4258 iLogger.WriteFormat(_L("<i>SendTo failed with error code %d.</i>"), iStatus.Int() ); |
|
4259 return EFail; |
|
4260 } |
|
4261 iBuf.Zero(); |
|
4262 iSocket.RecvFrom (iBuf, iRemoteAddr, 0, iStatus); |
|
4263 iState = EState3; |
|
4264 Reschedule(); |
|
4265 return EPass; |
|
4266 case EState3: |
|
4267 { |
|
4268 if(iStatus != KErrNone) |
|
4269 { |
|
4270 iLogger.WriteFormat(_L("<i>RecvFrom failed with error code %d.</i>"), iStatus.Int() ); |
|
4271 return EFail; |
|
4272 } |
|
4273 if (iDestAddr.Family() != iRemoteAddr.Family()) |
|
4274 { |
|
4275 iLogger.WriteFormat(_L("<i>SendTo address is different from RecvFrom address.</i>")); |
|
4276 return EFail; |
|
4277 } |
|
4278 |
|
4279 if ( iBuf != KSendData() ) |
|
4280 { |
|
4281 iLogger.WriteFormat(_L("<i>SendTo data is different from RecvFrom data.</i>")); |
|
4282 return EFail; |
|
4283 } |
|
4284 return EPass; |
|
4285 } |
|
4286 default: |
|
4287 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 43)); |
|
4288 return EFail; |
|
4289 } |
|
4290 } |
|
4291 |
|
4292 void CEIntSockTest41::Cleanup() |
|
4293 { |
|
4294 iSocket.Close(); |
|
4295 } |
|
4296 |
|
4297 //------------------------------------------------------------------------------------------------- |
|
4298 // CEIntSockTest42 |
|
4299 //------------------------------------------------------------------------------------------------- |
|
4300 CEIntSockTestBase* CEIntSockTest42::NewL(CProxyProvd* aProvd) |
|
4301 { |
|
4302 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest42(aProvd); |
|
4303 return ret; |
|
4304 } |
|
4305 |
|
4306 CEIntSockTest42::CEIntSockTest42(CProxyProvd* aProvd) : |
|
4307 CEIntSockTestBase(aProvd), |
|
4308 iState(EState1) |
|
4309 {} |
|
4310 |
|
4311 TVerdict CEIntSockTest42::RunTestL() |
|
4312 { |
|
4313 _LIT8(KSendData,"1234567890"); |
|
4314 TInt err; |
|
4315 switch(iState) |
|
4316 { |
|
4317 case EState1: |
|
4318 iLogger.WriteFormat(_L("<i>Test 42 - SendTo/RecvFrom with RMBufChain (datagram protocol)</i>")); |
|
4319 iLogger.WriteFormat(_L("<i>Opening a datagram socket.</i>")); |
|
4320 err = iSocket.Open (KDummyOneName); |
|
4321 if ( err != KErrNone ) |
|
4322 { |
|
4323 iLogger.WriteFormat(_L("<i>Opening of datagram socket failed.</i>")); |
|
4324 return EFail; |
|
4325 } |
|
4326 iDestAddr.SetFamily(KProxyAddrFamily); |
|
4327 iSendChain.CreateL(KSendData()); |
|
4328 |
|
4329 iLogger.WriteFormat(_L("<i>SendTo data over an internal socket using the RMBufChain API</i>")); |
|
4330 |
|
4331 iSocket.SendTo(iSendChain, iDestAddr, 0, iStatus); |
|
4332 iState = EState2; |
|
4333 Reschedule(); |
|
4334 return EPass; |
|
4335 case EState2: |
|
4336 if(iStatus != KErrNone) |
|
4337 { |
|
4338 iLogger.WriteFormat(_L("<i>SendTo failed with error code %d.</i>"), iStatus.Int() ); |
|
4339 return EFail; |
|
4340 } |
|
4341 iSendChain.Remove (); |
|
4342 |
|
4343 |
|
4344 iBuf.SetLength(KSendData().Length()); |
|
4345 iSocket.RecvFrom (iRecvChain, iRemoteAddr, 0, iStatus); |
|
4346 iState = EState3; |
|
4347 Reschedule(); |
|
4348 return EPass; |
|
4349 case EState3: |
|
4350 { |
|
4351 if(iStatus != KErrNone) |
|
4352 { |
|
4353 iLogger.WriteFormat(_L("<i>RecvFrom failed with error code %d.</i>"), iStatus.Int() ); |
|
4354 return EFail; |
|
4355 } |
|
4356 if (iDestAddr.Family() != iRemoteAddr.Family()) |
|
4357 { |
|
4358 iLogger.WriteFormat(_L("<i>SendTo address is different from RecvFrom address.</i>")); |
|
4359 return EFail; |
|
4360 } |
|
4361 iRecvChain.CopyOut(iBuf); |
|
4362 iRecvChain.Free (); |
|
4363 if ( iBuf != KSendData ) |
|
4364 { |
|
4365 iLogger.WriteFormat(_L("<i>SendTo data is different from RecvFrom data.</i>")); |
|
4366 return EFail; |
|
4367 } |
|
4368 |
|
4369 return EPass; |
|
4370 } |
|
4371 default: |
|
4372 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 44)); |
|
4373 return EFail; |
|
4374 } |
|
4375 } |
|
4376 |
|
4377 void CEIntSockTest42::Cleanup() |
|
4378 { |
|
4379 iSocket.Close(); |
|
4380 __ASSERT_DEBUG(iRecvChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 45)); |
|
4381 __ASSERT_DEBUG(iSendChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 46)); |
|
4382 } |
|
4383 |
|
4384 //------------------------------------------------------------------------------------------------- |
|
4385 // CEIntSockTest43 |
|
4386 //------------------------------------------------------------------------------------------------- |
|
4387 CEIntSockTestBase* CEIntSockTest43::NewL(CProxyProvd* aProvd) |
|
4388 { |
|
4389 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest43(aProvd); |
|
4390 return ret; |
|
4391 } |
|
4392 |
|
4393 CEIntSockTest43::CEIntSockTest43(CProxyProvd* aProvd) : |
|
4394 CEIntSockTestBase(aProvd), |
|
4395 iState(EState1) |
|
4396 {} |
|
4397 |
|
4398 TVerdict CEIntSockTest43::RunTestL() |
|
4399 { |
|
4400 _LIT8(KSendData,"1234567890"); |
|
4401 TInt err; |
|
4402 switch(iState) |
|
4403 { |
|
4404 case EState1: |
|
4405 iLogger.WriteFormat(_L("<i>Test 43 - SendTo/RecvFrom with length --- descriptior (datagram protocol)</i>")); |
|
4406 iLogger.WriteFormat(_L("<i>Opening a datagram socket.</i>")); |
|
4407 err = iSocket.Open (KDummyOneName); |
|
4408 if ( err != KErrNone ) |
|
4409 { |
|
4410 iLogger.WriteFormat(_L("<i>Opening of datagram socket failed.</i>")); |
|
4411 return EFail; |
|
4412 } |
|
4413 iDestAddr.SetFamily(KProxyAddrFamily); |
|
4414 iBuf.Copy (KSendData()); |
|
4415 iSocket.SendTo(iBuf, iDestAddr, 0, iStatus, iLength); |
|
4416 iState = EState2; |
|
4417 Reschedule(); |
|
4418 return EPass; |
|
4419 case EState2: |
|
4420 if(iStatus != KErrNone) |
|
4421 { |
|
4422 iLogger.WriteFormat(_L("<i>SendTo failed with error code %d.</i>"), iStatus.Int() ); |
|
4423 return EFail; |
|
4424 } |
|
4425 |
|
4426 if ( iLength() != KSendData().Length() ) |
|
4427 { |
|
4428 iLogger.WriteFormat(_L("<i>SendTo didn't return the expected send length.</i>") ); |
|
4429 return EFail; |
|
4430 } |
|
4431 iLength = 0; |
|
4432 iBuf.Zero(); |
|
4433 iSocket.RecvFrom (iBuf, iRemoteAddr, 0, iStatus, iLength); |
|
4434 iState = EState3; |
|
4435 Reschedule(); |
|
4436 return EPass; |
|
4437 case EState3: |
|
4438 { |
|
4439 if(iStatus != KErrNone) |
|
4440 { |
|
4441 iLogger.WriteFormat(_L("<i>RecvFrom failed with error code %d.</i>"), iStatus.Int() ); |
|
4442 return EFail; |
|
4443 } |
|
4444 if ( iLength() != 0 ) |
|
4445 { |
|
4446 iLogger.WriteFormat(_L("<i>RecvFrom didn't return the expected send length.</i>")); |
|
4447 return EFail; |
|
4448 } |
|
4449 if (iDestAddr.Family() != iRemoteAddr.Family()) |
|
4450 { |
|
4451 iLogger.WriteFormat(_L("<i>SendTo address is different from RecvFrom address.</i>")); |
|
4452 return EFail; |
|
4453 } |
|
4454 |
|
4455 if ( iBuf != KSendData() ) |
|
4456 { |
|
4457 iLogger.WriteFormat(_L("<i>SendTo data is different from RecvFrom data.</i>")); |
|
4458 return EFail; |
|
4459 } |
|
4460 |
|
4461 return EPass; |
|
4462 } |
|
4463 default: |
|
4464 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 47)); |
|
4465 return EFail; |
|
4466 } |
|
4467 } |
|
4468 |
|
4469 void CEIntSockTest43::Cleanup() |
|
4470 { |
|
4471 iSocket.Close(); |
|
4472 } |
|
4473 |
|
4474 //------------------------------------------------------------------------------------------------- |
|
4475 // CEIntSockTest44 |
|
4476 //------------------------------------------------------------------------------------------------- |
|
4477 CEIntSockTestBase* CEIntSockTest44::NewL(CProxyProvd* aProvd) |
|
4478 { |
|
4479 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest44(aProvd); |
|
4480 return ret; |
|
4481 } |
|
4482 |
|
4483 CEIntSockTest44::CEIntSockTest44(CProxyProvd* aProvd) : |
|
4484 CEIntSockTestBase(aProvd), |
|
4485 iState(EState1) |
|
4486 {} |
|
4487 |
|
4488 TVerdict CEIntSockTest44::RunTestL() |
|
4489 { |
|
4490 _LIT8(KSendData,"1234567890"); |
|
4491 TInt err; |
|
4492 switch(iState) |
|
4493 { |
|
4494 case EState1: |
|
4495 iLogger.WriteFormat(_L("<i>Test 44 - SendTo/RecvFrom with RMBufChain (datagram protocol)</i>")); |
|
4496 iLogger.WriteFormat(_L("<i>Opening a datagram socket.</i>")); |
|
4497 err = iSocket.Open (KDummyOneName); |
|
4498 if ( err != KErrNone ) |
|
4499 { |
|
4500 iLogger.WriteFormat(_L("<i>Opening of datagram socket failed.</i>")); |
|
4501 return EFail; |
|
4502 } |
|
4503 iDestAddr.SetFamily(KProxyAddrFamily); |
|
4504 iSendChain.CreateL(KSendData()); |
|
4505 |
|
4506 iLogger.WriteFormat(_L("<i>SendTo data over an internal socket using the RMBufChain API</i>")); |
|
4507 |
|
4508 iSocket.SendTo(iSendChain, iDestAddr, 0, iStatus, iLength); |
|
4509 iState = EState2; |
|
4510 Reschedule(); |
|
4511 return EPass; |
|
4512 case EState2: |
|
4513 if(iStatus != KErrNone) |
|
4514 { |
|
4515 iLogger.WriteFormat(_L("<i>SendTo failed with error code %d.</i>"), iStatus.Int() ); |
|
4516 return EFail; |
|
4517 } |
|
4518 if ( iLength() != KSendData().Length() ) |
|
4519 { |
|
4520 iLogger.WriteFormat(_L("<i>SendTo didn't return the expected send length.</i>") ); |
|
4521 return EFail; |
|
4522 } |
|
4523 |
|
4524 iSendChain.Remove (); |
|
4525 |
|
4526 iLength = 0; |
|
4527 iBuf.SetLength(KSendData().Length()); |
|
4528 iSocket.RecvFrom (iRecvChain, iRemoteAddr, 0, iStatus, iLength); |
|
4529 iState = EState3; |
|
4530 Reschedule(); |
|
4531 return EPass; |
|
4532 case EState3: |
|
4533 { |
|
4534 if(iStatus != KErrNone) |
|
4535 { |
|
4536 iLogger.WriteFormat(_L("<i>RecvFrom failed with error code %d.</i>"), iStatus.Int() ); |
|
4537 return EFail; |
|
4538 } |
|
4539 |
|
4540 if ( iLength() != 0 ) |
|
4541 { |
|
4542 iLogger.WriteFormat(_L("<i>RecvFrom didn't return the expected send length %d.</i>"), iLength() ); |
|
4543 return EFail; |
|
4544 } |
|
4545 |
|
4546 if (iDestAddr.Family() != iRemoteAddr.Family()) |
|
4547 { |
|
4548 iLogger.WriteFormat(_L("<i>SendTo address is different from RecvFrom address.</i>")); |
|
4549 return EFail; |
|
4550 } |
|
4551 iRecvChain.CopyOut(iBuf); |
|
4552 iRecvChain.Free (); |
|
4553 |
|
4554 if ( iBuf != KSendData ) |
|
4555 { |
|
4556 iLogger.WriteFormat(_L("<i>SendTo data is different from RecvFrom data.</i>")); |
|
4557 return EFail; |
|
4558 } |
|
4559 |
|
4560 return EPass; |
|
4561 } |
|
4562 default: |
|
4563 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 48)); |
|
4564 return EFail; |
|
4565 } |
|
4566 } |
|
4567 |
|
4568 void CEIntSockTest44::Cleanup() |
|
4569 { |
|
4570 iSocket.Close(); |
|
4571 __ASSERT_DEBUG(iSendChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 49)); |
|
4572 __ASSERT_DEBUG(iRecvChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 50)); |
|
4573 } |
|
4574 |
|
4575 //------------------------------------------------------------------------------------------------- |
|
4576 // CEIntSockTest45 |
|
4577 //------------------------------------------------------------------------------------------------- |
|
4578 |
|
4579 CEIntSockTestBase* CEIntSockTest45::NewL(CProxyProvd* aProvd) |
|
4580 { |
|
4581 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest45(aProvd); |
|
4582 return ret; |
|
4583 } |
|
4584 |
|
4585 CEIntSockTest45::CEIntSockTest45(CProxyProvd* aProvd) : |
|
4586 CEIntSockTestBase(aProvd), |
|
4587 iState(EState1) |
|
4588 {} |
|
4589 |
|
4590 TVerdict CEIntSockTest45::RunTestL() |
|
4591 { |
|
4592 TInt err; |
|
4593 _LIT8(KSendData,"1234567890"); |
|
4594 switch (iState) |
|
4595 { |
|
4596 case EState1: |
|
4597 { |
|
4598 iLogger.WriteFormat(_L("<i> Test 45 - Send and receive a stream protocol that temporarily flows control off(RMBufChain API)</i>")); |
|
4599 iLogger.WriteFormat(_L("<i>Opening PDummy 2</i>")); |
|
4600 err = iSocket.Open(KDummyTwoName); |
|
4601 if (err != KErrNone) |
|
4602 { |
|
4603 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
4604 return EFail; |
|
4605 } |
|
4606 |
|
4607 iDestAddr.SetFamily(KProxyAddrFamily); |
|
4608 iLogger.WriteFormat(_L("<i>Opening an internal socket (stream protocol)</i>")); |
|
4609 iSocket.Connect(iDestAddr, iStatus); |
|
4610 |
|
4611 iState = EState2; |
|
4612 Reschedule(); |
|
4613 return EPass; |
|
4614 } |
|
4615 case EState2: |
|
4616 { |
|
4617 if (iStatus != KErrNone) |
|
4618 { |
|
4619 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
4620 return EFail; |
|
4621 } |
|
4622 |
|
4623 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the RMBufChain API</i>")); |
|
4624 |
|
4625 iSendChain.CreateL(KSendData()); |
|
4626 iSocket.SetOpt(KDummyOptionSetTimedFlowOffWrite, 0, KDummyWriteFlowOffTimeout); |
|
4627 iSocket.Send(iSendChain,0,iStatus); |
|
4628 |
|
4629 iState = EState3; |
|
4630 Reschedule(); |
|
4631 return EPass; |
|
4632 } |
|
4633 case EState3: |
|
4634 { |
|
4635 if (iStatus != KErrNone) |
|
4636 { |
|
4637 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iStatus.Int()); |
|
4638 return EFail; |
|
4639 } |
|
4640 |
|
4641 iSendChain.Remove(); |
|
4642 |
|
4643 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the RMBufChain API</i>")); |
|
4644 iSocket.SetOpt(KDummyOptionSetTimedFlowOffWrite, 0, 0); |
|
4645 iBuf.SetLength(KSendData().Length()); |
|
4646 iSocket.Recv(iRecvChain,0,iStatus); |
|
4647 |
|
4648 iState = EState4; |
|
4649 Reschedule(); |
|
4650 return EPass; |
|
4651 } |
|
4652 case EState4: |
|
4653 { |
|
4654 if (iStatus != KErrNone) |
|
4655 { |
|
4656 iLogger.WriteFormat(_L("<i>Recv() failed returning %d</i>"),iStatus.Int()); |
|
4657 return EFail; |
|
4658 } |
|
4659 iRecvChain.CopyOut(iBuf); |
|
4660 iRecvChain.Free(); |
|
4661 |
|
4662 iLogger.WriteFormat(_L("<i>Checking that the data was read into the buffer</i>")); |
|
4663 if (iBuf != KSendData()) |
|
4664 { |
|
4665 iLogger.WriteFormat(_L("<i>Incorrect data to recved</i>")); |
|
4666 return EFail; |
|
4667 } |
|
4668 |
|
4669 return EPass; |
|
4670 } |
|
4671 |
|
4672 |
|
4673 default: |
|
4674 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 51)); |
|
4675 return EFail; |
|
4676 } |
|
4677 } |
|
4678 |
|
4679 void CEIntSockTest45::Cleanup() |
|
4680 { |
|
4681 iSocket.Close(); |
|
4682 __ASSERT_DEBUG(iSendChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 52)); |
|
4683 __ASSERT_DEBUG(iRecvChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 53)); |
|
4684 } |
|
4685 |
|
4686 //------------------------------------------------------------------------------------------------- |
|
4687 // CEIntSockTest46 |
|
4688 //------------------------------------------------------------------------------------------------- |
|
4689 |
|
4690 CEIntSockTestBase* CEIntSockTest46::NewL(CProxyProvd* aProvd) |
|
4691 { |
|
4692 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest46(aProvd); |
|
4693 return ret; |
|
4694 } |
|
4695 |
|
4696 CEIntSockTest46::CEIntSockTest46(CProxyProvd* aProvd) : |
|
4697 CEIntSockTestBase(aProvd), |
|
4698 iState(EState1) |
|
4699 {} |
|
4700 |
|
4701 TVerdict CEIntSockTest46::RunTestL() |
|
4702 { |
|
4703 |
|
4704 TInt err; |
|
4705 _LIT8(KSendData,"1234567890"); |
|
4706 switch (iState) |
|
4707 { |
|
4708 case EState1: |
|
4709 { |
|
4710 iLogger.WriteFormat(_L("<i>Test 46 - Send to and receive (with RecvOneOrMore )from a stream protocol (Descriptor API) </i>")); |
|
4711 iLogger.WriteFormat(_L("<i>Opening a socket to PDummy 2</i>")); |
|
4712 err = iSocket.Open(KDummyTwoName); |
|
4713 if (err != KErrNone) |
|
4714 { |
|
4715 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
4716 return EFail; |
|
4717 } |
|
4718 |
|
4719 iLogger.WriteFormat(_L("<i>Opening an internal socket (stream protocol)</i>")); |
|
4720 |
|
4721 iDestAddr.SetFamily(KProxyAddrFamily); |
|
4722 iSocket.Connect(iDestAddr, iStatus); |
|
4723 |
|
4724 iState = EState2; |
|
4725 Reschedule(); |
|
4726 return EPass; |
|
4727 } |
|
4728 case EState2: |
|
4729 { |
|
4730 if (iStatus != KErrNone) |
|
4731 { |
|
4732 iLogger.WriteFormat(_L("<i>Connect() failed with %d</i>"),iStatus.Int()); |
|
4733 return EFail; |
|
4734 } |
|
4735 iBuf.Copy ( KSendData() ); |
|
4736 iLogger.WriteFormat(_L("<i>Sending data over an internal socket using the descriptor API</i>")); |
|
4737 iSocket.Send(iBuf,0,iStatus); |
|
4738 |
|
4739 iState = EState3; |
|
4740 Reschedule(); |
|
4741 return EPass; |
|
4742 } |
|
4743 case EState3: |
|
4744 { |
|
4745 if (iStatus != KErrNone) |
|
4746 { |
|
4747 iLogger.WriteFormat(_L("<i>Send() failed with %d</i>"),iStatus.Int()); |
|
4748 return EFail; |
|
4749 } |
|
4750 |
|
4751 iLogger.WriteFormat(_L("<i>Receiving data over an internal socket using the descriptor API</i>")); |
|
4752 iBuf.Zero(); |
|
4753 iBuf.SetLength(KSendData().Length()); |
|
4754 iSocket.RecvOneOrMore(iBuf,0,iStatus, iLength); |
|
4755 |
|
4756 iState = EState4; |
|
4757 Reschedule(); |
|
4758 return EPass; |
|
4759 } |
|
4760 case EState4: |
|
4761 { |
|
4762 if (iStatus != KErrNone) |
|
4763 { |
|
4764 iLogger.WriteFormat(_L("<i>Recv() didn't return KErrNotSupported (returned %d)</i>"),iStatus.Int()); |
|
4765 return EFail; |
|
4766 } |
|
4767 |
|
4768 iLogger.WriteFormat(_L("<i>Checking that the data was read into the buffer</i>")); |
|
4769 if (iBuf != KSendData) |
|
4770 { |
|
4771 iLogger.WriteFormat(_L("<i>Incorrect data to recved</i>")); |
|
4772 return EFail; |
|
4773 } |
|
4774 |
|
4775 if ( iLength() != KSendData().Length() ) |
|
4776 { |
|
4777 iLogger.WriteFormat(_L("<i>RecvOneOrMore didn't return the expected send length.</i>") ); |
|
4778 return EFail; |
|
4779 } |
|
4780 |
|
4781 return EPass; |
|
4782 } |
|
4783 default: |
|
4784 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 54)); |
|
4785 return EFail; |
|
4786 } |
|
4787 } |
|
4788 |
|
4789 void CEIntSockTest46::Cleanup() |
|
4790 { |
|
4791 iSocket.Close(); |
|
4792 } |
|
4793 |
|
4794 //------------------------------------------------------------------------------------------------- |
|
4795 // CEIntSockTest47 |
|
4796 //------------------------------------------------------------------------------------------------- |
|
4797 |
|
4798 CEIntSockTestBase* CEIntSockTest47::NewL(CProxyProvd* aProvd) |
|
4799 { |
|
4800 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest47(aProvd); |
|
4801 return ret; |
|
4802 } |
|
4803 |
|
4804 CEIntSockTest47::CEIntSockTest47(CProxyProvd* aProvd) : |
|
4805 CEIntSockTestBase(aProvd), |
|
4806 iState(EState1) |
|
4807 {} |
|
4808 |
|
4809 TVerdict CEIntSockTest47::RunTestL() |
|
4810 { |
|
4811 |
|
4812 TInt err; |
|
4813 switch (iState) |
|
4814 { |
|
4815 case EState1: |
|
4816 { |
|
4817 iLogger.WriteFormat(_L("<i>Test 47 - Ioctl returns not supported on null socket </i>")); |
|
4818 iLogger.WriteFormat(_L("<i>Opening a null socket</i>")); |
|
4819 err = iSocket.Open(); |
|
4820 if (err != KErrNone) |
|
4821 { |
|
4822 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
4823 return EFail; |
|
4824 } |
|
4825 |
|
4826 iLogger.WriteFormat(_L("<i>Perform Ioctl on the null socket</i>")); |
|
4827 |
|
4828 iSocket.Ioctl(KDummyIoctlCheckStarted, iStatus); |
|
4829 iState = EState2; |
|
4830 Reschedule(); |
|
4831 return EPass; |
|
4832 } |
|
4833 case EState2: |
|
4834 { |
|
4835 if (iStatus != KErrNotSupported) |
|
4836 { |
|
4837 iLogger.WriteFormat(_L("<i>Ioctl operation on null socket returns %d != KErrNotSupported</i>"),iStatus.Int()); |
|
4838 return EFail; |
|
4839 } |
|
4840 return EPass; |
|
4841 } |
|
4842 default: |
|
4843 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 55)); |
|
4844 return EFail; |
|
4845 } |
|
4846 } |
|
4847 |
|
4848 void CEIntSockTest47::Cleanup() |
|
4849 { |
|
4850 iSocket.Close(); |
|
4851 } |
|
4852 |
|
4853 |
|
4854 //------------------------------------------------------------------------------------------------- |
|
4855 // CEIntSockTest48 |
|
4856 //------------------------------------------------------------------------------------------------- |
|
4857 |
|
4858 CEIntSockTestBase* CEIntSockTest48::NewL(CProxyProvd* aProvd) |
|
4859 { |
|
4860 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest48(aProvd); |
|
4861 return ret; |
|
4862 } |
|
4863 |
|
4864 CEIntSockTest48::CEIntSockTest48(CProxyProvd* aProvd) : |
|
4865 CEIntSockTestBase(aProvd), |
|
4866 iState(EState1) |
|
4867 {} |
|
4868 |
|
4869 TVerdict CEIntSockTest48::RunTestL() |
|
4870 { |
|
4871 TInt err = KErrNone; |
|
4872 switch (iState) |
|
4873 { |
|
4874 case EState1: |
|
4875 { |
|
4876 iLogger.WriteFormat(_L("<i>Test 48 - Ioctl observes InternalOptionBit </i>")); |
|
4877 iLogger.WriteFormat(_L("<i>Opening a Dummy Protocol 1 socket</i>")); |
|
4878 iSocket.Open(KDummyOneName, iStatus); |
|
4879 |
|
4880 iState = EState2; |
|
4881 Reschedule(); |
|
4882 return EPass; |
|
4883 } |
|
4884 case EState2: |
|
4885 { |
|
4886 if (iStatus != KErrNone) |
|
4887 { |
|
4888 iLogger.WriteFormat(_L("<i>Open on Dummy Protocol 1 socket returns %d</i>"),iStatus.Int()); |
|
4889 return EFail; |
|
4890 } |
|
4891 |
|
4892 iLogger.WriteFormat(_L("<i>Perform Ioctl with InternalIoctlBit</i>")); |
|
4893 iSocket.Ioctl(KInternalIoctlBit, iStatus); |
|
4894 |
|
4895 iState = EState3; |
|
4896 Reschedule(); |
|
4897 return EPass; |
|
4898 } |
|
4899 case EState3: |
|
4900 { |
|
4901 if (iStatus != KErrAccessDenied) |
|
4902 { |
|
4903 iLogger.WriteFormat(_L("<i>Ioctl option with KInternalIoctlBit failed with error = %d</i>"),iStatus.Int()); |
|
4904 return EFail; |
|
4905 } |
|
4906 |
|
4907 iLogger.WriteFormat(_L("<i>SetOpt with internal options bit</i>")); |
|
4908 err = iSocket.SetOpt(KSocketInternalOptionBit, KSOLSocket); |
|
4909 if (err != KErrAccessDenied) |
|
4910 { |
|
4911 iLogger.WriteFormat(_L("<i>Setopt with internal options bit returned with error = %d != KErrAccessDenied</i>"),iStatus.Int()); |
|
4912 return EFail; |
|
4913 } |
|
4914 |
|
4915 iLogger.WriteFormat(_L("Trying to GetOpt internal options bit")); |
|
4916 TPckgBuf<TBool> boolean; |
|
4917 err = iSocket.GetOpt(KSocketInternalOptionBit, KSOLSocket, boolean); |
|
4918 if (err != KErrAccessDenied) |
|
4919 { |
|
4920 iLogger.WriteFormat(_L("<i>Getopt with internal options bit returned with error = %d != KErrAccessDenied</i>"),iStatus.Int()); |
|
4921 return EFail; |
|
4922 } |
|
4923 |
|
4924 iLogger.WriteFormat(_L("<i>Testing StartL() with Ioctl KDummyIoctlCheckStarted</i>")); |
|
4925 iSocket.Ioctl(KDummyIoctlCheckStarted, iStatus, NULL, KIoctlDummyLevel); |
|
4926 |
|
4927 iState = EState4; |
|
4928 Reschedule(); |
|
4929 return EPass; |
|
4930 } |
|
4931 case EState4: |
|
4932 if (iStatus != KErrNone) |
|
4933 { |
|
4934 iLogger.WriteFormat(_L("<i>Ioctl with KDummIoctlCheckStarted returned with error = %d != KErrNone</i>"),iStatus.Int()); |
|
4935 return EFail; |
|
4936 } |
|
4937 return EPass; |
|
4938 default: |
|
4939 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 56)); |
|
4940 return EFail; |
|
4941 } |
|
4942 } |
|
4943 |
|
4944 void CEIntSockTest48::Cleanup() |
|
4945 { |
|
4946 iSocket.Close(); |
|
4947 } |
|
4948 |
|
4949 //------------------------------------------------------------------------------------------------- |
|
4950 // CEIntSockTest49 |
|
4951 //------------------------------------------------------------------------------------------------- |
|
4952 |
|
4953 CEIntSockTestBase* CEIntSockTest49::NewL(CProxyProvd* aProvd) |
|
4954 { |
|
4955 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest49(aProvd); |
|
4956 return ret; |
|
4957 } |
|
4958 |
|
4959 CEIntSockTest49::CEIntSockTest49(CProxyProvd* aProvd) : |
|
4960 CEIntSockTestBase(aProvd), |
|
4961 iState(EState1) |
|
4962 {} |
|
4963 |
|
4964 TVerdict CEIntSockTest49::RunTestL() |
|
4965 { |
|
4966 switch (iState) |
|
4967 { |
|
4968 case EState1: |
|
4969 { |
|
4970 iLogger.WriteFormat(_L("<i>Test 49 - Ioctl auto bind and check started </i>")); |
|
4971 iLogger.WriteFormat(_L("<i>Opening a Dummy Protocol 1 socket</i>")); |
|
4972 iSocket.Open(KDummyOneName, iStatus); |
|
4973 |
|
4974 iState = EState2; |
|
4975 Reschedule(); |
|
4976 return EPass; |
|
4977 } |
|
4978 case EState2: |
|
4979 { |
|
4980 if (iStatus != KErrNone) |
|
4981 { |
|
4982 iLogger.WriteFormat(_L("<i>Open on Dummy Protocol 1 socket returns %d</i>"),iStatus.Int()); |
|
4983 return EFail; |
|
4984 } |
|
4985 |
|
4986 iLogger.WriteFormat(_L("<i>Perform Ioctl with KDummyIoctlCheckStarted</i>")); |
|
4987 iSocket.Ioctl(KDummyIoctlCheckStarted, iStatus, NULL, KIoctlDummyLevel); |
|
4988 |
|
4989 iState = EState3; |
|
4990 Reschedule(); |
|
4991 return EPass; |
|
4992 } |
|
4993 case EState3: |
|
4994 if (iStatus != KErrNone) |
|
4995 { |
|
4996 iLogger.WriteFormat(_L("<i>Ioctl option with KInternalIoctlBit failed with error = %d</i>"),iStatus.Int()); |
|
4997 return EFail; |
|
4998 } |
|
4999 |
|
5000 iLogger.WriteFormat(_L("<i>Auto bind -- Connect the socket</i>")); |
|
5001 iSocket.Connect(iAddress, iStatus); |
|
5002 |
|
5003 iState = EState4; |
|
5004 Reschedule(); |
|
5005 return EPass; |
|
5006 case EState4: |
|
5007 if (iStatus != KErrNone) |
|
5008 { |
|
5009 iLogger.WriteFormat(_L("<i>Connect failed with = %d != KErrNone</i>"),iStatus.Int()); |
|
5010 return EFail; |
|
5011 } |
|
5012 iLogger.WriteFormat(_L("<i>Checking bound status with Ioctl</i>")); |
|
5013 iSocket.Ioctl(KDummyIoctlCheckBound, iStatus, NULL, KIoctlDummyLevel); |
|
5014 |
|
5015 iState = EState5; |
|
5016 Reschedule(); |
|
5017 return EPass; |
|
5018 case EState5: |
|
5019 if (iStatus != KErrNone) |
|
5020 { |
|
5021 iLogger.WriteFormat(_L("<i>Checking bound status with Ioctl failed with = %d != KErrNone</i>"),iStatus.Int()); |
|
5022 return EFail; |
|
5023 } |
|
5024 return EPass; |
|
5025 default: |
|
5026 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 57)); |
|
5027 return EFail; |
|
5028 } |
|
5029 } |
|
5030 |
|
5031 void CEIntSockTest49::Cleanup() |
|
5032 { |
|
5033 iSocket.Close(); |
|
5034 } |
|
5035 |
|
5036 //------------------------------------------------------------------------------------------------- |
|
5037 // CEIntSockTest50 |
|
5038 //------------------------------------------------------------------------------------------------- |
|
5039 |
|
5040 CEIntSockTestBase* CEIntSockTest50::NewL(CProxyProvd* aProvd) |
|
5041 { |
|
5042 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest50(aProvd); |
|
5043 return ret; |
|
5044 } |
|
5045 |
|
5046 CEIntSockTest50::CEIntSockTest50(CProxyProvd* aProvd) : |
|
5047 CEIntSockTestBase(aProvd), |
|
5048 iState(EState1) |
|
5049 {} |
|
5050 |
|
5051 TVerdict CEIntSockTest50::RunTestL() |
|
5052 { |
|
5053 TInt err = KErrNone; |
|
5054 switch (iState) |
|
5055 { |
|
5056 case EState1: |
|
5057 { |
|
5058 iLogger.WriteFormat(_L("<i>Test 50 - Get and Set options </i>")); |
|
5059 iLogger.WriteFormat(_L("<i>Opening a Dummy Protocol 1 socket</i>")); |
|
5060 iSocket.Open(KDummyOneName, iStatus); |
|
5061 |
|
5062 iState = EState2; |
|
5063 Reschedule(); |
|
5064 return EPass; |
|
5065 } |
|
5066 case EState2: |
|
5067 { |
|
5068 if (iStatus != KErrNone) |
|
5069 { |
|
5070 iLogger.WriteFormat(_L("<i>Open on Dummy Protocol 1 socket returns %d</i>"),iStatus.Int()); |
|
5071 return EFail; |
|
5072 } |
|
5073 |
|
5074 const TInt KPort = 666; |
|
5075 iLogger.WriteFormat(_L("Set local port as %d"), KPort); |
|
5076 err = iSocket.SetLocalPort(KPort); |
|
5077 if (err != KErrNone) |
|
5078 { |
|
5079 iLogger.WriteFormat(_L("<i>Set local port as 666 failed with error = %d</i>"),iStatus.Int()); |
|
5080 return EFail; |
|
5081 } |
|
5082 |
|
5083 iLogger.WriteFormat(_L("Get local port that is set. should be %d"), KPort); |
|
5084 TInt port = iSocket.LocalPort(); |
|
5085 if (port != KPort) |
|
5086 { |
|
5087 iLogger.WriteFormat(_L("<i>Get local port failed Got = %d Expected = %d</i>"), port, KPort); |
|
5088 return EFail; |
|
5089 } |
|
5090 |
|
5091 iLogger.WriteFormat(_L("SetOpt with KSONonBlockingIO")); |
|
5092 err = iSocket.SetOpt(KSONonBlockingIO, KSOLSocket); |
|
5093 if (err != KErrNone) |
|
5094 { |
|
5095 iLogger.WriteFormat(_L("SetOpt with KSONonBlockingIO failed with error = %d"), err); |
|
5096 return EFail; |
|
5097 } |
|
5098 |
|
5099 |
|
5100 iLogger.WriteFormat(_L("GetOpt with KSONonBlockingIO")); |
|
5101 TPckgBuf<TBool> boolean; |
|
5102 err = iSocket.GetOpt(KSONonBlockingIO, KSOLSocket, boolean); |
|
5103 if (err != KErrNone) |
|
5104 { |
|
5105 iLogger.WriteFormat(_L("GetOpt with KSONonBlockingIO failed with error = %d"), err); |
|
5106 return EFail; |
|
5107 } |
|
5108 |
|
5109 if (boolean() != TRUE) |
|
5110 { |
|
5111 iLogger.WriteFormat(_L("The value returned on GetOpt with KSONonBlockingIO failed")); |
|
5112 return EFail; |
|
5113 } |
|
5114 |
|
5115 iLogger.WriteFormat(_L("GetOpt with KSOBlockingIO")); |
|
5116 err = iSocket.GetOpt(KSOBlockingIO, KSOLSocket, boolean); |
|
5117 if (err != KErrNone) |
|
5118 { |
|
5119 iLogger.WriteFormat(_L("GetOpt with KSOBlockingIO failed with error = %d"), err); |
|
5120 return EFail; |
|
5121 } |
|
5122 |
|
5123 if (boolean() != FALSE) |
|
5124 { |
|
5125 iLogger.WriteFormat(_L("The value returned on GetOpt with KSOBlockingIO failed")); |
|
5126 return EFail; |
|
5127 } |
|
5128 |
|
5129 |
|
5130 iLogger.WriteFormat(_L("SetOpt with KSONonBlockingIO")); |
|
5131 err = iSocket.SetOpt(KSONonBlockingIO, KSOLSocket); |
|
5132 if (err != KErrNone) |
|
5133 { |
|
5134 iLogger.WriteFormat(_L("SetOpt with KSONonBlockingIO failed with error = %d"), err); |
|
5135 return EFail; |
|
5136 } |
|
5137 |
|
5138 iLogger.WriteFormat(_L("GetOpt with KSONonBlockingIO")); |
|
5139 err = iSocket.GetOpt(KSONonBlockingIO, KSOLSocket, boolean); |
|
5140 if (err != KErrNone) |
|
5141 { |
|
5142 iLogger.WriteFormat(_L("GetOpt with KSONonBlockingIO failed with error = %d"), err); |
|
5143 return EFail; |
|
5144 } |
|
5145 |
|
5146 if (boolean() != TRUE) |
|
5147 { |
|
5148 iLogger.WriteFormat(_L("The value returned on GetOpt with KSONonBlockingIO failed")); |
|
5149 return EFail; |
|
5150 } |
|
5151 |
|
5152 iLogger.WriteFormat(_L("GetOpt with KSOBlockingIO")); |
|
5153 err = iSocket.GetOpt(KSONonBlockingIO, KSOLSocket, boolean); |
|
5154 if (err != KErrNone) |
|
5155 { |
|
5156 iLogger.WriteFormat(_L("GetOpt with KSOBlockingIO failed with error = %d"), err); |
|
5157 return EFail; |
|
5158 } |
|
5159 |
|
5160 if (boolean() != TRUE) |
|
5161 { |
|
5162 iLogger.WriteFormat(_L("The value returned on GetOpt with KSOBlockingIO failed")); |
|
5163 return EFail; |
|
5164 } |
|
5165 return EPass; |
|
5166 } |
|
5167 default: |
|
5168 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 58)); |
|
5169 return EFail; |
|
5170 } |
|
5171 } |
|
5172 |
|
5173 void CEIntSockTest50::Cleanup() |
|
5174 { |
|
5175 iSocket.Close(); |
|
5176 } |
|
5177 |
|
5178 //------------------------------------------------------------------------------------------------- |
|
5179 // CEIntSockTest51 |
|
5180 //------------------------------------------------------------------------------------------------- |
|
5181 |
|
5182 CEIntSockTestBase* CEIntSockTest51::NewL(CProxyProvd* aProvd) |
|
5183 { |
|
5184 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest51(aProvd); |
|
5185 return ret; |
|
5186 } |
|
5187 |
|
5188 CEIntSockTest51::CEIntSockTest51(CProxyProvd* aProvd) : |
|
5189 CEIntSockTestBase(aProvd), |
|
5190 iState(EState1) |
|
5191 {} |
|
5192 |
|
5193 TVerdict CEIntSockTest51::RunTestL() |
|
5194 { |
|
5195 switch (iState) |
|
5196 { |
|
5197 case EState1: |
|
5198 { |
|
5199 iLogger.WriteFormat(_L("<i>Test 51 - Ioctl non-completion tests</i>")); |
|
5200 iLogger.WriteFormat(_L("<i>Opening a Dummy Protocol 1 socket</i>")); |
|
5201 iSocket.Open(KDummyOneName, iStatus); |
|
5202 |
|
5203 iState = EState2; |
|
5204 Reschedule(); |
|
5205 return EPass; |
|
5206 } |
|
5207 case EState2: |
|
5208 { |
|
5209 if (iStatus != KErrNone) |
|
5210 { |
|
5211 iLogger.WriteFormat(_L("<i>Open on Dummy Protocol 1 socket returns %d</i>"),iStatus.Int()); |
|
5212 return EFail; |
|
5213 } |
|
5214 iLogger.WriteFormat(_L("<i>Perform Ioctl with KDummyIoctlIgnore.</i>")); |
|
5215 iSocket.Ioctl(KDummyIoctlIgnore, iStatus); |
|
5216 iSocket.CancelAll(); |
|
5217 |
|
5218 iState = EState3; |
|
5219 Reschedule(); |
|
5220 return EPass; |
|
5221 } |
|
5222 case EState3: |
|
5223 { |
|
5224 if (iStatus != KErrCancel) |
|
5225 { |
|
5226 iLogger.WriteFormat(_L("<i>Cancelling of Ioctl returns with err = %d != KErrCancel</i>"), iStatus.Int()); |
|
5227 return EFail; |
|
5228 } |
|
5229 iLogger.WriteFormat(_L("<i>Query the status of previous of Ioctl call.</i>")); |
|
5230 iSocket.Ioctl(KDummyIoctlCancelled, iStatus); |
|
5231 |
|
5232 iState = EState4; |
|
5233 Reschedule(); |
|
5234 return EPass; |
|
5235 } |
|
5236 case EState4: |
|
5237 if (iStatus == KErrNotFound) |
|
5238 { |
|
5239 iLogger.WriteFormat(_L("<i>Ioctl returns with err = %d CancellAll failed to cancel the previous Ioctl</i>"), iStatus.Int()); |
|
5240 return EFail; |
|
5241 } |
|
5242 return EPass; |
|
5243 default: |
|
5244 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 59)); |
|
5245 return EFail; |
|
5246 } |
|
5247 } |
|
5248 |
|
5249 void CEIntSockTest51::Cleanup() |
|
5250 { |
|
5251 iSocket.Close(); |
|
5252 } |
|
5253 |
|
5254 //------------------------------------------------------------------------------------------------- |
|
5255 // CEIntSockTest52 |
|
5256 //------------------------------------------------------------------------------------------------- |
|
5257 |
|
5258 CEIntSockTestBase* CEIntSockTest52::NewL(CProxyProvd* aProvd) |
|
5259 { |
|
5260 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest52(aProvd); |
|
5261 return ret; |
|
5262 } |
|
5263 |
|
5264 CEIntSockTest52::CEIntSockTest52(CProxyProvd* aProvd) : |
|
5265 CEIntSockTestBase(aProvd), |
|
5266 iState(EState1) |
|
5267 {} |
|
5268 |
|
5269 TVerdict CEIntSockTest52::RunTestL() |
|
5270 { |
|
5271 const TUint KBufferSize = 1024; |
|
5272 TInt err = KErrNone; |
|
5273 switch (iState) |
|
5274 { |
|
5275 case EState1: |
|
5276 { |
|
5277 iLogger.WriteFormat(_L("<i>Test 52 - Retention of socket options from before Accept to after Accept</i>")); |
|
5278 iLogger.WriteFormat(_L("<i>Opening a Dummy Protocol 2 socket</i>")); |
|
5279 iAcceptingSocket.Open(KDummyThreeName, iStatus); |
|
5280 |
|
5281 iState = EState2; |
|
5282 Reschedule(); |
|
5283 return EPass; |
|
5284 } |
|
5285 case EState2: |
|
5286 { |
|
5287 if (iStatus != KErrNone) |
|
5288 { |
|
5289 iLogger.WriteFormat(_L("<i>Open on Dummy Protocol 1 socket returns %d</i>"),iStatus.Int()); |
|
5290 return EFail; |
|
5291 } |
|
5292 |
|
5293 iLogger.WriteFormat(_L("<i>Bind the socket</i>")); |
|
5294 TSockAddr addr; |
|
5295 err = iAcceptingSocket.Bind(addr); |
|
5296 if (err != KErrNone) |
|
5297 { |
|
5298 iLogger.WriteFormat(_L("<i>Bind failed with error %d</i>"), err); |
|
5299 return EFail; |
|
5300 } |
|
5301 iLogger.WriteFormat(_L("<i>Start listening on the socket</i>")); |
|
5302 err = iAcceptingSocket.Listen(5); |
|
5303 if (err != KErrNone) |
|
5304 { |
|
5305 iLogger.WriteFormat(_L("<i>Listening failed with error %d</i>"), err); |
|
5306 return EFail; |
|
5307 } |
|
5308 iLogger.WriteFormat(_L("<i>Opening a null socket</i>")); |
|
5309 err = iSocket.Open(); |
|
5310 if (err != KErrNone) |
|
5311 { |
|
5312 iLogger.WriteFormat(_L("<i>Opening a null socket returned with error %d</i>"), err); |
|
5313 return EFail; |
|
5314 } |
|
5315 |
|
5316 iLogger.WriteFormat(_L("<i>Setting a whole bunch of KSOLSocket options on the accepting socket</i>")); |
|
5317 err = iAcceptingSocket.SetOpt(KSOSendBuf, KSOLSocket, KBufferSize); |
|
5318 if (err != KErrNone) |
|
5319 { |
|
5320 iLogger.WriteFormat(_L("<i>SetOpt with KSOSendBuf returned with error %d</i>"), err); |
|
5321 return EFail; |
|
5322 } |
|
5323 err = iAcceptingSocket.SetOpt(KSORecvBuf, KSOLSocket, KBufferSize); |
|
5324 if (err != KErrNone) |
|
5325 { |
|
5326 iLogger.WriteFormat(_L("<i>SetOpt with KSORecvBuf returned with error %d</i>"), err); |
|
5327 return EFail; |
|
5328 } |
|
5329 err = iAcceptingSocket.SetOpt(KSODebug, KSOLSocket, ETrue); |
|
5330 if (err != KErrNone) |
|
5331 { |
|
5332 iLogger.WriteFormat(_L("<i>SetOpt with KSODebug returned with error %d</i>"), err); |
|
5333 return EFail; |
|
5334 } |
|
5335 err = iAcceptingSocket.SetOpt(KSONonBlockingIO, KSOLSocket); |
|
5336 if (err != KErrNone) |
|
5337 { |
|
5338 iLogger.WriteFormat(_L("<i>SetOpt with KSONonBlockingIO returned with error %d</i>"), err); |
|
5339 return EFail; |
|
5340 } |
|
5341 |
|
5342 iLogger.WriteFormat(_L("<i>Now simulating a remote connection to complete the accept</i>")); |
|
5343 err = iAcceptingSocket.SetOpt(KDummyOptionSetConnectComplete, KIoctlDummyLevel); |
|
5344 if (err != KErrNone) |
|
5345 { |
|
5346 iLogger.WriteFormat(_L("<i>SetOpt with KDummyOptionSetConnectComplete returned with error %d</i>"), err); |
|
5347 return EFail; |
|
5348 } |
|
5349 |
|
5350 // We set the connect complete option. Pdummy needs to run AO to complete the accept. |
|
5351 // So we cannot do the accept here. we move into the next state and do the accept there |
|
5352 // Here just do a self complete and keep going |
|
5353 iStatus = KRequestPending; |
|
5354 iState = EState3; |
|
5355 Reschedule(); |
|
5356 TRequestStatus* status = &iStatus; |
|
5357 User::RequestComplete(status, KErrNone); |
|
5358 return EPass; |
|
5359 } |
|
5360 case EState3: |
|
5361 { |
|
5362 iLogger.WriteFormat(_L("Perform an accept")); |
|
5363 iAcceptingSocket.Accept(iSocket, iStatus); |
|
5364 |
|
5365 iState = EState4; |
|
5366 Reschedule(); |
|
5367 return EPass; |
|
5368 } |
|
5369 case EState4: |
|
5370 { |
|
5371 if (iStatus != KErrNone) |
|
5372 { |
|
5373 iLogger.WriteFormat(_L("<i>Accept failed with error %d</i>"), iStatus.Int()); |
|
5374 return EFail; |
|
5375 } |
|
5376 |
|
5377 iLogger.WriteFormat(_L("<i>Retrieve the whole bunch of KSOLSocket options that is set</i>")); |
|
5378 |
|
5379 TInt retrievedOpt; |
|
5380 err = iSocket.GetOpt(KSOSendBuf, KSOLSocket, retrievedOpt); |
|
5381 if (err != KErrNone) |
|
5382 { |
|
5383 iLogger.WriteFormat(_L("<i>GetOpt with KSOSendBuf returned with error %d</i>"), err); |
|
5384 return EFail; |
|
5385 } |
|
5386 |
|
5387 if (retrievedOpt != KBufferSize) |
|
5388 { |
|
5389 iLogger.WriteFormat(_L("Opt KSOSendBuf did not return the correct value")); |
|
5390 return EFail; |
|
5391 } |
|
5392 |
|
5393 err = iSocket.GetOpt(KSORecvBuf, KSOLSocket, retrievedOpt); |
|
5394 if (err != KErrNone) |
|
5395 { |
|
5396 iLogger.WriteFormat(_L("<i>GetOpt with KSORecvBuf returned with error %d</i>"), err); |
|
5397 return EFail; |
|
5398 } |
|
5399 |
|
5400 if (retrievedOpt != KBufferSize) |
|
5401 { |
|
5402 iLogger.WriteFormat(_L("Opt KSORecvBuf did not return the correct value")); |
|
5403 return EFail; |
|
5404 } |
|
5405 |
|
5406 err = iSocket.GetOpt(KSODebug, KSOLSocket, retrievedOpt); |
|
5407 if (err != KErrNone) |
|
5408 { |
|
5409 iLogger.WriteFormat(_L("<i>GetOpt with KSODebug returned with error %d</i>"), err); |
|
5410 return EFail; |
|
5411 } |
|
5412 if (!retrievedOpt) |
|
5413 { |
|
5414 iLogger.WriteFormat(_L("Opt KSODebug did not return the correct value")); |
|
5415 return EFail; |
|
5416 } |
|
5417 |
|
5418 err = iSocket.GetOpt(KSONonBlockingIO, KSOLSocket, retrievedOpt); |
|
5419 if (err != KErrNone) |
|
5420 { |
|
5421 iLogger.WriteFormat(_L("<i>GetOpt with KSONonBlockingIO returned with error %d</i>"), err); |
|
5422 return EFail; |
|
5423 } |
|
5424 if (!retrievedOpt) |
|
5425 { |
|
5426 iLogger.WriteFormat(_L("<i>Opt KSONonBlockingIO did not return the correct value</i>")); |
|
5427 return EFail; |
|
5428 } |
|
5429 return EPass; |
|
5430 } |
|
5431 default: |
|
5432 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 60)); |
|
5433 return EFail; |
|
5434 } |
|
5435 } |
|
5436 |
|
5437 void CEIntSockTest52::Cleanup() |
|
5438 { |
|
5439 iAcceptingSocket.Close(); |
|
5440 iSocket.Close(); |
|
5441 } |
|
5442 |
|
5443 //------------------------------------------------------------------------------------------------- |
|
5444 // CEIntSockTest53 |
|
5445 //------------------------------------------------------------------------------------------------- |
|
5446 |
|
5447 CEIntSockTestBase* CEIntSockTest53::NewL(CProxyProvd* aProvd) |
|
5448 { |
|
5449 CEIntSockTest53* ret = new(ELeave) CEIntSockTest53(aProvd); |
|
5450 CleanupStack::PushL(ret); |
|
5451 ret->ConstructL(); |
|
5452 CleanupStack::Pop(ret); |
|
5453 return ret; |
|
5454 } |
|
5455 |
|
5456 CEIntSockTest53::CEIntSockTest53(CProxyProvd* aProvd) : |
|
5457 CEIntSockTestBase(aProvd), |
|
5458 iState(EState1) |
|
5459 {} |
|
5460 |
|
5461 CEIntSockTest53::~CEIntSockTest53() |
|
5462 { |
|
5463 delete iColl; |
|
5464 } |
|
5465 |
|
5466 void CEIntSockTest53::ConstructL() |
|
5467 { |
|
5468 iColl = CAggregateCollection::NewL(iStatus,CAggregateCollection::EAny); |
|
5469 iRecvItem = iColl->GetNewItemL(); |
|
5470 iSendItem = iColl->GetNewItemL(); |
|
5471 } |
|
5472 |
|
5473 TVerdict CEIntSockTest53::RunTestL() |
|
5474 { |
|
5475 TInt err; |
|
5476 _LIT8(KSendData,"abcdefghij"); |
|
5477 _LIT8(KSendData2,"KLMNOPQRST"); |
|
5478 |
|
5479 switch (iState) |
|
5480 { |
|
5481 case EState1: |
|
5482 { |
|
5483 iLogger.WriteFormat(_L("<i>Test 53 - Partial read with descriptor</i>")); |
|
5484 iLogger.WriteFormat(_L("<i>Opening a socket on Dummy protocol 2</i>")); |
|
5485 err = iSocket.Open(KDummyTwoName); |
|
5486 if (err != KErrNone) |
|
5487 { |
|
5488 iLogger.WriteFormat(_L("<i>Open on Dummy Protocol 2 failed with error %d</i>"), err); |
|
5489 return EFail; |
|
5490 } |
|
5491 |
|
5492 iLogger.WriteFormat(_L("<i>Attempting a connection</i>")); |
|
5493 iSocket.Connect(iAddress, iStatus); |
|
5494 |
|
5495 iState = EState2; |
|
5496 Reschedule(); |
|
5497 return EPass; |
|
5498 } |
|
5499 case EState2: |
|
5500 { |
|
5501 if (iStatus != KErrNone) |
|
5502 { |
|
5503 iLogger.WriteFormat(_L("<i>Connect failed with error %d</i>"), iStatus.Int()); |
|
5504 return EFail; |
|
5505 } |
|
5506 |
|
5507 iLogger.WriteFormat(_L("<i>Sending 20 octets and reciving 10</i>")); |
|
5508 iSendBuf.Copy(KSendData()); |
|
5509 iSendBuf.Append(KSendData2()); |
|
5510 |
|
5511 iRecvItem->Start(); |
|
5512 iSendItem->Start(); |
|
5513 iSocket.Recv(iRecvBuf, 0, iRecvItem->iStatus); |
|
5514 iSocket.Send(iSendBuf, 0, iSendItem->iStatus); |
|
5515 |
|
5516 iState = EState3; |
|
5517 iColl->Kick(); |
|
5518 Reschedule(); |
|
5519 return EPass; |
|
5520 } |
|
5521 case EState3: |
|
5522 { |
|
5523 // Check which operation completed first (no order can be enforced) and check to |
|
5524 // see if it was successful. |
|
5525 if ((iSendItem->ReturnCode() != KErrNone) && (iRecvItem->ReturnCode() != KErrNone)) |
|
5526 { |
|
5527 if(iSendItem->ReturnCode() != KRequestPending) |
|
5528 { |
|
5529 iLogger.WriteFormat(_L("<i>Send failed with error %d</i>"), iSendItem->ReturnCode()); |
|
5530 } |
|
5531 else |
|
5532 { |
|
5533 iLogger.WriteFormat(_L("<i>Recv failed with error %d</i>"), iRecvItem->ReturnCode()); |
|
5534 } |
|
5535 return EFail; |
|
5536 } |
|
5537 |
|
5538 iState = EState4; |
|
5539 iColl->Kick(); |
|
5540 Reschedule(); |
|
5541 return EPass; |
|
5542 } |
|
5543 case EState4: |
|
5544 { |
|
5545 // Check which operation completed second (no order can be enforced) and check to |
|
5546 // see if it was successful. |
|
5547 if ((iSendItem->ReturnCode() != KErrNone) && (iRecvItem->ReturnCode() != KErrNone)) |
|
5548 { |
|
5549 if(iSendItem->ReturnCode() != KRequestPending) |
|
5550 { |
|
5551 iLogger.WriteFormat(_L("<i>Send failed with error %d</i>"), iSendItem->ReturnCode()); |
|
5552 } |
|
5553 else |
|
5554 { |
|
5555 iLogger.WriteFormat(_L("<i>Recv failed with error %d</i>"), iRecvItem->ReturnCode()); |
|
5556 } |
|
5557 return EFail; |
|
5558 } |
|
5559 |
|
5560 iLogger.WriteFormat(_L("<i>Check whether the Recv gave the first 10octets</i>")); |
|
5561 if (iRecvBuf != KSendData()) |
|
5562 { |
|
5563 iLogger.WriteFormat(_L("<i>Recv data is not matching the first 10octets that is sent</i>")); |
|
5564 return EFail; |
|
5565 } |
|
5566 |
|
5567 iLogger.WriteFormat(_L("<i>Issue another recv to get the rest 10octets</i>")); |
|
5568 iRecvBuf.SetLength(0); |
|
5569 iRecvItem->Start(); |
|
5570 iSocket.Recv(iRecvBuf, 0, iRecvItem->iStatus); |
|
5571 |
|
5572 iState = EState5; |
|
5573 iColl->Kick(); |
|
5574 Reschedule(); |
|
5575 return EPass; |
|
5576 } |
|
5577 case EState5: |
|
5578 { |
|
5579 if (iRecvItem->ReturnCode() != KErrNone) |
|
5580 { |
|
5581 iLogger.WriteFormat(_L("<i>Recv failed with error %d</i>"), iRecvItem->ReturnCode()); |
|
5582 return EFail; |
|
5583 } |
|
5584 iLogger.WriteFormat(_L("<i>Check whether the Recv gave the last 10octets</i>")); |
|
5585 if (iRecvBuf != KSendData2()) |
|
5586 { |
|
5587 iLogger.WriteFormat(_L("<i>Recv data is not matching the last 10octets that is sent</i>")); |
|
5588 return EFail; |
|
5589 } |
|
5590 return EPass; |
|
5591 } |
|
5592 default: |
|
5593 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 61)); |
|
5594 return EFail; |
|
5595 |
|
5596 } |
|
5597 } |
|
5598 |
|
5599 void CEIntSockTest53::Cleanup() |
|
5600 { |
|
5601 iSocket.Close(); |
|
5602 } |
|
5603 |
|
5604 |
|
5605 //------------------------------------------------------------------------------------------------- |
|
5606 // CEIntSockTest54 |
|
5607 //------------------------------------------------------------------------------------------------- |
|
5608 |
|
5609 CEIntSockTestBase* CEIntSockTest54::NewL(CProxyProvd* aProvd) |
|
5610 { |
|
5611 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest54(aProvd); |
|
5612 return ret; |
|
5613 } |
|
5614 |
|
5615 CEIntSockTest54::CEIntSockTest54(CProxyProvd* aProvd) : |
|
5616 CEIntSockTestBase(aProvd), |
|
5617 iState(EState1) |
|
5618 {} |
|
5619 |
|
5620 TVerdict CEIntSockTest54::RunTestL() |
|
5621 { |
|
5622 TInt err = KErrNone; |
|
5623 switch (iState) |
|
5624 { |
|
5625 case EState1: |
|
5626 { |
|
5627 iLogger.WriteFormat(_L("<i>Test 54 - RecvFrom not supported on ConnectionOriented socket</i>")); |
|
5628 iLogger.WriteFormat(_L("<i>Opening a Dummy Protocol 2 socket</i>")); |
|
5629 err = iSocket.Open(KDummyTwoName); |
|
5630 if (err != KErrNone) |
|
5631 { |
|
5632 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
5633 return EFail; |
|
5634 } |
|
5635 |
|
5636 iLogger.WriteFormat(_L("<i>Attempting a Connect</i>")); |
|
5637 iSocket.Connect(iAddress, iStatus); |
|
5638 |
|
5639 iState = EState2; |
|
5640 Reschedule(); |
|
5641 return EPass; |
|
5642 } |
|
5643 case EState2: |
|
5644 { |
|
5645 if (iStatus != KErrNone) |
|
5646 { |
|
5647 iLogger.WriteFormat(_L("<i>Connect failed with error %d</i>"),iStatus.Int()); |
|
5648 return EFail; |
|
5649 } |
|
5650 |
|
5651 iLogger.WriteFormat(_L("<i>Attempt a RecvFrom</i>")); |
|
5652 iSocket.RecvFrom(iRecvBuf,iAddress,0, iStatus,iLen); |
|
5653 |
|
5654 iState = EState3; |
|
5655 Reschedule(); |
|
5656 return EPass; |
|
5657 } |
|
5658 case EState3: |
|
5659 { |
|
5660 if (iStatus != KErrNotSupported) |
|
5661 { |
|
5662 iLogger.WriteFormat(_L("<i>RecvFrom on a connection oriented failed with error %d</i>"), iStatus.Int()); |
|
5663 return EFail; |
|
5664 } |
|
5665 |
|
5666 return EPass; |
|
5667 } |
|
5668 default: |
|
5669 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 62)); |
|
5670 return EFail; |
|
5671 } |
|
5672 } |
|
5673 |
|
5674 void CEIntSockTest54::Cleanup() |
|
5675 { |
|
5676 iSocket.Close(); |
|
5677 } |
|
5678 |
|
5679 //------------------------------------------------------------------------------------------------- |
|
5680 // CEIntSockTest55 |
|
5681 //------------------------------------------------------------------------------------------------- |
|
5682 |
|
5683 CEIntSockTestBase* CEIntSockTest55::NewL(CProxyProvd* aProvd) |
|
5684 { |
|
5685 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest55(aProvd); |
|
5686 return ret; |
|
5687 } |
|
5688 |
|
5689 CEIntSockTest55::CEIntSockTest55(CProxyProvd* aProvd) : |
|
5690 CEIntSockTestBase(aProvd), |
|
5691 iState(EState1) |
|
5692 {} |
|
5693 |
|
5694 TVerdict CEIntSockTest55::RunTestL() |
|
5695 { |
|
5696 TInt err = KErrNone; |
|
5697 switch (iState) |
|
5698 { |
|
5699 case EState1: |
|
5700 { |
|
5701 iLogger.WriteFormat(_L("<i>Test 55 - Fail urgent data on a non supported socket</i>")); |
|
5702 iLogger.WriteFormat(_L("<i>Opening a Dummy Protocol 1 socket</i>")); |
|
5703 err = iSocket.Open(KDummyOneName); |
|
5704 if (err != KErrNone) |
|
5705 { |
|
5706 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
5707 return EFail; |
|
5708 } |
|
5709 |
|
5710 iLogger.WriteFormat(_L("<i>Send urgent data</i>")); |
|
5711 iSendBuf.SetLength(5); |
|
5712 iSocket.SendTo(iSendBuf, iAddress, KSockWriteUrgent, iStatus); |
|
5713 |
|
5714 iState = EState2; |
|
5715 Reschedule(); |
|
5716 return EPass; |
|
5717 } |
|
5718 case EState2: |
|
5719 { |
|
5720 if (iStatus != KErrNotSupported) |
|
5721 { |
|
5722 iLogger.WriteFormat(_L("<i>Send urgent data oepration failed with error %d Expected: KErrNotSupported</i>"),iStatus.Int()); |
|
5723 return EFail; |
|
5724 } |
|
5725 |
|
5726 return EPass; |
|
5727 } |
|
5728 default: |
|
5729 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 63)); |
|
5730 return EFail; |
|
5731 } |
|
5732 } |
|
5733 |
|
5734 void CEIntSockTest55::Cleanup() |
|
5735 { |
|
5736 iSocket.Close(); |
|
5737 } |
|
5738 |
|
5739 //------------------------------------------------------------------------------------------------- |
|
5740 // CEIntSockTest56 |
|
5741 //------------------------------------------------------------------------------------------------- |
|
5742 |
|
5743 CEIntSockTestBase* CEIntSockTest56::NewL(CProxyProvd* aProvd) |
|
5744 { |
|
5745 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest56(aProvd); |
|
5746 return ret; |
|
5747 } |
|
5748 |
|
5749 CEIntSockTest56::CEIntSockTest56(CProxyProvd* aProvd) : |
|
5750 CEIntSockTestBase(aProvd), |
|
5751 iState(EState1) |
|
5752 {} |
|
5753 |
|
5754 TVerdict CEIntSockTest56::RunTestL() |
|
5755 { |
|
5756 TInt err = KErrNone; |
|
5757 switch (iState) |
|
5758 { |
|
5759 case EState1: |
|
5760 { |
|
5761 iLogger.WriteFormat(_L("<i>Test 56 - Send to an unconnected socket</i>")); |
|
5762 iLogger.WriteFormat(_L("<i>Opening a Dummy Protocol 3 socket</i>")); |
|
5763 err = iSocket.Open(KDummyThreeName); |
|
5764 if (err != KErrNone) |
|
5765 { |
|
5766 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
5767 return EFail; |
|
5768 } |
|
5769 |
|
5770 iLogger.WriteFormat(_L("<i>Send urgent data</i>")); |
|
5771 iSendBuf.SetLength(5); |
|
5772 iSocket.Write(iSendBuf, iStatus); |
|
5773 |
|
5774 iState = EState2; |
|
5775 Reschedule(); |
|
5776 return EPass; |
|
5777 } |
|
5778 case EState2: |
|
5779 { |
|
5780 if (iStatus != KErrNotReady) |
|
5781 { |
|
5782 iLogger.WriteFormat(_L("<i>Write operation failed with error %d Expected: KErrNotReady</i>"),iStatus.Int()); |
|
5783 return EFail; |
|
5784 } |
|
5785 |
|
5786 return EPass; |
|
5787 } |
|
5788 default: |
|
5789 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 64)); |
|
5790 return EFail; |
|
5791 } |
|
5792 } |
|
5793 |
|
5794 void CEIntSockTest56::Cleanup() |
|
5795 { |
|
5796 iSocket.Close(); |
|
5797 } |
|
5798 |
|
5799 //------------------------------------------------------------------------------------------------- |
|
5800 // CEIntSockTest57 |
|
5801 //------------------------------------------------------------------------------------------------- |
|
5802 |
|
5803 CEIntSockTestBase* CEIntSockTest57::NewL(CProxyProvd* aProvd) |
|
5804 { |
|
5805 CEIntSockTest57* ret = new(ELeave) CEIntSockTest57(aProvd); |
|
5806 CleanupStack::PushL (ret); |
|
5807 ret->ConstructL(); |
|
5808 CleanupStack::Pop(); |
|
5809 return ret; |
|
5810 } |
|
5811 |
|
5812 CEIntSockTest57::CEIntSockTest57(CProxyProvd* aProvd) : |
|
5813 CEIntSockTestBase(aProvd), |
|
5814 iState(EState1) |
|
5815 {} |
|
5816 |
|
5817 void CEIntSockTest57::ConstructL() |
|
5818 { |
|
5819 iColl = CAggregateCollection::NewL(iStatus,CAggregateCollection::EAny); |
|
5820 iShutdownItem = iColl->GetNewItemL(); |
|
5821 iRecvItem = iColl->GetNewItemL(); |
|
5822 iSendItem = iColl->GetNewItemL(); |
|
5823 } |
|
5824 |
|
5825 CEIntSockTest57::~CEIntSockTest57() |
|
5826 { |
|
5827 delete iColl; |
|
5828 } |
|
5829 |
|
5830 TVerdict CEIntSockTest57::RunTestL() |
|
5831 { |
|
5832 TInt err = KErrNone; |
|
5833 switch (iState) |
|
5834 { |
|
5835 case EState1: |
|
5836 { |
|
5837 iLogger.WriteFormat(_L("<i>Test 57 - Shoutdown with EStopOutput</i>")); |
|
5838 iLogger.WriteFormat(_L("<i>Opening a Dummy Protocol 2 socket</i>")); |
|
5839 err = iSocket.Open(KDummyTwoName); |
|
5840 if (err != KErrNone) |
|
5841 { |
|
5842 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
5843 return EFail; |
|
5844 } |
|
5845 iLogger.WriteFormat(_L("<i>Attempting a shutdown</i>")); |
|
5846 iShutdownItem->Start(); |
|
5847 iSocket.Shutdown(RSocket::EStopOutput, iShutdownItem->iStatus); |
|
5848 if (iShutdownItem->iStatus != KRequestPending) |
|
5849 { |
|
5850 iLogger.WriteFormat(_L("<i>Shutdown failed with %d Expected: KRequestPending</i>"),err); |
|
5851 return EFail; |
|
5852 } |
|
5853 |
|
5854 iLogger.WriteFormat(_L("<i>Attempting a recv</i>")); |
|
5855 iRecvItem->Start(); |
|
5856 iSocket.Recv(iRecvBuf, 0, iRecvItem->iStatus, iRecvLen); |
|
5857 |
|
5858 iState = EState2; |
|
5859 iColl->Kick(); |
|
5860 Reschedule(); |
|
5861 return EPass; |
|
5862 } |
|
5863 case EState2: |
|
5864 { |
|
5865 if (iShutdownItem->ReturnCode() != KRequestPending || iRecvItem->ReturnCode() != KErrNone) |
|
5866 { |
|
5867 iLogger.WriteFormat(_L("<i>Shutdown with EStopInput and Recv operation failed with error Shutdown status:%d Recv status: %d</i>"),iShutdownItem->ReturnCode(), iRecvItem->ReturnCode()); |
|
5868 return EFail; |
|
5869 } |
|
5870 |
|
5871 if (iRecvLen() != 10) |
|
5872 { |
|
5873 iLogger.WriteFormat(_L("<i>Recv length matching failed</i>")); |
|
5874 return EFail; |
|
5875 } |
|
5876 |
|
5877 iLogger.WriteFormat(_L("<i>Attempting a Send</i>")); |
|
5878 iSendBuf.SetLength(1); |
|
5879 iSendItem->Start (); |
|
5880 iSocket.Send(iSendBuf, 0, iSendItem->iStatus); |
|
5881 |
|
5882 iState = EState3; |
|
5883 iColl->Kick(); |
|
5884 Reschedule(); |
|
5885 return EPass; |
|
5886 } |
|
5887 |
|
5888 case EState3: |
|
5889 { |
|
5890 if (iSendItem->ReturnCode() != KErrNotReady) |
|
5891 { |
|
5892 iLogger.WriteFormat(_L("<i>Send on a shutdowned socket failed with error %d Expected: KErrNotReady</i>"), iSendItem->ReturnCode()); |
|
5893 return EFail; |
|
5894 } |
|
5895 iLogger.WriteFormat(_L("<i>Attempting to read more data</i>")); |
|
5896 iRecvItem->Start(); |
|
5897 iSocket.Recv(iRecvBuf, 0, iRecvItem->iStatus, iRecvLen); |
|
5898 |
|
5899 iState = EState4; |
|
5900 iColl->Kick(); |
|
5901 Reschedule(); |
|
5902 return EPass; |
|
5903 } |
|
5904 case EState4: |
|
5905 { |
|
5906 if (iRecvItem->ReturnCode() != KErrEof) |
|
5907 { |
|
5908 iLogger.WriteFormat(_L("<i>Recv on a shutdowned socket failed with error %d Expected: KErrEof</i>"), iSendItem->ReturnCode()); |
|
5909 return EFail; |
|
5910 } |
|
5911 if (iRecvLen() != 1) |
|
5912 { |
|
5913 iLogger.WriteFormat(_L("<i>Recv length matching failed</i>")); |
|
5914 return EFail; |
|
5915 } |
|
5916 iRecvLen = 0; |
|
5917 iLogger.WriteFormat(_L("<i>Attempting to read more data</i>")); |
|
5918 iRecvItem->Start(); |
|
5919 iSocket.Recv(iRecvBuf, 0, iRecvItem->iStatus, iRecvLen); |
|
5920 |
|
5921 iState = EState5; |
|
5922 iColl->Kick(); |
|
5923 Reschedule(); |
|
5924 return EPass; |
|
5925 } |
|
5926 case EState5: |
|
5927 { |
|
5928 if (iRecvItem->ReturnCode() != KErrEof) |
|
5929 { |
|
5930 iLogger.WriteFormat(_L("<i>Recv on a shutdowned socket failed with error %d Expected: KErrEof</i>"), iRecvItem->ReturnCode()); |
|
5931 return EFail; |
|
5932 } |
|
5933 if (iRecvLen() != 0) |
|
5934 { |
|
5935 iLogger.WriteFormat(_L("<i>Recv length matching failed</i>")); |
|
5936 return EFail; |
|
5937 } |
|
5938 iLogger.WriteFormat(_L("<i>Closing the socket</i>")); |
|
5939 iSocket.Close(); |
|
5940 |
|
5941 iState = EState6; |
|
5942 iColl->Kick(); |
|
5943 Reschedule(); |
|
5944 return EPass; |
|
5945 } |
|
5946 case EState6: |
|
5947 { |
|
5948 if (iShutdownItem->ReturnCode() != KErrCancel) |
|
5949 { |
|
5950 iLogger.WriteFormat(_L("<i>Shutdown status returned %d Expected: KErrCancel</i>"), iShutdownItem->ReturnCode()); |
|
5951 return EFail; |
|
5952 } |
|
5953 return EPass; |
|
5954 } |
|
5955 |
|
5956 default: |
|
5957 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 65)); |
|
5958 return EFail; |
|
5959 } |
|
5960 } |
|
5961 |
|
5962 void CEIntSockTest57::Cleanup() |
|
5963 { |
|
5964 iSocket.Close(); |
|
5965 } |
|
5966 |
|
5967 //------------------------------------------------------------------------------------------------- |
|
5968 // CEIntSockTest52 |
|
5969 //------------------------------------------------------------------------------------------------- |
|
5970 |
|
5971 CEIntSockTestBase* CEIntSockTest58::NewL(CProxyProvd* aProvd) |
|
5972 { |
|
5973 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest58(aProvd); |
|
5974 return ret; |
|
5975 } |
|
5976 |
|
5977 CEIntSockTest58::CEIntSockTest58(CProxyProvd* aProvd) : |
|
5978 CEIntSockTestBase(aProvd), |
|
5979 iState(EState1) |
|
5980 {} |
|
5981 |
|
5982 TVerdict CEIntSockTest58::RunTestL() |
|
5983 { |
|
5984 TInt err = KErrNone; |
|
5985 switch (iState) |
|
5986 { |
|
5987 case EState1: |
|
5988 { |
|
5989 iLogger.WriteFormat(_L("<i>Test 58 - Close before completion of the accept</i>")); |
|
5990 iLogger.WriteFormat(_L("<i>Opening a Dummy Protocol 2 accepting socket</i>")); |
|
5991 err = iAcceptingSocket.Open(KDummyTwoName); |
|
5992 if (err != KErrNone) |
|
5993 { |
|
5994 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
5995 return EFail; |
|
5996 } |
|
5997 |
|
5998 iLogger.WriteFormat(_L("<i>Open a null socket</i>")); |
|
5999 err = iSocket.Open(); |
|
6000 if (err != KErrNone) |
|
6001 { |
|
6002 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
6003 return EFail; |
|
6004 } |
|
6005 |
|
6006 iLogger.WriteFormat(_L("<i>Bind the socket</i>")); |
|
6007 TSockAddr addr; |
|
6008 err = iAcceptingSocket.Bind(addr); |
|
6009 if (err != KErrNone) |
|
6010 { |
|
6011 iLogger.WriteFormat(_L("<i>Bind failed with error %d</i>"), err); |
|
6012 return EFail; |
|
6013 } |
|
6014 iLogger.WriteFormat(_L("<i>Start listening on the socket</i>")); |
|
6015 err = iAcceptingSocket.Listen(5); |
|
6016 if (err != KErrNone) |
|
6017 { |
|
6018 iLogger.WriteFormat(_L("<i>Listening failed with error %d</i>"), err); |
|
6019 return EFail; |
|
6020 } |
|
6021 |
|
6022 iLogger.WriteFormat(_L("Perform an accept")); |
|
6023 iAcceptingSocket.Accept(iSocket, iStatus); |
|
6024 |
|
6025 |
|
6026 iLogger.WriteFormat(_L("<i>Now simulating a remote connection to complete the accept</i>")); |
|
6027 err = iAcceptingSocket.SetOpt(KDummyOptionSetConnectComplete, KIoctlDummyLevel); |
|
6028 if (err != KErrNone) |
|
6029 { |
|
6030 iLogger.WriteFormat(_L("<i>SetOpt with KDummyOptionSetConnectComplete returned with error %d</i>"), err); |
|
6031 return EFail; |
|
6032 } |
|
6033 |
|
6034 iLogger.WriteFormat(_L("<i>Close the null socket</i>")); |
|
6035 iSocket.Close(); |
|
6036 |
|
6037 iState = EState2; |
|
6038 Reschedule(); |
|
6039 return EPass; |
|
6040 } |
|
6041 case EState2: |
|
6042 { |
|
6043 if ((iStatus != KErrCancel) && (iStatus != KErrNone)) |
|
6044 { |
|
6045 iLogger.WriteFormat(_L("<i>Accept failed on a closed null socket with error %d: Expected: KErrCancel or KErrNone</i>"),iStatus.Int()); |
|
6046 return EFail; |
|
6047 } |
|
6048 |
|
6049 iLogger.WriteFormat(_L("<i>Open a null socket again</i>")); |
|
6050 err = iSocket.Open(); |
|
6051 if (err != KErrNone) |
|
6052 { |
|
6053 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
6054 return EFail; |
|
6055 } |
|
6056 |
|
6057 iLogger.WriteFormat(_L("Perform an accept")); |
|
6058 iAcceptingSocket.Accept(iSocket, iStatus); |
|
6059 |
|
6060 |
|
6061 iLogger.WriteFormat(_L("<i>Now simulating a remote connection to complete the accept</i>")); |
|
6062 err = iAcceptingSocket.SetOpt(KDummyOptionSetConnectComplete, KIoctlDummyLevel); |
|
6063 if (err != KErrNone) |
|
6064 { |
|
6065 iLogger.WriteFormat(_L("<i>SetOpt with KDummyOptionSetConnectComplete returned with error %d</i>"), err); |
|
6066 return EFail; |
|
6067 } |
|
6068 |
|
6069 |
|
6070 iState = EState3; |
|
6071 Reschedule(); |
|
6072 return EPass; |
|
6073 } |
|
6074 case EState3: |
|
6075 { |
|
6076 if (iStatus != KErrNone) |
|
6077 { |
|
6078 iLogger.WriteFormat(_L("<i>Accept failed with error %d</i>"),iStatus.Int()); |
|
6079 return EFail; |
|
6080 } |
|
6081 |
|
6082 return EPass; |
|
6083 } |
|
6084 default: |
|
6085 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 66)); |
|
6086 return EFail; |
|
6087 } |
|
6088 } |
|
6089 |
|
6090 void CEIntSockTest58::Cleanup() |
|
6091 { |
|
6092 iAcceptingSocket.Close(); |
|
6093 iSocket.Close(); |
|
6094 } |
|
6095 |
|
6096 |
|
6097 //------------------------------------------------------------------------------------------------- |
|
6098 // CEIntSockTest59 |
|
6099 //------------------------------------------------------------------------------------------------- |
|
6100 CEIntSockTestBase* CEIntSockTest59::NewL(CProxyProvd* aProvd) |
|
6101 { |
|
6102 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest59(aProvd); |
|
6103 return ret; |
|
6104 } |
|
6105 |
|
6106 CEIntSockTest59::CEIntSockTest59(CProxyProvd* aProvd) : |
|
6107 CEIntSockTestBase(aProvd), |
|
6108 iState(EState1) |
|
6109 {} |
|
6110 |
|
6111 TVerdict CEIntSockTest59::RunTestL() |
|
6112 { |
|
6113 _LIT8(KSendData,"1234567890"); |
|
6114 TInt err; |
|
6115 switch(iState) |
|
6116 { |
|
6117 case EState1: |
|
6118 iLogger.WriteFormat(_L("<i>Test 59 - SendTo/RecvFrom with RMBufChain (datagram protocol) with KSockReadPeek</i>")); |
|
6119 iLogger.WriteFormat(_L("<i>Opening a datagram socket.</i>")); |
|
6120 err = iSocket.Open (KDummyOneName); |
|
6121 if ( err != KErrNone ) |
|
6122 { |
|
6123 iLogger.WriteFormat(_L("<i>Opening of datagram socket failed.</i>")); |
|
6124 return EFail; |
|
6125 } |
|
6126 iDestAddr.SetFamily(KProxyAddrFamily); |
|
6127 iSendChain.CreateL(KSendData()); |
|
6128 |
|
6129 iLogger.WriteFormat(_L("<i>SendTo data over an internal socket using the RMBufChain API</i>")); |
|
6130 |
|
6131 iSocket.SendTo(iSendChain, iDestAddr, 0, iStatus, iLength); |
|
6132 iState = EState2; |
|
6133 Reschedule(); |
|
6134 return EPass; |
|
6135 case EState2: |
|
6136 if(iStatus != KErrNone) |
|
6137 { |
|
6138 iLogger.WriteFormat(_L("<i>SendTo failed with error code %d.</i>"), iStatus.Int() ); |
|
6139 return EFail; |
|
6140 } |
|
6141 if ( iLength() != KSendData().Length() ) |
|
6142 { |
|
6143 iLogger.WriteFormat(_L("<i>SendTo didn't return the expected send length.</i>") ); |
|
6144 return EFail; |
|
6145 } |
|
6146 |
|
6147 iSendChain.Remove (); |
|
6148 |
|
6149 iLength = 0; |
|
6150 iBuf.SetLength(KSendData().Length()); |
|
6151 iSocket.RecvFrom (iRecvChain, iRemoteAddr, KSockReadPeek, iStatus, iLength); |
|
6152 iState = EState3; |
|
6153 Reschedule(); |
|
6154 return EPass; |
|
6155 case EState3: |
|
6156 { |
|
6157 if(iStatus != KErrNone) |
|
6158 { |
|
6159 iLogger.WriteFormat(_L("<i>RecvFrom failed with error code %d.</i>"), iStatus.Int() ); |
|
6160 return EFail; |
|
6161 } |
|
6162 TInt len = iLength(); |
|
6163 if ( iLength() != 0 ) |
|
6164 { |
|
6165 iLogger.WriteFormat(_L("<i>RecvFrom didn't return the expected send length %d.</i>"), iLength() ); |
|
6166 return EFail; |
|
6167 } |
|
6168 if (iDestAddr.Family() != iRemoteAddr.Family()) |
|
6169 { |
|
6170 iLogger.WriteFormat(_L("<i>SendTo address is different from RecvFrom address.</i>")); |
|
6171 return EFail; |
|
6172 } |
|
6173 iRecvChain.CopyOut(iBuf); |
|
6174 |
|
6175 if ( iBuf != KSendData ) |
|
6176 { |
|
6177 iLogger.WriteFormat(_L("<i>SendTo data is different from RecvFrom data.</i>")); |
|
6178 return EFail; |
|
6179 } |
|
6180 |
|
6181 iLength = 0; |
|
6182 iBuf.SetLength(KSendData().Length()); |
|
6183 iSocket.RecvFrom (iRecvChain, iRemoteAddr, 0, iStatus, iLength); |
|
6184 iState = EState4; |
|
6185 Reschedule(); |
|
6186 return EPass; |
|
6187 } |
|
6188 case EState4: |
|
6189 { |
|
6190 if(iStatus != KErrNone) |
|
6191 { |
|
6192 iLogger.WriteFormat(_L("<i>RecvFrom failed with error code %d.</i>"), iStatus.Int() ); |
|
6193 return EFail; |
|
6194 } |
|
6195 |
|
6196 if (iLength() != 0) |
|
6197 { |
|
6198 iLogger.WriteFormat(_L("<i>RecvFrom didn't return the expected send length %d.</i>"), iLength() ); |
|
6199 return EFail; |
|
6200 } |
|
6201 |
|
6202 if (iDestAddr.Family() != iRemoteAddr.Family()) |
|
6203 { |
|
6204 iLogger.WriteFormat(_L("<i>SendTo address is different from RecvFrom address.</i>")); |
|
6205 return EFail; |
|
6206 } |
|
6207 iRecvChain.CopyOut(iBuf); |
|
6208 iRecvChain.Free (); |
|
6209 |
|
6210 if ( iBuf != KSendData ) |
|
6211 { |
|
6212 iLogger.WriteFormat(_L("<i>SendTo data is different from RecvFrom data.</i>")); |
|
6213 return EFail; |
|
6214 } |
|
6215 |
|
6216 return EPass; |
|
6217 } |
|
6218 default: |
|
6219 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 67)); |
|
6220 return EFail; |
|
6221 } |
|
6222 } |
|
6223 |
|
6224 void CEIntSockTest59::Cleanup() |
|
6225 { |
|
6226 iSocket.Close(); |
|
6227 __ASSERT_DEBUG(iSendChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 68)); |
|
6228 __ASSERT_DEBUG(iRecvChain.IsEmpty(), User::Panic(KSpecAssert_ESockTestptstcs, 69)); |
|
6229 } |
|
6230 |
|
6231 //------------------------------------------------------------------------------------------------- |
|
6232 // CEIntSockTest60 |
|
6233 //------------------------------------------------------------------------------------------------- |
|
6234 CEIntSockTestBase* CEIntSockTest60::NewL(CProxyProvd* aProvd) |
|
6235 { |
|
6236 CEIntSockTest60* ret = new(ELeave) CEIntSockTest60(aProvd); |
|
6237 CleanupStack::PushL (ret); |
|
6238 ret->ConstructL(); |
|
6239 CleanupStack::Pop(); |
|
6240 return ret; |
|
6241 } |
|
6242 |
|
6243 CEIntSockTest60::CEIntSockTest60(CProxyProvd* aProvd) : |
|
6244 CEIntSockTestBase(aProvd), |
|
6245 iState(EState1), |
|
6246 iInetAddrTo(INET_ADDR(127,0,0,1),7) |
|
6247 {} |
|
6248 |
|
6249 void CEIntSockTest60::ConstructL() |
|
6250 { |
|
6251 iColl = CAggregateCollection::NewL(iStatus,CAggregateCollection::EAny); |
|
6252 iRecvItem = iColl->GetNewItemL(); |
|
6253 iSendItem = iColl->GetNewItemL(); |
|
6254 } |
|
6255 |
|
6256 CEIntSockTest60::~CEIntSockTest60() |
|
6257 { |
|
6258 delete iColl; |
|
6259 } |
|
6260 |
|
6261 TVerdict CEIntSockTest60::RunTestL() |
|
6262 { |
|
6263 const TInt KIPHeaderSize = 20; //-- IP header size |
|
6264 const TInt KUdpHeaderSize= 8; //-- UDP header size |
|
6265 |
|
6266 _LIT8(KSendData, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
|
6267 |
|
6268 TInt err = KErrNone; |
|
6269 switch (iState) |
|
6270 { |
|
6271 case EState1: |
|
6272 { |
|
6273 iLogger.WriteFormat(_L("<i>Test 60 - Read from socket with KSockReadPeek flag set in different situations</i>")); |
|
6274 iLogger.WriteFormat(_L("<i>Opening a UDP input socket</i>")); |
|
6275 err = iSocketIn.Open(KAfInet, KSockDatagram, KProtocolInetUdp); |
|
6276 if (err != KErrNone) |
|
6277 { |
|
6278 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
6279 return EFail; |
|
6280 } |
|
6281 iLogger.WriteFormat(_L("<i>Opening a UDP output socket</i>")); |
|
6282 err = iSocketOut.Open(KAfInet, KSockDatagram, KProtocolInetUdp); |
|
6283 if (err != KErrNone) |
|
6284 { |
|
6285 iLogger.WriteFormat(_L("<i>Open() failed with %d</i>"),err); |
|
6286 return EFail; |
|
6287 } |
|
6288 |
|
6289 iLogger.WriteFormat(_L("<i>Bind the address</i>")); |
|
6290 iSocketIn.Bind (iInetAddrTo); |
|
6291 |
|
6292 iLogger.WriteFormat(_L("<i>Send the data</i>")); |
|
6293 iSendBuf.Copy(KSendData()); |
|
6294 iSendItem->Start(); |
|
6295 iSocketOut.SendTo(iSendBuf, iInetAddrTo, 0, iSendItem->iStatus); |
|
6296 |
|
6297 iState = EState2; |
|
6298 Reschedule(); |
|
6299 iColl->Kick(); |
|
6300 return EPass; |
|
6301 } |
|
6302 case EState2: |
|
6303 { |
|
6304 if (iSendItem->ReturnCode() != KErrNone) |
|
6305 { |
|
6306 iLogger.WriteFormat(_L("<i>SendTo failed with %d</i>"),iSendItem->ReturnCode()); |
|
6307 return EFail; |
|
6308 } |
|
6309 iLogger.WriteFormat(_L("<i>Peek data from socket and check the size</i>")); |
|
6310 iRecvItem->Start(); |
|
6311 iSocketIn.RecvFrom(iRecvBuf, iInetAddrFrom, KIpHeaderIncluded|KSockReadPeek, iRecvItem->iStatus); |
|
6312 |
|
6313 iState = EState3; |
|
6314 Reschedule(); |
|
6315 iColl->Kick(); |
|
6316 return EPass; |
|
6317 } |
|
6318 case EState3: |
|
6319 { |
|
6320 if (iRecvItem->ReturnCode() != KErrNone) |
|
6321 { |
|
6322 iLogger.WriteFormat(_L("<i>RecvFrom failed with %d</i>"),iRecvItem->ReturnCode()); |
|
6323 return EFail; |
|
6324 } |
|
6325 |
|
6326 if (iRecvBuf.Length() != (KIPHeaderSize+KUdpHeaderSize+KSendData().Length())) |
|
6327 { |
|
6328 iLogger.WriteFormat(_L("<i>RecvFrom failed to deliver the expected data %d</i>"),err); |
|
6329 return EFail; |
|
6330 } |
|
6331 iLogger.WriteFormat(_L("<i>Peek data from socket and check the size</i>")); |
|
6332 iRecvItem->Start(); |
|
6333 iSocketIn.RecvFrom(iRecvBuf2, iInetAddrFrom, KIpHeaderIncluded|KSockReadPeek, iRecvItem->iStatus); |
|
6334 |
|
6335 iState = EState4; |
|
6336 Reschedule(); |
|
6337 iColl->Kick(); |
|
6338 return EPass; |
|
6339 } |
|
6340 case EState4: |
|
6341 { |
|
6342 if (iRecvItem->ReturnCode() != KErrNone) |
|
6343 { |
|
6344 iLogger.WriteFormat(_L("<i>RecvFrom failed with %d</i>"),iRecvItem->ReturnCode()); |
|
6345 return EFail; |
|
6346 } |
|
6347 if (iRecvBuf != iRecvBuf2) |
|
6348 { |
|
6349 iLogger.WriteFormat(_L("<i>Received data is not same</i>")); |
|
6350 return EFail; |
|
6351 } |
|
6352 iLogger.WriteFormat(_L("<i>Recv data from socket and check the size</i>")); |
|
6353 iRecvBuf.SetLength(0); |
|
6354 iRecvItem->Start(); |
|
6355 iSocketIn.RecvFrom(iRecvBuf, iInetAddrFrom, 0, iRecvItem->iStatus); |
|
6356 |
|
6357 iState = EState5; |
|
6358 Reschedule(); |
|
6359 iColl->Kick(); |
|
6360 return EPass; |
|
6361 } |
|
6362 case EState5: |
|
6363 { |
|
6364 if (iRecvItem->ReturnCode() != KErrNone) |
|
6365 { |
|
6366 iLogger.WriteFormat(_L("<i>RecvFrom failed with %d</i>"),iRecvItem->ReturnCode()); |
|
6367 return EFail; |
|
6368 } |
|
6369 if (iRecvBuf.Length() != KSendData().Length()) |
|
6370 { |
|
6371 iLogger.WriteFormat(_L("<i>Received data is not same</i>")); |
|
6372 return EFail; |
|
6373 } |
|
6374 |
|
6375 iLogger.WriteFormat(_L("<i>Peek data from socket and Cancel the recv</i>")); |
|
6376 iRecvItem->Start(); |
|
6377 iRecvBuf.SetLength(0); |
|
6378 iSocketIn.RecvFrom(iRecvBuf, iInetAddrFrom, KIpHeaderIncluded|KSockReadPeek, iRecvItem->iStatus); |
|
6379 iSocketIn.CancelRecv(); |
|
6380 |
|
6381 iLogger.WriteFormat(_L("<i>Send data to the socket</i>")); |
|
6382 iSendItem->Start(); |
|
6383 iSocketOut.SendTo(iSendBuf, iInetAddrTo, 0, iSendItem->iStatus); |
|
6384 |
|
6385 iState = EState6; |
|
6386 Reschedule(); |
|
6387 iColl->Kick(); |
|
6388 return EPass; |
|
6389 } |
|
6390 case EState6: |
|
6391 { |
|
6392 if (iRecvItem->ReturnCode() != KErrCancel) |
|
6393 { |
|
6394 iLogger.WriteFormat(_L("<i>CancelRecv failed with %d</i>"),iRecvItem->ReturnCode()); |
|
6395 return EFail; |
|
6396 } |
|
6397 |
|
6398 iState = EState7; |
|
6399 Reschedule(); |
|
6400 iColl->Kick(); |
|
6401 return EPass; |
|
6402 } |
|
6403 case EState7: |
|
6404 { |
|
6405 if (iSendItem->ReturnCode() != KErrNone) |
|
6406 { |
|
6407 iLogger.WriteFormat(_L("<i>SendTo failed with %d</i>"),iSendItem->ReturnCode()); |
|
6408 return EFail; |
|
6409 } |
|
6410 |
|
6411 iLogger.WriteFormat(_L("<i>Peek data from socket</i>")); |
|
6412 iRecvBuf.SetLength(0); |
|
6413 iRecvItem->Start(); |
|
6414 iSocketIn.RecvFrom(iRecvBuf, iInetAddrFrom, KIpHeaderIncluded|KSockReadPeek, iRecvItem->iStatus); |
|
6415 |
|
6416 iState = EState8; |
|
6417 Reschedule(); |
|
6418 iColl->Kick(); |
|
6419 return EPass; |
|
6420 } |
|
6421 case EState8: |
|
6422 { |
|
6423 if (iRecvItem->ReturnCode() != KErrNone) |
|
6424 { |
|
6425 iLogger.WriteFormat(_L("<i>RecvFrom failed with %d</i>"),iRecvItem->ReturnCode()); |
|
6426 return EFail; |
|
6427 } |
|
6428 |
|
6429 if (iRecvBuf.Length() != KIPHeaderSize + KUdpHeaderSize + KSendData().Length()) |
|
6430 { |
|
6431 iLogger.WriteFormat(_L("<i>Received data is not same</i>")); |
|
6432 return EFail; |
|
6433 } |
|
6434 return EPass; |
|
6435 } |
|
6436 default: |
|
6437 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockTestptstcs, 70)); |
|
6438 return EFail; |
|
6439 } |
|
6440 } |
|
6441 |
|
6442 void CEIntSockTest60::Cleanup() |
|
6443 { |
|
6444 iSocketIn.Close(); |
|
6445 iSocketOut.Close(); |
|
6446 } |
|
6447 |
|
6448 |
|
6449 |
|
6450 //------------------------------------------------------------------------------------------------- |
|
6451 // CEIntSockTest61 |
|
6452 //------------------------------------------------------------------------------------------------- |
|
6453 |
|
6454 CEIntSockTestBase* CEIntSockTest61::NewL(CProxyProvd* aProvd) |
|
6455 { |
|
6456 CEIntSockTestBase* ret = new(ELeave) CEIntSockTest61(aProvd); |
|
6457 return ret; |
|
6458 } |
|
6459 |
|
6460 CEIntSockTest61::CEIntSockTest61(CProxyProvd* aProvd) : |
|
6461 CEIntSockTestBase(aProvd) |
|
6462 {} |
|
6463 |
|
6464 TVerdict CEIntSockTest61::RunTestL() |
|
6465 { |
|
6466 Messages::TNodeId sourceCookie; |
|
6467 Messages::TRuntimeCtxIdOp sourceCookieOp(sourceCookie); |
|
6468 Messages::TNodeIdOp sourceNodeIdOp(sourceCookie); |
|
6469 |
|
6470 // Arbitrary numbers to test with |
|
6471 const TUint16 KSomeWorkerId = 0xf0f0; |
|
6472 const TUint8 KSomeSalt = 127; |
|
6473 TAny* KSomePtr = (TAny*)0xff0000ff; |
|
6474 sourceCookieOp.Set(KSomeSalt, KSomeWorkerId); |
|
6475 sourceNodeIdOp.SetPtr(KSomePtr); |
|
6476 |
|
6477 TEIntSockOpMsgWrapper opMsgWrapper; |
|
6478 CInternalSocketImpl* dummyImplPtr = NULL; |
|
6479 CommsFW::MCommsTransportSender* dummyTransportSender = NULL; |
|
6480 |
|
6481 TBuf8<sizeof(TEIntSockMsgExt)> msgBuff; |
|
6482 TEIntSockMsgExt* msgPtr = const_cast<TEIntSockMsgExt*>(reinterpret_cast<const TEIntSockMsgExt*>(msgBuff.Ptr())); |
|
6483 |
|
6484 // Test part 1 |
|
6485 iLogger.WriteFormat(_L("Corrupting TEIntSockMsgExt memory with 0xcc")); |
|
6486 Mem::Fill(msgPtr, sizeof(TEIntSockMsgExt), TChar(0xcc)); |
|
6487 |
|
6488 iLogger.WriteFormat(_L("Constructing TEIntSockMsgExt")); |
|
6489 new (msgPtr)TEIntSockMsgExt(ESoCreate, opMsgWrapper, dummyImplPtr, dummyTransportSender, sourceCookie); |
|
6490 |
|
6491 TInt result = Mem::Compare(reinterpret_cast<const TUint8*>(&sourceCookie), (TInt)sizeof(Messages::TNodeId), |
|
6492 reinterpret_cast<const TUint8*>(&msgPtr->ImplCookie()), (TInt)sizeof(Messages::TNodeId)); |
|
6493 if (result == 0) |
|
6494 { |
|
6495 iLogger.WriteFormat(_L("Cookie comparison result = 0 as expected")); |
|
6496 } |
|
6497 else |
|
6498 { |
|
6499 iLogger.WriteFormat(_L("Cookie comparison result = %d"), result); |
|
6500 return EFail; |
|
6501 } |
|
6502 |
|
6503 // Test part 2 |
|
6504 iLogger.WriteFormat(_L("Corrupting TEIntSockMsgExt memory with 0xaa")); |
|
6505 Mem::Fill(msgPtr, sizeof(TEIntSockMsgExt), TChar(0xaa)); |
|
6506 |
|
6507 iLogger.WriteFormat(_L("Constructing TEIntSockMsgExt")); |
|
6508 new (msgPtr)TEIntSockMsgExt(ESoCreate, opMsgWrapper, dummyImplPtr, dummyTransportSender, sourceCookie); |
|
6509 |
|
6510 result = Mem::Compare(reinterpret_cast<const TUint8*>(&sourceCookie), sizeof(Messages::TNodeId), |
|
6511 reinterpret_cast<const TUint8*>(&msgPtr->ImplCookie()), sizeof(Messages::TNodeId)); |
|
6512 if (result == 0) |
|
6513 { |
|
6514 iLogger.WriteFormat(_L("Cookie comparison result = 0 as expected")); |
|
6515 } |
|
6516 else |
|
6517 { |
|
6518 iLogger.WriteFormat(_L("Cookie comparison result = %d"), result); |
|
6519 return EFail; |
|
6520 } |
|
6521 |
|
6522 return EPass; |
|
6523 } |
|
6524 |
|
6525 void CEIntSockTest61::Cleanup() |
|
6526 { |
|
6527 } |