|
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 IPC Test 08 |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 |
|
21 // Test system includes |
|
22 #include "Test08IPCOpenSocketMemoryLeak.h" |
|
23 |
|
24 const TDesC& CTest08IPCOpenSocketMemoryLeak::GetTestName() |
|
25 { |
|
26 _LIT(ret,"IPCTest08"); |
|
27 return ret; |
|
28 } |
|
29 |
|
30 enum TVerdict CTest08IPCOpenSocketMemoryLeak::InternalDoTestStepL() |
|
31 { |
|
32 |
|
33 #if defined (_DEBUG_SOCKET_FUNCTIONS) |
|
34 //-------------------substep 00----------------------------- |
|
35 _LIT(aLog00,"00 Open socket server:"); Logger().Write(aLog00); |
|
36 TInt err; |
|
37 RSocketServ ss; |
|
38 CleanupClosePushL(ss); |
|
39 if ( (err = OptimalConnect(ss)) != KErrNone ) |
|
40 { |
|
41 Logger().WriteFormat(_L("Connecting to socket server failed with %d"), err); |
|
42 User::Leave(EFail); |
|
43 } |
|
44 |
|
45 //-------------------substep 01----------------------------- |
|
46 Logger().Write(_L("01 Set heap to fails after N=0 allocations...")); |
|
47 Logger().Write(_L(" ...Try to Open a socket. If it returns error, check memory leak.")); |
|
48 Logger().Write(_L(" ...Increase N by one and repeat the same untill open-socket returns NoError:")); |
|
49 |
|
50 RSocket aSock; |
|
51 CleanupClosePushL(aSock); |
|
52 RSocket aSockets[16]; |
|
53 |
|
54 TInt aFailure = 0; |
|
55 TInt i; |
|
56 for (i=0; i < 16; i++) |
|
57 CleanupClosePushL(aSockets[i]); |
|
58 |
|
59 for (i=0;i<16;i++) |
|
60 { |
|
61 if ((err = aSockets[i].Open(ss, iProt)) != KErrNone) |
|
62 { |
|
63 Logger().WriteFormat(_L("Error: Open socket error %d"), err); |
|
64 User::Leave(EFail); |
|
65 } |
|
66 } |
|
67 |
|
68 CleanupStack::Pop(&aSockets[15]); |
|
69 for (i=14; i >= 0; i--) |
|
70 { |
|
71 CleanupStack::PopAndDestroy(&aSockets[i]); |
|
72 } |
|
73 |
|
74 do |
|
75 { |
|
76 ss.__DbgFailNext(aFailure); |
|
77 ss.__DbgMarkHeap(); |
|
78 |
|
79 err = aSock.Open(ss, iProt); |
|
80 |
|
81 if (err != KErrNone) |
|
82 { |
|
83 ss.__DbgMarkEnd(0); |
|
84 } |
|
85 aFailure++; |
|
86 } while (err != KErrNone); |
|
87 |
|
88 // To flush the hanging __DbgFailNext |
|
89 ss.__DbgFailNext(-1); |
|
90 Logger().WriteFormat(_L("Info: Loop has passed %d times"), aFailure - 1); |
|
91 |
|
92 aSockets[15].Close(); |
|
93 |
|
94 //-------------------substep 02----------------------------- |
|
95 Logger().WriteFormat(_L("02 Close the socket & socket server")); |
|
96 CleanupStack::PopAndDestroy(2, &ss); |
|
97 return EPass; |
|
98 #else |
|
99 Logger().WriteFormat(_L("Info: Test Disabled on release build")); |
|
100 return EPass; |
|
101 #endif |
|
102 |
|
103 } |
|
104 |