72
|
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 |
|
|
33 |
#include "Test14HeapFreeCheck.h"
|
|
34 |
#include <comms-infras/commsbufpond.h>
|
|
35 |
// constructor
|
|
36 |
CTest14HeapFreeCheck::CTest14HeapFreeCheck()
|
|
37 |
{
|
|
38 |
SetTestStepName(_L("MBufMgrTest14"));// Store the name of this test case
|
|
39 |
}
|
|
40 |
|
|
41 |
// destructor
|
|
42 |
CTest14HeapFreeCheck::~CTest14HeapFreeCheck()
|
|
43 |
{
|
|
44 |
}
|
|
45 |
|
|
46 |
//
|
|
47 |
enum TVerdict CTest14HeapFreeCheck::doTestStepL(void)
|
|
48 |
{
|
|
49 |
SetTestStepResult(EFail);
|
|
50 |
#if defined (_DEBUG)
|
|
51 |
//-------------- substep 1 --------------------
|
|
52 |
INFO_PRINTF1(_L(" 01 Creating CMBufManager and installing active scheduler:"));
|
|
53 |
CleanupStack::PushL( iActSch = new(ELeave) CActiveScheduler );
|
|
54 |
CActiveScheduler::Install(iActSch);
|
|
55 |
CreateInstanceMBufMgrL(KMBufDefaultHeapSize);
|
|
56 |
CleanupClosePushL(iBufPond);
|
|
57 |
|
|
58 |
//-------------- substep 2 --------------------
|
|
59 |
INFO_PRINTF1(_L(" 02 Allocating two descriptors (Des1 & Des2):"));
|
|
60 |
TBuf8<1000> *aDes1, *aDes2;
|
|
61 |
CleanupStack::PushL( aDes1 = new(ELeave) TBuf8<1000> );
|
|
62 |
CleanupStack::PushL( aDes2 = new(ELeave) TBuf8<1000> );
|
|
63 |
aDes1->SetLength(1000);
|
|
64 |
aDes2->SetLength(1000);
|
|
65 |
|
|
66 |
//-------------- substep 2 --------------------
|
|
67 |
INFO_PRINTF1(_L(" 02 Set User heap to fail at the next alloc.:"));
|
|
68 |
User::__DbgSetAllocFail(RHeap::EUser, RHeap::EFailNext, 0);
|
|
69 |
|
|
70 |
//-------------- substep 3 --------------------
|
|
71 |
INFO_PRINTF1(_L(" 03 Allocate Chain1:"));
|
|
72 |
RMBufChain aChain1;
|
|
73 |
TRAPD(ret,aChain1.AllocL(1000));
|
|
74 |
if (ret != KErrNone)
|
|
75 |
{
|
|
76 |
INFO_PRINTF1(_L("Error: Couldn't allocate Chain1:"));
|
|
77 |
User::__DbgSetAllocFail(RHeap::EUser, RHeap::ENone, 0);
|
|
78 |
User::Leave(EFail);
|
|
79 |
}
|
|
80 |
|
|
81 |
//-------------- substep 4 --------------------
|
|
82 |
INFO_PRINTF1(_L(" 04 Copy in Des1 into Chain1:"));
|
|
83 |
aChain1.CopyIn(*aDes1);
|
|
84 |
|
|
85 |
//-------------- substep 5 --------------------
|
|
86 |
INFO_PRINTF1(_L(" 05 Split Chain1. The 2nd part goes to Chain2:"));
|
|
87 |
RMBufChain aChain2;
|
|
88 |
TRAP(ret,aChain1.SplitL(300, aChain2));
|
|
89 |
if (ret != KErrNone)
|
|
90 |
{
|
|
91 |
INFO_PRINTF1(_L("Error: Couldn't Split"));
|
|
92 |
aChain1.Free();
|
|
93 |
aChain2.Free();
|
|
94 |
User::__DbgSetAllocFail(RHeap::EUser, RHeap::ENone, 0);
|
|
95 |
User::Leave(EFail);
|
|
96 |
}
|
|
97 |
|
|
98 |
//-------------- substep 6 --------------------
|
|
99 |
INFO_PRINTF1(_L(" 06 Copy out Chain1 into Des2:"));
|
|
100 |
aChain1.CopyOut(*aDes2);
|
|
101 |
|
|
102 |
//-------------- substep 7 --------------------
|
|
103 |
INFO_PRINTF1(_L(" 07 Copy Chain1 into Chain3:"));
|
|
104 |
RMBufChain aChain3;
|
|
105 |
aChain1.CopyL(aChain3,0, 200);
|
|
106 |
|
|
107 |
//-------------- substep 8 --------------------
|
|
108 |
INFO_PRINTF1(_L(" 08 Free the chains. Clean up stack:"));
|
|
109 |
aChain1.Free();
|
|
110 |
aChain2.Free();
|
|
111 |
aChain3.Free();
|
|
112 |
User::__DbgSetAllocFail(RHeap::EUser, RHeap::ENone, 0);
|
|
113 |
CleanupStack::PopAndDestroy(aDes2);
|
|
114 |
CleanupStack::PopAndDestroy(aDes1);
|
|
115 |
CleanupStack::PopAndDestroy();
|
|
116 |
CActiveScheduler::Install(NULL);
|
|
117 |
CleanupStack::PopAndDestroy(iActSch);
|
|
118 |
SetTestStepResult(EPass);
|
|
119 |
|
|
120 |
return TestStepResult();
|
|
121 |
#else
|
|
122 |
INFO_PRINTF1(_L("Info: Test Disabled on release build"));
|
|
123 |
SetTestStepResult(EPass);
|
|
124 |
|
|
125 |
return TestStepResult();
|
|
126 |
#endif
|
|
127 |
}
|