|
1 // Copyright (c) 2002-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 MBufMgr Test Step 03 |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 |
|
21 // Test system includes |
|
22 #ifdef SYMBIAN_OLD_EXPORT_LOCATION |
|
23 #include "networking/log.h" |
|
24 #include "networking/teststep.h" |
|
25 #else |
|
26 #include <networking/log.h> |
|
27 #include <networking/teststep.h> |
|
28 #endif |
|
29 #include "TestStepCTMbufmgr.h" |
|
30 #include "TestSuiteCTMbufmgr.h" |
|
31 |
|
32 #include "Test03AllocLeave.h" |
|
33 #include <comms-infras/commsbufpond.h> |
|
34 |
|
35 // constructor |
|
36 CTest03AllocLeave::CTest03AllocLeave() |
|
37 { |
|
38 iTestStepName = _L("MBufMgrTest03");// Store the name of this test case |
|
39 } |
|
40 |
|
41 // destructor |
|
42 CTest03AllocLeave::~CTest03AllocLeave() |
|
43 { |
|
44 } |
|
45 |
|
46 // |
|
47 enum TVerdict CTest03AllocLeave::doTestStepL(void) |
|
48 { |
|
49 __UHEAP_MARK; |
|
50 |
|
51 #ifdef __CFLOG_ACTIVE |
|
52 __CFLOG_CREATEL; |
|
53 __CFLOG_OPEN; |
|
54 #endif |
|
55 |
|
56 TVerdict verdict(EFail); |
|
57 //-------------- substep 1 -------------------- |
|
58 Log(_L(" 01 Create CMBufManager (with 15K alloc memory) and install active scheduler:")); |
|
59 CleanupStack::PushL( iActSch = new(ELeave) CActiveScheduler ); |
|
60 CActiveScheduler::Install(iActSch); |
|
61 |
|
62 CreateInstanceMBufMgrL(65536); |
|
63 CleanupClosePushL(iBufPond); |
|
64 //-------------- substep 2 -------------------- |
|
65 RMBuf* mbufs[14]; |
|
66 TInt i; |
|
67 Log(_L(" 02 Allocate 42000-bytes long worth of mbufs")); |
|
68 for (i = 0; i < sizeof(mbufs)/sizeof(mbufs[0]); ++i) |
|
69 { |
|
70 mbufs[i] = static_cast<RMBuf*>(iBufPond.Alloc(3000, 0, KMaxTInt)); |
|
71 // Log(_L(" Heap Size after %d allocs : %d"),i,iMBMngr->__DbgGetHeapSize()); |
|
72 if (mbufs[i] == NULL) |
|
73 { |
|
74 Log(_L("Error: Couldn't allocate RMBuf:")); |
|
75 |
|
76 #ifdef __CFLOG_ACTIVE |
|
77 __CFLOG_CLOSE; |
|
78 __CFLOG_DELETE; |
|
79 #endif |
|
80 User::Leave(EFail); |
|
81 } |
|
82 } |
|
83 |
|
84 |
|
85 //-------------- substep 3 -------------------- |
|
86 Log(_L(" 03 Allocate 8192-bytes long RMBuf2:")); |
|
87 RMBuf* aMBuf2 = NULL; |
|
88 RMBufChain chain; |
|
89 TInt ret; |
|
90 TRAP(ret,chain.AllocL(16384);) |
|
91 if (ret != KErrNone) |
|
92 { |
|
93 Log(_L("Info: Couldn't allocate RMBuf as it should be so.")); |
|
94 if (ret == KErrNoMBufs) |
|
95 verdict = EPass; |
|
96 else |
|
97 { |
|
98 Log(_L("Error: The reason AllocL has failed with %d"),KErrNoMBufs); |
|
99 verdict = EFail; |
|
100 } |
|
101 } |
|
102 // Log(_L(" Heap Size after failed alloc %d"),iMBMngr->__DbgGetHeapSize()); |
|
103 // Cleanup . |
|
104 //-------------- substep 4 -------------------- |
|
105 Log(_L(" 04 Deallocate RMBufs (1, 2 & 3):")); |
|
106 for (i = 0; i < sizeof(mbufs)/sizeof(mbufs[0]); ++i) |
|
107 { |
|
108 mbufs[i]->Free(); |
|
109 } |
|
110 |
|
111 if (aMBuf2 != NULL) |
|
112 aMBuf2->Free(); |
|
113 |
|
114 //-------------- substep 5 -------------------- |
|
115 Log(_L(" 05 Clean up stack:")); |
|
116 CleanupStack::PopAndDestroy(); |
|
117 CActiveScheduler::Install(NULL); |
|
118 CleanupStack::PopAndDestroy(iActSch); |
|
119 |
|
120 #ifdef __CFLOG_ACTIVE |
|
121 __CFLOG_CLOSE; |
|
122 __CFLOG_DELETE; |
|
123 #endif |
|
124 __UHEAP_MARKEND; |
|
125 return verdict; |
|
126 } |