|
1 // Copyright (c) 2004-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 // This contains ESock Test cases from section 12 |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 #include <ss_std.h> |
|
21 #include <e32std.h> |
|
22 #include <e32kpan.h> |
|
23 |
|
24 // Test system includes |
|
25 |
|
26 #include "SocketTestSection12.h" |
|
27 |
|
28 // vc doesn't like taking address of t.ExitCategory() for logging |
|
29 #pragma warning (disable:4238) |
|
30 |
|
31 // Test step 12.1 |
|
32 const TDesC& CSocketTest12_1::GetTestName() |
|
33 { |
|
34 _LIT(ret,"Test12.1"); |
|
35 return ret; |
|
36 } |
|
37 |
|
38 enum TVerdict CSocketTest12_1::InternalDoTestStepL( void ) |
|
39 { |
|
40 TVerdict verdict = EPass; |
|
41 |
|
42 Logger().WriteFormat(_L("Test Purpose: Panic Client using a Bad Handle")); |
|
43 |
|
44 // stop debugger crashing |
|
45 TBool oldJit = User::JustInTime(); |
|
46 User::SetJustInTime(EFalse); |
|
47 |
|
48 Logger().WriteFormat(_L("Creating thread which uses a bad handle")); |
|
49 RThread t; |
|
50 |
|
51 TSocketThreadArg tArg; |
|
52 tArg.iHandle = this; |
|
53 tArg.iSem = NULL; |
|
54 tArg.iNumSockets = 0; |
|
55 |
|
56 //Need to share logger across different threads |
|
57 Logger().ShareAuto(); |
|
58 TInt ret = t.Create(_L("BadHandle"), BadHandleThread, KDefaultStackSize, |
|
59 KDefaultHeapSize, KDefaultHeapSize, &tArg); |
|
60 CleanupClosePushL(t); |
|
61 Logger().WriteFormat(_L("Create returned %S"), &EpocErrorToText(ret)); |
|
62 TESTL(KErrNone == ret); |
|
63 |
|
64 Logger().WriteFormat(_L("Logging on and resuming thread")); |
|
65 TRequestStatus stat; |
|
66 t.Logon(stat); |
|
67 t.Resume(); |
|
68 User::WaitForRequest(stat); |
|
69 TPtrC catName = t.ExitCategory(); |
|
70 Logger().WriteFormat(_L("Thread Exit Category '%S', Reason %d, Type %d"), |
|
71 &catName, t.ExitReason(), t.ExitType()); |
|
72 TESTL(t.ExitCategory() == KESockClientPanic); |
|
73 TESTL(EBadHandle == t.ExitReason()); |
|
74 TESTL(EExitPanic == t.ExitType()); |
|
75 |
|
76 CleanupStack::PopAndDestroy(&t); |
|
77 |
|
78 // reset JIT state |
|
79 User::SetJustInTime(oldJit); |
|
80 |
|
81 SetTestStepResult(verdict); |
|
82 return verdict; |
|
83 } |
|
84 |
|
85 // Test step 12.2 |
|
86 const TDesC& CSocketTest12_2::GetTestName() |
|
87 { |
|
88 _LIT(ret,"Test12.2"); |
|
89 return ret; |
|
90 } |
|
91 |
|
92 enum TVerdict CSocketTest12_2::InternalDoTestStepL( void ) |
|
93 { |
|
94 TVerdict verdict = EPass; |
|
95 |
|
96 Logger().WriteFormat(_L("Test Purpose: Panic for Reading Twice")); |
|
97 |
|
98 // stop debugger crashing |
|
99 TBool oldJit = User::JustInTime(); |
|
100 User::SetJustInTime(EFalse); |
|
101 |
|
102 Logger().WriteFormat(_L("Creating thread which reads twice")); |
|
103 RThread t; |
|
104 TSocketThreadArg tArg; |
|
105 tArg.iHandle = this; |
|
106 tArg.iSem = NULL; |
|
107 tArg.iNumSockets = 0; |
|
108 //Need to share logger across different threads |
|
109 Logger().ShareAuto(); |
|
110 TInt ret = t.Create(_L("ReadTwice"), ReadTwiceThread, KDefaultStackSize, |
|
111 KDefaultHeapSize, KDefaultHeapSize, &tArg); |
|
112 CleanupClosePushL(t); |
|
113 Logger().WriteFormat(_L("Create returned %S"), &EpocErrorToText(ret)); |
|
114 TESTL(KErrNone == ret); |
|
115 |
|
116 Logger().WriteFormat(_L("Logging on and resuming thread")); |
|
117 TRequestStatus stat; |
|
118 t.Logon(stat); |
|
119 t.Resume(); |
|
120 User::WaitForRequest(stat); |
|
121 TPtrC catName = t.ExitCategory(); |
|
122 Logger().WriteFormat(_L("Thread Exit Category '%S', Reason %d, Type %d"), |
|
123 &catName, t.ExitReason(), t.ExitType()); |
|
124 TESTL(t.ExitCategory() == KESockClientPanic ); |
|
125 TESTL(EReadingAlready == t.ExitReason()); |
|
126 TESTL(EExitPanic == t.ExitType()); |
|
127 |
|
128 CleanupStack::PopAndDestroy(&t); |
|
129 |
|
130 // reset JIT state |
|
131 User::SetJustInTime(oldJit); |
|
132 |
|
133 SetTestStepResult(verdict); |
|
134 return verdict; |
|
135 } |
|
136 |
|
137 |