|
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 // Contains declaration of CTestStepSocket class that is |
|
15 // base class for all test step classes in this test. |
|
16 // |
|
17 // |
|
18 |
|
19 #if (!defined __TESTSTEPSOCKET_H__) |
|
20 #define __TESTSTEPSOCKET_H__ |
|
21 #include <in_sock.h> |
|
22 #include <test/testexecutestepbase.h> |
|
23 |
|
24 |
|
25 class CTestStepSocket : public CTestStep |
|
26 { |
|
27 public: |
|
28 CTestStepSocket(); |
|
29 ~CTestStepSocket(); |
|
30 |
|
31 struct TSocketThreadArg |
|
32 { |
|
33 CTestStepSocket* iHandle; |
|
34 RSemaphore* iSem; |
|
35 TUint iNumSockets; |
|
36 }; |
|
37 |
|
38 protected: |
|
39 |
|
40 const TPtrC& EpocErrorToText(const TInt aErrCode); |
|
41 enum TVerdict doTestStepL(); |
|
42 virtual enum TVerdict InternalDoTestStepL() =0; |
|
43 |
|
44 // test threads |
|
45 static TInt ConnectThread(TAny * anArg); |
|
46 static TInt SocketThread(TAny * anArg); |
|
47 static TInt BadHandleThread(TAny* anArg); |
|
48 static TInt ReadTwiceThread(TAny* anArg); |
|
49 static TInt BadDescriptorThread(TAny* anArg); |
|
50 |
|
51 static TInt OptimalConnect(RSocketServ &aSrv); |
|
52 |
|
53 // Helpers for test threads |
|
54 static void DoCreateSubsessionsL(CTestStepSocket *aTestStep, TInt aNumSubsess); |
|
55 |
|
56 static const TUint KNumTestSockets; |
|
57 static const TInt KNumExhaustiveSockets; |
|
58 static const TInt KNumStretchOpens; |
|
59 |
|
60 private: |
|
61 TPtrC iErrText; |
|
62 TBuf<16> iErrBuf; // size must at least satisfy the number of digits used to represent a TInt |
|
63 }; |
|
64 |
|
65 |
|
66 class CSocketTestStep_OOMCapable : public CTestStepSocket |
|
67 { |
|
68 public: |
|
69 ~CSocketTestStep_OOMCapable() |
|
70 { |
|
71 iOOMSess.Close(); |
|
72 } |
|
73 |
|
74 void SetHeapFailNext(TInt aFailureIndex) |
|
75 { |
|
76 if(iOOMSess.Handle() == KNullHandle) |
|
77 { |
|
78 iOOMSess.Connect(); |
|
79 } |
|
80 if(iOOMSess.Handle() != KNullHandle) |
|
81 { |
|
82 iOOMSess.__DbgFailNext(aFailureIndex - 1); // want to start with 0th |
|
83 } |
|
84 } |
|
85 |
|
86 void ResetHeapFailNext() |
|
87 { |
|
88 if(iOOMSess.Handle() != KNullHandle) |
|
89 { |
|
90 iOOMSess.__DbgFailNext(-1); |
|
91 } |
|
92 } |
|
93 |
|
94 TBool CheckForHeapFailNext(); |
|
95 virtual enum TVerdict InternalDoTestStepL() =0; |
|
96 private: |
|
97 RSocketServ iOOMSess; |
|
98 }; |
|
99 |
|
100 |
|
101 |
|
102 #endif /* __TESTSTEPSOCKET_H__ */ |
|
103 |