|
1 // Copyright (c) 2001-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 definition of CTestStepCTMbufmgr which is the base class |
|
15 // for all the Mbufmgr Test Step classes |
|
16 // |
|
17 // |
|
18 |
|
19 // EPOC includes |
|
20 //#include <e32base.h> |
|
21 //#include <es_sock.h> |
|
22 |
|
23 // Test system includes |
|
24 #include <es_mbuf.h> |
|
25 |
|
26 //#ifdef SYMBIAN_OLD_EXPORT_LOCATION |
|
27 //#include "networking/log.h" |
|
28 //#include "networking/teststep.h" |
|
29 //#include "networking/testsuite.h" |
|
30 //#else |
|
31 //#include <networking/log.h> |
|
32 //#include <networking/teststep.h> |
|
33 //#include <networking/testsuite.h> |
|
34 //#endif |
|
35 |
|
36 #include "TestStepCTMbufmgr.h" |
|
37 #include <comms-infras/commsbufpond.h> |
|
38 #include <comms-infras/commsbufpondop.h> |
|
39 |
|
40 // constructor |
|
41 CTestStepCTMbufmgr::CTestStepCTMbufmgr() |
|
42 { |
|
43 } |
|
44 |
|
45 // destructor |
|
46 CTestStepCTMbufmgr::~CTestStepCTMbufmgr() |
|
47 { |
|
48 } |
|
49 |
|
50 void CTestStepCTMbufmgr::StripeMem(TUint8 *aBuf, |
|
51 TInt aStartPos, |
|
52 TInt anEndPos, |
|
53 TUint aStartChar, |
|
54 TUint anEndChar) |
|
55 { |
|
56 TUint character=aStartChar; |
|
57 for (TInt i=aStartPos;i<anEndPos;i++) |
|
58 { |
|
59 aBuf[i]=(TText8)character; |
|
60 if(++character>anEndChar) character=aStartChar; |
|
61 } |
|
62 } |
|
63 |
|
64 void CTestStepCTMbufmgr::StripeDes(TDes8 &aBuf, |
|
65 TInt aStartPos, |
|
66 TInt anEndPos, |
|
67 TUint aStartChar, |
|
68 TUint anEndChar) |
|
69 // Mark a buffer with repeating byte pattern |
|
70 { |
|
71 __ASSERT_ALWAYS(aStartChar<=anEndChar, User::Panic(_L("MBufTest"),0)); |
|
72 __ASSERT_ALWAYS(aStartPos<=anEndPos, User::Panic(_L("MBufTest"),0)); |
|
73 __ASSERT_ALWAYS(anEndPos<=aBuf.Length(), User::Panic(_L("MBufTest"),0)); |
|
74 |
|
75 StripeMem((TUint8 *)aBuf.Ptr(), aStartPos, anEndPos, aStartChar, anEndChar); |
|
76 } |
|
77 |
|
78 // create an mbuf manager instance with some arbitrary default mbuf size alloc info |
|
79 // - refer CMBufManager::NewL notes regarding explaination of why this is deliberately not done within the mbuf manager |
|
80 static const TInt KMBuf_MBufSize = 128; |
|
81 static const TInt KMBuf_MinGrowth = 64; |
|
82 static const TInt KMBuf_GrowthThreshold = 40; |
|
83 #define SYMBIAN_MBUFMGR_BACKGROUND_ALLOCATION |
|
84 #ifndef SYMBIAN_MBUFMGR_BACKGROUND_ALLOCATION |
|
85 static const TInt KMBuf_InitialAllocation = 128; |
|
86 #endif |
|
87 void CTestStepCTMbufmgr::CreateInstanceMBufMgrL(TInt aMaxHeapSize) |
|
88 { |
|
89 |
|
90 RArray<TCommsBufPoolCreateInfo> poolInfoArray; |
|
91 TCommsBufPoolCreateInfo createInfo; |
|
92 #ifdef SYMBIAN_MBUFMGR_BACKGROUND_ALLOCATION |
|
93 |
|
94 // this method used for tests that dont do background allocation so make the |
|
95 // pool big enough to fill the heap |
|
96 createInfo.iBufSize = KMBuf_MBufSize; |
|
97 createInfo.iInitialBufs = (aMaxHeapSize/(KMBuf_MBufSize+sizeof(RMBuf)))-1; |
|
98 createInfo.iGrowByBufs = KMBuf_MinGrowth; |
|
99 createInfo.iMinFreeBufs = KMBuf_GrowthThreshold; |
|
100 createInfo.iCeiling = aMaxHeapSize/KMBuf_MBufSize; |
|
101 #else |
|
102 createInfo.iBufSize = KMBuf_MBufSize; |
|
103 createInfo.iInitialBufs = KMBuf_InitialAllocation; |
|
104 createInfo.iGrowByBufs = KMBuf_MinGrowth; |
|
105 createInfo.iMinFreeBufs = KMBuf_GrowthThreshold; |
|
106 createInfo.iCeiling = aMaxHeapSize/KMBuf_MBufSize; |
|
107 #endif |
|
108 poolInfoArray.Append ( createInfo ); |
|
109 |
|
110 User::LeaveIfError(iBufPond.Open(poolInfoArray)); |
|
111 poolInfoArray.Close (); |
|
112 } |
|
113 |
|
114 void CTestStepCTMbufmgr::CreateInstanceMBufMgrL(RArray<TCommsBufPoolCreateInfo>& aPoolCreateInfo) |
|
115 { |
|
116 User::LeaveIfError(iBufPond.Open(aPoolCreateInfo)); |
|
117 } |