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