|
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 14 that check rmbud does not use heap allocation |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 //#include <e32cmn.h> // maybe this is needed for eka2 ? |
|
21 #include <e32std.h> |
|
22 |
|
23 // Test system includes |
|
24 #ifdef SYMBIAN_OLD_EXPORT_LOCATION |
|
25 #include "networking/log.h" |
|
26 #include "networking/teststep.h" |
|
27 #else |
|
28 #include <networking/log.h> |
|
29 #include <networking/teststep.h> |
|
30 #endif |
|
31 #include "TestStepCTMbufmgr.h" |
|
32 #include "TestSuiteCTMbufmgr.h" |
|
33 |
|
34 #include "Test14HeapFreeCheck.h" |
|
35 #include <comms-infras/commsbufpond.h> |
|
36 // constructor |
|
37 CTest14HeapFreeCheck::CTest14HeapFreeCheck() |
|
38 { |
|
39 iTestStepName = _L("MBufMgrTest14");// Store the name of this test case |
|
40 } |
|
41 |
|
42 // destructor |
|
43 CTest14HeapFreeCheck::~CTest14HeapFreeCheck() |
|
44 { |
|
45 } |
|
46 |
|
47 // |
|
48 enum TVerdict CTest14HeapFreeCheck::doTestStepL(void) |
|
49 { |
|
50 #if defined (_DEBUG) |
|
51 __UHEAP_MARK; |
|
52 |
|
53 #ifdef __CFLOG_ACTIVE |
|
54 __CFLOG_CREATEL; |
|
55 __CFLOG_OPEN; |
|
56 #endif |
|
57 |
|
58 //-------------- substep 1 -------------------- |
|
59 Log(_L(" 01 Creating CMBufManager and installing active scheduler:")); |
|
60 CleanupStack::PushL( iActSch = new(ELeave) CActiveScheduler ); |
|
61 CActiveScheduler::Install(iActSch); |
|
62 CreateInstanceMBufMgrL(KMBufDefaultHeapSize); |
|
63 CleanupClosePushL(iBufPond); |
|
64 |
|
65 //-------------- substep 2 -------------------- |
|
66 Log(_L(" 02 Allocating two descriptors (Des1 & Des2):")); |
|
67 TBuf8<1000> *aDes1, *aDes2; |
|
68 CleanupStack::PushL( aDes1 = new(ELeave) TBuf8<1000> ); |
|
69 CleanupStack::PushL( aDes2 = new(ELeave) TBuf8<1000> ); |
|
70 aDes1->SetLength(1000); |
|
71 aDes2->SetLength(1000); |
|
72 |
|
73 //-------------- substep 2 -------------------- |
|
74 Log(_L(" 02 Set User heap to fail at the next alloc.:")); |
|
75 User::__DbgSetAllocFail(RHeap::EUser, RHeap::EFailNext, 0); |
|
76 |
|
77 //-------------- substep 3 -------------------- |
|
78 Log(_L(" 03 Allocate Chain1:")); |
|
79 RMBufChain aChain1; |
|
80 TRAPD(ret,aChain1.AllocL(1000)); |
|
81 if (ret != KErrNone) |
|
82 { |
|
83 Log(_L("Error: Couldn't allocate Chain1:")); |
|
84 User::__DbgSetAllocFail(RHeap::EUser, RHeap::ENone, 0); |
|
85 |
|
86 #ifdef __CFLOG_ACTIVE |
|
87 __CFLOG_CLOSE; |
|
88 __CFLOG_DELETE; |
|
89 #endif |
|
90 User::Leave(EFail); |
|
91 } |
|
92 |
|
93 //-------------- substep 4 -------------------- |
|
94 Log(_L(" 04 Copy in Des1 into Chain1:")); |
|
95 aChain1.CopyIn(*aDes1); |
|
96 |
|
97 //-------------- substep 5 -------------------- |
|
98 Log(_L(" 05 Split Chain1. The 2nd part goes to Chain2:")); |
|
99 RMBufChain aChain2; |
|
100 TRAP(ret,aChain1.SplitL(300, aChain2)); |
|
101 if (ret != KErrNone) |
|
102 { |
|
103 Log(_L("Error: Couldn't Split")); |
|
104 aChain1.Free(); |
|
105 aChain2.Free(); |
|
106 User::__DbgSetAllocFail(RHeap::EUser, RHeap::ENone, 0); |
|
107 |
|
108 #ifdef __CFLOG_ACTIVE |
|
109 __CFLOG_CLOSE; |
|
110 __CFLOG_DELETE; |
|
111 #endif |
|
112 User::Leave(EFail); |
|
113 } |
|
114 |
|
115 //-------------- substep 6 -------------------- |
|
116 Log(_L(" 06 Copy out Chain1 into Des2:")); |
|
117 aChain1.CopyOut(*aDes2); |
|
118 |
|
119 //-------------- substep 7 -------------------- |
|
120 Log(_L(" 07 Copy Chain1 into Chain3:")); |
|
121 RMBufChain aChain3; |
|
122 aChain1.CopyL(aChain3,0, 200); |
|
123 |
|
124 //-------------- substep 8 -------------------- |
|
125 Log(_L(" 08 Free the chains. Clean up stack:")); |
|
126 aChain1.Free(); |
|
127 aChain2.Free(); |
|
128 aChain3.Free(); |
|
129 User::__DbgSetAllocFail(RHeap::EUser, RHeap::ENone, 0); |
|
130 CleanupStack::PopAndDestroy(aDes2); |
|
131 CleanupStack::PopAndDestroy(aDes1); |
|
132 CleanupStack::PopAndDestroy(); |
|
133 CActiveScheduler::Install(NULL); |
|
134 CleanupStack::PopAndDestroy(iActSch); |
|
135 |
|
136 #ifdef __CFLOG_ACTIVE |
|
137 __CFLOG_CLOSE; |
|
138 __CFLOG_DELETE; |
|
139 #endif |
|
140 |
|
141 __UHEAP_MARKEND; |
|
142 return EPass; |
|
143 #else |
|
144 Log(_L("Info: Test Disabled on release build")); |
|
145 return EPass; |
|
146 #endif |
|
147 } |