|
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 // Test system includes |
|
19 #include <networking/log.h> |
|
20 #include <networking/teststep.h> |
|
21 #include "TestStepCTMbufmgr.h" |
|
22 #include "TestSuiteCTMbufmgr.h" |
|
23 #include <networking/testsuite.h> |
|
24 |
|
25 // constructor |
|
26 CTestStepCTMbufmgr::CTestStepCTMbufmgr() |
|
27 { |
|
28 } |
|
29 |
|
30 // destructor |
|
31 CTestStepCTMbufmgr::~CTestStepCTMbufmgr() |
|
32 { |
|
33 } |
|
34 |
|
35 void CTestStepCTMbufmgr::StripeMem(TUint8 *aBuf, |
|
36 TInt aStartPos, |
|
37 TInt anEndPos, |
|
38 TUint aStartChar, |
|
39 TUint anEndChar) |
|
40 { |
|
41 TUint character=aStartChar; |
|
42 for (TInt i=aStartPos;i<anEndPos;i++) |
|
43 { |
|
44 aBuf[i]=(TText8)character; |
|
45 if(++character>anEndChar) character=aStartChar; |
|
46 } |
|
47 } |
|
48 |
|
49 void CTestStepCTMbufmgr::StripeDes(TDes8 &aBuf, |
|
50 TInt aStartPos, |
|
51 TInt anEndPos, |
|
52 TUint aStartChar, |
|
53 TUint anEndChar) |
|
54 // Mark a buffer with repeating byte pattern |
|
55 { |
|
56 __ASSERT_ALWAYS(aStartChar<=anEndChar, User::Panic(_L("MBufTest"),0)); |
|
57 __ASSERT_ALWAYS(aStartPos<=anEndPos, User::Panic(_L("MBufTest"),0)); |
|
58 __ASSERT_ALWAYS(anEndPos<=aBuf.Length(), User::Panic(_L("MBufTest"),0)); |
|
59 |
|
60 StripeMem((TUint8 *)aBuf.Ptr(), aStartPos, anEndPos, aStartChar, anEndChar); |
|
61 } |
|
62 |
|
63 // create an mbuf manager instance with some arbitrary default mbuf size alloc info |
|
64 // - refer CMBufManager::NewL notes regarding explaination of why this is deliberately not done within the mbuf manager |
|
65 static const TInt KMBuf_MBufSize = 128; |
|
66 static const TInt KMBuf_MinGrowth = 64; |
|
67 static const TInt KMBuf_GrowthThreshold = 40; |
|
68 #define SYMBIAN_MBUFMGR_BACKGROUND_ALLOCATION |
|
69 #ifndef SYMBIAN_MBUFMGR_BACKGROUND_ALLOCATION |
|
70 static const TInt KMBuf_InitialAllocation = 128; |
|
71 #endif |
|
72 CMBufManager * CTestStepCTMbufmgr::CreateInstanceMBufMgrL(TInt aMaxHeapSize) |
|
73 { |
|
74 MMBufSizeAllocator* mbufSizeAllocator; |
|
75 CMBufManager* mngr; |
|
76 mngr = CreateInstanceMBufMgrL(aMaxHeapSize, mbufSizeAllocator); |
|
77 if (iMBMngr) |
|
78 { |
|
79 #ifdef SYMBIAN_MBUFMGR_BACKGROUND_ALLOCATION |
|
80 // this method used for tests that dont do background allocation so make the |
|
81 // pool big enough to fill the heap |
|
82 mbufSizeAllocator->AddL(KMBuf_MBufSize, (aMaxHeapSize/(KMBuf_MBufSize+sizeof(RMBuf)))-1, KMBuf_MinGrowth, KMBuf_GrowthThreshold); |
|
83 #else |
|
84 mbufSizeAllocator->AddL(KMBuf_MBufSize, KMBuf_InitialAllocation, KMBuf_MinGrowth, KMBuf_GrowthThreshold); |
|
85 #endif |
|
86 } |
|
87 return mngr; |
|
88 } |
|
89 |
|
90 CMBufManager * CTestStepCTMbufmgr::CreateInstanceMBufMgrL(TInt aMaxHeapSize, MMBufSizeAllocator* &aMBufSizeAllocator) |
|
91 { |
|
92 __ASSERT_ALWAYS(aMaxHeapSize >= 0, User::Panic(_L("MBufTest"),0)); |
|
93 |
|
94 iMBMngr = CMBufManager::NewL(aMaxHeapSize, aMBufSizeAllocator); |
|
95 |
|
96 return iMBMngr; |
|
97 } |