|
1 // Copyright (c) 1997-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 "TE_c32.h" |
|
17 #include "TTHREAD.H" |
|
18 |
|
19 #include <e32test.h> |
|
20 #include "C32COMM.H" |
|
21 #include "dummy.h" |
|
22 #include <rsshared.h> |
|
23 |
|
24 #include <e32cmn.h> |
|
25 |
|
26 #if defined (__WINS__) |
|
27 #define PDD_NAME _L("ECDRV") |
|
28 #define LDD_NAME _L("ECOMM") |
|
29 #define LDD_NAMETST _L("ECOMMTST") |
|
30 #else |
|
31 #define PDD_NAME _L("EUART1") //< Physical Device Driver #1 |
|
32 #define LDD_NAME _L("ECOMM") //< Logical Device Driver |
|
33 #define LDD_NAMETST _L("ECOMMTST") |
|
34 #endif |
|
35 |
|
36 #if (!defined __WINS__ && defined EKA1) |
|
37 #define PDD2_NAME _L("EUART2") //< Physical Device Driver #2 |
|
38 #endif |
|
39 |
|
40 const TInt KInvalidArgument=-1; |
|
41 |
|
42 CTestLoopback::CTestLoopback() |
|
43 { |
|
44 SetTestStepName(_L("TestLoopback")); |
|
45 } |
|
46 |
|
47 TInt CTestLoopback::DataReadThread(TAny* aArg) |
|
48 /** |
|
49 * Thread which attempts to read a chunk of data from loopback port |
|
50 */ |
|
51 { |
|
52 CTestLoopback* stepTest = reinterpret_cast<CTestLoopback*> (aArg); |
|
53 |
|
54 _LIT(KPortName1,"LOOPBACK::1"); |
|
55 _LIT(KCSYName,"LOOPBACK.CSY"); |
|
56 |
|
57 RCommServ commServ; |
|
58 TInt res=commServ.Connect(); |
|
59 if(res!=KErrNone) |
|
60 { |
|
61 stepTest->iState1 = __LINE__ - 2; |
|
62 return(res); |
|
63 } |
|
64 |
|
65 res=commServ.LoadCommModule(KCSYName); |
|
66 if(res!=KErrNone) |
|
67 { |
|
68 stepTest->iState2 = __LINE__ - 2; |
|
69 return(res); |
|
70 } |
|
71 |
|
72 res=stepTest->iSerialPortList[0].Open(commServ,KPortName1,ECommShared); |
|
73 if(res!=KErrNone) |
|
74 { |
|
75 stepTest->iState3 = __LINE__ - 2; |
|
76 return(res); |
|
77 } |
|
78 |
|
79 TRequestStatus stat0; |
|
80 TBuf8<20> readBuf; |
|
81 for (TInt i=0;i<=200;i++) |
|
82 { |
|
83 |
|
84 stepTest->iSerialPortList[0].ReadOneOrMore(stat0,readBuf); |
|
85 User::WaitForRequest(stat0); |
|
86 res = stat0.Int(); |
|
87 if(res!=KErrNone) |
|
88 { |
|
89 stepTest->iState4 = __LINE__ - 2; |
|
90 return(res); |
|
91 } |
|
92 } |
|
93 |
|
94 stepTest->iSem.Signal(); |
|
95 stepTest->iSerialPortList[0].Close(); |
|
96 |
|
97 return KErrNone; |
|
98 |
|
99 } |
|
100 |
|
101 TVerdict CTestLoopback::doTestStepL() |
|
102 { |
|
103 INFO_PRINTF1(_L("===================================")); |
|
104 INFO_PRINTF1(_L("Test : TestLoopback")); |
|
105 INFO_PRINTF1(_L("===================================")); |
|
106 |
|
107 _LIT(KCsyName,"LOOPBACK.CSY"); |
|
108 _LIT(KPortName0,"LOOPBACK::0"); |
|
109 _LIT8(KServerText,"Test Loopback : "); |
|
110 |
|
111 iSem.CreateLocal(0); |
|
112 |
|
113 RCommServ commServ; |
|
114 TInt ret=commServ.Connect(); |
|
115 ret=commServ.LoadCommModule(KCsyName); |
|
116 TESTCHECKL(ret,KErrNone); |
|
117 |
|
118 ret=iSerialPortList[1].Open(commServ,KPortName0,ECommShared); |
|
119 TESTCHECKL(ret,KErrNone); |
|
120 |
|
121 RThread readThread; |
|
122 TInt res=readThread.Create(_L("DataReadThread"),DataReadThread,KDefaultStackSize,KDefaultHeapSizeThread,KDefaultHeapSizeThread,this); |
|
123 TESTCHECKL(res, KErrNone); |
|
124 |
|
125 TRequestStatus stat; |
|
126 readThread.Logon(stat); |
|
127 |
|
128 readThread.Resume(); |
|
129 |
|
130 TRequestStatus stat0; |
|
131 |
|
132 for (TInt i=0;i<=200;i++) |
|
133 { |
|
134 TBuf8<20> writeBuf; |
|
135 writeBuf.Append(KServerText); |
|
136 writeBuf.AppendNum(i); |
|
137 |
|
138 if(i<=9) |
|
139 { |
|
140 writeBuf.AppendFill(' ',3); |
|
141 } |
|
142 |
|
143 if ((i >= 10) && (i<=99)) |
|
144 { |
|
145 writeBuf.AppendFill(' ',2); |
|
146 } |
|
147 |
|
148 if((i >= 100) && (i <= 999)) |
|
149 { |
|
150 writeBuf.AppendFill(' ', 1); |
|
151 } |
|
152 |
|
153 iSerialPortList[1].Write(stat0,writeBuf); |
|
154 User::WaitForRequest(stat0); |
|
155 TESTCHECKL(stat0.Int(), KErrNone); |
|
156 } |
|
157 |
|
158 iSem.Wait(); |
|
159 |
|
160 User::WaitForRequest(stat); |
|
161 TESTCHECKL(stat.Int(), KErrNone); |
|
162 |
|
163 iSem.Close(); |
|
164 CLOSE_AND_WAIT(readThread); |
|
165 iSerialPortList[1].Close(); |
|
166 |
|
167 commServ.Close(); |
|
168 |
|
169 if(iState1 != KErrNone) |
|
170 { |
|
171 INFO_PRINTF2(_L("Error occured, iState1, in DataReadThread at line %d, expected KErrNone."), iState1); |
|
172 SetTestStepResult(EFail); |
|
173 } |
|
174 if(iState2 != KErrNone) |
|
175 { |
|
176 INFO_PRINTF2(_L("Error occured, iState2, in DataReadThread at line %d, expected KErrNone."), iState2); |
|
177 SetTestStepResult(EFail); |
|
178 } |
|
179 if(iState3 != KErrNone) |
|
180 { |
|
181 INFO_PRINTF2(_L("Error occured, iState3, in DataReadThread at line %d, expected KErrNone."), iState3); |
|
182 SetTestStepResult(EFail); |
|
183 } |
|
184 if(iState4 != KErrNone) |
|
185 { |
|
186 INFO_PRINTF2(_L("Error occured, iState4, in DataReadThread at line %d, expected KErrNone."), iState4); |
|
187 SetTestStepResult(EFail); |
|
188 } |
|
189 |
|
190 return TestStepResult(); |
|
191 } |
|
192 |
|
193 CTestAllocMoreWriteMem::CTestAllocMoreWriteMem() |
|
194 { |
|
195 SetTestStepName(_L("TestAllocMoreWriteMem")); |
|
196 } |
|
197 |
|
198 |
|
199 TVerdict CTestAllocMoreWriteMem::doTestStepL() |
|
200 { |
|
201 INFO_PRINTF1(_L("===================================")); |
|
202 INFO_PRINTF1(_L("Test : TestAllocMoreWriteMem")); |
|
203 INFO_PRINTF1(_L("===================================")); |
|
204 |
|
205 _LIT(KCsyName,"LOOPBACK.CSY"); |
|
206 _LIT(KPortName0,"LOOPBACK::0"); |
|
207 _LIT8(KServerText,"Test Loopback : "); |
|
208 |
|
209 RCommServ commServ; |
|
210 TInt ret=commServ.Connect(); |
|
211 ret=commServ.LoadCommModule(KCsyName); |
|
212 TESTCHECKL(ret,KErrNone); |
|
213 |
|
214 TRequestStatus stat0; |
|
215 |
|
216 ret = iSerialPortList[1].Open(commServ,KPortName0,ECommShared); |
|
217 TESTCHECKL(ret,KErrNone); |
|
218 |
|
219 // This many loops ensures we need to allocate more memory for |
|
220 // write buffer. |
|
221 const TInt KNumOfLoopIterations = 1500; |
|
222 |
|
223 for (TInt i = 0; i < KNumOfLoopIterations; i++) |
|
224 { |
|
225 TBuf8<20> writeBuf; |
|
226 writeBuf.Append(KServerText); |
|
227 writeBuf.AppendNum(i); |
|
228 |
|
229 if(i <=9) |
|
230 { |
|
231 writeBuf.AppendFill(' ', 3); |
|
232 } |
|
233 |
|
234 if ((i >= 10) && (i <= 99)) |
|
235 { |
|
236 writeBuf.AppendFill(' ', 2); |
|
237 } |
|
238 |
|
239 if((i >= 100) && (i <= 999)) |
|
240 { |
|
241 writeBuf.AppendFill(' ', 1); |
|
242 } |
|
243 |
|
244 iSerialPortList[1].Write(stat0,writeBuf); |
|
245 User::WaitForRequest(stat0); |
|
246 TESTCHECKL(stat0.Int(), KErrNone); |
|
247 |
|
248 } |
|
249 |
|
250 TInt numOfBuffers = 0; |
|
251 |
|
252 // This method has been used to query the amount of data in the |
|
253 // write buffer |
|
254 numOfBuffers = iSerialPortList[1].QueryReceiveBuffer(); |
|
255 |
|
256 // The default buffer size for a write port is 4096. If we write |
|
257 // more than 4096 bytes we can confirm we have allocated more memory |
|
258 // for the write port |
|
259 TESTCHECKCONDITIONL(numOfBuffers == (20 * KNumOfLoopIterations)); |
|
260 |
|
261 iSerialPortList[1].Close(); |
|
262 |
|
263 commServ.Close(); |
|
264 |
|
265 return TestStepResult(); |
|
266 |
|
267 } |
|
268 |
|
269 CTestMemoryWriteFail::CTestMemoryWriteFail() |
|
270 { |
|
271 SetTestStepName(_L("TestMemoryWriteFail")); |
|
272 } |
|
273 |
|
274 TVerdict CTestMemoryWriteFail::doTestStepL() |
|
275 { |
|
276 INFO_PRINTF1(_L("===================================")); |
|
277 INFO_PRINTF1(_L("Test : TestMemoryWriteFail")); |
|
278 INFO_PRINTF1(_L("===================================")); |
|
279 |
|
280 |
|
281 #ifdef _DEBUG |
|
282 // The following test can only be tested under DEBUG situations as the |
|
283 // __DbgFailNext returns KErrNone for the RELEASE situation |
|
284 _LIT(KCsyName,"LOOPBACK.CSY"); |
|
285 _LIT(KPortName0,"LOOPBACK::0"); |
|
286 |
|
287 RCommServ commServ; |
|
288 |
|
289 TInt ret=commServ.Connect(); |
|
290 ret=commServ.LoadCommModule(KCsyName); |
|
291 TESTCHECKL(ret,KErrNone); |
|
292 |
|
293 TRequestStatus stat0; |
|
294 |
|
295 ret = iSerialPortList[1].Open(commServ,KPortName0,ECommShared); |
|
296 TESTCHECKL(ret,KErrNone); |
|
297 |
|
298 // The following code writes in small chunks of data filling the write data |
|
299 // with X's |
|
300 TBuf8<64> writeData; |
|
301 writeData.Fill('X', 64); |
|
302 |
|
303 // 64 * 64 = 4096, currently the default buffer size |
|
304 const TInt KLoopFillBuffer = 64; |
|
305 |
|
306 for(int i = 0; i < KLoopFillBuffer; i++) |
|
307 { |
|
308 iSerialPortList[1].Write(stat0,writeData); |
|
309 User::WaitForRequest(stat0); |
|
310 TESTCHECKL(stat0.Int(), KErrNone); |
|
311 } |
|
312 |
|
313 // if the size of the standard write buffer is 4096 bytes then |
|
314 // the above will fill in all the data |
|
315 // if we try and write more data a new memory allocation is required. |
|
316 commServ.__DbgFailNext(1); |
|
317 iSerialPortList[1].Write(stat0, writeData); |
|
318 User::WaitForRequest(stat0); |
|
319 TESTCHECKL(stat0.Int(), KErrNoMemory); |
|
320 commServ.__DbgFailNext(-1); |
|
321 |
|
322 iSerialPortList[1].Close(); |
|
323 commServ.Close(); |
|
324 #else |
|
325 INFO_PRINTF1(_L("Test : TestMemoryWriteFail not executed for non debug tests")); |
|
326 #endif |
|
327 return TestStepResult(); |
|
328 } |
|
329 |
|
330 |
|
331 CTestResetBuffers::CTestResetBuffers() |
|
332 { |
|
333 SetTestStepName(_L("TestResetBuffers")); |
|
334 } |
|
335 |
|
336 |
|
337 TVerdict CTestResetBuffers::doTestStepL() |
|
338 { |
|
339 INFO_PRINTF1(_L("===================================")); |
|
340 INFO_PRINTF1(_L("Test : TestResetBuffers")); |
|
341 INFO_PRINTF1(_L("===================================")); |
|
342 |
|
343 _LIT(KCsyName,"LOOPBACK.CSY"); |
|
344 _LIT(KPortName0,"LOOPBACK::0"); |
|
345 _LIT8(KServerText,"Test Loopback : "); |
|
346 |
|
347 RCommServ commServ; |
|
348 |
|
349 TInt ret=commServ.Connect(); |
|
350 ret=commServ.LoadCommModule(KCsyName); |
|
351 TESTCHECKL(ret,KErrNone); |
|
352 |
|
353 TRequestStatus stat0; |
|
354 |
|
355 ret = iSerialPortList[1].Open(commServ,KPortName0,ECommShared); |
|
356 TESTCHECKL(ret,KErrNone); |
|
357 |
|
358 // This value is to ensure we exceed the standard write buffer size |
|
359 const TInt KNumOfLoopIterations = 1500; |
|
360 |
|
361 for (TInt i = 0; i < KNumOfLoopIterations; i++) |
|
362 { |
|
363 TBuf8<20> writeBuf; |
|
364 writeBuf.Append(KServerText); |
|
365 writeBuf.AppendNum(i); |
|
366 |
|
367 if(i <=9) |
|
368 { |
|
369 writeBuf.AppendFill(' ', 3); |
|
370 } |
|
371 |
|
372 if ((i >= 10) && (i <= 99)) |
|
373 { |
|
374 writeBuf.AppendFill(' ', 2); |
|
375 } |
|
376 |
|
377 if((i >= 100) && (i <= 999)) |
|
378 { |
|
379 writeBuf.AppendFill(' ', 1); |
|
380 } |
|
381 |
|
382 iSerialPortList[1].Write(stat0,writeBuf); |
|
383 User::WaitForRequest(stat0); |
|
384 TESTCHECKL(stat0.Int(), KErrNone); |
|
385 |
|
386 } |
|
387 |
|
388 TInt numOfBuffers = 0; |
|
389 |
|
390 // This method has been used to query the amount of data in the |
|
391 // write buffer |
|
392 numOfBuffers = iSerialPortList[1].QueryReceiveBuffer(); |
|
393 |
|
394 // check the amount of data we have in our buffer. |
|
395 // 20 bytes * number of times around the loop |
|
396 TESTCHECKCONDITION(numOfBuffers == (20 * KNumOfLoopIterations)); |
|
397 |
|
398 // reset the amount of data in our buffer |
|
399 ret = iSerialPortList[1].ResetBuffers(); |
|
400 TESTCHECKL(ret, KErrNone); |
|
401 |
|
402 numOfBuffers = iSerialPortList[1].QueryReceiveBuffer(); |
|
403 |
|
404 TESTCHECKCONDITION(numOfBuffers == 0); |
|
405 |
|
406 iSerialPortList[1].Close(); |
|
407 |
|
408 commServ.Close(); |
|
409 |
|
410 return TestStepResult(); |
|
411 } |
|
412 |
|
413 CTestCorrectDataRead::CTestCorrectDataRead() |
|
414 { |
|
415 SetTestStepName(_L("TestCorrectDataRead")); |
|
416 } |
|
417 |
|
418 |
|
419 TVerdict CTestCorrectDataRead::doTestStepL() |
|
420 { |
|
421 INFO_PRINTF1(_L("===================================")); |
|
422 INFO_PRINTF1(_L("Test : TestCorrectDataRead")); |
|
423 INFO_PRINTF1(_L("===================================")); |
|
424 |
|
425 _LIT(KCsyName,"LOOPBACK.CSY"); |
|
426 _LIT(KPortName0,"LOOPBACK::0"); |
|
427 _LIT(KPortName1,"LOOPBACK::1"); |
|
428 _LIT8(KServerText,"Test Loopback : "); |
|
429 |
|
430 RCommServ commServ; |
|
431 |
|
432 |
|
433 TInt ret=commServ.Connect(); |
|
434 ret=commServ.LoadCommModule(KCsyName); |
|
435 TESTCHECKL(ret,KErrNone); |
|
436 |
|
437 TRequestStatus stat, stat0; |
|
438 |
|
439 ret = iSerialPortList[1].Open(commServ,KPortName0,ECommShared); |
|
440 TESTCHECKL(ret,KErrNone); |
|
441 |
|
442 ret = iSerialPortList[0].Open(commServ,KPortName1, ECommShared); |
|
443 TESTCHECKL(ret,KErrNone); |
|
444 |
|
445 // This value is to ensure we exceed the standard write buffer size |
|
446 const TInt KNumOfLoopIterations = 1500; |
|
447 |
|
448 for (TInt i = 0; i < KNumOfLoopIterations; i++) |
|
449 { |
|
450 TBuf8<20> writeBuf; |
|
451 writeBuf.Append(KServerText); |
|
452 writeBuf.AppendNum(i); |
|
453 |
|
454 if(i <=9) |
|
455 { |
|
456 writeBuf.AppendFill(' ', 3); |
|
457 } |
|
458 |
|
459 if ((i >= 10) && (i <= 99)) |
|
460 { |
|
461 writeBuf.AppendFill(' ', 2); |
|
462 } |
|
463 |
|
464 if((i >= 100) && (i <= 999)) |
|
465 { |
|
466 writeBuf.AppendFill(' ', 1); |
|
467 } |
|
468 |
|
469 iSerialPortList[1].Write(stat0,writeBuf); |
|
470 User::WaitForRequest(stat0); |
|
471 TESTCHECKL(stat0.Int(), KErrNone); |
|
472 |
|
473 } |
|
474 |
|
475 for (TInt i = 0; i < KNumOfLoopIterations; i++) |
|
476 { |
|
477 TBuf8<20> readBuf; |
|
478 TBuf8<20> compareBuf; |
|
479 |
|
480 compareBuf.Append(KServerText); |
|
481 compareBuf.AppendNum(i); |
|
482 |
|
483 if(i <= 9) |
|
484 { |
|
485 compareBuf.AppendFill(' ', 3); |
|
486 } |
|
487 |
|
488 if ((i >= 10) && (i <= 99)) |
|
489 { |
|
490 compareBuf.AppendFill(' ', 2); |
|
491 } |
|
492 |
|
493 if((i >= 100) && (i <= 999)) |
|
494 { |
|
495 compareBuf.AppendFill(' ', 1); |
|
496 } |
|
497 |
|
498 iSerialPortList[0].Read(stat0, readBuf); |
|
499 User::WaitForRequest(stat0); |
|
500 TESTCHECKL(stat0.Int(), KErrNone); |
|
501 |
|
502 // compare what we have read against what we are expecting. Remember |
|
503 // this is a first in last out buffer so the first read will read a |
|
504 // "Loopback : 0" |
|
505 TESTCHECKCONDITION(readBuf == compareBuf); |
|
506 |
|
507 } |
|
508 |
|
509 iSerialPortList[0].Close(); |
|
510 iSerialPortList[1].Close(); |
|
511 |
|
512 |
|
513 commServ.Close(); |
|
514 |
|
515 return TestStepResult(); |
|
516 |
|
517 } |
|
518 |
|
519 CTestMaxBufferOverflow::CTestMaxBufferOverflow() |
|
520 { |
|
521 SetTestStepName(_L("TestMaxBufferOverflow")); |
|
522 } |
|
523 |
|
524 |
|
525 TVerdict CTestMaxBufferOverflow::doTestStepL() |
|
526 { |
|
527 INFO_PRINTF1(_L("===================================")); |
|
528 INFO_PRINTF1(_L("Test : TestMaxBufferOverflow")); |
|
529 INFO_PRINTF1(_L("===================================")); |
|
530 |
|
531 _LIT(KCsyName,"LOOPBACK.CSY"); |
|
532 _LIT(KPortName1,"LOOPBACK::0"); |
|
533 |
|
534 RCommServ commServ; |
|
535 TRequestStatus stat0(KErrNone); |
|
536 |
|
537 TInt ret=commServ.Connect(); |
|
538 ret=commServ.LoadCommModule(KCsyName); |
|
539 TESTCHECKL(ret,KErrNone); |
|
540 |
|
541 ret = iSerialPortList[1].Open(commServ,KPortName1, ECommShared); |
|
542 TESTCHECKL(ret,KErrNone); |
|
543 |
|
544 // At the time of writing the maximum size was 32768 bytes (0x8000) |
|
545 // Therefore write 32768 bytes then write once more to exceed the |
|
546 // maximum buffer size |
|
547 const TInt KNumOfLoopIterations = 1024; |
|
548 |
|
549 TBuf8<32> writeBuf; |
|
550 writeBuf.Fill('X', 32); |
|
551 |
|
552 for (TInt i = 0; i < KNumOfLoopIterations; i++) |
|
553 { |
|
554 iSerialPortList[1].Write(stat0,writeBuf); |
|
555 User::WaitForRequest(stat0); |
|
556 TESTCHECKL(stat0.Int(), KErrNone); |
|
557 } |
|
558 |
|
559 iSerialPortList[1].Write(stat0, writeBuf); |
|
560 User::WaitForRequest(stat0); |
|
561 TESTCHECKL(stat0.Int(), KErrNoMemory); |
|
562 |
|
563 iSerialPortList[1].Close(); |
|
564 |
|
565 commServ.Close(); |
|
566 |
|
567 return TestStepResult(); |
|
568 |
|
569 } |
|
570 |
|
571 |
|
572 CTestInit::CTestInit() |
|
573 { |
|
574 SetTestStepName(_L("TestInit")); |
|
575 } |
|
576 |
|
577 TVerdict CTestInit::doTestStepL() |
|
578 /** |
|
579 * @test initializes the c32 drivers |
|
580 */ |
|
581 { |
|
582 INFO_PRINTF1(_L("Loading LDD and PDD")); |
|
583 |
|
584 INFO_PRINTF1(_L("Load driver")); |
|
585 TInt r=User::LoadPhysicalDevice(PDD_NAME); |
|
586 TEST(r==KErrNone || r==KErrAlreadyExists); |
|
587 #if defined PDD2_NAME |
|
588 INFO_PRINTF1(_L("Load COMM::2 driver")); |
|
589 r=User::LoadPhysicalDevice(PDD2_NAME); |
|
590 TEST(r==KErrNone || r==KErrAlreadyExists); |
|
591 INFO_PRINTF2(_L("Error: %d"), r); |
|
592 #endif |
|
593 //7 |
|
594 INFO_PRINTF1(_L("Load device")); |
|
595 r=User::LoadLogicalDevice(LDD_NAME); |
|
596 TEST(r==KErrNone|| r==KErrAlreadyExists); |
|
597 |
|
598 INFO_PRINTF1(_L("start comm server")); |
|
599 // PhBkSync can interfere with the OOM steps by spawning new SerComm sessions during them |
|
600 _LIT(KPhbkSyncCMI, "phbsync.cmi"); |
|
601 |
|
602 r = WarmBootC32(KPhbkSyncCMI); |
|
603 |
|
604 TEST(r == KErrNone || r==KErrAlreadyExists); |
|
605 if (r!=KErrNone && r!=KErrAlreadyExists) |
|
606 INFO_PRINTF2(_L("Failed to start C32 %d"),r); |
|
607 |
|
608 #if defined (ETNA_PDD_NAME) |
|
609 INFO_PRINTF1(_L("Loading Etna PDD ")); |
|
610 r=User::LoadPhysicalDevice(ETNA_PDD_NAME); |
|
611 if (r!=KErrNone && r!=KErrAlreadyExists) |
|
612 { |
|
613 INFO_PRINTF2(_L("Failed %d!"),r); |
|
614 TEST(r==KErrNone); |
|
615 } |
|
616 else |
|
617 INFO_PRINTF1(_L("Loaded ETNA PDD")); |
|
618 #endif |
|
619 |
|
620 return TestStepResult(); |
|
621 } |
|
622 |
|
623 CTestDoubleStart::CTestDoubleStart() |
|
624 { |
|
625 SetTestStepName(_L("TestDoubleStart")); |
|
626 } |
|
627 |
|
628 TInt CTestDoubleStart::StartC32Thread(TAny* aArg) |
|
629 /** |
|
630 * Thread which attempts to startC32 simpultaneously from this new thread |
|
631 */ |
|
632 { |
|
633 CTestDoubleStart* stepTest = reinterpret_cast<CTestDoubleStart*> (aArg); |
|
634 |
|
635 TInt res = StartC32(); |
|
636 if(res!=KErrNone) |
|
637 { |
|
638 stepTest->iState1 = __LINE__ - 2; |
|
639 return(res); |
|
640 } |
|
641 return KErrNone; |
|
642 } |
|
643 |
|
644 |
|
645 TVerdict CTestDoubleStart::doTestStepL() |
|
646 /** |
|
647 * @test Attempt to start C32 twice, using another thread to start C32 simultaneously as StartC32 is a sync call |
|
648 */ |
|
649 { |
|
650 INFO_PRINTF1(_L("===================================")); |
|
651 INFO_PRINTF1(_L("Test : TestDoubleStart")); |
|
652 INFO_PRINTF1(_L("===================================")); |
|
653 INFO_PRINTF1(_L("Attempting to double start C32")); |
|
654 |
|
655 RThread startC32Thread; |
|
656 TInt res = startC32Thread.Create(_L("StartC32Thread"), StartC32Thread, KDefaultStackSize, KDefaultHeapSizeThread, KDefaultHeapSizeThread, this); |
|
657 TESTCHECKL(res, KErrNone); |
|
658 |
|
659 TRequestStatus stat; |
|
660 startC32Thread.Logon(stat); |
|
661 |
|
662 startC32Thread.Resume(); |
|
663 |
|
664 res = StartC32(); |
|
665 TESTCHECK(res, KErrNone); |
|
666 |
|
667 User::WaitForRequest(stat); |
|
668 CLOSE_AND_WAIT(startC32Thread); |
|
669 |
|
670 return TestStepResult(); |
|
671 } |
|
672 |
|
673 TVerdict CTestDoubleStart::doTestStepPreambleL( void ) |
|
674 { |
|
675 return TestStepResult(); |
|
676 } |
|
677 |
|
678 TVerdict CTestDoubleStart::doTestStepPostambleL( void ) |
|
679 { |
|
680 |
|
681 return TestStepResult(); |
|
682 } |
|
683 |
|
684 CTestOpen::CTestOpen() |
|
685 { |
|
686 SetTestStepName(_L("TestOpen")); |
|
687 } |
|
688 |
|
689 TVerdict CTestOpen::doTestStepL() |
|
690 /** |
|
691 * @test Check opening and closing |
|
692 */ |
|
693 { |
|
694 INFO_PRINTF1(_L("===================================")); |
|
695 INFO_PRINTF1(_L("Test : TestOpen")); |
|
696 INFO_PRINTF1(_L("===================================")); |
|
697 // |
|
698 INFO_PRINTF1(_L("Open/close ports")); |
|
699 |
|
700 TInt res = iSerialPortList[0].Open(iCommSession, KCommPort0, ECommShared); |
|
701 TESTCHECKL(res, KErrNone); |
|
702 |
|
703 INFO_PRINTF1(_L("Open another session")); |
|
704 RCommServ commSess2; |
|
705 res = commSess2.Connect(); |
|
706 TESTCHECKL(res, KErrNone); |
|
707 |
|
708 res=iSerialPortList[1].Open(commSess2, KCommPort0, ECommShared); |
|
709 TESTCHECKL(res, KErrNone); |
|
710 |
|
711 INFO_PRINTF1(_L("Close ports")); |
|
712 iSerialPortList[0].Close(); |
|
713 iSerialPortList[1].Close(); |
|
714 |
|
715 INFO_PRINTF1(_L("Open port exclusive")); |
|
716 res = iSerialPortList[0].Open(iCommSession, KCommPort0, ECommExclusive); |
|
717 TESTCHECKL(res, KErrNone); |
|
718 |
|
719 INFO_PRINTF1(_L("Open port again")); |
|
720 |
|
721 res = iSerialPortList[1].Open(commSess2, KCommPort0, ECommShared); |
|
722 TESTCHECKL(res, KErrAccessDenied); |
|
723 |
|
724 iSerialPortList[0].Close(); |
|
725 |
|
726 INFO_PRINTF1(_L("Close port without opening")); |
|
727 RComm port; |
|
728 port.Close(); |
|
729 |
|
730 commSess2.Close(); |
|
731 |
|
732 return TestStepResult(); |
|
733 } |
|
734 |
|
735 CTestInfo::CTestInfo() |
|
736 { |
|
737 SetTestStepName(_L("TestInfo")); |
|
738 } |
|
739 |
|
740 TVerdict CTestInfo::doTestStepL() |
|
741 /** |
|
742 * @test Test the information services |
|
743 */ |
|
744 { |
|
745 INFO_PRINTF1(_L("===================================")); |
|
746 INFO_PRINTF1(_L("Test : TestInfo")); |
|
747 INFO_PRINTF1(_L("===================================")); |
|
748 |
|
749 INFO_PRINTF1(_L("Test the information services")); |
|
750 |
|
751 RCommServ commSess; |
|
752 INFO_PRINTF1(_L("Connect to the Comms server")); |
|
753 TInt res=commSess.Connect(); |
|
754 TESTCHECKL(res, KErrNone); |
|
755 |
|
756 TInt num; |
|
757 res=commSess.NumPorts(num); |
|
758 INFO_PRINTF2(_L("Get number of loaded comms modules (should be 1) : %d"), num); |
|
759 TESTCHECKL(res, KErrNone); |
|
760 TESTCHECKL(num, 1); |
|
761 |
|
762 TPortName name; |
|
763 TSerialInfo protocolInfo; |
|
764 res=commSess.GetPortInfo(10000,name,protocolInfo); |
|
765 INFO_PRINTF1(_L("Get information on serial ports")); |
|
766 TESTCHECKL(res, KErrTooBig); |
|
767 |
|
768 res=commSess.GetPortInfo(0,name,protocolInfo); |
|
769 INFO_PRINTF1(_L("Get information on serial ports")); |
|
770 TESTCHECKL(res, KErrNone); |
|
771 TESTCHECKL(name.CompareF(_L("ECUART")), 0); |
|
772 |
|
773 res = commSess.GetPortInfo(name,protocolInfo ); |
|
774 INFO_PRINTF1(_L("Get information on serial ports using CSY name")); // INC052021 |
|
775 TESTCHECKL(res, KErrNone); |
|
776 TESTCHECKL(protocolInfo.iName.CompareF(_L("COMM")), 0); |
|
777 |
|
778 commSess.Close(); |
|
779 return TestStepResult(); |
|
780 } |
|
781 |
|
782 |
|
783 CTestDoubleRead::CTestDoubleRead() |
|
784 { |
|
785 SetTestStepName(_L("TestDoubleRead")); |
|
786 } |
|
787 |
|
788 TInt CTestDoubleRead::DoubleReadThread(TAny* aArg) |
|
789 /** |
|
790 * Thread which attempts to read twice and should panic |
|
791 */ |
|
792 { |
|
793 CTestDoubleRead* stepTest = reinterpret_cast<CTestDoubleRead*> (aArg); |
|
794 RCommServ serv; |
|
795 TInt res=serv.Connect(); |
|
796 if(res!=KErrNone) |
|
797 { |
|
798 stepTest->iState1 = __LINE__ - 2; |
|
799 return(res); |
|
800 } |
|
801 |
|
802 res=stepTest->iSerialPortList[0].Open(serv, KCommPort0, ECommShared); |
|
803 if(res!=KErrNone) |
|
804 { |
|
805 stepTest->iState2 = __LINE__ - 2; |
|
806 return(res); |
|
807 } |
|
808 |
|
809 |
|
810 res=stepTest->iSerialPortList[1].Open(serv, KCommPort0, ECommShared); |
|
811 if(res!=KErrNone) |
|
812 { |
|
813 stepTest->iState3 = __LINE__ - 2; |
|
814 return(res); |
|
815 } |
|
816 |
|
817 |
|
818 TBuf8<100> buf; |
|
819 TRequestStatus status; |
|
820 stepTest->iSerialPortList[0].Read(status, buf); |
|
821 |
|
822 TRequestStatus status2; |
|
823 stepTest->iSerialPortList[0].Read(status2, buf); |
|
824 |
|
825 User::WaitForRequest(status2); |
|
826 stepTest->iState4 = __LINE__ - 2; //shouldn't get here. |
|
827 return KErrNone; |
|
828 } |
|
829 |
|
830 TVerdict CTestDoubleRead::doTestStepL() |
|
831 /** |
|
832 * @test Test that double reads panics |
|
833 */ |
|
834 { |
|
835 User::SetJustInTime(EFalse); |
|
836 |
|
837 INFO_PRINTF1(_L("===================================")); |
|
838 INFO_PRINTF1(_L("Test : TestDoubleRead")); |
|
839 INFO_PRINTF1(_L("===================================")); |
|
840 |
|
841 INFO_PRINTF1(_L("Read twice on same port")); |
|
842 |
|
843 RThread t; |
|
844 TInt res=t.Create(_L("DoubleRead"),DoubleReadThread,KDefaultStackSize,KDefaultHeapSizeThread,KDefaultHeapSizeThread,this); |
|
845 TESTCHECKL(res, KErrNone); |
|
846 TRequestStatus stat; |
|
847 t.Logon(stat); |
|
848 t.Resume(); |
|
849 User::WaitForRequest(stat); |
|
850 TESTCHECKSTRL(t.ExitCategory(), KCommServerPanic); //"Comm server panic" from cc_utl.cpp |
|
851 TESTCHECKL(t.ExitReason(), 1); // 1==EReadTwice from cs_std.h |
|
852 TESTCHECKL(t.ExitType(), EExitPanic); |
|
853 CLOSE_AND_WAIT(t); |
|
854 |
|
855 User::SetJustInTime(ETrue); |
|
856 |
|
857 // Check return values of tests within the thread |
|
858 if(iState1 != 0) |
|
859 { |
|
860 INFO_PRINTF2(_L("Error occured in DoubleReadThread at line %d, expected KErrNone."), iState1); |
|
861 SetTestStepResult(EFail); |
|
862 } |
|
863 if(iState2 != 0) |
|
864 { |
|
865 INFO_PRINTF2(_L("Error occured in DoubleReadThread at line %d, expected KErrNone."), iState2); |
|
866 SetTestStepResult(EFail); |
|
867 } |
|
868 if(iState3 != 0) |
|
869 { |
|
870 INFO_PRINTF2(_L("Error occured in DoubleReadThread at line %d, expected KErrNone."), iState3); |
|
871 SetTestStepResult(EFail); |
|
872 } |
|
873 |
|
874 if(iState4 != 0) |
|
875 { |
|
876 INFO_PRINTF2(_L("Error occured in doubleReadThread at line %d, didn't expected to reach code."), iState4); |
|
877 SetTestStepResult(EFail); |
|
878 } |
|
879 |
|
880 return TestStepResult(); |
|
881 } |
|
882 |
|
883 CTestConfigPanic::CTestConfigPanic() |
|
884 { |
|
885 SetTestStepName(_L("TestConfigPanic")); |
|
886 } |
|
887 |
|
888 TInt CTestConfigPanic::ConfigPanic(TAny* aArg) |
|
889 /** |
|
890 * Thread which attempts to read twice and should panic |
|
891 */ |
|
892 { |
|
893 CTestConfigPanic* stepTest = reinterpret_cast<CTestConfigPanic*>(aArg); |
|
894 RCommServ serv; |
|
895 TUint res=serv.Connect(); |
|
896 if(res!=(TUint)KErrNone) |
|
897 { |
|
898 stepTest->iState1 = __LINE__ - 2; |
|
899 return(res); |
|
900 } |
|
901 |
|
902 res=stepTest->iSerialPortList[0].Open(serv,KCommPort0,ECommShared); |
|
903 if(res!=(TUint)KErrNone) |
|
904 { |
|
905 stepTest->iState2 = __LINE__ - 2; |
|
906 return(res); |
|
907 } |
|
908 |
|
909 TRequestStatus status; |
|
910 TBuf8<100> buf; |
|
911 stepTest->iSerialPortList[0].Read(status,buf); |
|
912 |
|
913 TCommConfig cfg; |
|
914 TInt ret=stepTest->iSerialPortList[0].Config(cfg); |
|
915 if(ret!=KErrNone) |
|
916 { |
|
917 stepTest->iState3 = __LINE__ - 2; |
|
918 } |
|
919 TInt val=stepTest->iSerialPortList[0].SetConfig(cfg); |
|
920 return val; |
|
921 } |
|
922 |
|
923 TVerdict CTestConfigPanic::doTestStepL() |
|
924 /** |
|
925 * @test Test thread is panicked if it tries to set configuration |
|
926 */ |
|
927 { |
|
928 User::SetJustInTime(EFalse); |
|
929 |
|
930 INFO_PRINTF1(_L("===================================")); |
|
931 INFO_PRINTF1(_L("Test : TestConfigPanic")); |
|
932 INFO_PRINTF1(_L("===================================")); |
|
933 |
|
934 INFO_PRINTF1(_L("Configuration panic")); |
|
935 |
|
936 RThread t; |
|
937 TInt res=t.Create(_L("ConfigPanic"),ConfigPanic,KDefaultStackSize,KDefaultHeapSizeThread,KDefaultHeapSizeThread,this); |
|
938 TESTCHECKL(res, KErrNone); |
|
939 TRequestStatus stat; |
|
940 t.Logon(stat); |
|
941 t.Resume(); |
|
942 User::WaitForRequest(stat); |
|
943 TESTCHECKL(stat.Int(), KErrInUse); |
|
944 CLOSE_AND_WAIT(t); |
|
945 |
|
946 User::SetJustInTime(ETrue); |
|
947 |
|
948 if(iState1 != 0) |
|
949 { |
|
950 INFO_PRINTF2(_L("Error occured in ConfigPanic at line %d, expected KErrNone."), iState1); |
|
951 SetTestStepResult(EFail); |
|
952 } |
|
953 if(iState2 != 0) |
|
954 { |
|
955 INFO_PRINTF2(_L("Error occured in ConfigPanic at line %d, expected KErrNone."), iState2); |
|
956 SetTestStepResult(EFail); |
|
957 } |
|
958 if(iState3 != 0) |
|
959 { |
|
960 INFO_PRINTF2(_L("Error occured in ConfigPanic at line %d, expected KErrNone."), iState3); |
|
961 SetTestStepResult(EFail); |
|
962 } |
|
963 |
|
964 return TestStepResult(); |
|
965 } |
|
966 |
|
967 CTestBadDescriptorPanic::CTestBadDescriptorPanic() |
|
968 { |
|
969 SetTestStepName(_L("TestBadDescriptorPanic")); |
|
970 } |
|
971 |
|
972 TInt CTestBadDescriptorPanic::BadDescriptor(TAny* aArg) |
|
973 /** |
|
974 * Thread which attempts to write with a bad descriptor should panic |
|
975 */ |
|
976 { |
|
977 CTestBadDescriptorPanic* testStep = reinterpret_cast<CTestBadDescriptorPanic*>(aArg); |
|
978 RCommServ serv; |
|
979 TUint res=serv.Connect(); |
|
980 if(res!=(TUint)KErrNone) |
|
981 { |
|
982 testStep->iState1 = __LINE__ - 2; |
|
983 return(res); |
|
984 } |
|
985 |
|
986 res=testStep->iSerialPortList[0].Open(serv,KCommPort0,ECommShared); |
|
987 if(res!=(TUint)KErrNone) |
|
988 { |
|
989 testStep->iState2 = __LINE__ - 2; |
|
990 return(res); |
|
991 } |
|
992 |
|
993 |
|
994 TRequestStatus status; |
|
995 TBufC8<100> buf = _L8("Hello"); |
|
996 |
|
997 // scribble on type part of descriptor |
|
998 *(TInt*)&buf |= 0xf0000000; |
|
999 testStep->iSerialPortList[0].Write(status,buf); |
|
1000 |
|
1001 User::WaitForRequest(status); |
|
1002 testStep->iState3 = __LINE__ - 2; // Shouldn't reach here |
|
1003 return KErrNone; |
|
1004 } |
|
1005 |
|
1006 TVerdict CTestBadDescriptorPanic::doTestStepL() |
|
1007 /** |
|
1008 * @test Test that double reads panics |
|
1009 */ |
|
1010 { |
|
1011 User::SetJustInTime(EFalse); |
|
1012 |
|
1013 INFO_PRINTF1(_L("===================================")); |
|
1014 INFO_PRINTF1(_L("Test : TestBadDescriptorPanic")); |
|
1015 INFO_PRINTF1(_L("===================================")); |
|
1016 |
|
1017 |
|
1018 INFO_PRINTF1(_L("Test that double reads panics")); |
|
1019 RThread t; |
|
1020 TInt res=t.Create(_L("DescriptorPanic"),BadDescriptor,KDefaultStackSize,KDefaultHeapSizeThread,KDefaultHeapSizeThread,this); |
|
1021 TESTCHECKL(res, KErrNone); |
|
1022 TRequestStatus stat; |
|
1023 t.Logon(stat); |
|
1024 t.Resume(); |
|
1025 User::WaitForRequest(stat); |
|
1026 TESTCHECKSTRL(t.ExitCategory(), KCommServerPanic); //"Comm server panic" from cc_utl.cpp |
|
1027 TESTCHECKL(t.ExitReason(), 4); // EBadDescriptor == 4 |
|
1028 TESTCHECKL(t.ExitType(), EExitPanic); |
|
1029 CLOSE_AND_WAIT(t); |
|
1030 |
|
1031 // Check return values of tests within the thread |
|
1032 if(iState1 != 0) |
|
1033 { |
|
1034 INFO_PRINTF2(_L("Error occured in BadDescriptor at line %d, expected KErrNone."), iState1); |
|
1035 SetTestStepResult(EFail); |
|
1036 } |
|
1037 if(iState2 != 0) |
|
1038 { |
|
1039 INFO_PRINTF2(_L("Error occured in BadDescriptor at line %d, expected KErrNone."), iState2); |
|
1040 SetTestStepResult(EFail); |
|
1041 } |
|
1042 if(iState3 != 0) |
|
1043 { |
|
1044 INFO_PRINTF2(_L("Error occured in BadDescriptor at line %d, didn't expected to reach code."), iState3); |
|
1045 SetTestStepResult(EFail); |
|
1046 } |
|
1047 |
|
1048 |
|
1049 User::SetJustInTime(ETrue); |
|
1050 return TestStepResult(); |
|
1051 } |
|
1052 |
|
1053 CTestBusyReturn::CTestBusyReturn() |
|
1054 { |
|
1055 SetTestStepName(_L("TestBusyReturn")); |
|
1056 } |
|
1057 |
|
1058 TInt CTestBusyReturn::CreateThread(TAny* aArg) |
|
1059 /** |
|
1060 * Thread which opens a port and then gets panicked |
|
1061 */ |
|
1062 { |
|
1063 __UHEAP_MARK; |
|
1064 CTrapCleanup *trap = CTrapCleanup::New(); |
|
1065 if (!trap) |
|
1066 { |
|
1067 return KErrNoMemory; |
|
1068 } |
|
1069 |
|
1070 TInt ret(KErrUnknown); |
|
1071 TRAPD(err, ret = OpenAndReadThreadL(aArg)); |
|
1072 __ASSERT_ALWAYS(!err, User::Panic(_L("OpenAndReadThreadL"), err)); |
|
1073 delete trap; |
|
1074 __UHEAP_MARKEND; |
|
1075 return ret; |
|
1076 } |
|
1077 |
|
1078 TInt CTestBusyReturn::OpenAndReadThreadL(TAny* aArg) |
|
1079 { |
|
1080 CTestBusyReturn* testStep = reinterpret_cast<CTestBusyReturn*>(aArg); |
|
1081 testStep->iBuffer.Append(_L("Entering Second thread\n")); |
|
1082 |
|
1083 RCommServ serv; |
|
1084 TInt res = serv.Connect(); |
|
1085 |
|
1086 if(res != KErrNone) |
|
1087 { |
|
1088 testStep->iState1 = __LINE__ - 2; |
|
1089 return(res); |
|
1090 } |
|
1091 |
|
1092 res = testStep->iSerialPortList[0].Open(serv, KCommPort1, ECommShared); |
|
1093 |
|
1094 if(res != KErrNone) |
|
1095 { |
|
1096 testStep->iState2 = __LINE__ - 2; |
|
1097 return(res); |
|
1098 } |
|
1099 |
|
1100 TRequestStatus status; |
|
1101 TUint8* b = new (ELeave) TUint8[100]; |
|
1102 TPtr8 buf(b, 100, 100); |
|
1103 |
|
1104 testStep->iBuffer.Append(_L("\t\t\t\t\tSecond thread : trying to write from second thread\n")); |
|
1105 testStep->iBuffer.Append(_L("\t\t\t\t\tSecond thread : It should return KErrInUse\n")); |
|
1106 testStep->iSerialPortList[0].Write(status, buf); |
|
1107 User::WaitForRequest(status); |
|
1108 |
|
1109 if(status.Int() != KErrInUse) |
|
1110 { |
|
1111 testStep->iState3 = __LINE__ - 2; |
|
1112 } |
|
1113 |
|
1114 |
|
1115 testStep->iSerialPortList[0].Read(status,buf); |
|
1116 testStep->iSem.Signal(); |
|
1117 |
|
1118 User::WaitForRequest(status); |
|
1119 |
|
1120 delete b; |
|
1121 return KErrNone; |
|
1122 } |
|
1123 |
|
1124 TVerdict CTestBusyReturn::doTestStepL() |
|
1125 /** |
|
1126 * @test Test reading on a port from another thread doesn't panic us.. |
|
1127 */ |
|
1128 { |
|
1129 // User::SetJustInTime(EFalse); |
|
1130 |
|
1131 INFO_PRINTF1(_L("==========================================")); |
|
1132 INFO_PRINTF1(_L("Test : TestBusyReturn (multithreaded test)")); |
|
1133 INFO_PRINTF1(_L("==========================================")); |
|
1134 |
|
1135 INFO_PRINTF1(_L("Main thread : Testing busy return when one thread already owns a port.")); |
|
1136 |
|
1137 TInt res; |
|
1138 RCommServ serv; |
|
1139 res = serv.Connect(); |
|
1140 TESTCHECKL(res, KErrNone); |
|
1141 |
|
1142 INFO_PRINTF1(_L("Main thread : open in this thread")); |
|
1143 |
|
1144 res = iSerialPortList[1].Open(serv, KCommPort1, ECommShared); |
|
1145 TESTCHECKL(res, KErrNone); |
|
1146 |
|
1147 TRequestStatus rstatus, wstatus; |
|
1148 const TInt KBufferSize=150; |
|
1149 TBuf8<KBufferSize> rbuf; |
|
1150 TBufC8<KBufferSize> wbuf = _L8("This thing here is a 150 character buffer, designed to clog up COM1. With a bit of luck it should be long enough to turn around and bite its own tail!"); |
|
1151 rbuf.SetMax(); |
|
1152 |
|
1153 iSem.CreateLocal(0); |
|
1154 |
|
1155 INFO_PRINTF1(_L("Main thread : write/read")); |
|
1156 iSerialPortList[1].Write(wstatus, wbuf); |
|
1157 |
|
1158 RThread t; |
|
1159 res = t.Create(_L("Open1"), CreateThread, KDefaultStackSize, KDefaultHeapSizeThread, KDefaultHeapSizeThread, this); |
|
1160 TESTCHECKL(res, KErrNone); |
|
1161 t.Resume(); |
|
1162 iSem.Wait(); |
|
1163 iSem.Close(); |
|
1164 |
|
1165 // Log.SeekEnd(); // To compensate the output of the other thread |
|
1166 |
|
1167 INFO_PRINTF1(_L("Main thread : read when busy")); |
|
1168 iSerialPortList[1].Read(rstatus, rbuf); |
|
1169 User::WaitForRequest(rstatus); |
|
1170 TESTCHECKL(rstatus.Int(), KErrInUse); |
|
1171 |
|
1172 |
|
1173 // iSerialPortList[1].Break(rstatus,10000); // temp removed cos DD has been broken |
|
1174 // User::WaitForRequest(rstatus); |
|
1175 // TESTCHECKL(rstatus, KErrNotSupported); |
|
1176 |
|
1177 INFO_PRINTF1(_L("Main thread : Kill second thread")); |
|
1178 t.Kill(KErrNone); |
|
1179 |
|
1180 INFO_PRINTF1(iBuffer); |
|
1181 |
|
1182 // Check return values of tests within the thread |
|
1183 if(iState1 != 0) |
|
1184 { |
|
1185 INFO_PRINTF2(_L("Error occured in CreateThread at line %d, expected KErrNone."), iState1); |
|
1186 SetTestStepResult(EFail); |
|
1187 } |
|
1188 if(iState2 != 0) |
|
1189 { |
|
1190 INFO_PRINTF2(_L("Error occured in CreateThread at line %d, expected KErrNone."), iState2); |
|
1191 SetTestStepResult(EFail); |
|
1192 } |
|
1193 if(iState3 != 0) |
|
1194 { |
|
1195 INFO_PRINTF2(_L("Error occured in CreateThread at line %d, expected KErrInUse."), iState3); |
|
1196 SetTestStepResult(EFail); |
|
1197 } |
|
1198 else |
|
1199 { |
|
1200 INFO_PRINTF1(_L("Main thread : KErrInUse returned as expected.")); |
|
1201 } |
|
1202 |
|
1203 TInt ret = iSerialPortList[1].WriteCancel(); |
|
1204 TESTCHECKL(ret, KErrNone); |
|
1205 User::WaitForRequest(wstatus); |
|
1206 TESTCHECKL(wstatus.Int(), KErrCancel); |
|
1207 |
|
1208 rbuf.SetLength(KBufferSize); |
|
1209 INFO_PRINTF1(_L("Main thread : And read OK")); |
|
1210 iSerialPortList[1].Read(rstatus,rbuf); |
|
1211 |
|
1212 User::After(100000); |
|
1213 |
|
1214 TESTCHECKL(rstatus.Int(), KRequestPending); |
|
1215 |
|
1216 ret = iSerialPortList[1].ReadCancel(); |
|
1217 TESTCHECKL(ret, KErrNone); |
|
1218 User::WaitForRequest(rstatus); |
|
1219 |
|
1220 // |
|
1221 // close down |
|
1222 // |
|
1223 CLOSE_AND_WAIT(t); |
|
1224 iSerialPortList[1].Close(); |
|
1225 serv.Close(); |
|
1226 |
|
1227 // User::SetJustInTime(ETrue); |
|
1228 return TestStepResult(); |
|
1229 } |
|
1230 |
|
1231 CTestCancel::CTestCancel() |
|
1232 { |
|
1233 SetTestStepName(_L("TestCancel")); |
|
1234 } |
|
1235 |
|
1236 TInt CTestCancel::CancelThread(TAny* aArg) |
|
1237 /** |
|
1238 * Thread which attempts to read twice and should panic |
|
1239 */ |
|
1240 { |
|
1241 CTestCancel* testStep = reinterpret_cast<CTestCancel*>(aArg); |
|
1242 testStep->iBuffer.Append(_L("Second thread : CancelThread")); |
|
1243 |
|
1244 RCommServ serv; |
|
1245 TUint res=serv.Connect(); |
|
1246 if(res!=(TUint)KErrNone) |
|
1247 { |
|
1248 testStep->iState1 = __LINE__ - 2; |
|
1249 return(res); |
|
1250 } |
|
1251 |
|
1252 res=testStep->iSerialPortList[0].Open(serv,KCommPort0,ECommShared); |
|
1253 if(res!=(TUint)KErrNone) |
|
1254 { |
|
1255 testStep->iState2 = __LINE__ - 2; |
|
1256 return(res); |
|
1257 } |
|
1258 |
|
1259 res=testStep->iSerialPortList[1].Open(serv,KCommPort0,ECommShared); |
|
1260 if(res!=(TUint)KErrNone) |
|
1261 { |
|
1262 testStep->iState3 = __LINE__ - 2; |
|
1263 return(res); |
|
1264 } |
|
1265 |
|
1266 TBuf8<100> buf; |
|
1267 TRequestStatus status; |
|
1268 testStep->iSerialPortList[0].Read(status,buf); |
|
1269 TInt ret = testStep->iSerialPortList[0].ReadCancel(); |
|
1270 if(ret!=KErrNone) |
|
1271 { |
|
1272 testStep->iState5 = __LINE__ - 2; |
|
1273 return(ret); |
|
1274 } |
|
1275 |
|
1276 TRequestStatus status2; |
|
1277 testStep->iSerialPortList[0].Read(status2,buf); // Should not panic.... |
|
1278 |
|
1279 User::WaitForRequest(status); |
|
1280 if(status.Int() != KErrCancel) |
|
1281 { |
|
1282 testStep->iState4 = __LINE__ - 2; |
|
1283 return(status.Int()); |
|
1284 } |
|
1285 |
|
1286 ret = testStep->iSerialPortList[0].ReadCancel(); |
|
1287 if(ret!=KErrNone) |
|
1288 { |
|
1289 testStep->iState6 = __LINE__ - 2; |
|
1290 return(ret); |
|
1291 } |
|
1292 User::WaitForRequest(status2); |
|
1293 |
|
1294 ret = testStep->iSerialPortList[0].ReadCancel(); // Test we can cancel a non existent request. |
|
1295 if(ret!=KErrNone) |
|
1296 { |
|
1297 testStep->iState7 = __LINE__ - 2; |
|
1298 return(ret); |
|
1299 } |
|
1300 |
|
1301 return KErrNone; |
|
1302 } |
|
1303 |
|
1304 |
|
1305 TVerdict CTestCancel::doTestStepL() |
|
1306 /** |
|
1307 * @test Test cancel works...and doesn't panic |
|
1308 */ |
|
1309 { |
|
1310 INFO_PRINTF1(_L("===================================")); |
|
1311 INFO_PRINTF1(_L("Test :TestCancel")); |
|
1312 INFO_PRINTF1(_L("===================================")); |
|
1313 |
|
1314 INFO_PRINTF1(_L("Test cancel works...and doesn't panic")); |
|
1315 |
|
1316 INFO_PRINTF1(_L("Cancel")); |
|
1317 RThread t; |
|
1318 TInt res=t.Create(_L("Cancel"),CancelThread,KDefaultStackSize,KDefaultHeapSizeThread,KDefaultHeapSizeThread,this); |
|
1319 TEST(res==KErrNone); |
|
1320 |
|
1321 TRequestStatus stat; |
|
1322 t.Logon(stat); |
|
1323 t.Resume(); |
|
1324 User::WaitForRequest(stat); |
|
1325 TESTCHECKSTR(t.ExitCategory(), KCommServerSuccess); |
|
1326 TESTCHECK(t.ExitReason(), KErrNone); |
|
1327 TESTCHECK(t.ExitType(), EExitKill); |
|
1328 CLOSE_AND_WAIT(t); |
|
1329 |
|
1330 INFO_PRINTF1(iBuffer); |
|
1331 |
|
1332 // Check return values of tests within the thread |
|
1333 if(iState1 != 0) |
|
1334 { |
|
1335 INFO_PRINTF2(_L("Error occured in CancelThread at line %d, expected KErrNone."), iState1); |
|
1336 SetTestStepResult(EFail); |
|
1337 } |
|
1338 if(iState2 != 0) |
|
1339 { |
|
1340 INFO_PRINTF2(_L("Error occured in CancelThread at line %d, expected KErrNone."), iState2); |
|
1341 SetTestStepResult(EFail); |
|
1342 } |
|
1343 if(iState3 != 0) |
|
1344 { |
|
1345 INFO_PRINTF2(_L("Error occured in CancelThread at line %d, expected KErrNone."), iState3); |
|
1346 SetTestStepResult(EFail); |
|
1347 } |
|
1348 if(iState4 != 0) |
|
1349 { |
|
1350 INFO_PRINTF2(_L("Error occured in CancelThread at line %d, expected KErrCancel."), iState3); |
|
1351 SetTestStepResult(EFail); |
|
1352 } |
|
1353 if(iState5 != 0) |
|
1354 { |
|
1355 INFO_PRINTF2(_L("Error occured in CancelThread at line %d, expected KErrCancel."), iState5); |
|
1356 SetTestStepResult(EFail); |
|
1357 } |
|
1358 if(iState6 != 0) |
|
1359 { |
|
1360 INFO_PRINTF2(_L("Error occured in CancelThread at line %d, expected KErrCancel."), iState6); |
|
1361 SetTestStepResult(EFail); |
|
1362 } |
|
1363 if(iState7 != 0) |
|
1364 { |
|
1365 INFO_PRINTF2(_L("Error occured in CancelThread at line %d, expected KErrCancel."), iState7); |
|
1366 SetTestStepResult(EFail); |
|
1367 } |
|
1368 |
|
1369 return TestStepResult(); |
|
1370 } |
|
1371 |
|
1372 CTestGetSetConfig::CTestGetSetConfig() |
|
1373 { |
|
1374 SetTestStepName(_L("TestGetSetConfig")); |
|
1375 } |
|
1376 |
|
1377 TVerdict CTestGetSetConfig::doTestStepL() |
|
1378 /** |
|
1379 * @test Test setting and getting config |
|
1380 */ |
|
1381 { |
|
1382 INFO_PRINTF1(_L("===================================")); |
|
1383 INFO_PRINTF1(_L("Test : TestGetSetConfig")); |
|
1384 INFO_PRINTF1(_L("===================================")); |
|
1385 |
|
1386 INFO_PRINTF1(_L("test setting and getting config")); |
|
1387 |
|
1388 // |
|
1389 // use COMM::1 |
|
1390 // |
|
1391 INFO_PRINTF1(_L("Open comm session")); |
|
1392 TInt res=iSerialPortList[0].Open(iCommSession, KCommPort1, ECommShared); |
|
1393 TESTCHECKL(res, KErrNone); |
|
1394 |
|
1395 INFO_PRINTF1(_L("Open 2nd session")); |
|
1396 RCommServ commSess2; |
|
1397 res=commSess2.Connect(); |
|
1398 TESTCHECKL(res, KErrNone); |
|
1399 |
|
1400 res=iSerialPortList[1].Open(commSess2, KCommPort1, ECommShared); |
|
1401 TESTCHECKL(res, KErrNone); |
|
1402 |
|
1403 TCommConfig cBuf0; |
|
1404 TCommConfigV01 &c0=cBuf0(); |
|
1405 TCommConfig cBuf1; |
|
1406 TCommConfigV01 &c1=cBuf1(); |
|
1407 |
|
1408 INFO_PRINTF1(_L("Check that config for both ports is the same")); |
|
1409 TInt ret=iSerialPortList[0].Config(cBuf0); |
|
1410 TESTCHECKL(ret, KErrNone); |
|
1411 ret=iSerialPortList[1].Config(cBuf1); |
|
1412 TESTCHECKL(ret, KErrNone); |
|
1413 |
|
1414 TESTCHECK(c0.iRate, c1.iRate); |
|
1415 TESTCHECK(c0.iDataBits, c1.iDataBits); |
|
1416 TESTCHECK(c0.iStopBits, c1.iStopBits); |
|
1417 TESTCHECK(c0.iParity, c1.iParity); |
|
1418 TESTCHECK(c0.iHandshake, c1.iHandshake); |
|
1419 TESTCHECK(c0.iParityError, c1.iParityError); |
|
1420 TESTCHECK(c0.iSpecialRate, c1.iSpecialRate); |
|
1421 TESTCHECK(c0.iTerminatorCount, c1.iTerminatorCount); |
|
1422 TESTCHECK(c0.iTerminator[0], c1.iTerminator[0]); |
|
1423 TESTCHECK(c0.iTerminator[1], c1.iTerminator[1]); |
|
1424 TESTCHECK(c0.iTerminator[2], c1.iTerminator[2]); |
|
1425 TESTCHECK(c0.iTerminator[3], c1.iTerminator[3]); |
|
1426 TESTCHECK(c0.iXonChar, c1.iXonChar); |
|
1427 TESTCHECK(c0.iXoffChar, c1.iXoffChar); |
|
1428 TESTCHECK(c0.iParityErrorChar, c1.iParityErrorChar); |
|
1429 // TESTCHECK(c0.iSpareChar, c1.iSpareChar); |
|
1430 |
|
1431 // Make a change... |
|
1432 // c0.iXonChar++; |
|
1433 // c0.iXoffChar++; |
|
1434 c0.iRate = EBps19200; |
|
1435 |
|
1436 INFO_PRINTF1(_L("Check that changing one changes the other")); |
|
1437 res = iSerialPortList[0].SetConfig(cBuf0); |
|
1438 TESTCHECKL(res, KErrNone); |
|
1439 ret=iSerialPortList[1].Config(cBuf1); |
|
1440 TESTCHECKL(ret, KErrNone); |
|
1441 |
|
1442 TESTCHECK(c0.iRate, c1.iRate); |
|
1443 TESTCHECK(c0.iDataBits, c1.iDataBits); |
|
1444 TESTCHECK(c0.iStopBits, c1.iStopBits); |
|
1445 TESTCHECK(c0.iParity, c1.iParity); |
|
1446 TESTCHECK(c0.iHandshake, c1.iHandshake); |
|
1447 TESTCHECK(c0.iParityError, c1.iParityError); |
|
1448 TESTCHECK(c0.iSpecialRate, c1.iSpecialRate); |
|
1449 TESTCHECK(c0.iTerminatorCount, c1.iTerminatorCount); |
|
1450 TESTCHECK(c0.iTerminator[0], c1.iTerminator[0]); |
|
1451 TESTCHECK(c0.iTerminator[1], c1.iTerminator[1]); |
|
1452 TESTCHECK(c0.iTerminator[2], c1.iTerminator[2]); |
|
1453 TESTCHECK(c0.iTerminator[3], c1.iTerminator[3]); |
|
1454 TESTCHECK(c0.iXonChar, c1.iXonChar); |
|
1455 TESTCHECK(c0.iXoffChar, c1.iXoffChar); |
|
1456 TESTCHECK(c0.iParityErrorChar, c1.iParityErrorChar); |
|
1457 // TESTCHECK(c0.iSpareChar, c1.iSpareChar); |
|
1458 |
|
1459 iSerialPortList[0].Close(); |
|
1460 iSerialPortList[1].Close(); |
|
1461 |
|
1462 commSess2.Close(); |
|
1463 |
|
1464 return TestStepResult(); |
|
1465 } |
|
1466 |
|
1467 CTestTimeOut::CTestTimeOut() |
|
1468 { |
|
1469 SetTestStepName(_L("TestTimeOut")); |
|
1470 } |
|
1471 |
|
1472 TVerdict CTestTimeOut::doTestStepL() |
|
1473 /** |
|
1474 * @test Test time outs... |
|
1475 */ |
|
1476 { |
|
1477 INFO_PRINTF1(_L("===================================")); |
|
1478 INFO_PRINTF1(_L("Test : TestTimeOut")); |
|
1479 INFO_PRINTF1(_L("===================================")); |
|
1480 |
|
1481 INFO_PRINTF1(_L("Test time outs....")); |
|
1482 INFO_PRINTF1(_L("Open port")); |
|
1483 |
|
1484 TInt res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
1485 TESTCHECKL(res, KErrNone); |
|
1486 |
|
1487 // Turn handshaking on. |
|
1488 |
|
1489 TCommConfig cBuf; |
|
1490 TCommConfigV01 &c=cBuf(); |
|
1491 |
|
1492 c.iRate=EBps9600; |
|
1493 c.iHandshake=KConfigObeyXoff|KConfigSendXoff|KConfigObeyCTS|KConfigObeyDSR|KConfigObeyDCD; |
|
1494 c.iTerminatorCount=0; |
|
1495 |
|
1496 iSerialPortList[0].SetConfig(cBuf); |
|
1497 const TUint KBufSize=0x5000; |
|
1498 TUint8* buf = new (ELeave) TUint8[KBufSize]; |
|
1499 CleanupStack::PushL(buf); |
|
1500 TPtr8 des(buf,KBufSize,KBufSize); |
|
1501 |
|
1502 TRequestStatus status; |
|
1503 |
|
1504 const TInt KTimeOutValue=1000000; |
|
1505 TTime starttime; |
|
1506 starttime.UniversalTime(); |
|
1507 INFO_PRINTF1(_L("Read with time out")); |
|
1508 iSerialPortList[0].Read(status,KTimeOutValue,des,KBufSize); |
|
1509 User::WaitForRequest(status); |
|
1510 TESTCHECKL(status.Int(), KErrTimedOut); |
|
1511 |
|
1512 TTime endtime; |
|
1513 endtime.UniversalTime(); |
|
1514 TTimeIntervalMicroSeconds interval = endtime.MicroSecondsFrom(starttime); |
|
1515 TInt64 milliseconds = interval.Int64() / TInt64(1000); |
|
1516 INFO_PRINTF2(_L("MilliSeconds taken %d"), I64LOW(milliseconds)); |
|
1517 |
|
1518 des.SetMax(); |
|
1519 INFO_PRINTF1(_L("Write with time out")); |
|
1520 starttime.UniversalTime(); |
|
1521 iSerialPortList[0].Write(status,KTimeOutValue,des,KBufSize); |
|
1522 User::WaitForRequest(status); |
|
1523 TESTCHECKL(status.Int(), KErrTimedOut); |
|
1524 |
|
1525 endtime.UniversalTime(); |
|
1526 interval = endtime.MicroSecondsFrom(starttime); |
|
1527 milliseconds = interval.Int64() / TInt64(1000); |
|
1528 INFO_PRINTF2(_L("MilliSeconds taken %d"), I64LOW(milliseconds)); |
|
1529 |
|
1530 iSerialPortList[0].Close(); |
|
1531 |
|
1532 res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
1533 TESTCHECKL(res, KErrNone); |
|
1534 |
|
1535 iSerialPortList[0].Read(status,KTimeOutValue,des); |
|
1536 TInt ret = iSerialPortList[0].ReadCancel(); |
|
1537 TESTCHECKL(ret, KErrNone); |
|
1538 User::WaitForRequest(status); |
|
1539 iSerialPortList[0].Close(); |
|
1540 TESTCHECKL(status.Int(), KErrCancel); |
|
1541 |
|
1542 CleanupStack::PopAndDestroy(1); // buf |
|
1543 return TestStepResult(); |
|
1544 |
|
1545 } |
|
1546 |
|
1547 CTestThreadPanic::CTestThreadPanic() |
|
1548 { |
|
1549 SetTestStepName(_L("TestThreadPanic")); |
|
1550 } |
|
1551 |
|
1552 TInt CTestThreadPanic::OpenExclusiveThread(TAny* aArg) |
|
1553 /** |
|
1554 * Thread which opens a port and then get's panicked |
|
1555 */ |
|
1556 { |
|
1557 CTestThreadPanic* testStep = reinterpret_cast<CTestThreadPanic*>(aArg); |
|
1558 testStep->iBuffer = _L("OpenExclusiveThread"); |
|
1559 RCommServ serv; |
|
1560 TUint res=serv.Connect(); |
|
1561 if(res!=(TUint)KErrNone) |
|
1562 { |
|
1563 testStep->iState1 = __LINE__ - 2; |
|
1564 return(res); |
|
1565 } |
|
1566 |
|
1567 res=testStep->iSerialPortList[0].Open(serv,KCommPort0,ECommExclusive); |
|
1568 if(res!=(TUint)KErrNone) |
|
1569 { |
|
1570 testStep->iState2 = __LINE__ - 2; |
|
1571 return(res); |
|
1572 } |
|
1573 |
|
1574 testStep->iSem1.Signal(); |
|
1575 User::WaitForAnyRequest(); |
|
1576 |
|
1577 return 0; |
|
1578 } |
|
1579 |
|
1580 TInt CTestThreadPanic::OpenSharedThread(TAny* aArg) |
|
1581 /** |
|
1582 * Thread which opens a port and then get's panicked |
|
1583 */ |
|
1584 { |
|
1585 CTestThreadPanic* testStep = reinterpret_cast<CTestThreadPanic*>(aArg); |
|
1586 testStep->iBuffer = _L("OpenSharedThread"); |
|
1587 RCommServ serv; |
|
1588 TUint res=serv.Connect(); |
|
1589 if(res!=(TUint)KErrNone) |
|
1590 { |
|
1591 testStep->iState3 = __LINE__ - 2; |
|
1592 return(res); |
|
1593 } |
|
1594 |
|
1595 res=testStep->iSerialPortList[0].Open(serv,KCommPort0,ECommShared); |
|
1596 if(res!=(TUint)KErrNone) |
|
1597 { |
|
1598 testStep->iState4 = __LINE__ - 2; |
|
1599 return(res); |
|
1600 } |
|
1601 |
|
1602 |
|
1603 testStep->iSem2.Signal(); |
|
1604 |
|
1605 return 0; |
|
1606 } |
|
1607 |
|
1608 TVerdict CTestThreadPanic::doTestStepL() |
|
1609 /** |
|
1610 * @test Test opening a port from a thread panicking the thread. |
|
1611 */ |
|
1612 { |
|
1613 INFO_PRINTF1(_L("===================================")); |
|
1614 INFO_PRINTF1(_L("Test : TestThreadPanic")); |
|
1615 INFO_PRINTF1(_L("===================================")); |
|
1616 |
|
1617 INFO_PRINTF1(_L("Testing opening and closing.")); |
|
1618 |
|
1619 iSem1.CreateLocal(0); |
|
1620 |
|
1621 INFO_PRINTF1(_L("Close due to panic")); |
|
1622 RThread t; |
|
1623 TInt res=t.Create(_L("Open2"),OpenExclusiveThread,KDefaultStackSize,KDefaultHeapSizeThread,KDefaultHeapSizeThread,reinterpret_cast<TAny*>(this)); |
|
1624 TESTCHECKL(res, KErrNone); |
|
1625 t.Resume(); |
|
1626 |
|
1627 RCommServ serv; |
|
1628 res=serv.Connect(); |
|
1629 TESTCHECKL(res, KErrNone); |
|
1630 |
|
1631 User::SetJustInTime(EFalse); |
|
1632 t.Panic(_L("Test Panic"),666); |
|
1633 User::SetJustInTime(ETrue); |
|
1634 |
|
1635 res=iSerialPortList[1].Open(serv,KCommPort0,ECommExclusive); |
|
1636 TESTCHECKL(res, KErrNone); |
|
1637 |
|
1638 iSerialPortList[1].Close(); |
|
1639 |
|
1640 iSem1.Close(); |
|
1641 CLOSE_AND_WAIT(t); |
|
1642 |
|
1643 INFO_PRINTF1(iBuffer); |
|
1644 |
|
1645 // Check return values of tests within the thread |
|
1646 if(iState1 != 0) |
|
1647 { |
|
1648 INFO_PRINTF2(_L("Error occured in OpenExclusiveThread at line %d, expected KErrNone."), iState1); |
|
1649 SetTestStepResult(EFail); |
|
1650 } |
|
1651 if(iState2 != 0) |
|
1652 { |
|
1653 INFO_PRINTF2(_L("Error occured in OpenExclusiveThread at line %d, expected KErrNone."), iState2); |
|
1654 SetTestStepResult(EFail); |
|
1655 } |
|
1656 |
|
1657 INFO_PRINTF1(_L("Open shared from two threads.")); |
|
1658 |
|
1659 res = iSerialPortList[1].Open(serv,KCommPort0,ECommShared); |
|
1660 TESTCHECKL(res, KErrNone); |
|
1661 |
|
1662 iSem2.CreateLocal(0); |
|
1663 RThread t2; |
|
1664 res=t2.Create(_L("Open3"),OpenSharedThread,KDefaultStackSize,KDefaultHeapSizeThread,KDefaultHeapSizeThread,this); |
|
1665 TESTCHECKL(res, KErrNone); |
|
1666 t2.Resume(); |
|
1667 iSem2.Wait(); |
|
1668 |
|
1669 serv.Close(); |
|
1670 CLOSE_AND_WAIT(t2); |
|
1671 |
|
1672 INFO_PRINTF1(iBuffer); |
|
1673 |
|
1674 // Check return values of tests within the thread |
|
1675 if(iState3 != 0) |
|
1676 { |
|
1677 INFO_PRINTF2(_L("Error occured in OpenSharedThread at line %d, expected KErrNone."), iState3); |
|
1678 SetTestStepResult(EFail); |
|
1679 } |
|
1680 if(iState4 != 0) |
|
1681 { |
|
1682 INFO_PRINTF2(_L("Error occured in OpenSharedThread at line %d, expected KErrNone."), iState4); |
|
1683 SetTestStepResult(EFail); |
|
1684 } |
|
1685 |
|
1686 return TestStepResult(); |
|
1687 } |
|
1688 |
|
1689 CTestBufferOptions::CTestBufferOptions() |
|
1690 { |
|
1691 SetTestStepName(_L("TestBufferOptions")); |
|
1692 } |
|
1693 |
|
1694 TVerdict CTestBufferOptions::doTestStepL() |
|
1695 /** |
|
1696 * @test Test Buffered comm server options |
|
1697 */ |
|
1698 { |
|
1699 INFO_PRINTF1(_L("==========================================")); |
|
1700 INFO_PRINTF1(_L("Test : TestBufferOptions")); |
|
1701 INFO_PRINTF1(_L("==========================================")); |
|
1702 |
|
1703 INFO_PRINTF1(_L("Test Buffered comm server options")); |
|
1704 |
|
1705 INFO_PRINTF1(_L("Open port")); |
|
1706 TInt res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
1707 TESTCHECKL(res, KErrNone); |
|
1708 // enable buffering |
|
1709 |
|
1710 TCommServerConfig bmcPckg; |
|
1711 TCommServerConfigV01 &bmc=bmcPckg(); |
|
1712 |
|
1713 TUint len=iSerialPortList[0].ReceiveBufferLength(); |
|
1714 TInt ret = iSerialPortList[0].SetReceiveBufferLength(len*2); |
|
1715 TESTCHECKL(ret, KErrNone); |
|
1716 ret = iSerialPortList[0].SetReceiveBufferLength(len/2); |
|
1717 TESTCHECKL(ret, KErrNone); |
|
1718 |
|
1719 bmc.iBufFlags=KCommBufferPartial; |
|
1720 bmc.iBufSize=0x1000; |
|
1721 |
|
1722 iSerialPortList[0].SetMode(bmcPckg); |
|
1723 |
|
1724 bmc.iBufFlags=KCommBufferPartial; |
|
1725 bmc.iBufSize=0x5; |
|
1726 |
|
1727 iSerialPortList[0].SetMode(bmcPckg); |
|
1728 |
|
1729 bmc.iBufFlags=KCommBufferPartial; |
|
1730 bmc.iBufSize=0x2000; |
|
1731 |
|
1732 iSerialPortList[0].SetMode(bmcPckg); |
|
1733 |
|
1734 iSerialPortList[0].Close(); |
|
1735 |
|
1736 return TestStepResult(); |
|
1737 } |
|
1738 |
|
1739 CTestOOMConnection::CTestOOMConnection() |
|
1740 { |
|
1741 SetTestStepName(_L("TestOOMConnection")); |
|
1742 } |
|
1743 |
|
1744 TVerdict CTestOOMConnection::doTestStepL() |
|
1745 /** |
|
1746 * @test Test connecting under OOM |
|
1747 */ |
|
1748 { |
|
1749 INFO_PRINTF1(_L("==========================================")); |
|
1750 INFO_PRINTF1(_L("Test : TestOOMConnection")); |
|
1751 INFO_PRINTF1(_L("==========================================")); |
|
1752 |
|
1753 #ifdef _DEBUG |
|
1754 INFO_PRINTF1(_L("Test connecting under OOM")); |
|
1755 RCommServ cs; |
|
1756 TInt ret=cs.Connect(); |
|
1757 TESTCHECKL(ret, KErrNone); |
|
1758 |
|
1759 INFO_PRINTF1(_L("Low memory connection")); |
|
1760 TInt failure=0; |
|
1761 RCommServ cs2; |
|
1762 ret=-1; |
|
1763 cs.__DbgMarkHeap(); |
|
1764 while (ret!=KErrNone) |
|
1765 { |
|
1766 INFO_PRINTF2(_L("Failing after %d Allocs"),failure); |
|
1767 cs.__DbgFailNext(failure); |
|
1768 ret=cs2.Connect(); |
|
1769 if (ret!=KErrNone) |
|
1770 cs.__DbgCheckHeap(0); |
|
1771 failure++; |
|
1772 } |
|
1773 INFO_PRINTF1(_L("Connected OK")); |
|
1774 |
|
1775 cs2.Close(); |
|
1776 |
|
1777 // Flush any FailNext there might be hanging around. |
|
1778 if (cs2.Connect()==KErrNone) |
|
1779 cs2.Close(); |
|
1780 |
|
1781 cs.__DbgMarkEnd(0); |
|
1782 cs.__DbgFailNext(-1); |
|
1783 cs.Close(); |
|
1784 #else |
|
1785 INFO_PRINTF1(_L("TestDisabled on release build.")); |
|
1786 #endif |
|
1787 return TestStepResult(); |
|
1788 } |
|
1789 |
|
1790 CTestOOMPortCreation::CTestOOMPortCreation() |
|
1791 { |
|
1792 SetTestStepName(_L("TestOOMPortCreation")); |
|
1793 } |
|
1794 |
|
1795 TVerdict CTestOOMPortCreation::doTestStepL() |
|
1796 /** |
|
1797 * @test Test creating ports under OOM |
|
1798 */ |
|
1799 { |
|
1800 INFO_PRINTF1(_L("==========================================")); |
|
1801 INFO_PRINTF1(_L("Test : TestOOMPortCreation")); |
|
1802 INFO_PRINTF1(_L("==========================================")); |
|
1803 |
|
1804 #ifdef _DEBUG |
|
1805 INFO_PRINTF1(_L("Test creating ports under OOM")); |
|
1806 RCommServ cs; |
|
1807 TInt ret=cs.Connect(); |
|
1808 TESTCHECKL(ret, KErrNone); |
|
1809 |
|
1810 INFO_PRINTF1(_L("Low memory port open no heap check")); |
|
1811 TInt failure=0; |
|
1812 RComm c; |
|
1813 ret=-1; |
|
1814 while (ret!=KErrNone) |
|
1815 { |
|
1816 INFO_PRINTF2(_L("Failing after %d Allocs"),failure); |
|
1817 cs.__DbgFailNext(failure); |
|
1818 ret=c.Open(cs,KCommPort0,ECommShared); |
|
1819 failure++; |
|
1820 } |
|
1821 INFO_PRINTF1(_L("Created port OK")); |
|
1822 |
|
1823 c.Close(); |
|
1824 // Flush any FailNext there might be hanging around. |
|
1825 if (c.Open(cs,KCommPort0,ECommShared)==KErrNone) |
|
1826 c.Close(); |
|
1827 |
|
1828 INFO_PRINTF1(_L("Low memory port open with heap check")); |
|
1829 RComm ports[16]; |
|
1830 TInt i; |
|
1831 for (i=0;i<16;i++) |
|
1832 { |
|
1833 |
|
1834 TInt res=ports[i].Open(cs,KCommPort1,ECommShared); |
|
1835 if(res==KErrNotFound) |
|
1836 { |
|
1837 INFO_PRINTF1(_L("Cannot do this test - no second serial port")); |
|
1838 iSerialPortList[0].Close(); |
|
1839 SetTestStepResult(EInconclusive); |
|
1840 return TestStepResult(); |
|
1841 } |
|
1842 } |
|
1843 |
|
1844 for (i=0;i<15;i++) |
|
1845 ports[i].Close(); |
|
1846 |
|
1847 failure=0; |
|
1848 ret=-1; |
|
1849 cs.__DbgMarkHeap(); |
|
1850 while (ret!=KErrNone) |
|
1851 { |
|
1852 INFO_PRINTF2(_L("Failing after %d Allocs"),failure); |
|
1853 cs.__DbgFailNext(failure); |
|
1854 ret=c.Open(cs,KCommPort0,ECommShared); |
|
1855 if (ret!=KErrNone) |
|
1856 cs.__DbgCheckHeap(0); |
|
1857 failure++; |
|
1858 } |
|
1859 INFO_PRINTF1(_L("Created port OK")); |
|
1860 |
|
1861 c.Close(); |
|
1862 ports[15].Close(); |
|
1863 |
|
1864 // Flush any FailNext there might be hanging around. |
|
1865 if (c.Open(cs,KCommPort0,ECommShared)==KErrNone) |
|
1866 c.Close(); |
|
1867 |
|
1868 cs.__DbgMarkEnd(0); |
|
1869 cs.__DbgFailNext(-1); |
|
1870 cs.Close(); |
|
1871 #else |
|
1872 INFO_PRINTF1(_L("TestDisabled on release build.")); |
|
1873 #endif |
|
1874 return TestStepResult(); |
|
1875 } |
|
1876 |
|
1877 |
|
1878 CTestSetSignalsPanicBug::CTestSetSignalsPanicBug() |
|
1879 { |
|
1880 SetTestStepName(_L("TestSetSignalsPanicBug")); |
|
1881 } |
|
1882 |
|
1883 TVerdict CTestSetSignalsPanicBug::doTestStepL() |
|
1884 /** |
|
1885 * @test Test SetSignals panic bug |
|
1886 * |
|
1887 * @note An ER5 defect report against C32 speaks of wrong behaviour when a client calls |
|
1888 * SetSignals while another request is pending. Currently C32 panics the client |
|
1889 * with ESetSignalsWhilePendingRequests in the mistaken belief that the device |
|
1890 * driver would panic C32 otherwise. However it should be a valid action. This |
|
1891 * tests that neither the bug-fixed C32 server is not panicked, and neither is |
|
1892 * the client. |
|
1893 */ |
|
1894 { |
|
1895 |
|
1896 INFO_PRINTF1(_L("==========================================")); |
|
1897 INFO_PRINTF1(_L("Test : TestSetSignalsPanicBug")); |
|
1898 INFO_PRINTF1(_L("==========================================")); |
|
1899 |
|
1900 INFO_PRINTF1(_L("Test SetSignals panic bug")); |
|
1901 |
|
1902 TInt res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
1903 TESTCHECKL(res, KErrNone); |
|
1904 |
|
1905 TRequestStatus status; |
|
1906 TBuf8<40> buf; |
|
1907 iSerialPortList[0].Read(status,buf); |
|
1908 |
|
1909 iSerialPortList[0].SetSignals(0,KSignalRTS|KSignalDTR); |
|
1910 |
|
1911 TInt ret = iSerialPortList[0].ReadCancel(); |
|
1912 TESTCHECKL(ret, KErrNone); |
|
1913 User::WaitForRequest(status); |
|
1914 TEST(status==KErrCancel); |
|
1915 |
|
1916 iSerialPortList[0].Close(); |
|
1917 return TestStepResult(); |
|
1918 } |
|
1919 |
|
1920 CTestStartServerThread::CTestStartServerThread() |
|
1921 { |
|
1922 SetTestStepName(_L("TestStartServerThread")); |
|
1923 } |
|
1924 |
|
1925 TVerdict CTestStartServerThread::doTestStepL() |
|
1926 /** |
|
1927 * @test Test Starting Thread within C32 Process |
|
1928 * |
|
1929 * @note This test requires TTHREAD, a separate test program, to have been built. |
|
1930 */ |
|
1931 { |
|
1932 INFO_PRINTF1(_L("==========================================")); |
|
1933 INFO_PRINTF1(_L("Test : TestStartServerThread")); |
|
1934 INFO_PRINTF1(_L("==========================================")); |
|
1935 |
|
1936 INFO_PRINTF1(_L("Test Starting Thread within C32 Process")); |
|
1937 |
|
1938 _LIT(KLibraryName,"TThread"); |
|
1939 _LIT(KThreadName,"newserver"); |
|
1940 TInt KDefaultStackSize=0x2000; |
|
1941 TInt KHeapSize=0x1000; |
|
1942 TInt KMaxHeapSize=0x40000; |
|
1943 |
|
1944 TInt res=iCommSession.CreateThreadInCommProc(KLibraryName,KThreadName,ServerThread,KDefaultStackSize,KHeapSize,KMaxHeapSize); |
|
1945 TESTCHECKL(res, KErrNotSupported); |
|
1946 |
|
1947 return TestStepResult(); |
|
1948 } |
|
1949 |
|
1950 CTestCapsV02::CTestCapsV02() |
|
1951 { |
|
1952 SetTestStepName(_L("TestCapsV02")); |
|
1953 } |
|
1954 |
|
1955 TVerdict CTestCapsV02::doTestStepL() |
|
1956 /** |
|
1957 * @test Test capabilities version 2 |
|
1958 */ |
|
1959 { |
|
1960 INFO_PRINTF1(_L("==========================================")); |
|
1961 INFO_PRINTF1(_L("Test : TestCapsV02")); |
|
1962 INFO_PRINTF1(_L("==========================================")); |
|
1963 |
|
1964 INFO_PRINTF1(_L("Test capabilities version 2")); |
|
1965 |
|
1966 iCommSession.__DbgMarkHeap(); |
|
1967 |
|
1968 // |
|
1969 // try COMM::0 first, then COMM::1 |
|
1970 // |
|
1971 TInt res = iSerialPortList[0].Open(iCommSession, KCommPort0, ECommShared); |
|
1972 if(res != KErrNone) |
|
1973 { |
|
1974 res = iSerialPortList[0].Open(iCommSession, KCommPort1, ECommShared); |
|
1975 TESTCHECKL(res, KErrNone); |
|
1976 } |
|
1977 |
|
1978 iSerialPortList[0].Close(); |
|
1979 iCommSession.__DbgMarkHeap(); |
|
1980 res = iSerialPortList[0].Open(iCommSession, KCommPort0, ECommShared); |
|
1981 if(res != KErrNone) |
|
1982 { |
|
1983 res = iSerialPortList[0].Open(iCommSession, KCommPort1, ECommShared); |
|
1984 TESTCHECKL(res, KErrNone); |
|
1985 } |
|
1986 |
|
1987 TCommCaps2 caps; |
|
1988 |
|
1989 TInt ret = iSerialPortList[0].Caps(caps); |
|
1990 TESTCHECKL(ret, KErrNone); |
|
1991 |
|
1992 TUint notifycaps = caps().iNotificationCaps; |
|
1993 INFO_PRINTF1(_L("Capabilities:")); |
|
1994 if (notifycaps&KNotifySignalsChangeSupported) |
|
1995 INFO_PRINTF1(_L("Notify Signals Change supported")); |
|
1996 if (notifycaps&KNotifyRateChangeSupported) |
|
1997 INFO_PRINTF1(_L("Notify Rate Change supported")); |
|
1998 if (notifycaps&KNotifyDataFormatChangeSupported) |
|
1999 INFO_PRINTF1(_L("Notify Data Format Change supported")); |
|
2000 if (notifycaps&KNotifyHandshakeChangeSupported) |
|
2001 INFO_PRINTF1(_L("Notify Handshake Change supported")); |
|
2002 if (notifycaps&KNotifyBreakSupported) |
|
2003 INFO_PRINTF1(_L("Notify Break supported")); |
|
2004 if (notifycaps&KNotifyFlowControlChangeSupported) |
|
2005 INFO_PRINTF1(_L("Notify Flow Control Change supported")); |
|
2006 if (notifycaps&KNotifyDataAvailableSupported) |
|
2007 INFO_PRINTF1(_L("Notify Data Available supported")); |
|
2008 if (notifycaps&KNotifyOutputEmptySupported) |
|
2009 INFO_PRINTF1(_L("Notify Output Empty supported")); |
|
2010 |
|
2011 if ((caps().iRoleCaps)&KCapsRoleSwitchSupported) |
|
2012 INFO_PRINTF1(_L("Role switching is supported")); |
|
2013 |
|
2014 if ((caps().iFlowControlCaps)&KCapsFlowControlStatusSupported) |
|
2015 INFO_PRINTF1(_L("Retrieve flow control status is supported")); |
|
2016 |
|
2017 #ifdef __WINS__ |
|
2018 // not supported on Brutus |
|
2019 TESTCHECKL((notifycaps==(KNotifySignalsChangeSupported|KNotifyDataAvailableSupported|KNotifyOutputEmptySupported)),1); |
|
2020 #endif |
|
2021 TESTCHECKL(caps().iRoleCaps,KCapsRoleSwitchSupported); |
|
2022 TESTCHECKL(caps().iFlowControlCaps,0); |
|
2023 iSerialPortList[0].Close(); |
|
2024 iCommSession.__DbgMarkEnd(0); |
|
2025 |
|
2026 return TestStepResult(); |
|
2027 } |
|
2028 |
|
2029 CTestOpenPortsWithHighNumbers::CTestOpenPortsWithHighNumbers() |
|
2030 { |
|
2031 SetTestStepName(_L("TestOpenPortsWithHighNumbers")); |
|
2032 } |
|
2033 |
|
2034 TVerdict CTestOpenPortsWithHighNumbers::doTestStepL() |
|
2035 /** |
|
2036 * @test Test that the RComm::Open can handle more than 0-9 comports |
|
2037 * |
|
2038 * It was added on 9. Jan 2000 after the defect BOX-4RLH33 was fixed. |
|
2039 * |
|
2040 * It covers: |
|
2041 * |
|
2042 * o Open a comport with legal values |
|
2043 * o Open a comport with illegal values |
|
2044 * o Open a comport with garbage after :: |
|
2045 */ |
|
2046 { |
|
2047 INFO_PRINTF1(_L("==========================================")); |
|
2048 INFO_PRINTF1(_L("Test : TestOpenPortsWithHighNumbers")); |
|
2049 INFO_PRINTF1(_L("==========================================")); |
|
2050 |
|
2051 INFO_PRINTF1(_L("Test Opening Ports with values greater than 10")); |
|
2052 |
|
2053 TBool platsecEnforced = EFalse; |
|
2054 PlatSec::TConfigSetting aSetting(PlatSec::EPlatSecEnforcement); |
|
2055 if(PlatSec::ConfigSetting(aSetting)>0) |
|
2056 { |
|
2057 platsecEnforced = ETrue; |
|
2058 } |
|
2059 |
|
2060 RCommServ serv; |
|
2061 TInt res=serv.Connect(); |
|
2062 TESTCHECKL(res, KErrNone); |
|
2063 |
|
2064 _LIT(KCommPrefix, "COMM::" ); |
|
2065 |
|
2066 // test with garbage after ::, expect Bad Name |
|
2067 TInt expectedError; |
|
2068 if(platsecEnforced) |
|
2069 { |
|
2070 INFO_PRINTF1(_L("open ports with garbage after :: - expect KErrBadName (-28)")); |
|
2071 expectedError = KErrPermissionDenied; |
|
2072 } |
|
2073 else |
|
2074 { |
|
2075 INFO_PRINTF1(_L("open ports with garbage after :: - expect KErrBadName (-28)")); |
|
2076 expectedError = KErrBadName; |
|
2077 } |
|
2078 |
|
2079 TName portName; |
|
2080 portName.Append(KCommPrefix); |
|
2081 portName.AppendFormat(_L("garbage")); |
|
2082 res=iSerialPortList[0].Open(serv, portName, ECommShared); |
|
2083 |
|
2084 |
|
2085 |
|
2086 TESTCHECK(res, expectedError); |
|
2087 INFO_PRINTF2(_L(" open port w/garbage - res=%d "), res); |
|
2088 |
|
2089 if(platsecEnforced) |
|
2090 { |
|
2091 INFO_PRINTF1(_L("open ports with illegal values - expect KErrPermissionDenied (-46) ")); |
|
2092 expectedError = KErrPermissionDenied; |
|
2093 } |
|
2094 else |
|
2095 { |
|
2096 INFO_PRINTF1(_L("open ports with illegal values - expect KErrBadName (-28) ")); |
|
2097 expectedError = KErrBadName; |
|
2098 } |
|
2099 // test with illegal values, expect Bad Name |
|
2100 |
|
2101 for(TInt i=-3;i<0;i++) |
|
2102 { |
|
2103 TName portName; |
|
2104 portName.Append(KCommPrefix); |
|
2105 portName.AppendFormat(_L("%d"), i); |
|
2106 res=iSerialPortList[0].Open(serv, portName, ECommShared); |
|
2107 INFO_PRINTF3(_L(" open port %d - res=%d "), i, res); |
|
2108 TESTCHECK(res, expectedError); |
|
2109 } |
|
2110 |
|
2111 // test with legal values, and expect KErrNone, KErrNotSupported, KErrNotReady, KErrUnknown or KErrAccessDenied |
|
2112 // KMaxUnits is defined as 0x20 in e32std.h and means |
|
2113 // that the RBusDevComm::Open only take unit numbers |
|
2114 // from 0...31 |
|
2115 // if 32 or higher is used, the Kernel with panic |
|
2116 // with EBadUnitNumber=11 |
|
2117 // |
|
2118 // TODOAEH: where is this KErrNotReady coming from? |
|
2119 // it says so on COMM::3 on the Brutus board... |
|
2120 // |
|
2121 INFO_PRINTF1(_L("open ports from 0 to 1 - expect KErrNone, KErrNotSupported, KErrNotReady, KErrUnknown or KErrAccessDenied ")); |
|
2122 for(TInt j=0;j<KMaxUnits;j++) |
|
2123 { |
|
2124 TName portName; |
|
2125 portName.Append(KCommPrefix); |
|
2126 portName.AppendFormat(_L("%d"), j); |
|
2127 res=iSerialPortList[0].Open(serv, portName, ECommShared); |
|
2128 INFO_PRINTF3(_L(" open port %d - res=%d "), j, res); |
|
2129 TEST(res==KErrNone || res==KErrNotSupported || res==KErrNotReady || res==KErrUnknown || res==KErrAccessDenied ); |
|
2130 iSerialPortList[0].Close(); |
|
2131 } |
|
2132 |
|
2133 // test with illegal unit number, make sure that CSY picks this up |
|
2134 // and return KErrNotSupported |
|
2135 // |
|
2136 TInt k = KMaxUnits; |
|
2137 if(platsecEnforced) |
|
2138 { |
|
2139 INFO_PRINTF2(_L("open port %d, illegal unit number for device driver - expect KErrPermissionDenied "),k); |
|
2140 expectedError = KErrPermissionDenied; |
|
2141 } |
|
2142 else |
|
2143 { |
|
2144 INFO_PRINTF2(_L("open port %d, illegal unit number for device driver - expect KErrNotSupported "),k); |
|
2145 expectedError = KErrNotSupported; |
|
2146 } |
|
2147 |
|
2148 { |
|
2149 TName portName; |
|
2150 portName.Append(KCommPrefix); |
|
2151 portName.AppendFormat(_L("%d"), k); |
|
2152 res=iSerialPortList[0].Open(serv, portName, ECommShared); |
|
2153 INFO_PRINTF3(_L(" open port %d - res=%d "), k, res); |
|
2154 TEST(res == expectedError); |
|
2155 } |
|
2156 |
|
2157 // |
|
2158 // cleanup |
|
2159 // |
|
2160 serv.Close(); |
|
2161 |
|
2162 INFO_PRINTF1(_L("Ports opened OK")); |
|
2163 return TestStepResult(); |
|
2164 } |
|
2165 |
|
2166 |
|
2167 CTestTimerAllocation::CTestTimerAllocation() |
|
2168 { |
|
2169 SetTestStepName(_L("TestTimerAllocation")); |
|
2170 } |
|
2171 |
|
2172 void CTestTimerAllocation::TestTimerAllocationL(TInt aAllocFailValue) |
|
2173 { |
|
2174 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
2175 CleanupStack::PushL(scheduler); |
|
2176 CActiveScheduler::Install(scheduler); |
|
2177 |
|
2178 const TInt KTimeOutValue=1000000; |
|
2179 TDeltaTimerEntry timer; |
|
2180 |
|
2181 if (aAllocFailValue > 0) |
|
2182 { |
|
2183 __UHEAP_SETFAIL(RHeap::EDeterministic, aAllocFailValue); |
|
2184 CommTimer::Queue(KTimeOutValue, timer); |
|
2185 __UHEAP_RESET; |
|
2186 } |
|
2187 else |
|
2188 { |
|
2189 CommTimer::Queue(KTimeOutValue, timer); |
|
2190 } |
|
2191 |
|
2192 CleanupStack::Pop(scheduler); |
|
2193 delete scheduler; |
|
2194 } |
|
2195 |
|
2196 TInt CTestTimerAllocation::TimerThread(TAny* aArg) |
|
2197 { |
|
2198 TInt failNthAllocValue = *((TInt*) aArg); |
|
2199 |
|
2200 CTrapCleanup::New(); |
|
2201 TRAPD(retVal, TestTimerAllocationL(failNthAllocValue)); |
|
2202 |
|
2203 return retVal; |
|
2204 } |
|
2205 |
|
2206 TVerdict CTestTimerAllocation::doTestStepL() |
|
2207 /** |
|
2208 * @test Test that attempts to allocate a timer under OOM conditions. |
|
2209 */ |
|
2210 { |
|
2211 User::SetJustInTime(EFalse); |
|
2212 |
|
2213 INFO_PRINTF1(_L("===================================")); |
|
2214 INFO_PRINTF1(_L("Test : TestTimerAllocation")); |
|
2215 INFO_PRINTF1(_L("===================================")); |
|
2216 |
|
2217 #ifdef _DEBUG |
|
2218 INFO_PRINTF1(_L("Trying to handle a global timer allocation failure")); |
|
2219 |
|
2220 // |
|
2221 // Test for failure... |
|
2222 // |
|
2223 RThread failureThread; |
|
2224 TInt failNthAllocValue(1); |
|
2225 |
|
2226 TInt res = failureThread.Create(_L("TimerThreadFailure"), TimerThread, |
|
2227 KDefaultStackSize, KDefaultHeapSizeThread, |
|
2228 KDefaultHeapSizeThread, &failNthAllocValue); |
|
2229 TESTCHECKL(res, KErrNone); |
|
2230 TRequestStatus stat; |
|
2231 failureThread.Logon(stat); |
|
2232 failureThread.Resume(); |
|
2233 User::WaitForRequest(stat); |
|
2234 TESTCHECKSTR(failureThread.ExitCategory(), KCommServerFault); //"Comm server fault" from cc_utl.cpp |
|
2235 TESTCHECK(failureThread.ExitReason(), 7); // 7==EDTimerAllocFailure from cs_std.h |
|
2236 TESTCHECK(failureThread.ExitType(), EExitPanic); |
|
2237 CLOSE_AND_WAIT(failureThread); |
|
2238 |
|
2239 // |
|
2240 // Test for success... |
|
2241 // |
|
2242 INFO_PRINTF1(_L("Test global timer allocation success")); |
|
2243 |
|
2244 RThread successThread; |
|
2245 failNthAllocValue = 0; |
|
2246 |
|
2247 res=successThread.Create(_L("TimerThreadSuccess"), TimerThread, |
|
2248 KDefaultStackSize, KDefaultHeapSizeThread, |
|
2249 KDefaultHeapSizeThread, &failNthAllocValue); |
|
2250 TESTCHECKL(res, KErrNone); |
|
2251 successThread.Logon(stat); |
|
2252 successThread.Resume(); |
|
2253 User::WaitForRequest(stat); |
|
2254 TESTCHECKSTR(successThread.ExitCategory(), KCommServerSuccess); |
|
2255 TESTCHECK(successThread.ExitReason(), 0); |
|
2256 TESTCHECK(successThread.ExitType(), EExitKill); |
|
2257 CLOSE_AND_WAIT(successThread); |
|
2258 #else |
|
2259 INFO_PRINTF1(_L("TestTimerAllocation not executed on release builds.")); |
|
2260 #endif |
|
2261 |
|
2262 User::SetJustInTime(ETrue); |
|
2263 return TestStepResult(); |
|
2264 } |
|
2265 |
|
2266 CTestReadWrite::CTestReadWrite() |
|
2267 { |
|
2268 SetTestStepName(_L("TestReadWrite")); |
|
2269 } |
|
2270 |
|
2271 TVerdict CTestReadWrite::doTestStepL() |
|
2272 /** |
|
2273 * @test Test Read and write |
|
2274 */ |
|
2275 { |
|
2276 INFO_PRINTF1(_L("===================================")); |
|
2277 INFO_PRINTF1(_L("Test : TestReadWrite")); |
|
2278 INFO_PRINTF1(_L("===================================")); |
|
2279 |
|
2280 INFO_PRINTF1(_L("Checking read and write")); |
|
2281 INFO_PRINTF1(_L("This test needs a null modem cable")); |
|
2282 |
|
2283 INFO_PRINTF1(_L("Open ports")); |
|
2284 TInt res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
2285 TESTCHECKL(res, KErrNone); |
|
2286 |
|
2287 res=iSerialPortList[1].Open(iCommSession, KCommPort1, ECommShared); |
|
2288 if(res==KErrNotFound) |
|
2289 { |
|
2290 INFO_PRINTF1(_L("Cannot do this test - no second serial port")); |
|
2291 iSerialPortList[0].Close(); |
|
2292 SetTestStepResult(EInconclusive); |
|
2293 return TestStepResult(); |
|
2294 } |
|
2295 |
|
2296 TESTCHECKL(res, KErrNone); |
|
2297 #if 0 |
|
2298 TCommConfig cBuf; |
|
2299 TCommConfigV01 &c=cBuf(); |
|
2300 |
|
2301 TInt ret=iSerialPortList[0].Config(cBuf); |
|
2302 TESTCHECKL(ret, KErrNone); |
|
2303 c.iFifo=EFifoEnable; |
|
2304 c.iRate=EBps9600; |
|
2305 // c.iHandshake=0;//KConfigObeyCTS; |
|
2306 c.iHandshake=KConfigFailDSR | KConfigFailCTS; |
|
2307 c.iTerminatorCount=0; |
|
2308 c.iDataBits=EData8; |
|
2309 c.iParity=EParityNone; |
|
2310 c.iStopBits=EStop1; |
|
2311 TESTCHECKL(iSerialPortList[0].SetConfig(cBuf), KErrNone); |
|
2312 |
|
2313 ret=iSerialPortList[1].Config(cBuf); |
|
2314 TESTCHECKL(ret, KErrNone); |
|
2315 c.iRate=EBps9600; |
|
2316 // c.iHandshake=0;//KConfigObeyCTS; |
|
2317 c.iHandshake=KConfigFailDSR | KConfigFailCTS; |
|
2318 c.iTerminatorCount=0; |
|
2319 c.iDataBits=EData8; |
|
2320 c.iParity=EParityNone; |
|
2321 c.iStopBits=EStop1; |
|
2322 TESTCHECKL(iSerialPortList[1].SetConfig(cBuf), KErrNone); |
|
2323 #endif |
|
2324 const TUint KBufSize=0xff; |
|
2325 TUint8* inBuf = new (ELeave) TUint8[KBufSize]; |
|
2326 CleanupStack::PushL(inBuf); |
|
2327 TUint8* outBuf = new (ELeave) TUint8[KBufSize]; |
|
2328 CleanupStack::PushL(outBuf); |
|
2329 TPtr8 outDes(outBuf,KBufSize,KBufSize); |
|
2330 TPtr8 inDes(inBuf,KBufSize,KBufSize); |
|
2331 |
|
2332 TRequestStatus readStatus; |
|
2333 TRequestStatus writeStatus; |
|
2334 |
|
2335 for(TUint i=0;i<10;i++) |
|
2336 { |
|
2337 outDes.Fill('A'+i); |
|
2338 inDes.FillZ(); |
|
2339 |
|
2340 iSerialPortList[1].Read(readStatus,KHugeTimeoutValue,inDes,KBufSize); |
|
2341 |
|
2342 INFO_PRINTF2(_L( "Write # %d of 10"),i+1); |
|
2343 iSerialPortList[0].Write(writeStatus,KHugeTimeoutValue,outDes,KBufSize); |
|
2344 |
|
2345 User::WaitForRequest(writeStatus); |
|
2346 if(writeStatus != KErrNone) |
|
2347 User::WaitForRequest(readStatus); // flush reqs |
|
2348 TESTCHECKL(writeStatus.Int(), KErrNone); |
|
2349 |
|
2350 User::WaitForRequest(readStatus); |
|
2351 TESTCHECKL(readStatus.Int(), KErrNone); |
|
2352 |
|
2353 outDes.SetLength(inDes.Length()); |
|
2354 TESTCHECKL(inDes.Compare(outDes), 0); |
|
2355 |
|
2356 } |
|
2357 |
|
2358 outDes.Fill('B'); |
|
2359 inDes.FillZ(); |
|
2360 |
|
2361 INFO_PRINTF1(_L("Read")); |
|
2362 iSerialPortList[0].Read(readStatus,KHugeTimeoutValue,inDes,KBufSize); |
|
2363 |
|
2364 INFO_PRINTF1(_L("Write")); |
|
2365 iSerialPortList[1].Write(writeStatus,KHugeTimeoutValue,outDes,KBufSize); |
|
2366 |
|
2367 User::WaitForRequest(writeStatus); |
|
2368 TESTCHECKL(writeStatus.Int(), KErrNone); |
|
2369 |
|
2370 User::WaitForRequest(readStatus); |
|
2371 TESTCHECKL(readStatus.Int(), KErrNone); |
|
2372 |
|
2373 outDes.SetLength(inDes.Length()); |
|
2374 TESTCHECKL(inDes.Compare(outDes), 0); |
|
2375 |
|
2376 TCommServerConfig bmcPckg; |
|
2377 TCommServerConfigV01 &bmc=bmcPckg(); |
|
2378 bmc.iBufFlags=KCommBufferPartial; |
|
2379 TInt ret = iSerialPortList[0].Mode(bmcPckg); |
|
2380 TEST(ret==KErrNone); |
|
2381 TESTCHECKL(bmc.iBufFlags!=KCommBufferPartial, 1); |
|
2382 |
|
2383 // |
|
2384 // cleanup |
|
2385 // |
|
2386 iSerialPortList[0].Close(); |
|
2387 iSerialPortList[1].Close(); |
|
2388 CleanupStack::PopAndDestroy(2); // inBuf, outBuf |
|
2389 // delete inBuf; |
|
2390 // delete outBuf; |
|
2391 return TestStepResult(); |
|
2392 } |
|
2393 |
|
2394 |
|
2395 |
|
2396 CTestReadWrite2::CTestReadWrite2() |
|
2397 { |
|
2398 SetTestStepName(_L("TestReadWrite")); |
|
2399 } |
|
2400 |
|
2401 TVerdict CTestReadWrite2::doTestStepL() |
|
2402 /** |
|
2403 * @test Test Read and write |
|
2404 */ |
|
2405 //This test is created for the purpose of testing Defect DEF113371 |
|
2406 { |
|
2407 INFO_PRINTF1(_L("===================================")); |
|
2408 INFO_PRINTF1(_L("Test : TestReadWrite2")); |
|
2409 INFO_PRINTF1(_L("===================================")); |
|
2410 |
|
2411 INFO_PRINTF1(_L("Open ports")); |
|
2412 TInt res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
2413 TESTCHECKL(res, KErrNone); |
|
2414 |
|
2415 res=iSerialPortList[1].Open(iCommSession,KCommPort1,ECommShared); |
|
2416 if(res==KErrNotFound) |
|
2417 { |
|
2418 INFO_PRINTF1(_L("Cannot do this test - no second serial port")); |
|
2419 iSerialPortList[0].Close(); |
|
2420 SetTestStepResult(EInconclusive); |
|
2421 return TestStepResult(); |
|
2422 } |
|
2423 TESTCHECKL(res, KErrNone); |
|
2424 |
|
2425 TCommConfig cBuf; |
|
2426 TCommConfigV01 &c=cBuf(); |
|
2427 |
|
2428 TInt ret=iSerialPortList[0].Config(cBuf); |
|
2429 TESTCHECKL(ret, KErrNone); |
|
2430 c.iRate=EBps9600; |
|
2431 c.iHandshake=KConfigObeyCTS; |
|
2432 c.iTerminatorCount=0; |
|
2433 c.iParity=EParityNone; |
|
2434 c.iStopBits=EStop1; |
|
2435 c.iDataBits=EData8; |
|
2436 res = iSerialPortList[0].SetConfig(cBuf); |
|
2437 TESTCHECKL(res, KErrNone); |
|
2438 |
|
2439 ret=iSerialPortList[1].Config(cBuf); |
|
2440 TESTCHECKL(ret, KErrNone); |
|
2441 c.iRate=EBps9600; |
|
2442 c.iHandshake=KConfigObeyCTS; |
|
2443 c.iTerminatorCount=0; |
|
2444 c.iParity=EParityNone; |
|
2445 c.iStopBits=EStop1; |
|
2446 c.iDataBits=EData8; |
|
2447 TESTCHECKL(iSerialPortList[1].SetConfig(cBuf), KErrNone); |
|
2448 // enable buffering |
|
2449 |
|
2450 TCommServerConfig bmcPckg; |
|
2451 TCommServerConfigV01 &bmc=bmcPckg(); |
|
2452 |
|
2453 //bmc.iBufFlags=KCommBufferPartial; |
|
2454 bmc.iBufFlags=0; |
|
2455 bmc.iBufSize=0x10; |
|
2456 |
|
2457 iSerialPortList[0].SetMode(bmcPckg); |
|
2458 iSerialPortList[1].SetMode(bmcPckg); |
|
2459 |
|
2460 const TUint KBufSize=0x120; //0xff |
|
2461 |
|
2462 TUint8* inBuf = new (ELeave) TUint8[KBufSize]; |
|
2463 CleanupStack::PushL(inBuf); |
|
2464 |
|
2465 TUint8* outBuf = new (ELeave) TUint8[KBufSize]; |
|
2466 CleanupStack::PushL(outBuf); |
|
2467 |
|
2468 TPtr8 outDes(outBuf, KBufSize, KBufSize); |
|
2469 TPtr8 inDes(inBuf, KBufSize, KBufSize); |
|
2470 |
|
2471 outDes.Fill('A'); |
|
2472 inDes.FillZ(); |
|
2473 |
|
2474 TRequestStatus readStatus; |
|
2475 TRequestStatus writeStatus; |
|
2476 |
|
2477 INFO_PRINTF1(_L("Read")); |
|
2478 iSerialPortList[0].Read(readStatus,KHugeTimeoutValue,inDes,KBufSize); |
|
2479 |
|
2480 INFO_PRINTF1(_L("Write")); |
|
2481 iSerialPortList[1].Write(writeStatus,KHugeTimeoutValue,outDes,KBufSize); |
|
2482 |
|
2483 User::WaitForRequest(writeStatus); |
|
2484 User::WaitForRequest(readStatus); |
|
2485 outDes.SetLength(inDes.Length()); |
|
2486 TESTCHECKL(inDes.Compare(outDes), 0); |
|
2487 |
|
2488 bmc.iBufFlags=0; |
|
2489 bmc.iBufSize=0xffffffff; |
|
2490 |
|
2491 ret=iSerialPortList[0].Mode(bmcPckg); |
|
2492 TEST(ret==KErrNone); |
|
2493 |
|
2494 // cleanup |
|
2495 // |
|
2496 iSerialPortList[0].Close(); |
|
2497 iSerialPortList[1].Close(); |
|
2498 CleanupStack::PopAndDestroy(2); // inBuf, outBuf |
|
2499 |
|
2500 return TestStepResult(); |
|
2501 } |
|
2502 |
|
2503 |
|
2504 |
|
2505 CTestSignalLines::CTestSignalLines() |
|
2506 { |
|
2507 SetTestStepName(_L("TestSignalLines")); |
|
2508 } |
|
2509 |
|
2510 TVerdict CTestSignalLines::doTestStepL() |
|
2511 /** |
|
2512 * @test Tests of setting and clearing RS232 output lines (DTR and RTS) |
|
2513 */ |
|
2514 { |
|
2515 INFO_PRINTF1(_L("===================================")); |
|
2516 INFO_PRINTF1(_L("Test : TestSignalLines")); |
|
2517 INFO_PRINTF1(_L("===================================")); |
|
2518 |
|
2519 INFO_PRINTF1(_L("Checking signaling")); |
|
2520 |
|
2521 INFO_PRINTF1(_L("Open ports")); |
|
2522 TInt res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
2523 TESTCHECKL(res, KErrNone); |
|
2524 |
|
2525 res=iSerialPortList[1].Open(iCommSession,KCommPort1,ECommShared); |
|
2526 if(res==KErrNotFound) |
|
2527 { |
|
2528 INFO_PRINTF1(_L("Cannot do this test - no second serial port")); |
|
2529 iSerialPortList[0].Close(); |
|
2530 SetTestStepResult(EInconclusive); |
|
2531 return TestStepResult(); |
|
2532 } |
|
2533 TESTCHECKL(res, KErrNone); |
|
2534 |
|
2535 TCommConfig conf; |
|
2536 TInt ret=iSerialPortList[0].Config(conf); |
|
2537 TESTCHECKL(ret, KErrNone); |
|
2538 conf().iHandshake=KConfigFreeRTS|KConfigFreeDTR; |
|
2539 res = iSerialPortList[0].SetConfig(conf); |
|
2540 TESTCHECKL(res, KErrNone); |
|
2541 |
|
2542 ret=iSerialPortList[1].Config(conf); |
|
2543 TESTCHECKL(ret, KErrNone); |
|
2544 conf().iHandshake=KConfigFreeRTS|KConfigFreeDTR; |
|
2545 TESTCHECKL(iSerialPortList[1].SetConfig(conf), KErrNone); |
|
2546 |
|
2547 iSerialPortList[0].SetSignals(0,KSignalRTS|KSignalDTR); |
|
2548 |
|
2549 iSerialPortList[0].SetSignals(KSignalRTS,KSignalDTR); |
|
2550 TInt signals=iSerialPortList[1].Signals(0x0f); // CTS, DSR, DCD, RNG |
|
2551 TInt sig = KSignalCTS; |
|
2552 TESTCHECKL(signals, sig); |
|
2553 |
|
2554 |
|
2555 iSerialPortList[0].SetSignals(KSignalDTR,KSignalRTS); // Raises DTR, Clears RTS and DCD |
|
2556 signals=iSerialPortList[1].Signals(0x0f); // CTS, DSR, DCD and RNG masked |
|
2557 TBool pass=(signals==(TInt)KSignalDSR)||(signals==(TInt)(KSignalDSR|KSignalDCD)); // Data transfer cables just pull DSR up, NULL modems pull DSR and DCD up - either is acceptable |
|
2558 TESTCHECKL(pass, (TInt)ETrue); |
|
2559 |
|
2560 iSerialPortList[0].SetSignals(KSignalDTR|KSignalRTS,0); |
|
2561 signals=0; |
|
2562 signals=iSerialPortList[1].Signals(0x0f); |
|
2563 pass=(signals==(KSignalDSR|KSignalCTS))||(signals==(KSignalDSR|KSignalCTS|KSignalDCD)); |
|
2564 TESTCHECKL(pass,(TInt)ETrue); |
|
2565 |
|
2566 iSerialPortList[0].SetSignals(0,KSignalDTR|KSignalRTS); |
|
2567 signals=0; |
|
2568 signals=iSerialPortList[1].Signals(0x0f); |
|
2569 TESTCHECKL(signals, 0); |
|
2570 |
|
2571 iSerialPortList[0].Close(); |
|
2572 iSerialPortList[1].Close(); |
|
2573 |
|
2574 |
|
2575 return TestStepResult(); |
|
2576 |
|
2577 } |
|
2578 |
|
2579 CTestQueryreceiveBuffer::CTestQueryreceiveBuffer() |
|
2580 { |
|
2581 SetTestStepName(_L("TestQueryreceiveBuffer")); |
|
2582 } |
|
2583 |
|
2584 TVerdict CTestQueryreceiveBuffer::doTestStepL() |
|
2585 /** |
|
2586 * @test Test Query Receive Buffer method |
|
2587 */ |
|
2588 { |
|
2589 INFO_PRINTF1(_L("===================================")); |
|
2590 INFO_PRINTF1(_L("Test : TestQueryreceiveBuffer")); |
|
2591 INFO_PRINTF1(_L("===================================")); |
|
2592 |
|
2593 INFO_PRINTF1(_L("Checking QueryReceiveBuffer")); |
|
2594 |
|
2595 INFO_PRINTF1(_L("Open ports")); |
|
2596 TInt res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
2597 TESTCHECKL(res, KErrNone); |
|
2598 |
|
2599 res=iSerialPortList[1].Open(iCommSession,KCommPort1,ECommShared); |
|
2600 if(res==KErrNotFound) |
|
2601 { |
|
2602 INFO_PRINTF1(_L("Cannot do this test - no second serial port")); |
|
2603 iSerialPortList[0].Close(); |
|
2604 SetTestStepResult(EInconclusive); |
|
2605 return TestStepResult(); |
|
2606 } |
|
2607 TESTCHECKL(res, KErrNone); |
|
2608 |
|
2609 INFO_PRINTF1(_L("Zero before driver starts up")); |
|
2610 res = iSerialPortList[0].QueryReceiveBuffer(); |
|
2611 TESTCHECKL(res, KErrNone); |
|
2612 |
|
2613 TCommConfig cBuf; |
|
2614 TCommConfigV01 &c=cBuf(); |
|
2615 |
|
2616 TInt ret=iSerialPortList[0].Config(cBuf); |
|
2617 TESTCHECKL(ret, KErrNone); |
|
2618 c.iFifo=EFifoEnable; |
|
2619 c.iRate=EBps9600; |
|
2620 c.iHandshake=KConfigObeyCTS; |
|
2621 c.iTerminatorCount=0; |
|
2622 c.iDataBits=EData8; |
|
2623 c.iParity=EParityNone; |
|
2624 c.iStopBits=EStop1; |
|
2625 res = iSerialPortList[0].SetConfig(cBuf); |
|
2626 TESTCHECKL(res, KErrNone); |
|
2627 |
|
2628 ret=iSerialPortList[1].Config(cBuf); |
|
2629 TESTCHECKL(ret, KErrNone); |
|
2630 c.iRate=EBps9600; |
|
2631 c.iHandshake=KConfigObeyCTS; |
|
2632 c.iTerminatorCount=0; |
|
2633 c.iDataBits=EData8; |
|
2634 c.iParity=EParityNone; |
|
2635 c.iStopBits=EStop1; |
|
2636 res = iSerialPortList[1].SetConfig(cBuf); |
|
2637 TESTCHECKL(res, KErrNone); |
|
2638 |
|
2639 const TUint KBufSize=0xff; |
|
2640 TUint8* outBuf=new (ELeave) TUint8[KBufSize]; |
|
2641 CleanupStack::PushL(outBuf); |
|
2642 TPtr8 outDes(outBuf,KBufSize,KBufSize); |
|
2643 TUint8* inBuf=new (ELeave) TUint8[KBufSize]; |
|
2644 CleanupStack::PushL(inBuf); |
|
2645 TPtr8 inDes(inBuf,KBufSize,KBufSize); |
|
2646 |
|
2647 TRequestStatus writeStatus; |
|
2648 TRequestStatus readStatus; |
|
2649 |
|
2650 INFO_PRINTF1(_L("Zero after driver starts")); |
|
2651 iSerialPortList[0].Read(readStatus,inDes,0); |
|
2652 User::WaitForRequest(readStatus); |
|
2653 TESTCHECKL(iSerialPortList[0].QueryReceiveBuffer(), 0); |
|
2654 |
|
2655 INFO_PRINTF1(_L("zero after flush")); |
|
2656 ret = iSerialPortList[0].ResetBuffers(); |
|
2657 TESTCHECKL(ret, KErrNone); |
|
2658 TESTCHECKL(iSerialPortList[0].QueryReceiveBuffer(), 0); |
|
2659 |
|
2660 outDes.SetLength(10); |
|
2661 inDes.SetLength(10); |
|
2662 |
|
2663 iSerialPortList[0].Read(readStatus,KHugeTimeoutValue,inDes,1); |
|
2664 iSerialPortList[1].Write(writeStatus,KHugeTimeoutValue,outDes); |
|
2665 User::WaitForRequest(readStatus); |
|
2666 User::WaitForRequest(writeStatus); |
|
2667 TESTCHECKL(readStatus.Int(), KErrNone); |
|
2668 TESTCHECKL(writeStatus.Int(), KErrNone); |
|
2669 |
|
2670 User::After(1000000); // Wait for everything to filter through the WINs driver - NT may be buffering |
|
2671 |
|
2672 INFO_PRINTF1(_L("test byte counts")); |
|
2673 TESTCHECKL(iSerialPortList[0].QueryReceiveBuffer(), 9); |
|
2674 |
|
2675 iSerialPortList[0].Read(readStatus,KHugeTimeoutValue,inDes,1); |
|
2676 iSerialPortList[1].Write(writeStatus,KHugeTimeoutValue,outDes); |
|
2677 User::WaitForRequest(readStatus); |
|
2678 User::WaitForRequest(writeStatus); |
|
2679 TESTCHECKL(readStatus.Int(), KErrNone); |
|
2680 TESTCHECKL(writeStatus.Int(), KErrNone); |
|
2681 |
|
2682 User::After(1000000); |
|
2683 TESTCHECKL(iSerialPortList[0].QueryReceiveBuffer(), 18); |
|
2684 |
|
2685 INFO_PRINTF1(_L("zero after flush with data present")); |
|
2686 ret = iSerialPortList[0].ResetBuffers(); |
|
2687 TESTCHECKL(ret, KErrNone); |
|
2688 TESTCHECKL(iSerialPortList[0].QueryReceiveBuffer(), 0); |
|
2689 |
|
2690 iSerialPortList[0].Close(); |
|
2691 iSerialPortList[1].Close(); |
|
2692 |
|
2693 CleanupStack::PopAndDestroy(2); // inBuf, outBuf |
|
2694 // delete outBuf; |
|
2695 // delete inBuf; |
|
2696 |
|
2697 return TestStepResult(); |
|
2698 |
|
2699 } |
|
2700 |
|
2701 CTestWrite0::CTestWrite0() |
|
2702 { |
|
2703 SetTestStepName(_L("TestWrite0")); |
|
2704 } |
|
2705 |
|
2706 TVerdict CTestWrite0::doTestStepL() |
|
2707 /** |
|
2708 * @test Test Write 0 functionality |
|
2709 */ |
|
2710 { |
|
2711 INFO_PRINTF1(_L("===================================")); |
|
2712 INFO_PRINTF1(_L("Test : TestWrite0n")); |
|
2713 INFO_PRINTF1(_L("===================================")); |
|
2714 |
|
2715 INFO_PRINTF1(_L("Testing Write 0")); |
|
2716 |
|
2717 INFO_PRINTF1(_L("Open ports")); |
|
2718 TInt res = iSerialPortList[0].Open(iCommSession, KCommPort0, ECommShared); |
|
2719 TESTCHECKL(res, KErrNone); |
|
2720 |
|
2721 // Turn handshaking on. |
|
2722 TCommConfig cBuf; |
|
2723 TCommConfigV01 &c=cBuf(); |
|
2724 TInt ret=iSerialPortList[0].Config(cBuf); |
|
2725 TESTCHECKL(ret, KErrNone); |
|
2726 c.iRate=EBps9600; |
|
2727 c.iHandshake=KConfigObeyCTS; |
|
2728 c.iTerminatorCount=0; |
|
2729 TESTCHECKL(iSerialPortList[0].SetConfig(cBuf), KErrNone); |
|
2730 |
|
2731 // Write 0 - should time out |
|
2732 const TInt KTimeOutValue=1000000; |
|
2733 INFO_PRINTF1(_L("Write(0) to timeout")); |
|
2734 TRequestStatus writeStat; |
|
2735 iSerialPortList[0].Write(writeStat, KTimeOutValue, TPtr8(NULL,0), 0); |
|
2736 User::WaitForRequest(writeStat); |
|
2737 TESTCHECKL(writeStat.Int(), KErrTimedOut); |
|
2738 |
|
2739 // Write 0 should complete KErrNone when we open the port. |
|
2740 INFO_PRINTF1(_L("Write(0) to completion")); |
|
2741 iSerialPortList[0].Write(writeStat, KHugeTimeoutValue, TPtr8(NULL,0), 0); |
|
2742 res=iSerialPortList[1].Open(iCommSession, KCommPort1, ECommShared); |
|
2743 if(res==KErrNotFound) |
|
2744 { |
|
2745 INFO_PRINTF1(_L("Cannot do this test - no second serial port")); |
|
2746 iSerialPortList[0].Close(); |
|
2747 SetTestStepResult(EInconclusive); |
|
2748 return TestStepResult(); |
|
2749 } |
|
2750 TESTCHECKL(res, KErrNone); |
|
2751 ret=iSerialPortList[1].Config(cBuf); |
|
2752 TESTCHECKL(ret, KErrNone); |
|
2753 c.iRate=EBps9600; |
|
2754 c.iHandshake=KConfigObeyCTS; |
|
2755 TESTCHECKL(iSerialPortList[1].SetConfig(cBuf), KErrNone); |
|
2756 |
|
2757 TBuf8<2> buf; |
|
2758 TRequestStatus readStat; |
|
2759 iSerialPortList[1].Read(readStat,buf,1); |
|
2760 User::WaitForRequest(writeStat); |
|
2761 ret = iSerialPortList[1].ReadCancel(); |
|
2762 TESTCHECKL(ret, KErrNone); |
|
2763 if(writeStat != KErrNone) |
|
2764 User::WaitForRequest(readStat); // flush |
|
2765 TESTCHECKL(writeStat.Int(), KErrNone); |
|
2766 iSerialPortList[1].Close(); |
|
2767 |
|
2768 // Write 0 - should time out again |
|
2769 INFO_PRINTF1(_L("Write(0) to timeout")); |
|
2770 iSerialPortList[0].Write(writeStat, KTimeOutValue, TPtr8(NULL,0), 0); |
|
2771 User::WaitForRequest(writeStat); |
|
2772 TESTCHECKL(writeStat.Int(), KErrTimedOut); |
|
2773 |
|
2774 INFO_PRINTF1(_L("check read 0")); |
|
2775 TPtr8 p(NULL,0); |
|
2776 iSerialPortList[0].Read(readStat, 10, p, 0); |
|
2777 User::WaitForRequest(writeStat); |
|
2778 |
|
2779 // cleanup |
|
2780 ret = iSerialPortList[0].ReadCancel(); |
|
2781 TESTCHECKL(ret, KErrNone); |
|
2782 User::WaitForRequest(readStat); |
|
2783 iSerialPortList[0].Close(); |
|
2784 |
|
2785 return TestStepResult(); |
|
2786 } |
|
2787 |
|
2788 CTestReadOneOrMore::CTestReadOneOrMore() |
|
2789 { |
|
2790 SetTestStepName(_L("TestReadOneOrMore")); |
|
2791 } |
|
2792 |
|
2793 TVerdict CTestReadOneOrMore::doTestStepL() |
|
2794 /** |
|
2795 * @test Test Read One or more |
|
2796 */ |
|
2797 { |
|
2798 INFO_PRINTF1(_L("===================================")); |
|
2799 INFO_PRINTF1(_L("Test : TestReadOneOrMore")); |
|
2800 INFO_PRINTF1(_L("===================================")); |
|
2801 |
|
2802 INFO_PRINTF1(_L("Test Read One or more")); |
|
2803 |
|
2804 INFO_PRINTF1(_L("Open ports")); |
|
2805 TInt res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
2806 TESTCHECKL(res, KErrNone); |
|
2807 res=iSerialPortList[1].Open(iCommSession,KCommPort1,ECommShared); |
|
2808 if(res==KErrNotFound) |
|
2809 { |
|
2810 INFO_PRINTF1(_L("Cannot do this test - no second serial port")); |
|
2811 iSerialPortList[0].Close(); |
|
2812 SetTestStepResult(EInconclusive); |
|
2813 return TestStepResult(); |
|
2814 } |
|
2815 TESTCHECKL(res, KErrNone); |
|
2816 |
|
2817 // Turn handshaking on. |
|
2818 TCommConfig cBuf; |
|
2819 TCommConfigV01 &c=cBuf(); |
|
2820 TInt ret=iSerialPortList[0].Config(cBuf); |
|
2821 TESTCHECKL(ret, KErrNone); |
|
2822 c.iRate=EBps9600; |
|
2823 c.iHandshake=0; |
|
2824 c.iTerminatorCount=0; |
|
2825 TESTCHECKL(iSerialPortList[0].SetConfig(cBuf), KErrNone); |
|
2826 |
|
2827 ret=iSerialPortList[1].Config(cBuf); |
|
2828 TESTCHECKL(ret, KErrNone); |
|
2829 c.iRate=EBps9600; |
|
2830 c.iHandshake=0; |
|
2831 c.iTerminatorCount=0; |
|
2832 TESTCHECKL(iSerialPortList[1].SetConfig(cBuf), KErrNone); |
|
2833 |
|
2834 const TUint KBufSize = 0x10; |
|
2835 TUint8* inBuf = new (ELeave) TUint8[KBufSize]; |
|
2836 CleanupStack::PushL(inBuf); |
|
2837 TUint8* outBuf = new (ELeave) TUint8[KBufSize]; |
|
2838 CleanupStack::PushL(outBuf); |
|
2839 TPtr8 outDes(outBuf, KBufSize, KBufSize); |
|
2840 TPtr8 inDes(inBuf, KBufSize, KBufSize); |
|
2841 |
|
2842 outDes.Fill('A'); |
|
2843 inDes.FillZ(); |
|
2844 |
|
2845 outDes.Fill('B'); |
|
2846 inDes.FillZ(); |
|
2847 |
|
2848 ret = iSerialPortList[0].ResetBuffers(); |
|
2849 TESTCHECKL(ret, KErrNone); |
|
2850 |
|
2851 TRequestStatus status; |
|
2852 iSerialPortList[0].Read(status, KHugeTimeoutValue, inDes, 1); |
|
2853 |
|
2854 TRequestStatus writeStat; |
|
2855 INFO_PRINTF1(_L("ReadOneorMore with data in buffer")); |
|
2856 iSerialPortList[1].Write(writeStat, KHugeTimeoutValue, outDes); |
|
2857 User::After(1000000); |
|
2858 User::WaitForRequest(writeStat); |
|
2859 User::WaitForRequest(status); |
|
2860 |
|
2861 TESTCHECKL(status.Int(), KErrNone); |
|
2862 TESTCHECKL(iSerialPortList[0].QueryReceiveBuffer()>0, TRUE); |
|
2863 TRequestStatus readStat; |
|
2864 inDes.SetLength(10); |
|
2865 iSerialPortList[0].ReadOneOrMore(readStat,inDes); |
|
2866 User::WaitForRequest(readStat); |
|
2867 TESTCHECKL((inDes.Length()>1), TRUE); |
|
2868 |
|
2869 ret = iSerialPortList[0].ResetBuffers(); |
|
2870 TESTCHECKL(ret, KErrNone); |
|
2871 |
|
2872 INFO_PRINTF1(_L("ReadOneorMore on empty buffer")); |
|
2873 iSerialPortList[0].ReadOneOrMore(readStat,inDes); |
|
2874 iSerialPortList[1].Write(writeStat,outDes); |
|
2875 User::WaitForRequest(writeStat); |
|
2876 User::WaitForRequest(readStat); |
|
2877 TESTCHECKL(inDes.Length(), 1); |
|
2878 |
|
2879 ret = iSerialPortList[0].ResetBuffers(); |
|
2880 TESTCHECKL(ret, KErrNone); |
|
2881 |
|
2882 // |
|
2883 // cleanup |
|
2884 // |
|
2885 iSerialPortList[1].Close(); |
|
2886 iSerialPortList[0].Close(); |
|
2887 CleanupStack::PopAndDestroy(2); // inBuf, outBuf |
|
2888 // delete inBuf; |
|
2889 // delete outBuf; |
|
2890 |
|
2891 return TestStepResult(); |
|
2892 } |
|
2893 |
|
2894 CTestBufferReadWrite::CTestBufferReadWrite() |
|
2895 { |
|
2896 SetTestStepName(_L("TestBufferReadWrite")); |
|
2897 } |
|
2898 |
|
2899 TVerdict CTestBufferReadWrite::doTestStepL() |
|
2900 /** |
|
2901 * @test Test Buffered Read and write |
|
2902 */ |
|
2903 { |
|
2904 INFO_PRINTF1(_L("==========================================")); |
|
2905 INFO_PRINTF1(_L("Test : TestBufferReadWrite")); |
|
2906 INFO_PRINTF1(_L("==========================================")); |
|
2907 |
|
2908 INFO_PRINTF1(_L("Buffered Read and write")); |
|
2909 |
|
2910 INFO_PRINTF1(_L("Open ports")); |
|
2911 TInt res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
2912 TESTCHECKL(res, KErrNone); |
|
2913 |
|
2914 res=iSerialPortList[1].Open(iCommSession,KCommPort1,ECommShared); |
|
2915 if(res==KErrNotFound) |
|
2916 { |
|
2917 INFO_PRINTF1(_L("Cannot do this test - no second serial port")); |
|
2918 iSerialPortList[0].Close(); |
|
2919 SetTestStepResult(EInconclusive); |
|
2920 return TestStepResult(); |
|
2921 } |
|
2922 TESTCHECKL(res, KErrNone); |
|
2923 |
|
2924 TCommConfig cBuf; |
|
2925 TCommConfigV01 &c=cBuf(); |
|
2926 |
|
2927 TInt ret=iSerialPortList[0].Config(cBuf); |
|
2928 TESTCHECKL(ret, KErrNone); |
|
2929 c.iRate=EBps9600; |
|
2930 c.iHandshake=KConfigObeyCTS; |
|
2931 c.iTerminatorCount=0; |
|
2932 c.iParity=EParityNone; |
|
2933 c.iStopBits=EStop1; |
|
2934 c.iDataBits=EData8; |
|
2935 res = iSerialPortList[0].SetConfig(cBuf); |
|
2936 TESTCHECKL(res, KErrNone); |
|
2937 |
|
2938 ret=iSerialPortList[1].Config(cBuf); |
|
2939 TESTCHECKL(ret, KErrNone); |
|
2940 c.iRate=EBps9600; |
|
2941 c.iHandshake=KConfigObeyCTS; |
|
2942 c.iTerminatorCount=0; |
|
2943 c.iParity=EParityNone; |
|
2944 c.iStopBits=EStop1; |
|
2945 c.iDataBits=EData8; |
|
2946 TESTCHECKL(iSerialPortList[1].SetConfig(cBuf), KErrNone); |
|
2947 // enable buffering |
|
2948 |
|
2949 TCommServerConfig bmcPckg; |
|
2950 TCommServerConfigV01 &bmc=bmcPckg(); |
|
2951 |
|
2952 //bmc.iBufFlags=KCommBufferPartial; |
|
2953 bmc.iBufFlags=0; |
|
2954 bmc.iBufSize=0x10; |
|
2955 |
|
2956 iSerialPortList[0].SetMode(bmcPckg); |
|
2957 iSerialPortList[1].SetMode(bmcPckg); |
|
2958 |
|
2959 const TUint KBufSize=0x100; |
|
2960 TUint8* inBuf = new (ELeave) TUint8[KBufSize]; |
|
2961 CleanupStack::PushL(inBuf); |
|
2962 TUint8* outBuf = new (ELeave) TUint8[KBufSize]; |
|
2963 CleanupStack::PushL(outBuf); |
|
2964 TPtr8 outDes(outBuf, KBufSize, KBufSize); |
|
2965 TPtr8 inDes(inBuf, KBufSize, KBufSize); |
|
2966 |
|
2967 outDes.Fill('A'); |
|
2968 inDes.FillZ(); |
|
2969 |
|
2970 TRequestStatus readStatus; |
|
2971 TRequestStatus writeStatus; |
|
2972 |
|
2973 INFO_PRINTF1(_L("Read")); |
|
2974 iSerialPortList[0].Read(readStatus, KHugeTimeoutValue, inDes, KBufSize); |
|
2975 INFO_PRINTF1(_L("Write")); |
|
2976 iSerialPortList[1].Write(writeStatus,KHugeTimeoutValue,outDes,KBufSize); |
|
2977 User::WaitForRequest(writeStatus); |
|
2978 if(writeStatus != KErrNone) |
|
2979 User::WaitForRequest(readStatus); // flush |
|
2980 TESTCHECKL(writeStatus.Int(), KErrNone); |
|
2981 |
|
2982 User::WaitForRequest(readStatus); |
|
2983 TESTCHECKL(readStatus.Int(), KErrNone); |
|
2984 |
|
2985 outDes.SetLength(inDes.Length()); |
|
2986 TESTCHECKL(inDes.Compare(outDes), 0); |
|
2987 |
|
2988 INFO_PRINTF1(_L("Read With Invalid Parameter")); |
|
2989 iSerialPortList[0].Read(readStatus, KHugeTimeoutValue, inDes, KInvalidArgument); |
|
2990 |
|
2991 User::WaitForRequest(readStatus); |
|
2992 TESTCHECKL(readStatus.Int(), KErrArgument); |
|
2993 |
|
2994 INFO_PRINTF1(_L("Read With Parameter = MaxLength + 1")); |
|
2995 iSerialPortList[0].Read(readStatus, KHugeTimeoutValue, inDes, inDes.MaxLength() + 1); |
|
2996 |
|
2997 User::WaitForRequest(readStatus); |
|
2998 TESTCHECKL(readStatus.Int(), KErrArgument); |
|
2999 |
|
3000 INFO_PRINTF1(_L("Write With Invalid Argument")); |
|
3001 iSerialPortList[1].Write(writeStatus,KHugeTimeoutValue,outDes,KInvalidArgument); |
|
3002 |
|
3003 User::WaitForRequest(writeStatus); |
|
3004 TESTCHECKL(writeStatus.Int(), KErrArgument); |
|
3005 |
|
3006 INFO_PRINTF1(_L("Write With Parameter = Length + 1")); |
|
3007 iSerialPortList[1].Write(writeStatus,KHugeTimeoutValue,outDes,outDes.Length() + 1); |
|
3008 |
|
3009 User::WaitForRequest(writeStatus); |
|
3010 TESTCHECKL(writeStatus.Int(), KErrArgument); |
|
3011 |
|
3012 outDes.Fill('B'); |
|
3013 inDes.FillZ(); |
|
3014 |
|
3015 INFO_PRINTF1(_L("Read")); |
|
3016 iSerialPortList[0].Read(readStatus,inDes,KBufSize); |
|
3017 |
|
3018 INFO_PRINTF1(_L("Write")); |
|
3019 iSerialPortList[1].Write(writeStatus,outDes,KBufSize); |
|
3020 User::WaitForRequest(writeStatus); |
|
3021 TESTCHECKL(writeStatus.Int(), KErrNone); |
|
3022 |
|
3023 User::WaitForRequest(readStatus); |
|
3024 TESTCHECKL(readStatus.Int(), KErrNone); |
|
3025 |
|
3026 INFO_PRINTF1(_L("Read2 With Invalid Parameter")); |
|
3027 iSerialPortList[0].Read(readStatus,inDes,KInvalidArgument); |
|
3028 |
|
3029 User::WaitForRequest(readStatus); |
|
3030 TESTCHECKL(readStatus.Int(), KErrArgument); |
|
3031 |
|
3032 INFO_PRINTF1(_L("Read2 With Parameter = MaxLength + 1")); |
|
3033 iSerialPortList[0].Read(readStatus,inDes,inDes.MaxLength() + 1); |
|
3034 |
|
3035 User::WaitForRequest(readStatus); |
|
3036 TESTCHECKL(readStatus.Int(), KErrArgument); |
|
3037 |
|
3038 INFO_PRINTF1(_L("Write2 With Invalid Argument")); |
|
3039 iSerialPortList[1].Write(writeStatus,outDes,KInvalidArgument); |
|
3040 |
|
3041 User::WaitForRequest(writeStatus); |
|
3042 TESTCHECKL(writeStatus.Int(), KErrArgument); |
|
3043 |
|
3044 INFO_PRINTF1(_L("Write2 With Parameter = Length + 1")); |
|
3045 iSerialPortList[1].Write(writeStatus,outDes,outDes.Length() + 1); |
|
3046 |
|
3047 User::WaitForRequest(writeStatus); |
|
3048 TESTCHECKL(writeStatus.Int(), KErrArgument); |
|
3049 |
|
3050 outDes.SetLength(inDes.Length()); |
|
3051 TESTCHECKL(inDes.Compare(outDes), 0); |
|
3052 |
|
3053 bmc.iBufFlags=0; |
|
3054 bmc.iBufSize=0xffffffff; |
|
3055 |
|
3056 ret=iSerialPortList[0].Mode(bmcPckg); |
|
3057 TEST(ret==KErrNone); |
|
3058 |
|
3059 //test(bmc.iBufFlags==KCommBufferPartial); |
|
3060 //test(bmc.iBufSize==0x10); |
|
3061 |
|
3062 // |
|
3063 // cleanup |
|
3064 // |
|
3065 iSerialPortList[0].Close(); |
|
3066 iSerialPortList[1].Close(); |
|
3067 CleanupStack::PopAndDestroy(2); // inBuf, outBuf |
|
3068 |
|
3069 return TestStepResult(); |
|
3070 } |
|
3071 |
|
3072 CTestBufferreadOneOrMore::CTestBufferreadOneOrMore() |
|
3073 { |
|
3074 SetTestStepName(_L("TestBufferreadOneOrMore")); |
|
3075 } |
|
3076 |
|
3077 TVerdict CTestBufferreadOneOrMore::doTestStepL() |
|
3078 /** |
|
3079 * @test Test Buffered Read One or more |
|
3080 */ |
|
3081 { |
|
3082 INFO_PRINTF1(_L("==========================================")); |
|
3083 INFO_PRINTF1(_L("Test : TestBufferreadOneOrMore")); |
|
3084 INFO_PRINTF1(_L("==========================================")); |
|
3085 |
|
3086 INFO_PRINTF1(_L("Test Buffered Read One or more")); |
|
3087 |
|
3088 INFO_PRINTF1(_L("Open ports")); |
|
3089 TInt res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
3090 TESTCHECKL(res, KErrNone); |
|
3091 res=iSerialPortList[1].Open(iCommSession,KCommPort1,ECommShared); |
|
3092 if(res==KErrNotFound) |
|
3093 { |
|
3094 INFO_PRINTF1(_L("Cannot do this test - no second serial port")); |
|
3095 iSerialPortList[0].Close(); |
|
3096 SetTestStepResult(EInconclusive); |
|
3097 return TestStepResult(); |
|
3098 } |
|
3099 TESTCHECKL(res, KErrNone); |
|
3100 |
|
3101 // Turn handshaking on. |
|
3102 TCommConfig cBuf; |
|
3103 TCommConfigV01 &c=cBuf(); |
|
3104 TInt ret=iSerialPortList[0].Config(cBuf); |
|
3105 TESTCHECKL(ret, KErrNone); |
|
3106 c.iRate=EBps9600; |
|
3107 c.iHandshake=0; |
|
3108 c.iTerminatorCount=0; |
|
3109 iSerialPortList[0].SetConfig(cBuf); |
|
3110 |
|
3111 ret=iSerialPortList[1].Config(cBuf); |
|
3112 TESTCHECKL(ret, KErrNone); |
|
3113 c.iRate=EBps9600; |
|
3114 c.iHandshake=0; |
|
3115 c.iTerminatorCount=0; |
|
3116 iSerialPortList[1].SetConfig(cBuf); |
|
3117 // enable buffering |
|
3118 |
|
3119 TCommServerConfig bmcPckg; |
|
3120 TCommServerConfigV01 &bmc=bmcPckg(); |
|
3121 |
|
3122 bmc.iBufFlags=KCommBufferPartial; |
|
3123 bmc.iBufSize=0x10; |
|
3124 |
|
3125 iSerialPortList[0].SetMode(bmcPckg); |
|
3126 iSerialPortList[1].SetMode(bmcPckg); |
|
3127 |
|
3128 const TUint KBufSize=0x100; |
|
3129 TUint8* inBuf = new (ELeave) TUint8[KBufSize]; |
|
3130 CleanupStack::PushL(inBuf); |
|
3131 TUint8* outBuf = new (ELeave) TUint8[KBufSize]; |
|
3132 CleanupStack::PushL(outBuf); |
|
3133 TPtr8 outDes(outBuf, KBufSize, KBufSize); |
|
3134 TPtr8 inDes(inBuf, KBufSize, KBufSize); |
|
3135 |
|
3136 outDes.Fill('A'); |
|
3137 inDes.FillZ(); |
|
3138 |
|
3139 outDes.Fill('B'); |
|
3140 inDes.FillZ(); |
|
3141 |
|
3142 ret = iSerialPortList[0].ResetBuffers(); |
|
3143 TESTCHECKL(ret, KErrNone); |
|
3144 |
|
3145 TRequestStatus status; |
|
3146 iSerialPortList[0].Read(status, KHugeTimeoutValue, inDes, 1); |
|
3147 |
|
3148 TRequestStatus writeStat; |
|
3149 INFO_PRINTF1(_L("ReadOneorMore with data in buffer")); |
|
3150 iSerialPortList[1].Write(writeStat, KHugeTimeoutValue, outDes); |
|
3151 User::After(1000000); |
|
3152 User::WaitForRequest(writeStat); |
|
3153 User::WaitForRequest(status); |
|
3154 |
|
3155 TESTCHECKL(status.Int(), KErrNone); |
|
3156 TESTCHECKL(iSerialPortList[0].QueryReceiveBuffer()>0, TRUE); |
|
3157 TRequestStatus readStat; |
|
3158 inDes.SetLength(10); |
|
3159 iSerialPortList[0].ReadOneOrMore(readStat,inDes); |
|
3160 User::WaitForRequest(readStat); |
|
3161 TESTCHECKL((inDes.Length()>1), TRUE); |
|
3162 |
|
3163 ret = iSerialPortList[0].ResetBuffers(); |
|
3164 TESTCHECKL(ret, KErrNone); |
|
3165 |
|
3166 INFO_PRINTF1(_L("ReadOneorMore on empty buffer")); |
|
3167 iSerialPortList[0].ReadOneOrMore(readStat,inDes); |
|
3168 iSerialPortList[1].Write(writeStat,outDes); |
|
3169 User::WaitForRequest(writeStat); |
|
3170 User::WaitForRequest(readStat); |
|
3171 TESTCHECKL(inDes.Length(), 1); |
|
3172 |
|
3173 ret = iSerialPortList[0].ResetBuffers(); |
|
3174 TESTCHECKL(ret, KErrNone); |
|
3175 |
|
3176 // |
|
3177 // cleanup |
|
3178 // |
|
3179 iSerialPortList[1].Close(); |
|
3180 iSerialPortList[0].Close(); |
|
3181 CleanupStack::PopAndDestroy(2); // inBuf, outBuf |
|
3182 |
|
3183 return TestStepResult(); |
|
3184 } |
|
3185 |
|
3186 CTestNotifySignals::CTestNotifySignals() |
|
3187 { |
|
3188 SetTestStepName(_L("TestNotifySignals")); |
|
3189 } |
|
3190 |
|
3191 TVerdict CTestNotifySignals::doTestStepL() |
|
3192 /** |
|
3193 * @test Test notification of signals changing |
|
3194 */ |
|
3195 { |
|
3196 INFO_PRINTF1(_L("==========================================")); |
|
3197 INFO_PRINTF1(_L("Test : TestNotifySignals")); |
|
3198 INFO_PRINTF1(_L("==========================================")); |
|
3199 |
|
3200 INFO_PRINTF1(_L("Test notification of signals changing")); |
|
3201 // PRE-STRTECH sub-session containers START |
|
3202 |
|
3203 TInt res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
3204 TESTCHECKL(res, KErrNone); |
|
3205 iSerialPortList[0].Close(); |
|
3206 |
|
3207 // PRE-STRECT END |
|
3208 iCommSession.__DbgMarkHeap(); |
|
3209 res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
3210 TESTCHECKL(res, KErrNone); |
|
3211 |
|
3212 res=iSerialPortList[1].Open(iCommSession,KCommPort1,ECommShared); |
|
3213 if(res==KErrNotFound) |
|
3214 { |
|
3215 INFO_PRINTF1(_L("Cannot do this test - no second serial port")); |
|
3216 iSerialPortList[0].Close(); |
|
3217 SetTestStepResult(EInconclusive); |
|
3218 return TestStepResult(); |
|
3219 } |
|
3220 TESTCHECKL(res, KErrNone); |
|
3221 |
|
3222 TCommConfig conf; |
|
3223 |
|
3224 TInt ret=iSerialPortList[0].Config(conf); |
|
3225 TESTCHECKL(ret, KErrNone); |
|
3226 conf().iHandshake=KConfigFreeRTS|KConfigFreeDTR; // we take control of outputs |
|
3227 TESTCHECKL(iSerialPortList[0].SetConfig(conf), KErrNone); |
|
3228 |
|
3229 ret=iSerialPortList[1].Config(conf); |
|
3230 TESTCHECKL(ret, KErrNone); |
|
3231 conf().iHandshake=KConfigFreeRTS|KConfigFreeDTR; |
|
3232 TESTCHECKL(iSerialPortList[1].SetConfig(conf), KErrNone); |
|
3233 |
|
3234 TRequestStatus status,status2; |
|
3235 TUint signals; |
|
3236 iSerialPortList[1].SetSignals(0,KSignalRTS|KSignalDTR); |
|
3237 |
|
3238 iSerialPortList[0].NotifySignalChange(status,signals); |
|
3239 ret = iSerialPortList[1].SetSignalsToMark(KSignalRTS); |
|
3240 TESTCHECKL(ret, KErrNone); |
|
3241 |
|
3242 User::WaitForRequest(status); |
|
3243 TESTCHECKL(status.Int(), KErrNone); |
|
3244 TESTCHECKL(signals,(KSignalCTS|KCTSChanged)); |
|
3245 |
|
3246 // Test that the notification signal goes off when signals lower as well as rise |
|
3247 iSerialPortList[0].NotifySignalChange(status,signals); |
|
3248 ret = iSerialPortList[1].SetSignalsToSpace(KSignalRTS); |
|
3249 TESTCHECKL(ret, KErrNone); |
|
3250 User::WaitForRequest(status); |
|
3251 TESTCHECKL(status.Int(), KErrNone); |
|
3252 TESTCHECKL(signals,KCTSChanged); |
|
3253 |
|
3254 iSerialPortList[0].NotifySignalChange(status,signals); |
|
3255 ret = iSerialPortList[1].SetSignalsToMark(KSignalDTR); |
|
3256 TESTCHECKL(ret, KErrNone); |
|
3257 User::WaitForRequest(status); |
|
3258 TESTCHECKL(status.Int(), KErrNone); |
|
3259 TBool pass=(signals==(KSignalDSR|KDSRChanged))||(signals==(KSignalDSR|KSignalDCD|KDSRChanged|KDCDChanged)); |
|
3260 TESTCHECKL(pass,(TInt)ETrue); |
|
3261 |
|
3262 ret = iSerialPortList[1].SetSignalsToSpace(KSignalDTR); |
|
3263 TESTCHECKL(ret, KErrNone); |
|
3264 signals = iSerialPortList[0].Signals(); |
|
3265 TESTCHECKL(signals,0); |
|
3266 |
|
3267 // Test the KErrInUse that should be returned when a notification of data available is posted at the same |
|
3268 // time as a Read - or visa versa. |
|
3269 TBuf8<10> buf; |
|
3270 iSerialPortList[0].ReadOneOrMore(status,buf); |
|
3271 iSerialPortList[0].NotifyDataAvailable(status2); |
|
3272 User::WaitForRequest(status2); |
|
3273 TESTCHECKL(status2.Int(),KErrInUse); |
|
3274 ret = iSerialPortList[0].ReadCancel(); |
|
3275 TESTCHECKL(ret, KErrNone); |
|
3276 User::WaitForRequest(status); |
|
3277 TESTCHECKL(status.Int(),KErrCancel); |
|
3278 |
|
3279 iSerialPortList[0].NotifyDataAvailable(status); |
|
3280 iSerialPortList[0].ReadOneOrMore(status2,buf); |
|
3281 User::WaitForRequest(status2); |
|
3282 TESTCHECKL(status2.Int(),KErrInUse); |
|
3283 ret = iSerialPortList[0].NotifyDataAvailableCancel(); |
|
3284 TESTCHECKL(ret, KErrNone); |
|
3285 User::WaitForRequest(status); |
|
3286 TESTCHECKL(status.Int(),KErrCancel); |
|
3287 |
|
3288 iSerialPortList[0].Close(); |
|
3289 iSerialPortList[1].Close(); |
|
3290 iCommSession.__DbgMarkEnd(0); |
|
3291 |
|
3292 return TestStepResult(); |
|
3293 } |
|
3294 |
|
3295 CTestRxDataAvailable::CTestRxDataAvailable() |
|
3296 { |
|
3297 SetTestStepName(_L("TestRxDataAvailable")); |
|
3298 } |
|
3299 |
|
3300 TVerdict CTestRxDataAvailable::doTestStepL() |
|
3301 /** |
|
3302 * @test Test notification of data being newly available to be read |
|
3303 */ |
|
3304 { |
|
3305 INFO_PRINTF1(_L("==========================================")); |
|
3306 INFO_PRINTF1(_L("Test : TestRxDataAvailable")); |
|
3307 INFO_PRINTF1(_L("==========================================")); |
|
3308 |
|
3309 INFO_PRINTF1(_L("Test notification of data being newly available to be read")); |
|
3310 // PRE-STRECT subsession containers START |
|
3311 |
|
3312 TInt res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
3313 TESTCHECKL(res, KErrNone); |
|
3314 iSerialPortList[0].Close(); |
|
3315 |
|
3316 // PRE-STRETCH END |
|
3317 iCommSession.__DbgMarkHeap(); |
|
3318 res=iSerialPortList[0].Open(iCommSession,KCommPort0,ECommShared); |
|
3319 TESTCHECKL(res, KErrNone); |
|
3320 |
|
3321 res=iSerialPortList[1].Open(iCommSession, KCommPort1, ECommShared); |
|
3322 if(res==KErrNotFound) |
|
3323 { |
|
3324 INFO_PRINTF1(_L("Cannot do this test - no second serial port")); |
|
3325 iSerialPortList[0].Close(); |
|
3326 SetTestStepResult(EInconclusive); |
|
3327 return TestStepResult(); |
|
3328 } |
|
3329 TESTCHECKL(res, KErrNone); |
|
3330 |
|
3331 TRequestStatus status; |
|
3332 TRequestStatus status2; |
|
3333 iSerialPortList[0].NotifyDataAvailable(status); |
|
3334 |
|
3335 _LIT8(KBuffer,"Data"); |
|
3336 iSerialPortList[1].Write(status2, KHugeTimeoutValue, KBuffer); |
|
3337 User::WaitForRequest(status2); |
|
3338 if(status2 != KErrNone) |
|
3339 { |
|
3340 TInt ret = iSerialPortList[0].Cancel(); |
|
3341 TEST(ret==KErrNone); |
|
3342 User::WaitForRequest(status); // flush |
|
3343 } |
|
3344 TESTCHECKL(status2.Int(), KErrNone); |
|
3345 |
|
3346 User::WaitForRequest(status); // wait until the data is available |
|
3347 TESTCHECKL(status.Int(), KErrNone); |
|
3348 |
|
3349 TBuf8<30> receive; |
|
3350 iSerialPortList[0].ReadOneOrMore(status,receive); |
|
3351 User::WaitForRequest(status); |
|
3352 TESTCHECKL(status.Int(), KErrNone); |
|
3353 TESTCHECKL((receive==KBuffer), 1); // check that the received data equals sent data |
|
3354 |
|
3355 iSerialPortList[0].Close(); |
|
3356 iSerialPortList[1].Close(); |
|
3357 iCommSession.__DbgMarkEnd(0); |
|
3358 |
|
3359 return TestStepResult(); |
|
3360 } |
|
3361 |
|
3362 CTestHelloEllo::CTestHelloEllo() |
|
3363 { |
|
3364 SetTestStepName(_L("TestHelloEllo")); |
|
3365 } |
|
3366 |
|
3367 TVerdict CTestHelloEllo::doTestStepL() |
|
3368 /** |
|
3369 * @test Test that sending 'Hello' is not received as 'ello' |
|
3370 * |
|
3371 * @note attempt to reproduce defect CLE-4TVLRD 'Querying output buffer state loses a byte on timeout' |
|
3372 */ |
|
3373 { |
|
3374 INFO_PRINTF1(_L("===================================")); |
|
3375 INFO_PRINTF1(_L("Test : TestHelloEllo")); |
|
3376 INFO_PRINTF1(_L("===================================")); |
|
3377 |
|
3378 INFO_PRINTF1(_L("test Hello - Ello")); |
|
3379 |
|
3380 // |
|
3381 // Open first com port |
|
3382 // |
|
3383 INFO_PRINTF1(_L("Open ports")); |
|
3384 TInt res = iSerialPortList[0].Open(iCommSession, KCommPort0, ECommShared); |
|
3385 TESTCHECKL(res, KErrNone); |
|
3386 |
|
3387 // |
|
3388 // set config - 115200, 8N1, HW flowcontrol |
|
3389 // |
|
3390 TCommConfig cBuf; |
|
3391 TCommConfigV01 &c=cBuf(); |
|
3392 |
|
3393 TInt ret=iSerialPortList[0].Config(cBuf); |
|
3394 TESTCHECKL(ret, KErrNone); |
|
3395 c.iFifo=EFifoEnable; |
|
3396 c.iRate=EBps115200; |
|
3397 c.iHandshake=KConfigObeyCTS | KConfigObeyDSR | KConfigWriteBufferedComplete; |
|
3398 c.iTerminatorCount=0; |
|
3399 c.iDataBits=EData8; |
|
3400 c.iParity=EParityNone; |
|
3401 c.iStopBits=EStop1; |
|
3402 TESTCHECKL(iSerialPortList[0].SetConfig(cBuf), KErrNone); |
|
3403 |
|
3404 // |
|
3405 // flush and test |
|
3406 // |
|
3407 ret = iSerialPortList[0].ResetBuffers(); |
|
3408 TESTCHECKL(ret, KErrNone); |
|
3409 TESTCHECKL(iSerialPortList[0].QueryReceiveBuffer(), 0); |
|
3410 |
|
3411 const TTimeIntervalMicroSeconds32 timeOut = 2000000; |
|
3412 RTest gTest(_L("Test Window")); |
|
3413 FOREVER |
|
3414 { |
|
3415 INFO_PRINTF1(_L("press a key")); |
|
3416 TInt key = gTest.Getch(); |
|
3417 if(key == 'Q' || key == 'q') |
|
3418 User::Leave(KErrAbort); |
|
3419 |
|
3420 TRequestStatus status; |
|
3421 iSerialPortList[0].Write(status, timeOut, _L8("Hello")); |
|
3422 User::WaitForRequest(status); |
|
3423 INFO_PRINTF2(_L("iStatus=%d"), status.Int()); |
|
3424 INFO_PRINTF2(_L("recBuffer=%d"), iSerialPortList[0].QueryReceiveBuffer()); |
|
3425 |
|
3426 if(status.Int() == KErrTimedOut) |
|
3427 { |
|
3428 INFO_PRINTF2(_L("recBuffer=%d"), iSerialPortList[0].QueryReceiveBuffer()); |
|
3429 iSerialPortList[0].Write(status, KNullDesC8); // length=0 |
|
3430 User::WaitForRequest(status); |
|
3431 INFO_PRINTF1(_L("wrote 0 bytes")); |
|
3432 INFO_PRINTF2(_L("recBuffer=%d"), iSerialPortList[0].QueryReceiveBuffer()); |
|
3433 } |
|
3434 |
|
3435 } |
|
3436 |
|
3437 // Unreachable code... |
|
3438 //gTest.Close(); |
|
3439 /* |
|
3440 TRequestStatus notifyStatus; |
|
3441 TUint signals; |
|
3442 TUint signalMask = 0x3f; |
|
3443 FOREVER |
|
3444 { |
|
3445 iSerialPortList[0].NotifySignalChange(notifyStatus, signals, signalMask); |
|
3446 User::WaitForRequest(notifyStatus); |
|
3447 if(notifyStatus.Int() != KErrNone) |
|
3448 INFO_PRINTF2(_L("Hmm. iStatus=%d\n"), notifyStatus.Int()); |
|
3449 else |
|
3450 INFO_PRINTF2(_L("sigs: 0x%08x\n"), signals); |
|
3451 } |
|
3452 |
|
3453 |
|
3454 // |
|
3455 // cleanup |
|
3456 // |
|
3457 iSerialPortList[0].Close(); |
|
3458 iSerialPortList[1].Close(); |
|
3459 |
|
3460 test.End(); |
|
3461 */ |
|
3462 // Unreachable code... |
|
3463 //return TestStepResult(); |
|
3464 } |
|
3465 |
|
3466 CLsc32ListAvailablePorts::CLsc32ListAvailablePorts() |
|
3467 { |
|
3468 SetTestStepName(_L("Lsc32ListAvailablePorts")); |
|
3469 } |
|
3470 |
|
3471 TVerdict CLsc32ListAvailablePorts::doTestStepL() |
|
3472 /** |
|
3473 * @test Test for listing available serial comm ports |
|
3474 */ |
|
3475 { |
|
3476 INFO_PRINTF1(_L("===================================")); |
|
3477 INFO_PRINTF1(_L("Test : Lsc32ListAvailablePorts")); |
|
3478 INFO_PRINTF1(_L("===================================")); |
|
3479 |
|
3480 INFO_PRINTF1(_L("available ports:")); |
|
3481 |
|
3482 const TInt KNumberOfPorts = 5; |
|
3483 RComm ports[KNumberOfPorts]; |
|
3484 _LIT(KCommNamePrefix, "COMM::"); |
|
3485 |
|
3486 INFO_PRINTF1(_L("-------- DTE DCE")); |
|
3487 for(TInt i=0;i<KNumberOfPorts;i++) |
|
3488 { |
|
3489 TBuf<128> comName; |
|
3490 comName.Append(KCommNamePrefix); |
|
3491 comName.AppendFormat(_L("%d"), i); |
|
3492 TInt dte = ports[i].Open(iCommSession, comName, ECommShared, ECommRoleDTE); |
|
3493 if(dte==KErrNone) |
|
3494 ports[i].Close(); |
|
3495 TInt dce = ports[i].Open(iCommSession, comName, ECommShared, ECommRoleDCE); |
|
3496 if(dce==KErrNone) |
|
3497 ports[i].Close(); |
|
3498 INFO_PRINTF1(comName); |
|
3499 INFO_PRINTF3(_L(" %d %d"), dte, dce); |
|
3500 } |
|
3501 |
|
3502 return TestStepResult(); |
|
3503 } |
|
3504 |
|
3505 |
|
3506 CLsc32ListNumberOfLoadedCSYs::CLsc32ListNumberOfLoadedCSYs() |
|
3507 { |
|
3508 SetTestStepName(_L("Lsc32ListNumberOfLoadedCSYs")); |
|
3509 } |
|
3510 |
|
3511 TVerdict CLsc32ListNumberOfLoadedCSYs::doTestStepL() |
|
3512 /** |
|
3513 * @test Tests number of loaded CSY modules |
|
3514 */ |
|
3515 { |
|
3516 INFO_PRINTF1(_L("===================================")); |
|
3517 INFO_PRINTF1(_L("Test : Lsc32ListNumberOfLoadedCSYs")); |
|
3518 INFO_PRINTF1(_L("===================================")); |
|
3519 |
|
3520 TInt csys; |
|
3521 TInt ret = iCommSession.NumPorts(csys); |
|
3522 TEST(ret == KErrNone); |
|
3523 if(ret != KErrNone) |
|
3524 { |
|
3525 INFO_PRINTF2(_L("ERROR: could not get number of loaded CSY's due to %d"), ret); |
|
3526 SetTestStepResult(EFail); |
|
3527 } |
|
3528 else |
|
3529 INFO_PRINTF2(_L("number of loaded CSY's: %d"), csys); |
|
3530 |
|
3531 return TestStepResult(); |
|
3532 } |
|
3533 |
|
3534 CLsc32LoadUnloadCsy::CLsc32LoadUnloadCsy() |
|
3535 { |
|
3536 SetTestStepName(_L("Lsc32LoadUnloadCsy")); |
|
3537 } |
|
3538 |
|
3539 TVerdict CLsc32LoadUnloadCsy::doTestStepL() |
|
3540 /** |
|
3541 * @test Test that load and unload comms module |
|
3542 */ |
|
3543 { |
|
3544 INFO_PRINTF1(_L("===================================")); |
|
3545 INFO_PRINTF1(_L("Test : Lsc32LoadUnloadCsy")); |
|
3546 INFO_PRINTF1(_L("===================================")); |
|
3547 |
|
3548 INFO_PRINTF1(_L("Loading Dummy CSY...")); |
|
3549 |
|
3550 TInt ret = iCommSession.LoadCommModule(KCsyName); |
|
3551 TEST(ret == KErrNone); |
|
3552 if(ret != KErrNone) |
|
3553 { |
|
3554 INFO_PRINTF3(_L("ERROR: could not load CSY '%S' due to %d"), &KCsyName, ret); |
|
3555 SetTestStepResult(EFail); |
|
3556 } |
|
3557 else |
|
3558 INFO_PRINTF2(_L("OK. CSY '%S' loaded"), &KCsyName); |
|
3559 |
|
3560 INFO_PRINTF1(_L("Unloading Dummy CSY...")); |
|
3561 |
|
3562 ret = iCommSession.UnloadCommModule(KCsyName); |
|
3563 TEST(ret == KErrNone); |
|
3564 if(ret != KErrNone) |
|
3565 { |
|
3566 INFO_PRINTF3(_L("ERROR: could not unload CSY '%S' due to %d"), &KCsyName, ret); |
|
3567 SetTestStepResult(EFail); |
|
3568 } |
|
3569 else |
|
3570 INFO_PRINTF2(_L("OK. CSY '%S' unloaded"), &KCsyName); |
|
3571 |
|
3572 INFO_PRINTF1(_L("Unloading Dummy CSY again should give error...")); |
|
3573 |
|
3574 ret = iCommSession.UnloadCommModule(KCsyName); |
|
3575 TEST(ret != KErrNone); |
|
3576 if(ret != KErrNone) |
|
3577 { |
|
3578 INFO_PRINTF3(_L("TEST PASSED: could not unload CSY '%S' due to %d"), &KCsyName, ret); |
|
3579 } |
|
3580 else |
|
3581 { |
|
3582 INFO_PRINTF2(_L("ERROR: CSY '%S' unloaded twice!"), &KCsyName); |
|
3583 SetTestStepResult(EFail); |
|
3584 } |
|
3585 return TestStepResult(); |
|
3586 } |
|
3587 |
|
3588 CLsc32GetPortInfo::CLsc32GetPortInfo() |
|
3589 { |
|
3590 SetTestStepName(_L("Lsc32GetPortInfo")); |
|
3591 } |
|
3592 |
|
3593 TVerdict CLsc32GetPortInfo::doTestStepL() |
|
3594 /** |
|
3595 * @test Test that gets port info for all comms modules loaded |
|
3596 */ |
|
3597 { |
|
3598 INFO_PRINTF1(_L("===================================")); |
|
3599 INFO_PRINTF1(_L("Test : Lsc32GetPortInfo")); |
|
3600 INFO_PRINTF1(_L("===================================")); |
|
3601 |
|
3602 TInt csys; |
|
3603 TInt ret = iCommSession.NumPorts(csys); |
|
3604 TEST(ret == KErrNone); |
|
3605 if(ret != KErrNone) |
|
3606 { |
|
3607 INFO_PRINTF2(_L("ERROR: could not get number of loaded CSY's due to %d"), ret); |
|
3608 SetTestStepResult(EFail); |
|
3609 } |
|
3610 |
|
3611 for(TInt i=0;i<csys;i++) |
|
3612 { |
|
3613 TBuf<100> moduleName; |
|
3614 TSerialInfo serialInfo; |
|
3615 TInt ret = iCommSession.GetPortInfo(i, moduleName, serialInfo); |
|
3616 if(ret!=KErrNone) |
|
3617 INFO_PRINTF3(_L("index %d: GetPortInfo returned %d"), i, ret); |
|
3618 else |
|
3619 { |
|
3620 INFO_PRINTF3(_L("index %d: '%S'"), i, &moduleName); |
|
3621 INFO_PRINTF2(_L(" description: %S"), &serialInfo.iDescription); |
|
3622 INFO_PRINTF2(_L(" port name: %S"), &serialInfo.iName); |
|
3623 INFO_PRINTF2(_L(" low unit: %d"), serialInfo.iLowUnit); |
|
3624 INFO_PRINTF2(_L(" high unit: %d"), serialInfo.iHighUnit); |
|
3625 } |
|
3626 } |
|
3627 |
|
3628 return TestStepResult(); |
|
3629 } |
|
3630 |
|
3631 CDummyTest::CDummyTest() |
|
3632 { |
|
3633 SetTestStepName(_L("DummyTest")); |
|
3634 } |
|
3635 |
|
3636 TVerdict CDummyTest::doTestStepL() |
|
3637 /** |
|
3638 * @test Calls every C32 API methods, will panic if errors occurs on received |
|
3639 * parameters or return values |
|
3640 */ |
|
3641 { |
|
3642 INFO_PRINTF1(_L("===================================")); |
|
3643 INFO_PRINTF1(_L("Test : Dummy Tests")); |
|
3644 INFO_PRINTF1(_L("===================================")); |
|
3645 TBool theBool = EFalse; |
|
3646 GetBoolFromConfig(ConfigSection(),_L("TheBool"),theBool); |
|
3647 INFO_PRINTF1(_L("Testing DCE role")); |
|
3648 DummyClientTestsL(ECommRoleDCE, theBool); |
|
3649 INFO_PRINTF1(_L("Testing DTE role")); |
|
3650 DummyClientTestsL(ECommRoleDTE, theBool); |
|
3651 INFO_PRINTF1(_L("Finished OK")); |
|
3652 |
|
3653 return TestStepResult(); |
|
3654 } |
|
3655 |
|
3656 void CDummyTest::DummyClientTestsL(TCommRole aRole, TBool aHeapCheck) |
|
3657 /** |
|
3658 * @test Calls every C32 API methods, will panic if errors occurs on received |
|
3659 * parameters o return values |
|
3660 */ |
|
3661 { |
|
3662 TRequestStatus stat,stat2,stat3,stat4,stat5,stat6,stat7,stat8,stat9; |
|
3663 TUint inputs; |
|
3664 TUint sig; |
|
3665 |
|
3666 INFO_PRINTF1(_L("Opening dummy")); |
|
3667 TInt res = iCommSession.Connect(); |
|
3668 TESTCHECKL(res, KErrNone); |
|
3669 |
|
3670 if(aHeapCheck == EFalse) |
|
3671 { |
|
3672 |
|
3673 |
|
3674 // PRE-STRETCH START - Load dummy csy and open a CPort |
|
3675 |
|
3676 res = iCommSession.LoadCommModule(_L("dummy")); |
|
3677 TESTCHECKL(res, KErrNone); |
|
3678 |
|
3679 TEST(iDPort0.Open(iCommSession,KDummyPortName,ECommShared,aRole)==KErrNone); |
|
3680 iDPort0.Close(); |
|
3681 User::After(2000000); // Give dummy time to do the deferred close |
|
3682 TEST(iCommSession.UnloadCommModule(_L("dummy"))==KErrNone); |
|
3683 |
|
3684 // PRE-STRETCH END |
|
3685 } |
|
3686 iCommSession.__DbgMarkHeap(); |
|
3687 res = iCommSession.LoadCommModule(_L("dummy")); |
|
3688 TESTCHECKL(res, KErrNone); |
|
3689 |
|
3690 // new tests |
|
3691 WaitingTestsL(aRole); |
|
3692 DummyPreemptableTestsL(aRole); |
|
3693 |
|
3694 if (aRole==ECommRoleDTE) |
|
3695 INFO_PRINTF1(_L("Open dummy serial port in shared mode as DTE")); |
|
3696 else |
|
3697 INFO_PRINTF1(_L("Open dummy serial port in shared mode as DCE")); |
|
3698 |
|
3699 TEST(iDPort0.Open(iCommSession,KDummyPortName,ECommShared,aRole)==KErrNone); |
|
3700 |
|
3701 HBufC8* hbuf=HBufC8::NewL(2046); |
|
3702 TPtr8 outbuf=hbuf->Des(); |
|
3703 outbuf =_L8("This string has to be exactly like this othervice write returns KErrCommsLineFail."); |
|
3704 |
|
3705 if (aRole==ECommRoleDTE) |
|
3706 inputs = KSignalDTEInputs; |
|
3707 else |
|
3708 inputs = KSignalDCEInputs; |
|
3709 |
|
3710 |
|
3711 // testing write & signals |
|
3712 INFO_PRINTF1(_L("*********************************")); |
|
3713 INFO_PRINTF1(_L("testing write & signals")); |
|
3714 |
|
3715 iDPort0.Write(stat,5000000L,outbuf); |
|
3716 INFO_PRINTF1(_L("About to notifysignalchange")); |
|
3717 iDPort0.NotifySignalChange(stat2,sig,inputs); |
|
3718 User::WaitForRequest(stat); |
|
3719 INFO_PRINTF2(_L("Write completed with %d"),stat.Int()); |
|
3720 TEST(stat==KErrNone); |
|
3721 User::WaitForRequest(stat2); |
|
3722 INFO_PRINTF2(_L("Notify completed with %d"),stat2.Int()); |
|
3723 INFO_PRINTF2(_L("Signals = %x"),sig); |
|
3724 TEST(stat2==KErrNone); |
|
3725 if (aRole==ECommRoleDTE) |
|
3726 TEST(sig==(KSignalDTEInputs|KCTSChanged)); |
|
3727 else |
|
3728 TEST(sig==(KSignalDCEInputs|KRTSChanged)); |
|
3729 |
|
3730 //ShowSignals(sig,aRole); |
|
3731 INFO_PRINTF1(_L("SetSignalsToSpace")); |
|
3732 TInt ret; |
|
3733 if (aRole==ECommRoleDTE) |
|
3734 { |
|
3735 ret = iDPort0.SetSignalsToSpace(KSignalDTEOutputs); |
|
3736 } |
|
3737 else |
|
3738 { |
|
3739 ret = iDPort0.SetSignalsToSpace(KSignalDCEOutputs); |
|
3740 } |
|
3741 TESTCHECKL(ret, KErrNone); |
|
3742 |
|
3743 INFO_PRINTF1(_L("SetSignalsToMark")); |
|
3744 if (aRole==ECommRoleDTE) |
|
3745 { |
|
3746 ret = iDPort0.SetSignalsToMark(KSignalDTEOutputs); |
|
3747 } |
|
3748 else |
|
3749 { |
|
3750 ret = iDPort0.SetSignalsToMark(KSignalDCEOutputs); |
|
3751 } |
|
3752 TESTCHECKL(ret, KErrNone); |
|
3753 User::After(2000000); |
|
3754 |
|
3755 INFO_PRINTF1(_L("NotifySignalChange")); |
|
3756 iDPort0.NotifySignalChange(stat2,sig,inputs); |
|
3757 User::WaitForRequest(stat2); |
|
3758 //ShowSignals(sig,aRole); |
|
3759 if (aRole==ECommRoleDTE) |
|
3760 { |
|
3761 TEST(sig==(KSignalDTEInputs|KCTSChanged)); |
|
3762 } |
|
3763 else |
|
3764 { |
|
3765 TEST(sig==(KSignalDCEInputs|KRTSChanged)); |
|
3766 } |
|
3767 |
|
3768 sig=iDPort0.Signals(KSignalDTEInputs|KSignalDCEInputs); |
|
3769 //ShowSignals(sig,aRole); |
|
3770 if (aRole==ECommRoleDTE) |
|
3771 { |
|
3772 TEST(sig==(KSignalDTEInputs)); |
|
3773 } |
|
3774 else |
|
3775 { |
|
3776 TEST(sig==(KSignalDCEInputs)); |
|
3777 } |
|
3778 |
|
3779 // canceling |
|
3780 stat2=KErrNone; |
|
3781 INFO_PRINTF1(_L("Canceling signal notification")); |
|
3782 iDPort0.NotifySignalChange(stat2,sig,inputs); |
|
3783 ret = iDPort0.NotifySignalChangeCancel(); |
|
3784 TESTCHECKL(ret, KErrNone); |
|
3785 User::WaitForRequest(stat2); |
|
3786 TEST(stat2==KErrCancel); |
|
3787 stat2=KErrNone; |
|
3788 iDPort0.NotifySignalChange(stat2,sig,inputs); |
|
3789 ret = iDPort0.NotifySignalChangeCancel(); |
|
3790 TESTCHECKL(ret, KErrNone); |
|
3791 User::WaitForRequest(stat2); |
|
3792 TEST(stat2==KErrCancel); |
|
3793 |
|
3794 |
|
3795 // testing flow control & read |
|
3796 INFO_PRINTF1(_L("*********************************")); |
|
3797 INFO_PRINTF1(_L("testing flow control & read")); |
|
3798 TFlowControl flow,flow2; |
|
3799 iDPort0.NotifyFlowControlChange(stat2,flow); |
|
3800 User::WaitForRequest(stat2); |
|
3801 iDPort0.GetFlowControlStatus(flow2); |
|
3802 TEST(flow2==flow); |
|
3803 TEST(flow==EFlowControlOn); |
|
3804 //ShowFlow(flow); |
|
3805 iDPort0.GetFlowControlStatus(flow2); |
|
3806 TEST(flow2==flow); |
|
3807 |
|
3808 HBufC8* hbuf2=HBufC8::NewL(2048); |
|
3809 TPtr8 inbuf=hbuf2->Des(); |
|
3810 inbuf.SetLength(0); |
|
3811 INFO_PRINTF1(_L("NotifyFlowControlChange & read")); |
|
3812 iDPort0.NotifyFlowControlChange(stat2,flow); |
|
3813 iDPort0.ReadOneOrMore(stat,inbuf); |
|
3814 User::WaitForRequest(stat); |
|
3815 User::WaitForRequest(stat2); |
|
3816 TEST(inbuf.Length()==2048); |
|
3817 //ShowFlow(flow); |
|
3818 TEST(flow==EFlowControlOn); |
|
3819 //INFO_PRINTF1(_L("Received>>>")); |
|
3820 //ShowReceived(inbuf); |
|
3821 iDPort0.GetFlowControlStatus(flow2); |
|
3822 TEST(flow2==flow); |
|
3823 |
|
3824 // testing canceling |
|
3825 stat2=KErrNone; |
|
3826 INFO_PRINTF1(_L("NotifyFlowControlChange canceling")); |
|
3827 iDPort0.NotifyFlowControlChange(stat2,flow); |
|
3828 ret = iDPort0.NotifyFlowControlChangeCancel(); |
|
3829 TESTCHECKL(ret, KErrNone); |
|
3830 User::WaitForRequest(stat2); |
|
3831 TEST(stat2==KErrCancel); |
|
3832 stat2=KErrNone; |
|
3833 iDPort0.NotifyFlowControlChange(stat2,flow); |
|
3834 ret = iDPort0.NotifyFlowControlChangeCancel(); |
|
3835 TESTCHECKL(ret, KErrNone); |
|
3836 User::WaitForRequest(stat2); |
|
3837 TEST(stat2==KErrCancel); |
|
3838 |
|
3839 |
|
3840 // testing break |
|
3841 INFO_PRINTF1(_L("*********************************")); |
|
3842 INFO_PRINTF1(_L("testing break")); |
|
3843 iDPort0.Break(stat,1); |
|
3844 User::WaitForRequest(stat); |
|
3845 |
|
3846 INFO_PRINTF1(_L("NotifyBreak")); |
|
3847 iDPort0.NotifyBreak(stat); |
|
3848 User::WaitForRequest(stat); |
|
3849 |
|
3850 INFO_PRINTF1(_L("Sending break")); |
|
3851 iDPort0.Break(stat,100); |
|
3852 User::WaitForRequest(stat); |
|
3853 |
|
3854 INFO_PRINTF1(_L("NotifyBreak")); |
|
3855 iDPort0.NotifyBreak(stat); |
|
3856 User::WaitForRequest(stat); |
|
3857 |
|
3858 INFO_PRINTF1(_L("Sending break")); |
|
3859 iDPort0.Break(stat,10000); |
|
3860 User::WaitForRequest(stat); |
|
3861 |
|
3862 INFO_PRINTF1(_L("NotifyBreak")); |
|
3863 iDPort0.NotifyBreak(stat); |
|
3864 User::WaitForRequest(stat); |
|
3865 |
|
3866 // Testing canceling |
|
3867 INFO_PRINTF1(_L("NotifyBreak canceling")); |
|
3868 stat2=KErrNone; |
|
3869 iDPort0.NotifyBreak(stat2); |
|
3870 ret = iDPort0.NotifyBreakCancel(); |
|
3871 TESTCHECKL(ret, KErrNone); |
|
3872 User::WaitForRequest(stat2); |
|
3873 TEST(stat2==KErrCancel); |
|
3874 stat2=KErrNone; |
|
3875 iDPort0.NotifyBreak(stat2); |
|
3876 ret = iDPort0.NotifyBreakCancel(); |
|
3877 TESTCHECKL(ret, KErrNone); |
|
3878 User::WaitForRequest(stat2); |
|
3879 TEST(stat2==KErrCancel); |
|
3880 |
|
3881 INFO_PRINTF1(_L("Break canceling")); |
|
3882 stat2=KErrNone; |
|
3883 iDPort0.Break(stat2,1000000); |
|
3884 ret = iDPort0.BreakCancel(); |
|
3885 TESTCHECKL(ret, KErrNone); |
|
3886 User::WaitForRequest(stat2); |
|
3887 TEST(stat2==KErrCancel); |
|
3888 stat2=KErrNone; |
|
3889 iDPort0.Break(stat2,100000000); |
|
3890 ret = iDPort0.BreakCancel(); |
|
3891 TESTCHECKL(ret, KErrNone); |
|
3892 User::WaitForRequest(stat2); |
|
3893 TEST(stat2==KErrCancel); |
|
3894 |
|
3895 |
|
3896 // testing configuration changes & settings |
|
3897 INFO_PRINTF1(_L("*********************************")); |
|
3898 INFO_PRINTF1(_L("testing configuration changes & settings")); |
|
3899 TCommNotificationV01 config; |
|
3900 TPckg<TCommNotificationV01> cfg(config); |
|
3901 |
|
3902 // get config |
|
3903 TCommConfig ownConfig; |
|
3904 ret=iDPort0.Config(ownConfig); |
|
3905 TESTCHECKL(ret, KErrNone); |
|
3906 TEST(ownConfig().iRate==EBps9600); |
|
3907 TEST(ownConfig().iDataBits==EData8); |
|
3908 TEST(ownConfig().iParity==EParityNone); |
|
3909 TEST(ownConfig().iStopBits==EStop1); |
|
3910 if (aRole==ECommRoleDTE) |
|
3911 TEST(ownConfig().iHandshake==KConfigObeyCTS); |
|
3912 else |
|
3913 TEST(ownConfig().iHandshake==KConfigObeyRTS); |
|
3914 |
|
3915 // set config |
|
3916 // |
|
3917 // If you receive a KErrGeneral (-1) error on this test, it is most likely |
|
3918 // because the TThread.dll library is missing from your build. An annoying |
|
3919 // error to debug!!! |
|
3920 // |
|
3921 ownConfig().iStopBits=EStop2; |
|
3922 TInt myRet = iDPort0.SetConfig(ownConfig); |
|
3923 TEST(myRet==KErrNotSupported); |
|
3924 |
|
3925 |
|
3926 // notify config |
|
3927 iDPort0.NotifyConfigChange(stat2,cfg); |
|
3928 User::WaitForRequest(stat2); |
|
3929 //ShowConfig(config); |
|
3930 TEST(config.iChangedMembers=KHandshakeChanged); |
|
3931 TEST(config.iRate==EBps9600); |
|
3932 TEST(config.iDataBits==EData8); |
|
3933 TEST(config.iParity==EParityNone); |
|
3934 TEST(config.iStopBits==EStop1); |
|
3935 TEST(config.iHandshake==(KConfigObeyCTS|KConfigObeyRTS)); |
|
3936 |
|
3937 // testing canceling |
|
3938 stat2=KErrNone; |
|
3939 iDPort0.NotifyConfigChange(stat2,cfg); |
|
3940 ret = iDPort0.NotifyConfigChangeCancel(); |
|
3941 TESTCHECKL(ret, KErrNone); |
|
3942 User::WaitForRequest(stat2); // |
|
3943 TEST(stat2==KErrCancel); |
|
3944 stat2=KErrNone; |
|
3945 iDPort0.NotifyConfigChange(stat2,cfg); |
|
3946 ret = iDPort0.NotifyConfigChangeCancel(); |
|
3947 TESTCHECKL(ret, KErrNone); |
|
3948 User::WaitForRequest(stat2); // |
|
3949 TEST(stat2==KErrCancel); |
|
3950 |
|
3951 |
|
3952 // testing capabilities querying |
|
3953 INFO_PRINTF1(_L("*********************************")); |
|
3954 INFO_PRINTF1(_L("testing capabilities querying")); |
|
3955 TCommCapsV01 capsV01; |
|
3956 TCommCapsV02 capsV02; |
|
3957 TPckg<TCommCapsV01> cV01(capsV01); |
|
3958 TPckg<TCommCapsV02> cV02(capsV02); |
|
3959 INFO_PRINTF1(_L("Querying TCommCapsV01")); |
|
3960 INFO_PRINTF1(_L("-----------------------")); |
|
3961 |
|
3962 // TCommCapsV01 |
|
3963 ret = iDPort0.Caps(cV01); |
|
3964 TESTCHECKL(ret, KErrNone); |
|
3965 //ShowCapsV01(capsV01); |
|
3966 TEST(capsV01.iRate== |
|
3967 ( KCapsBps50 | KCapsBps75 | KCapsBps110 | KCapsBps134 | KCapsBps150 | KCapsBps300 |
|
3968 | KCapsBps600 | KCapsBps1200 | KCapsBps1800 | KCapsBps2000 | KCapsBps2400 | KCapsBps3600 |
|
3969 | KCapsBps4800 | KCapsBps7200 | KCapsBps9600 | KCapsBps19200 | KCapsBps38400 |
|
3970 | KCapsBps57600 | KCapsBps115200)); |
|
3971 TEST(capsV01.iDataBits ==0xf); |
|
3972 TEST(capsV01.iStopBits ==0x3); |
|
3973 TEST(capsV01.iParity ==0x7); |
|
3974 TEST(capsV01.iHandshake ==0x1ff); |
|
3975 TEST(capsV01.iSignals ==0x3f); |
|
3976 TEST(capsV01.iFifo ==KCapsHasFifo); |
|
3977 TEST(capsV01.iSIR ==0); |
|
3978 |
|
3979 // TCommCapsV02 |
|
3980 INFO_PRINTF1(_L("Querying TCommCapsV02")); |
|
3981 ret = iDPort0.Caps(cV02); |
|
3982 TESTCHECKL(ret, KErrNone); |
|
3983 //ShowCapsV02(capsV02); |
|
3984 TEST(capsV02.iRate== |
|
3985 ( KCapsBps50 | KCapsBps75 | KCapsBps110 | KCapsBps134 | KCapsBps150 | KCapsBps300 |
|
3986 | KCapsBps600 | KCapsBps1200 | KCapsBps1800 | KCapsBps2000 | KCapsBps2400 | KCapsBps3600 |
|
3987 | KCapsBps4800 | KCapsBps7200 | KCapsBps9600 | KCapsBps19200 | KCapsBps38400 |
|
3988 | KCapsBps57600 | KCapsBps115200)); |
|
3989 TEST(capsV02.iDataBits ==0xf); |
|
3990 TEST(capsV02.iStopBits ==0x3); |
|
3991 TEST(capsV02.iParity ==0x7); |
|
3992 TEST(capsV02.iHandshake ==0x1ff); |
|
3993 TEST(capsV02.iSignals ==0x3f); |
|
3994 TEST(capsV02.iFifo ==KCapsHasFifo); |
|
3995 TEST(capsV02.iSIR ==0); |
|
3996 TEST(capsV02.iNotificationCaps== |
|
3997 (KNotifySignalsChangeSupported | KNotifyRateChangeSupported |
|
3998 | KNotifyDataFormatChangeSupported | KNotifyHandshakeChangeSupported |
|
3999 | KNotifyBreakSupported | KNotifyFlowControlChangeSupported)); |
|
4000 TEST(capsV02.iRoleCaps==KCapsRoleSwitchSupported); |
|
4001 TEST(capsV02.iFlowControlCaps==KCapsFlowControlStatusSupported); |
|
4002 |
|
4003 |
|
4004 iDPort0.Close(); |
|
4005 User::After(2000000); // Give dummy time to do the deferred close |
|
4006 TEST(iCommSession.UnloadCommModule(_L("dummy"))==KErrNone); |
|
4007 User::After(500000); |
|
4008 if(aHeapCheck == EFalse) |
|
4009 { |
|
4010 iCommSession.__DbgMarkEnd(0); |
|
4011 } |
|
4012 else |
|
4013 { |
|
4014 iCommSession.__DbgMarkEnd(5); |
|
4015 } |
|
4016 iCommSession.Close(); |
|
4017 |
|
4018 User::After(2000000); |
|
4019 |
|
4020 // test role conflicts |
|
4021 INFO_PRINTF1(_L("*********************************")); |
|
4022 INFO_PRINTF1(_L("test role conflicts")); |
|
4023 res = iCommSession.Connect(); |
|
4024 TESTCHECKL(res, KErrNone); |
|
4025 |
|
4026 if(aHeapCheck == EFalse) |
|
4027 { |
|
4028 // PRE-STRETCH START - Load a CSY and open a CPort (new session) |
|
4029 TEST(iCommSession.LoadCommModule(_L("dummy"))==KErrNone); |
|
4030 TEST(iDPort0.Open(iCommSession,_L("dummy::0"),ECommShared,ECommRoleDCE)==KErrNone); |
|
4031 iDPort0.Close(); |
|
4032 User::After( 1200000L * 2 ); // Give it long enough to do the deferred delete of dummy. |
|
4033 TEST(iCommSession.UnloadCommModule(_L("dummy"))==KErrNone); |
|
4034 // PRE-STRETCH END |
|
4035 } |
|
4036 iCommSession.__DbgMarkHeap(); |
|
4037 INFO_PRINTF1(_L("Loading dummy module")); |
|
4038 TEST(iCommSession.LoadCommModule(_L("dummy"))==KErrNone); |
|
4039 |
|
4040 INFO_PRINTF1(_L("Open dummy serial port in shared mode as DCE")); |
|
4041 TEST(iDPort0.Open(iCommSession,_L("dummy::0"),ECommShared,ECommRoleDCE)==KErrNone); |
|
4042 INFO_PRINTF1(_L("Open dummy serial port in shared mode as DCE")); |
|
4043 TEST(iDPort1.Open(iCommSession,_L("dummy::0"),ECommShared,ECommRoleDCE)==KErrNone); |
|
4044 INFO_PRINTF1(_L("Open dummy serial port in shared mode as DTE")); |
|
4045 TEST(iDPort2.Open(iCommSession,_L("dummy::0"),ECommShared,ECommRoleDTE)==KErrLocked); |
|
4046 iDPort1.Close(); |
|
4047 iDPort2.Close(); |
|
4048 |
|
4049 |
|
4050 // test rest of reads of the API |
|
4051 INFO_PRINTF1(_L("*********************************")); |
|
4052 INFO_PRINTF1(_L("test rest of reads of the API")); |
|
4053 iDPort0.Read(stat,inbuf); |
|
4054 User::WaitForRequest(stat); |
|
4055 TEST(stat==KErrNone); |
|
4056 //INFO_PRINTF1(_L("Received>>>")); |
|
4057 //ShowReceived(inbuf); |
|
4058 TEST(inbuf.Length()==2048); |
|
4059 |
|
4060 iDPort0.Read(stat,inbuf,257); |
|
4061 User::WaitForRequest(stat); |
|
4062 TEST(stat==KErrNone); |
|
4063 //INFO_PRINTF1(_L("Received>>>")); |
|
4064 //ShowReceived(inbuf); |
|
4065 TEST(inbuf.Length()==257); |
|
4066 |
|
4067 TTimeIntervalMicroSeconds32 time = 10; |
|
4068 |
|
4069 iDPort0.Read(stat,time,inbuf); |
|
4070 User::WaitForRequest(stat); |
|
4071 TEST(stat==KErrTimedOut); |
|
4072 //INFO_PRINTF1(_L("Received>>>")); |
|
4073 //ShowReceived(inbuf); |
|
4074 TEST(inbuf.Length()==2048); |
|
4075 |
|
4076 time = 10000000; |
|
4077 iDPort0.Read(stat,time,inbuf,2048); |
|
4078 User::WaitForRequest(stat); |
|
4079 TEST(stat==KErrNone); |
|
4080 //INFO_PRINTF1(_L("Received>>>")); |
|
4081 //ShowReceived(inbuf); |
|
4082 TEST(inbuf.Length()==2048); |
|
4083 |
|
4084 // test rest of writes of the API |
|
4085 INFO_PRINTF1(_L("*********************************")); |
|
4086 INFO_PRINTF1(_L("test rest of writes of the API")); |
|
4087 iDPort0.Write(stat,outbuf); |
|
4088 User::WaitForRequest(stat); |
|
4089 TEST(stat==KErrNone); |
|
4090 |
|
4091 iDPort0.Write(stat,outbuf,82); |
|
4092 User::WaitForRequest(stat); |
|
4093 TEST(stat==KErrNone); |
|
4094 |
|
4095 iDPort0.Write(stat,5000000L,outbuf,50); |
|
4096 User::WaitForRequest(stat); |
|
4097 TEST(stat==KErrCommsLineFail); |
|
4098 |
|
4099 |
|
4100 // test SetMode & Mode |
|
4101 INFO_PRINTF1(_L("*********************************")); |
|
4102 INFO_PRINTF1(_L("test SetMode & Mode")); |
|
4103 TCommServerConfig bmcPckg; |
|
4104 TCommServerConfigV01 &bmc=bmcPckg(); |
|
4105 //bmc.iBufFlags=KCommBufferPartial; |
|
4106 bmc.iBufFlags=KCommBufferPartial; |
|
4107 bmc.iBufSize=0x10; |
|
4108 ret = iDPort0.SetMode(bmcPckg); |
|
4109 TEST(ret==KErrNone); |
|
4110 bmc.iBufFlags=KCommBufferFull; |
|
4111 bmc.iBufSize=0; |
|
4112 |
|
4113 ret = iDPort0.Mode(bmcPckg); |
|
4114 TEST(ret==KErrNone); |
|
4115 TEST(bmc.iBufFlags==KCommBufferPartial); |
|
4116 TEST(bmc.iBufSize==0x10); |
|
4117 |
|
4118 |
|
4119 // test NotifyDataAvailable |
|
4120 INFO_PRINTF1(_L("*********************************")); |
|
4121 INFO_PRINTF1(_L("test NotifyDataAvailable")); |
|
4122 iDPort0.NotifyDataAvailable(stat); |
|
4123 User::WaitForRequest(stat); |
|
4124 TEST(stat==KErrNone); |
|
4125 // testing canceling |
|
4126 stat2=KErrNone; |
|
4127 iDPort0.NotifyDataAvailable(stat2); |
|
4128 ret = iDPort0.NotifyDataAvailableCancel(); |
|
4129 TESTCHECKL(ret, KErrNone); |
|
4130 User::WaitForRequest(stat2); // |
|
4131 TEST(stat2==KErrCancel); |
|
4132 stat2=KErrNone; |
|
4133 iDPort0.NotifyDataAvailable(stat2); |
|
4134 ret = iDPort0.NotifyDataAvailableCancel(); |
|
4135 TESTCHECKL(ret, KErrNone); |
|
4136 User::WaitForRequest(stat2); // |
|
4137 TEST(stat2==KErrCancel); |
|
4138 |
|
4139 |
|
4140 // test NotifyOutputEmpty |
|
4141 INFO_PRINTF1(_L("*********************************")); |
|
4142 INFO_PRINTF1(_L("test NotifyOutputEmpty")); |
|
4143 iDPort0.NotifyOutputEmpty(stat); |
|
4144 User::WaitForRequest(stat); |
|
4145 TEST(stat==KErrNone); |
|
4146 // testing canceling |
|
4147 stat2=KErrNone; |
|
4148 iDPort0.NotifyOutputEmpty(stat2); |
|
4149 ret = iDPort0.NotifyOutputEmptyCancel(); |
|
4150 TESTCHECKL(ret, KErrNone); |
|
4151 User::WaitForRequest(stat2); // |
|
4152 TEST(stat2==KErrCancel); |
|
4153 stat2=KErrNone; |
|
4154 iDPort0.NotifyOutputEmpty(stat2); |
|
4155 ret = iDPort0.NotifyOutputEmptyCancel(); |
|
4156 TESTCHECKL(ret, KErrNone); |
|
4157 User::WaitForRequest(stat2); // |
|
4158 TEST(stat2==KErrCancel); |
|
4159 |
|
4160 |
|
4161 // test buffer lengths & ResetBuffers |
|
4162 INFO_PRINTF1(_L("*********************************")); |
|
4163 INFO_PRINTF1(_L("test test buffer lengths & ResetBuffers")); |
|
4164 TInt bufferLength=2000; |
|
4165 TInt bufferLength2=0; |
|
4166 |
|
4167 ret = iDPort0.SetReceiveBufferLength(bufferLength); |
|
4168 TESTCHECKL(ret, KErrNone); |
|
4169 bufferLength2=iDPort0.ReceiveBufferLength(); |
|
4170 TEST(bufferLength2==bufferLength); |
|
4171 ret = iDPort0.ResetBuffers(); |
|
4172 TESTCHECKL(ret, KErrNone); |
|
4173 TEST(iDPort0.QueryReceiveBuffer()==0); |
|
4174 iDPort0.Close(); |
|
4175 |
|
4176 |
|
4177 // test GetRole |
|
4178 INFO_PRINTF1(_L("*********************************")); |
|
4179 INFO_PRINTF1(_L("test GetRole")); |
|
4180 TEST(iDPort0.Open(iCommSession,_L("dummy::0"),ECommExclusive,aRole)==KErrNone); |
|
4181 TCommRole role; |
|
4182 if (aRole==ECommRoleDTE) |
|
4183 role=ECommRoleDCE; |
|
4184 else |
|
4185 role=ECommRoleDTE; |
|
4186 ret = iDPort0.GetRole(role); |
|
4187 TEST(ret==KErrNone); |
|
4188 TEST(role==aRole); |
|
4189 |
|
4190 |
|
4191 // test cancel |
|
4192 INFO_PRINTF1(_L("*********************************")); |
|
4193 INFO_PRINTF1(_L("test cancel")); |
|
4194 iDPort0.Break(stat3,1); |
|
4195 User::WaitForRequest(stat3); |
|
4196 iDPort0.Break(stat3,100); |
|
4197 User::WaitForRequest(stat3); |
|
4198 iDPort0.Break(stat3,10000); |
|
4199 User::WaitForRequest(stat3); |
|
4200 |
|
4201 iDPort0.Write(stat,outbuf); |
|
4202 iDPort0.Break(stat2,1000000); |
|
4203 iDPort0.Read(stat3,inbuf); |
|
4204 iDPort0.NotifySignalChange(stat4,sig,inputs); |
|
4205 iDPort0.NotifyConfigChange(stat5,cfg); |
|
4206 iDPort0.NotifyFlowControlChange(stat6,flow); |
|
4207 iDPort0.NotifyBreak(stat7); |
|
4208 iDPort0.NotifyDataAvailable(stat8); |
|
4209 iDPort0.NotifyOutputEmpty(stat9); |
|
4210 |
|
4211 ret = iDPort0.Cancel(); |
|
4212 TESTCHECKL(ret, KErrNone); |
|
4213 |
|
4214 User::WaitForRequest(stat); |
|
4215 User::WaitForRequest(stat2); |
|
4216 User::WaitForRequest(stat3); |
|
4217 User::WaitForRequest(stat4); |
|
4218 User::WaitForRequest(stat5); |
|
4219 User::WaitForRequest(stat6); |
|
4220 User::WaitForRequest(stat7); |
|
4221 |
|
4222 User::WaitForRequest(stat8); |
|
4223 User::WaitForRequest(stat9); |
|
4224 TEST(stat==KErrCancel); |
|
4225 TEST(stat2==KErrCancel); |
|
4226 TEST(stat3==KErrCancel); |
|
4227 TEST(stat4==KErrCancel); |
|
4228 TEST(stat5==KErrCancel); |
|
4229 |
|
4230 TEST(stat6==KErrCancel); |
|
4231 TEST(stat7==KErrCancel); |
|
4232 TEST(stat8==KErrCancel); |
|
4233 TEST(stat9==KErrCancel); |
|
4234 |
|
4235 INFO_PRINTF1(_L("---------------------------------")); |
|
4236 iDPort0.Close(); |
|
4237 User::After( 1200000L * 2 ); // Give it long enough to do the deferred delete of dummy. |
|
4238 TEST(iCommSession.UnloadCommModule(_L("dummy"))==KErrNone); |
|
4239 User::After( 500000 ); |
|
4240 if(aHeapCheck == EFalse) |
|
4241 { |
|
4242 iCommSession.__DbgMarkEnd(0); |
|
4243 } |
|
4244 else |
|
4245 { |
|
4246 iCommSession.__DbgMarkEnd(5); |
|
4247 } |
|
4248 iCommSession.Close(); |
|
4249 |
|
4250 delete hbuf; |
|
4251 delete hbuf2; |
|
4252 } |
|
4253 |
|
4254 void CDummyTest::WaitingTestsL(TCommRole aRole) |
|
4255 /** |
|
4256 * @test Test the new waiting functionality |
|
4257 */ |
|
4258 { |
|
4259 RCommServ csB; |
|
4260 RCommServ csC; |
|
4261 RComm A; |
|
4262 RComm B; |
|
4263 RComm C; |
|
4264 |
|
4265 TEST(csB.Connect()==KErrNone); |
|
4266 TEST(csC.Connect()==KErrNone); |
|
4267 |
|
4268 TRequestStatus stat; |
|
4269 |
|
4270 // ************************************************************* |
|
4271 |
|
4272 INFO_PRINTF1(_L("Testing transition from waiting to preemptable")); |
|
4273 |
|
4274 TRequestStatus statusA; |
|
4275 TRequestStatus statusB; |
|
4276 A.OpenWhenAvailable(statusA,iCommSession,KDummyPortName); |
|
4277 User::WaitForRequest(statusA); |
|
4278 TEST(statusA==KErrNone); |
|
4279 |
|
4280 B.OpenWhenAvailable(statusB,csB,KDummyPortName); |
|
4281 User::WaitForRequest(statusB); |
|
4282 TEST(statusB==KErrNotSupported); |
|
4283 |
|
4284 #ifdef _DEBUG |
|
4285 TCommDebugInfo s; |
|
4286 TInt ret = A.DebugState(s); |
|
4287 TESTCHECKL(ret, KErrNone); |
|
4288 TEST(s.iAccessCount == 1 ); |
|
4289 TEST(s.iMode == EIntCommPreemptable); |
|
4290 TEST(s.iRole == KCommDefaultPreemptRole ); // reflects change in cc_cli.cpp |
|
4291 TEST(s.iOutstandingCommands == 0); |
|
4292 #endif |
|
4293 |
|
4294 TEST(A.SetAccessMode(ECommExclusive)==KErrNone); |
|
4295 #ifdef _DEBUG |
|
4296 ret = A.DebugState(s); |
|
4297 TESTCHECKL(ret, KErrNone); |
|
4298 TEST(s.iAccessCount == 1 ); |
|
4299 TEST(s.iMode == EIntCommExclusive); |
|
4300 TEST(s.iRole == KCommDefaultPreemptRole ); // reflects change in cc_cli.cpp |
|
4301 TEST(s.iOutstandingCommands == 0); |
|
4302 #endif |
|
4303 |
|
4304 B.OpenWhenAvailable(statusB,csB,KDummyPortName); |
|
4305 TEST(statusB==KRequestPending); |
|
4306 |
|
4307 B.OpenWhenAvailableCancel(); |
|
4308 TEST(statusB==KErrCancel); |
|
4309 User::WaitForRequest(statusB); |
|
4310 |
|
4311 #ifdef _DEBUG |
|
4312 ret = A.DebugState(s); |
|
4313 TESTCHECKL(ret, KErrNone); |
|
4314 TEST(s.iAccessCount == 1 ); |
|
4315 TEST(s.iMode == EIntCommExclusive); |
|
4316 TEST(s.iRole == KCommDefaultPreemptRole ); // reflects change in cc_cli.cpp |
|
4317 TEST(s.iOutstandingCommands == 0); |
|
4318 #endif |
|
4319 |
|
4320 B.OpenWhenAvailable(statusB,csB,KDummyPortName); |
|
4321 TEST(statusB==KRequestPending); |
|
4322 |
|
4323 B.Write(stat,5000000L,testbufWrite); |
|
4324 User::WaitForRequest(stat); |
|
4325 TEST(stat==KErrNotReady); |
|
4326 |
|
4327 TEST(B.SetAccessMode(ECommExclusive)==KErrNotSupported); |
|
4328 TEST(B.SetAccessMode(ECommShared)==KErrNotSupported); |
|
4329 |
|
4330 A.Close(); |
|
4331 TEST(statusB==KErrNone); |
|
4332 User::WaitForRequest(statusB); |
|
4333 |
|
4334 #ifdef _DEBUG |
|
4335 ret = B.DebugState(s); |
|
4336 TEST(ret==KErrNone); |
|
4337 TEST(s.iAccessCount == 1 ); |
|
4338 TEST(s.iMode == EIntCommPreemptable); |
|
4339 TEST(s.iRole == KCommDefaultPreemptRole ); // reflects change in cc_cli.cpp |
|
4340 TEST(s.iOutstandingCommands == 0); |
|
4341 #endif |
|
4342 |
|
4343 B.Write(stat,5000000L,testbufWrite); |
|
4344 User::WaitForRequest(stat); |
|
4345 TEST(stat==KErrNone); |
|
4346 |
|
4347 B.Close(); |
|
4348 |
|
4349 TEST(B.Open(csB,KDummyPortName,ECommShared,ECommRoleDCE)==KErrNone); |
|
4350 A.OpenWhenAvailable(statusA,iCommSession,KDummyPortName); |
|
4351 TEST(statusA==KRequestPending); |
|
4352 |
|
4353 B.Close(); |
|
4354 |
|
4355 User::WaitForRequest(statusA); |
|
4356 TEST(statusA==KErrNone); |
|
4357 |
|
4358 #ifdef _DEBUG |
|
4359 ret = A.DebugState(s); |
|
4360 TESTCHECKL(ret, KErrNone); |
|
4361 TEST(s.iAccessCount == 1 ); |
|
4362 TEST(s.iMode == EIntCommPreemptable); |
|
4363 TEST(s.iRole == ECommRoleDCE ); |
|
4364 TEST(s.iOutstandingCommands == 0); |
|
4365 #endif |
|
4366 |
|
4367 A.Close(); |
|
4368 |
|
4369 // ************************************************************* |
|
4370 |
|
4371 INFO_PRINTF1(_L("Testing Asynchronous open")); |
|
4372 |
|
4373 TEST(B.Open(csB,KDummyPortName,ECommExclusive,aRole)==KErrNone); |
|
4374 B.Write(stat,5000000L,testbufWrite); |
|
4375 User::WaitForRequest(stat); |
|
4376 TEST(stat==KErrNone); |
|
4377 TRequestStatus statusC; |
|
4378 |
|
4379 A.OpenWhenAvailable(statusC,iCommSession,KDummyPortName); |
|
4380 |
|
4381 A.Write(stat,5000000L,testbufWrite); |
|
4382 User::WaitForRequest(stat); |
|
4383 TEST(stat==KErrNotReady); |
|
4384 |
|
4385 TEST(C.Open(csC,KDummyPortName,ECommExclusive,aRole)==KErrAccessDenied); |
|
4386 TEST(C.Open(csC,KDummyPortName,ECommPreemptable,aRole)==KErrAccessDenied); |
|
4387 C.OpenWhenAvailable(stat,csC,KDummyPortName); |
|
4388 User::WaitForRequest(stat); |
|
4389 TEST(stat==KErrAccessDenied); |
|
4390 |
|
4391 TInt ret1=B.WriteCancel(); |
|
4392 TESTCHECKL(ret1, KErrNone); |
|
4393 TEST(statusC==KRequestPending); |
|
4394 B.Close(); |
|
4395 TEST(statusC==KErrNone); // OpenWhenAvailable completed. |
|
4396 User::WaitForRequest(statusC); |
|
4397 |
|
4398 A.Write(stat,5000000L,testbufWrite); |
|
4399 User::WaitForRequest(stat); |
|
4400 TEST(stat==KErrNone); |
|
4401 |
|
4402 TEST(A.SetAccessMode(ECommExclusive)==KErrNone); |
|
4403 |
|
4404 B.OpenWhenAvailable(statusC,csB,KDummyPortName); |
|
4405 TEST(statusC==KRequestPending); |
|
4406 |
|
4407 B.Write(stat,5000000L,testbufWrite); |
|
4408 User::WaitForRequest(stat); |
|
4409 TEST(stat==KErrNotReady); |
|
4410 |
|
4411 A.Close(); |
|
4412 |
|
4413 TEST(statusC==KErrNone); |
|
4414 User::WaitForRequest(statusC); |
|
4415 |
|
4416 B.Write(stat,5000000L,testbufWrite); |
|
4417 User::WaitForRequest(stat); |
|
4418 TEST(stat==KErrNone); |
|
4419 |
|
4420 #ifdef _DEBUG |
|
4421 ret = B.DebugState(s); |
|
4422 TESTCHECKL(ret, KErrNone); |
|
4423 TEST(s.iAccessCount == 1 ); |
|
4424 TEST(s.iMode == EIntCommPreemptable); |
|
4425 TEST(s.iRole == aRole ); |
|
4426 TEST(s.iOutstandingCommands == 0); |
|
4427 #endif |
|
4428 |
|
4429 B.Close(); |
|
4430 |
|
4431 // ************************************************************* |
|
4432 |
|
4433 INFO_PRINTF1(_L("Testing Timing issues, Cancel and Sharing with Async open")); |
|
4434 |
|
4435 TRequestStatus statusE; |
|
4436 A.OpenWhenAvailable(statusE,csC,KDummyPortName); |
|
4437 |
|
4438 TEST(B.Open(csC,KDummyPortName,ECommPreemptable,aRole)==KErrAccessDenied); |
|
4439 TEST(statusE==KErrNone); |
|
4440 |
|
4441 User::WaitForRequest(statusE); |
|
4442 |
|
4443 #ifdef _DEBUG |
|
4444 ret = A.DebugState(s); |
|
4445 TESTCHECKL(ret, KErrNone); |
|
4446 TEST(s.iAccessCount == 1 ); |
|
4447 TEST(s.iMode == EIntCommPreemptable); |
|
4448 TEST(s.iOutstandingCommands == 0); |
|
4449 #endif |
|
4450 |
|
4451 A.Close(); |
|
4452 |
|
4453 csB.Close(); |
|
4454 csC.Close(); |
|
4455 |
|
4456 INFO_PRINTF1(_L("*** Waiting tests completed *** ")); |
|
4457 } |
|
4458 |
|
4459 void CDummyTest::DummyPreemptableTestsL(TCommRole aRole) |
|
4460 /** |
|
4461 * @test Test the new preemption functionality |
|
4462 */ |
|
4463 { |
|
4464 RCommServ csB; |
|
4465 RComm A; |
|
4466 RComm B; |
|
4467 |
|
4468 TEST(csB.Connect()==KErrNone); |
|
4469 |
|
4470 TRequestStatus stat,stat2; |
|
4471 |
|
4472 // ************************************************************* |
|
4473 |
|
4474 INFO_PRINTF1(_L("Testing preemptable mode ")); |
|
4475 TInt erra = A.Open(iCommSession,KDummyPortName,ECommPreemptable,aRole); |
|
4476 TEST(erra==KErrNone); |
|
4477 |
|
4478 HBufC8* hbuf2=HBufC8::NewL(2048); |
|
4479 TPtr8 inbuf=hbuf2->Des(); |
|
4480 inbuf.SetLength(0); |
|
4481 |
|
4482 INFO_PRINTF1(_L("Doing read then write")); |
|
4483 A.Read(stat,inbuf); |
|
4484 User::WaitForRequest(stat); |
|
4485 TEST(stat==KErrNone); |
|
4486 TEST(inbuf.Length() == 2048 && inbuf.Left( testbufRead().Length() ) ==testbufRead); |
|
4487 A.Write(stat,5000000L,testbufWrite); |
|
4488 User::WaitForRequest(stat); |
|
4489 TEST(stat==KErrNone); |
|
4490 |
|
4491 // ************************************************************* |
|
4492 |
|
4493 INFO_PRINTF1(_L("Testing simple preemption")); |
|
4494 |
|
4495 TEST(B.Open(csB,KDummyPortName,ECommExclusive,aRole)==KErrNone); |
|
4496 A.Read(stat,inbuf); |
|
4497 User::WaitForRequest(stat); |
|
4498 TEST(stat==KErrCancel); |
|
4499 A.Write(stat,5000000L,testbufWrite); |
|
4500 User::WaitForRequest(stat); |
|
4501 TEST(stat==KErrCancel); |
|
4502 #ifdef _DEBUG |
|
4503 TCommDebugInfo s; |
|
4504 TInt ret = B.DebugState(s); |
|
4505 TEST(ret==KErrNone); |
|
4506 TEST(s.iAccessCount == 2 ); |
|
4507 TEST(s.iMode == EIntCommExclusive); |
|
4508 TEST(s.iRole == aRole ); |
|
4509 TEST(s.iOutstandingCommands == 0); |
|
4510 #endif |
|
4511 |
|
4512 B.Read(stat,inbuf); |
|
4513 User::WaitForRequest(stat); |
|
4514 TEST(stat==KErrNone); |
|
4515 TEST(inbuf.Length() == 2048 && inbuf.Left( testbufRead().Length() ) ==testbufRead); |
|
4516 B.Write(stat,5000000L,testbufWrite); |
|
4517 User::WaitForRequest(stat); |
|
4518 TEST(stat==KErrNone); |
|
4519 |
|
4520 A.Close(); |
|
4521 |
|
4522 TEST(A.Open(iCommSession,KDummyPortName,ECommPreemptable,aRole)==KErrAccessDenied); |
|
4523 TInt err = A.Open(iCommSession,KDummyPortName,ECommExclusive,aRole); |
|
4524 TEST(err==KErrAccessDenied); |
|
4525 B.Close(); |
|
4526 |
|
4527 // ************************************************************* |
|
4528 |
|
4529 INFO_PRINTF1(_L("Testing preemption with outstanding requests and role change")); |
|
4530 |
|
4531 TCommRole altRole = (aRole==ECommRoleDTE) ? ECommRoleDCE:ECommRoleDTE; |
|
4532 TEST(A.Open(iCommSession,KDummyPortName,ECommPreemptable,altRole)==KErrNone); |
|
4533 #ifdef _DEBUG |
|
4534 ret = A.DebugState(s); |
|
4535 TESTCHECKL(ret, KErrNone); |
|
4536 TEST(s.iRole == altRole ); |
|
4537 TEST(s.iOutstandingCommands == 0); |
|
4538 #endif |
|
4539 A.Read(stat,inbuf); |
|
4540 A.Write(stat2,5000000L,testbufWrite); |
|
4541 TEST(B.Open(csB,KDummyPortName,ECommShared,aRole)==KErrNone); |
|
4542 TEST(stat==KErrCancel); // You've been preempted error! |
|
4543 TEST(stat2==KErrCancel); |
|
4544 |
|
4545 |
|
4546 #ifdef _DEBUG |
|
4547 ret = B.DebugState(s); |
|
4548 TESTCHECKL(ret, KErrNone); |
|
4549 TEST(s.iAccessCount == 2 ); |
|
4550 TEST(s.iMode == EIntCommShared); |
|
4551 TEST(s.iRole == aRole ); |
|
4552 TEST(s.iOutstandingCommands == 0); |
|
4553 #endif |
|
4554 B.Write(stat,5000000L,testbufWrite); |
|
4555 B.Read(stat2,inbuf); |
|
4556 User::WaitForRequest(stat2); |
|
4557 TEST(stat2==KErrNone); |
|
4558 User::WaitForRequest(stat); |
|
4559 TEST(stat==KErrNone); |
|
4560 TEST(inbuf.Length() == 2048 && inbuf.Left( testbufRead().Length() ) ==testbufRead); |
|
4561 |
|
4562 |
|
4563 B.Close(); |
|
4564 |
|
4565 // ************************************************************* |
|
4566 |
|
4567 INFO_PRINTF1(_L("Testing open when port has a deferred destruction")); |
|
4568 |
|
4569 A.Close(); |
|
4570 TEST(A.Open(iCommSession,KDummyPortName,ECommPreemptable,aRole)==KErrNone); |
|
4571 A.Close(); |
|
4572 |
|
4573 TEST(A.Open(iCommSession,KDummyPortName,ECommPreemptable,aRole)==KErrNone); |
|
4574 err = A.SetAccessMode(ECommExclusive); |
|
4575 TEST(err==KErrNone); |
|
4576 |
|
4577 |
|
4578 TEST(B.Open(csB,KDummyPortName,ECommExclusive,aRole)==KErrAccessDenied); |
|
4579 A.Close(); |
|
4580 |
|
4581 TEST(A.Open(iCommSession,KDummyPortName,ECommPreemptable,aRole)==KErrNone); |
|
4582 TEST(A.SetAccessMode(ECommShared)==KErrNone); |
|
4583 |
|
4584 #ifdef _DEBUG |
|
4585 ret = A.DebugState(s); |
|
4586 TESTCHECKL(ret, KErrNone); |
|
4587 TEST(s.iAccessCount == 1 ); |
|
4588 TEST(s.iMode == EIntCommShared); |
|
4589 TEST(s.iRole == aRole ); |
|
4590 TEST(s.iOutstandingCommands == 0); |
|
4591 #endif |
|
4592 A.Close(); |
|
4593 |
|
4594 delete hbuf2; |
|
4595 iDPort0.Close(); |
|
4596 csB.Close(); |
|
4597 |
|
4598 INFO_PRINTF1(_L("*** Preemption tests complete *** ")); |
|
4599 } |
|
4600 |
|
4601 void CDummyTest::ShowSignals(TUint aSig, TCommRole aRole) |
|
4602 /** |
|
4603 * Displays DCE/DTE RS232 signal values |
|
4604 */ |
|
4605 { |
|
4606 INFO_PRINTF1(_L("Signals ")); |
|
4607 if (aRole == ECommRoleDTE) |
|
4608 { |
|
4609 if (aSig&KSignalCTS) |
|
4610 INFO_PRINTF1(_L("CTS1: ")); |
|
4611 else |
|
4612 INFO_PRINTF1(_L("CTS0: ")); |
|
4613 |
|
4614 if (aSig&KSignalDSR) |
|
4615 INFO_PRINTF1(_L("DSR1: ")); |
|
4616 else |
|
4617 INFO_PRINTF1(_L("DSR0: ")); |
|
4618 |
|
4619 if (aSig&KSignalDCD) |
|
4620 INFO_PRINTF1(_L("DCD1: ")); |
|
4621 else |
|
4622 INFO_PRINTF1(_L("DCD0: ")); |
|
4623 |
|
4624 if (aSig&KSignalRNG) |
|
4625 INFO_PRINTF1(_L("RNG1: ")); |
|
4626 else |
|
4627 INFO_PRINTF1(_L("RNG0: ")); |
|
4628 if (aSig&KSignalDCEInputs) |
|
4629 INFO_PRINTF2(_L("Got DCE signals, this is wrong %X"),aSig); |
|
4630 |
|
4631 } |
|
4632 else |
|
4633 { |
|
4634 if (aSig&KSignalRTS) |
|
4635 INFO_PRINTF1(_L("RTS1: ")); |
|
4636 else |
|
4637 INFO_PRINTF1(_L("RTS0: ")); |
|
4638 |
|
4639 if (aSig&KSignalDTR) |
|
4640 INFO_PRINTF1(_L("DTR1: ")); |
|
4641 else |
|
4642 INFO_PRINTF1(_L("DTR0: ")); |
|
4643 |
|
4644 if (aSig&KSignalDTEInputs) |
|
4645 INFO_PRINTF2(_L("Got DCE signals, this is wrong %X"),aSig); |
|
4646 } |
|
4647 |
|
4648 if (aRole == ECommRoleDTE) |
|
4649 { |
|
4650 if (aSig&(KCTSChanged|KDSRChanged|KDCDChanged|KRNGChanged)) |
|
4651 INFO_PRINTF1(_L("Deltas ")); |
|
4652 } |
|
4653 else |
|
4654 { |
|
4655 if (aSig&(KRTSChanged|KDTRChanged)) |
|
4656 INFO_PRINTF1(_L("Deltas ")); |
|
4657 } |
|
4658 |
|
4659 |
|
4660 if (aRole == ECommRoleDTE) |
|
4661 { |
|
4662 if (aSig&KCTSChanged) |
|
4663 INFO_PRINTF1(_L("CTS ")); |
|
4664 if (aSig&KDSRChanged) |
|
4665 INFO_PRINTF1(_L("DSR ")); |
|
4666 if (aSig&KDCDChanged) |
|
4667 INFO_PRINTF1(_L("DCD ")); |
|
4668 if (aSig&KRNGChanged) |
|
4669 INFO_PRINTF1(_L("RNG ")); |
|
4670 } |
|
4671 else |
|
4672 { |
|
4673 if (aSig&KRTSChanged) |
|
4674 INFO_PRINTF1(_L("RTS ")); |
|
4675 if (aSig&KDTRChanged) |
|
4676 INFO_PRINTF1(_L("DTR ")); |
|
4677 } |
|
4678 } |
|
4679 |
|
4680 void CDummyTest::ShowFlow(TFlowControl aFlow) |
|
4681 /** |
|
4682 * @test Displays flowcontrol info |
|
4683 */ |
|
4684 { |
|
4685 if (aFlow==EFlowControlOn) |
|
4686 INFO_PRINTF1(_L("EFlowControlOn <XOFF> or CTS is LO or RTS is LO")); |
|
4687 else |
|
4688 INFO_PRINTF1(_L("EFlowControlOff <XON> or CTS is HI or RTS is HI")); |
|
4689 } |
|
4690 |
|
4691 void CDummyTest::ShowConfig(TCommNotificationV01 aConfig) |
|
4692 /** |
|
4693 * Displays TCommNotificationV01 values |
|
4694 */ |
|
4695 { |
|
4696 |
|
4697 INFO_PRINTF1(_L("---------------------------------------------------------------")); |
|
4698 if (aConfig.iChangedMembers&KRateChanged) |
|
4699 INFO_PRINTF1(_L("KRateChanged ")); |
|
4700 |
|
4701 if (aConfig.iChangedMembers&KDataFormatChanged) |
|
4702 INFO_PRINTF1(_L("KDataFormatChanged ")); |
|
4703 |
|
4704 if (aConfig.iChangedMembers&KHandshakeChanged) |
|
4705 INFO_PRINTF1(_L("KHandshakeChanged ")); |
|
4706 |
|
4707 INFO_PRINTF1(_L(" \n - ")); |
|
4708 switch (aConfig.iRate) |
|
4709 { |
|
4710 case EBps110: |
|
4711 INFO_PRINTF1(_L("EBps110 ")); |
|
4712 break; |
|
4713 case EBps300: |
|
4714 INFO_PRINTF1(_L("EBps300 ")); |
|
4715 break; |
|
4716 case EBps600: |
|
4717 INFO_PRINTF1(_L("EBps600 ")); |
|
4718 break; |
|
4719 case EBps1200: |
|
4720 INFO_PRINTF1(_L("EBps1200 ")); |
|
4721 break; |
|
4722 case EBps2400: |
|
4723 INFO_PRINTF1(_L("EBps2400 ")); |
|
4724 break; |
|
4725 case EBps4800: |
|
4726 INFO_PRINTF1(_L("EBps4800 ")); |
|
4727 break; |
|
4728 case EBps9600: |
|
4729 INFO_PRINTF1(_L("EBps9600 ")); |
|
4730 break; |
|
4731 case EBps19200: |
|
4732 INFO_PRINTF1(_L("EBps19200 ")); |
|
4733 break; |
|
4734 case EBps38400: |
|
4735 INFO_PRINTF1(_L("EBps38400 ")); |
|
4736 break; |
|
4737 case EBps57600: |
|
4738 INFO_PRINTF1(_L("EBps57600 ")); |
|
4739 break; |
|
4740 case EBps115200: |
|
4741 INFO_PRINTF1(_L("EBps115200 ")); |
|
4742 break; |
|
4743 case EBpsSpecial: |
|
4744 INFO_PRINTF1(_L("EBpsSpecial ")); |
|
4745 break; |
|
4746 default: |
|
4747 INFO_PRINTF1(_L("Not OK! ")); |
|
4748 } |
|
4749 |
|
4750 switch (aConfig.iDataBits) |
|
4751 { |
|
4752 case EData5: |
|
4753 INFO_PRINTF1(_L("EData5 ")); |
|
4754 break; |
|
4755 case EData6: |
|
4756 INFO_PRINTF1(_L("EData6 ")); |
|
4757 break; |
|
4758 case EData7: |
|
4759 INFO_PRINTF1(_L("EData7 ")); |
|
4760 break; |
|
4761 case EData8: |
|
4762 INFO_PRINTF1(_L("EData8 ")); |
|
4763 break; |
|
4764 default: |
|
4765 INFO_PRINTF1(_L("Not OK! ")); |
|
4766 } |
|
4767 |
|
4768 switch (aConfig.iStopBits) |
|
4769 { |
|
4770 case EStop1: |
|
4771 INFO_PRINTF1(_L("EStop1 ")); |
|
4772 break; |
|
4773 case EStop2: |
|
4774 INFO_PRINTF1(_L("EStop2 ")); |
|
4775 break; |
|
4776 default: |
|
4777 INFO_PRINTF1(_L("Not OK! ")); |
|
4778 } |
|
4779 |
|
4780 switch (aConfig.iParity) |
|
4781 { |
|
4782 case EParityNone: |
|
4783 INFO_PRINTF1(_L("EParityNone ")); |
|
4784 break; |
|
4785 case EParityEven: |
|
4786 INFO_PRINTF1(_L("EParityEven ")); |
|
4787 break; |
|
4788 case EParityOdd: |
|
4789 INFO_PRINTF1(_L("EParityOdd ")); |
|
4790 break; |
|
4791 case EParityMark: |
|
4792 INFO_PRINTF1(_L("EParityMark ")); |
|
4793 break; |
|
4794 case EParitySpace: |
|
4795 INFO_PRINTF1(_L("EParitySpace ")); |
|
4796 break; |
|
4797 default: |
|
4798 INFO_PRINTF1(_L("Not OK! ")); |
|
4799 } |
|
4800 |
|
4801 if (aConfig.iHandshake&KConfigSendXoff) |
|
4802 INFO_PRINTF1(_L("KConfigSendXoff ")); |
|
4803 |
|
4804 if (aConfig.iHandshake&KConfigObeyXoff) |
|
4805 INFO_PRINTF1(_L("KConfigObeyXoff ")); |
|
4806 |
|
4807 if (aConfig.iHandshake&KConfigObeyCTS) |
|
4808 INFO_PRINTF1(_L("KConfigObeyCTS ")); |
|
4809 |
|
4810 if (aConfig.iHandshake&KConfigObeyRTS) |
|
4811 INFO_PRINTF1(_L("KConfigObeyRTS ")); |
|
4812 |
|
4813 if (aConfig.iHandshake&KConfigObeyDTR) |
|
4814 INFO_PRINTF1(_L("KConfigObeyDTR ")); |
|
4815 |
|
4816 if (aConfig.iHandshake&KConfigObeyDSR) |
|
4817 INFO_PRINTF1(_L("KConfigObeyDSR ")); |
|
4818 |
|
4819 INFO_PRINTF1(_L("")); |
|
4820 } |
|
4821 |
|
4822 void CDummyTest::ShowCapsV01(TCommCapsV01 aCaps) |
|
4823 /** |
|
4824 * Displays capabilities TCommCapsV01 values |
|
4825 */ |
|
4826 { |
|
4827 INFO_PRINTF1(_L("iRates: ")); |
|
4828 if (aCaps.iRate&EBps50) |
|
4829 INFO_PRINTF1(_L("50 ")); |
|
4830 if (aCaps.iRate&EBps75) |
|
4831 INFO_PRINTF1(_L("75 ")); |
|
4832 if (aCaps.iRate&EBps110) |
|
4833 INFO_PRINTF1(_L("110 ")); |
|
4834 if (aCaps.iRate&EBps134) |
|
4835 INFO_PRINTF1(_L("134 ")); |
|
4836 if (aCaps.iRate&EBps150) |
|
4837 INFO_PRINTF1(_L("150 ")); |
|
4838 if (aCaps.iRate&EBps300) |
|
4839 INFO_PRINTF1(_L("300 ")); |
|
4840 if (aCaps.iRate&EBps600) |
|
4841 INFO_PRINTF1(_L("600 ")); |
|
4842 if (aCaps.iRate&EBps1200) |
|
4843 INFO_PRINTF1(_L("1200 ")); |
|
4844 if (aCaps.iRate&EBps1800) |
|
4845 INFO_PRINTF1(_L("1800 ")); |
|
4846 if (aCaps.iRate&EBps2000) |
|
4847 INFO_PRINTF1(_L("2000 ")); |
|
4848 if (aCaps.iRate&EBps4800) |
|
4849 INFO_PRINTF1(_L("4800 ")); |
|
4850 if (aCaps.iRate&EBps7200) |
|
4851 INFO_PRINTF1(_L("7200 ")); |
|
4852 if (aCaps.iRate&EBps9600) |
|
4853 INFO_PRINTF1(_L(" 9600 ")); |
|
4854 if (aCaps.iRate&EBps19200) |
|
4855 INFO_PRINTF1(_L("19200 ")); |
|
4856 if (aCaps.iRate&EBps38400) |
|
4857 INFO_PRINTF1(_L("38400 ")); |
|
4858 if (aCaps.iRate&EBps57600) |
|
4859 INFO_PRINTF1(_L("57600 ")); |
|
4860 if (aCaps.iRate&EBps115200) |
|
4861 INFO_PRINTF1(_L("115200 ")); |
|
4862 if (aCaps.iRate& static_cast<TUint>(EBpsSpecial)) |
|
4863 INFO_PRINTF1(_L("Special ")); |
|
4864 INFO_PRINTF1(_L("")); |
|
4865 |
|
4866 INFO_PRINTF1(_L("iDataBits: ")); |
|
4867 if (aCaps.iDataBits&EData5) |
|
4868 INFO_PRINTF1(_L("EData5 ")); |
|
4869 if (aCaps.iDataBits&EData6) |
|
4870 INFO_PRINTF1(_L("EData6 ")); |
|
4871 if (aCaps.iDataBits&EData7) |
|
4872 INFO_PRINTF1(_L("EData7 ")); |
|
4873 if (aCaps.iDataBits&EData8) |
|
4874 INFO_PRINTF1(_L("EData8 ")); |
|
4875 INFO_PRINTF1(_L("")); |
|
4876 |
|
4877 INFO_PRINTF1(_L("iStopBits: ")); |
|
4878 if (aCaps.iStopBits&EStop1) |
|
4879 INFO_PRINTF1(_L("EStop1 ")); |
|
4880 if (aCaps.iStopBits&EStop2) |
|
4881 INFO_PRINTF1(_L("EStop2 ")); |
|
4882 INFO_PRINTF1(_L("")); |
|
4883 |
|
4884 INFO_PRINTF1(_L("iParity: ")); |
|
4885 if (aCaps.iParity&EParityNone) |
|
4886 INFO_PRINTF1(_L("EParityNone ")); |
|
4887 if (aCaps.iParity&EParityEven) |
|
4888 INFO_PRINTF1(_L("EParityEven ")); |
|
4889 if (aCaps.iParity&EParityOdd) |
|
4890 INFO_PRINTF1(_L("EParityOdd ")); |
|
4891 if (aCaps.iParity&EParityMark) |
|
4892 INFO_PRINTF1(_L("EParityMark ")); |
|
4893 if (aCaps.iParity&EParitySpace) |
|
4894 INFO_PRINTF1(_L("EParitySpace ")); |
|
4895 INFO_PRINTF1(_L("")); |
|
4896 |
|
4897 INFO_PRINTF1(_L("iHandshake:")); |
|
4898 if (aCaps.iHandshake&KConfigSendXoff) |
|
4899 INFO_PRINTF1(_L("KConfigSendXoff ")); |
|
4900 if (aCaps.iHandshake&KConfigObeyXoff) |
|
4901 INFO_PRINTF1(_L("KConfigObeyXoff ")); |
|
4902 if (aCaps.iHandshake&KConfigObeyCTS) |
|
4903 INFO_PRINTF1(_L("KConfigObeyCTS ")); |
|
4904 if (aCaps.iHandshake&KConfigObeyRTS) |
|
4905 INFO_PRINTF1(_L("KConfigObeyRTS ")); |
|
4906 if (aCaps.iHandshake&KConfigObeyDTR) |
|
4907 INFO_PRINTF1(_L("KConfigObeyDTR ")); |
|
4908 if (aCaps.iHandshake&KConfigObeyDSR) |
|
4909 INFO_PRINTF1(_L("KConfigObeyDSR ")); |
|
4910 INFO_PRINTF1(_L("")); |
|
4911 |
|
4912 INFO_PRINTF2((_L("iSignals: %X")),aCaps.iSignals); |
|
4913 INFO_PRINTF1(_L("")); |
|
4914 |
|
4915 INFO_PRINTF2((_L("iFifo: %X")),aCaps.iFifo); |
|
4916 INFO_PRINTF1(_L("")); |
|
4917 |
|
4918 INFO_PRINTF2((_L("iSIR: %X")),aCaps.iSIR); |
|
4919 INFO_PRINTF1(_L("")); |
|
4920 } |
|
4921 |
|
4922 |
|
4923 void CDummyTest::ShowCapsV02(TCommCapsV02 aCaps) |
|
4924 /** |
|
4925 * Displays capabilities TCommCapsV02 values |
|
4926 */ |
|
4927 { |
|
4928 ShowCapsV01(aCaps); |
|
4929 |
|
4930 INFO_PRINTF2((_L("V02 iNotificationCaps: %X")),aCaps.iNotificationCaps); |
|
4931 INFO_PRINTF1(_L("")); |
|
4932 |
|
4933 INFO_PRINTF2((_L("V02 iRoleCaps: %X")),aCaps.iRoleCaps); |
|
4934 INFO_PRINTF1(_L("")); |
|
4935 |
|
4936 INFO_PRINTF2((_L("V02 iFlowControlCaps: %X")),aCaps.iFlowControlCaps); |
|
4937 INFO_PRINTF1(_L("")); |
|
4938 } |
|
4939 |
|
4940 |
|
4941 CTestDCEPort::CTestDCEPort() |
|
4942 { |
|
4943 SetTestStepName(_L("TestDCEPort")); |
|
4944 } |
|
4945 |
|
4946 TVerdict CTestDCEPort::doTestStepPreambleL() |
|
4947 { |
|
4948 return TestStepResult(); |
|
4949 } |
|
4950 |
|
4951 TVerdict CTestDCEPort::doTestStepPostambleL() |
|
4952 { |
|
4953 return TestStepResult(); |
|
4954 } |
|
4955 |
|
4956 TVerdict CTestDCEPort::doTestStepL() |
|
4957 /** |
|
4958 * @test Tests setting a comm port as a DCE |
|
4959 */ |
|
4960 { |
|
4961 INFO_PRINTF1(_L("===================================")); |
|
4962 INFO_PRINTF1(_L("Test : TestDCEPort")); |
|
4963 INFO_PRINTF1(_L("===================================")); |
|
4964 |
|
4965 return TestStepResult(); |
|
4966 } |
|
4967 |
|
4968 CTestPlatSecOpenPortDummy::CTestPlatSecOpenPortDummy() |
|
4969 { |
|
4970 SetTestStepName(_L("CTestPlatSecOpenPortDummy")); |
|
4971 } |
|
4972 |
|
4973 TVerdict CTestPlatSecOpenPortDummy::doTestStepL() |
|
4974 /** |
|
4975 * @test Check opening and closing ports with PlatSec |
|
4976 */ |
|
4977 { |
|
4978 INFO_PRINTF1(_L("===================================")); |
|
4979 INFO_PRINTF1(_L("Test : TestPlatSecOpenPortDummy")); |
|
4980 INFO_PRINTF1(_L("===================================")); |
|
4981 |
|
4982 const TInt KPlatSecEnforced=1; |
|
4983 |
|
4984 //Only run this test if PlatSec enabled |
|
4985 PlatSec::TConfigSetting aSetting(PlatSec::EPlatSecEnforcement); |
|
4986 if(PlatSec::ConfigSetting(aSetting) == KPlatSecEnforced) |
|
4987 { |
|
4988 |
|
4989 INFO_PRINTF1(_L("Opening dummy CSY")); |
|
4990 RCommServ commSession; |
|
4991 TInt res = commSession.Connect(); |
|
4992 CleanupClosePushL(commSession); |
|
4993 TESTCHECKL(res, KErrNone); |
|
4994 |
|
4995 res = commSession.LoadCommModule(KCsyName); |
|
4996 TESTCHECKL(res, KErrNone); |
|
4997 |
|
4998 _LIT(KCommPort, "Dummy::%d"); |
|
4999 RComm dummyport0; |
|
5000 RComm dummyport1; |
|
5001 RComm dummyport2; |
|
5002 RComm dummyport3; |
|
5003 |
|
5004 CleanupClosePushL(dummyport0); |
|
5005 CleanupClosePushL(dummyport1); |
|
5006 CleanupClosePushL(dummyport2); |
|
5007 CleanupClosePushL(dummyport3); |
|
5008 |
|
5009 TBuf<10> portnumber; |
|
5010 |
|
5011 //Open port 0 - should pass always |
|
5012 portnumber.Format(KCommPort, PORT_0_NOCAPS); |
|
5013 res = dummyport0.Open(commSession, portnumber, ECommShared); |
|
5014 TESTCHECKL(res, KErrNone); |
|
5015 |
|
5016 //Open port 1 - should pas because it is nrequires NetworkServices |
|
5017 portnumber.Format(KCommPort, PORT_1_NETWORKSERVICES); |
|
5018 res = dummyport1.Open(commSession, portnumber, ECommShared); |
|
5019 TESTCHECKL(res, KErrNone); |
|
5020 |
|
5021 //Open port 2 - should fail because it is not a supported port |
|
5022 portnumber.Format(KCommPort, PORT_2_NOTSUPPORT); |
|
5023 res = dummyport2.Open(commSession, portnumber, ECommShared); |
|
5024 TESTCHECKL(res, KErrPermissionDenied); |
|
5025 |
|
5026 //Open port 3 - should fail with lack of capabilities |
|
5027 portnumber.Format(KCommPort, PORT_3_ALLCAPS); |
|
5028 res = dummyport3.Open(commSession, portnumber, ECommShared); |
|
5029 TESTCHECKL(res, KErrPermissionDenied); |
|
5030 |
|
5031 //now test with a second session |
|
5032 INFO_PRINTF1(_L("Open another session")); |
|
5033 RComm ecuartport; |
|
5034 CleanupClosePushL(ecuartport); |
|
5035 |
|
5036 _LIT(KCommPortWild, "COMM::%d"); |
|
5037 TBuf<10> portstring; |
|
5038 |
|
5039 //first try and open port with incorrect name |
|
5040 _LIT(KBadProtName, "IGLOO::0"); |
|
5041 res = ecuartport.Open(iCommSession, KBadProtName, ECommShared); |
|
5042 TESTCHECKL(res, KErrPermissionDenied); |
|
5043 |
|
5044 //Go through each port 0-KMaxUnits and try to open it. |
|
5045 for(TInt port = 0;port<=KMaxUnits;port++) |
|
5046 { |
|
5047 portstring.Format(KCommPortWild, port); |
|
5048 res = ecuartport.Open(iCommSession, portstring, ECommShared); |
|
5049 INFO_PRINTF3(_L("Tried opening port=%S. Return code = %d."), &portstring, res); |
|
5050 if(res == KErrAccessDenied) |
|
5051 { |
|
5052 INFO_PRINTF1(_L("Error is KErrAccessDenied: Port is already in use disable the attachment and try again!")); |
|
5053 } |
|
5054 if(port < KMaxUnits ) |
|
5055 { |
|
5056 //we don't mind if it fails because of KErrAccessDenied or KErrNotSupported. |
|
5057 TESTCHECKCONDITIONL(res==KErrNone || res==KErrAccessDenied || res == KErrNotSupported); |
|
5058 } |
|
5059 else |
|
5060 { |
|
5061 TESTCHECKL(res, KErrPermissionDenied); |
|
5062 } |
|
5063 ecuartport.Close(); |
|
5064 } |
|
5065 dummyport0.Close(); |
|
5066 dummyport1.Close(); |
|
5067 dummyport2.Close(); |
|
5068 dummyport3.Close(); |
|
5069 |
|
5070 //delay added as dummy.csy has slow closure of ports becuase it kicks a 2sec timer off before deleting the port object. |
|
5071 User::After(5000000); |
|
5072 |
|
5073 res = commSession.UnloadCommModule(_L("Dummy")); |
|
5074 |
|
5075 iCommSession.NumPorts(res); |
|
5076 commSession.NumPorts(res); |
|
5077 |
|
5078 commSession.Close(); |
|
5079 |
|
5080 CleanupStack::PopAndDestroy(6); |
|
5081 } |
|
5082 else |
|
5083 { |
|
5084 INFO_PRINTF1(_L("No tests run as PlatSec not enforced.")); |
|
5085 } |
|
5086 |
|
5087 return TestStepResult(); |
|
5088 } |
|
5089 |
|
5090 |
|
5091 TVerdict CTestOpenWhenAvailable::doTestStepL() |
|
5092 { |
|
5093 // |
|
5094 // Note: The server is designed to support the OpenWhenAvailable request |
|
5095 // dispatched from a different RCommServ session than the one |
|
5096 // actively using the port. Testing follows this assumption. |
|
5097 // |
|
5098 _LIT(KCSYName, "LOOPBACK.CSY"); |
|
5099 _LIT(KPortName, "LOOPBACK::0"); |
|
5100 |
|
5101 // |
|
5102 // Connect to the server and load the CSY... |
|
5103 // |
|
5104 RCommServ commServ1, commServ2; |
|
5105 TInt ret; |
|
5106 |
|
5107 ret = commServ1.Connect(); |
|
5108 TESTCHECKL(ret, KErrNone); |
|
5109 CleanupClosePushL(commServ1); |
|
5110 |
|
5111 ret = commServ1.LoadCommModule(KCSYName); |
|
5112 TESTCHECKL(ret, KErrNone); |
|
5113 |
|
5114 ret = commServ2.Connect(); |
|
5115 TESTCHECKL(ret, KErrNone); |
|
5116 CleanupClosePushL(commServ2); |
|
5117 |
|
5118 ret = commServ2.LoadCommModule(KCSYName); |
|
5119 TESTCHECKL(ret, KErrNone); |
|
5120 |
|
5121 // |
|
5122 // First try OpenWhenAvailable() when nothing is holding the port... |
|
5123 // |
|
5124 INFO_PRINTF1(_L("Scenario: OpenWhenAvailable() when nothing is holding the port.")); |
|
5125 |
|
5126 TRequestStatus status; |
|
5127 |
|
5128 iSerialPortList[0].OpenWhenAvailable(status, commServ1, KPortName); |
|
5129 User::WaitForRequest(status); |
|
5130 TESTCHECK(status.Int(), KErrNone); |
|
5131 |
|
5132 ret = iSerialPortList[0].SetAccessMode(ECommExclusive); |
|
5133 TESTCHECKL(ret, KErrNone); |
|
5134 |
|
5135 // |
|
5136 // Now cancel the request (nothing should happen as the request was |
|
5137 // completed). Check that the port is still open and in use by opening |
|
5138 // the same port again. |
|
5139 // |
|
5140 INFO_PRINTF1(_L("Scenario: Cancel a completed request (nothing should happen & the port is still open).")); |
|
5141 |
|
5142 iSerialPortList[0].OpenWhenAvailableCancel(); |
|
5143 TESTCHECK(ret, KErrNone); |
|
5144 |
|
5145 ret = iSerialPortList[1].Open(commServ2, KPortName, ECommExclusive); |
|
5146 TESTCHECK(ret, KErrAccessDenied); |
|
5147 |
|
5148 iSerialPortList[0].Close(); |
|
5149 iSerialPortList[1].Close(); |
|
5150 |
|
5151 // |
|
5152 // Perform the main use case of waiting for a port to become free. |
|
5153 // |
|
5154 INFO_PRINTF1(_L("Scenario: Waiting for a port to become free.")); |
|
5155 |
|
5156 ret = iSerialPortList[0].Open(commServ1, KPortName, ECommExclusive); |
|
5157 TESTCHECK(ret, KErrNone); |
|
5158 |
|
5159 iSerialPortList[1].OpenWhenAvailable(status, commServ2, KPortName); |
|
5160 |
|
5161 User::After(5*1000000); |
|
5162 TESTCHECK(status.Int(), KRequestPending); |
|
5163 |
|
5164 iSerialPortList[0].Close(); |
|
5165 |
|
5166 User::WaitForRequest(status); |
|
5167 TESTCHECK(status.Int(), KErrNone); |
|
5168 |
|
5169 iSerialPortList[1].Close(); |
|
5170 |
|
5171 // |
|
5172 // Wait for the a port to become free but cancel the request. |
|
5173 // |
|
5174 INFO_PRINTF1(_L("Scenario: Wait for the a port to become free but cancel the request.")); |
|
5175 |
|
5176 ret = iSerialPortList[0].Open(commServ1, KPortName, ECommExclusive); |
|
5177 TESTCHECK(ret, KErrNone); |
|
5178 |
|
5179 iSerialPortList[1].OpenWhenAvailable(status, commServ2, KPortName); |
|
5180 |
|
5181 User::After(5*1000000); |
|
5182 TESTCHECK(status.Int(), KRequestPending); |
|
5183 |
|
5184 iSerialPortList[1].OpenWhenAvailableCancel(); |
|
5185 |
|
5186 User::WaitForRequest(status); |
|
5187 TESTCHECK(status.Int(), KErrCancel); |
|
5188 |
|
5189 iSerialPortList[0].Close(); |
|
5190 |
|
5191 // |
|
5192 // Wait for the a port to become free but close the sub-session. |
|
5193 // |
|
5194 INFO_PRINTF1(_L("Scenario: Wait for the a port to become free but close the sub-session.")); |
|
5195 |
|
5196 ret = iSerialPortList[0].Open(commServ1, KPortName, ECommExclusive); |
|
5197 TESTCHECK(ret, KErrNone); |
|
5198 |
|
5199 iSerialPortList[1].OpenWhenAvailable(status, commServ2, KPortName); |
|
5200 |
|
5201 User::After(5*1000000); |
|
5202 TESTCHECK(status.Int(), KRequestPending); |
|
5203 |
|
5204 iSerialPortList[1].Close(); |
|
5205 |
|
5206 User::WaitForRequest(status); |
|
5207 TESTCHECK(status.Int(), KErrCancel); |
|
5208 |
|
5209 iSerialPortList[0].Close(); |
|
5210 |
|
5211 // |
|
5212 // Clean up... |
|
5213 // |
|
5214 CleanupStack::PopAndDestroy(&commServ2); |
|
5215 CleanupStack::PopAndDestroy(&commServ1); |
|
5216 |
|
5217 return TestStepResult(); |
|
5218 } // CTestOpenWhenAvailable::doTestStepL |
|
5219 |
|
5220 |