|
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 02 Allocate/Dealocate RMBuf |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 |
|
21 // Test system includes |
|
22 #ifdef SYMBIAN_OLD_EXPORT_LOCATION |
|
23 #include "networking/log.h" |
|
24 #include "networking/teststep.h" |
|
25 #else |
|
26 #include <networking/log.h> |
|
27 #include <networking/teststep.h> |
|
28 #endif |
|
29 #include "TestStepCTMbufmgr.h" |
|
30 #include "TestSuiteCTMbufmgr.h" |
|
31 #include "Test02AllocDealloc.h" |
|
32 #include <comms-infras/commsbufpond.h> |
|
33 |
|
34 // constructor |
|
35 CTest02AllocDealloc::CTest02AllocDealloc() |
|
36 { |
|
37 iTestStepName = _L("MBufMgrTest02");// Store the name of this test case |
|
38 } |
|
39 |
|
40 // destructor |
|
41 CTest02AllocDealloc::~CTest02AllocDealloc() |
|
42 { |
|
43 } |
|
44 |
|
45 // |
|
46 enum TVerdict CTest02AllocDealloc::doTestStepL(void) |
|
47 { |
|
48 __UHEAP_MARK; |
|
49 |
|
50 #ifdef __CFLOG_ACTIVE |
|
51 __CFLOG_CREATEL; |
|
52 __CFLOG_OPEN; |
|
53 #endif |
|
54 |
|
55 //-------------- substep 1 -------------------- |
|
56 Log(_L(" 01 Create CMBufManager and install active scheduler:")); |
|
57 CleanupStack::PushL( iActSch = new(ELeave) CActiveScheduler ); |
|
58 CActiveScheduler::Install(iActSch); |
|
59 CreateInstanceMBufMgrL(KMBufDefaultHeapSize); |
|
60 CleanupClosePushL(iBufPond); |
|
61 |
|
62 TBool firstFail = EFalse; |
|
63 TBool secondFail = EFalse; |
|
64 |
|
65 //-------------- substep 2 -------------------- |
|
66 Log(_L(" 02 Allocate 5000-bytes long RMBuf:")); |
|
67 RMBuf* buf=static_cast<RMBuf*>(iBufPond.Alloc(5000, 0, KMaxTInt)); |
|
68 if (buf == NULL) |
|
69 { |
|
70 Log(_L("Error: Couldn't allocate RMBuf:")); |
|
71 firstFail = ETrue; |
|
72 } |
|
73 else |
|
74 { |
|
75 //-------------- substep 3 -------------------- |
|
76 Log(_L(" 03 Deallocating RMBuf")); |
|
77 buf->Free(); |
|
78 } |
|
79 |
|
80 //-------------- substep 4 -------------------- |
|
81 Log(_L(" 04 Allocate 0-byte long RMBuf:")); |
|
82 buf = static_cast<RMBuf*>(iBufPond.Alloc(0, 0, KMaxTInt)); |
|
83 if (buf == NULL) |
|
84 { |
|
85 Log(_L("Error: Couldn't allocate RMBuf:")); |
|
86 secondFail = ETrue; |
|
87 } |
|
88 else |
|
89 { |
|
90 //-------------- substep 5 -------------------- |
|
91 _LIT(aLog1, " 05 Allocated RMBuf size : %d"); |
|
92 Log(aLog1, buf->Size()); |
|
93 if (buf->Length() != 0) |
|
94 { |
|
95 _LIT(aLog2, "Error: RMBuf length : %d "); |
|
96 Log(aLog2, buf->Length()); |
|
97 secondFail = ETrue; |
|
98 } |
|
99 else |
|
100 { |
|
101 _LIT(aLog3, " Info: RMBuf length : %d "); |
|
102 Log(aLog3, buf->Length()); |
|
103 } |
|
104 //-------------- substep 6 -------------------- |
|
105 Log(_L(" 06 Deallocating RMBuf")); |
|
106 buf->Free(); |
|
107 } |
|
108 //-------------- substep 7 -------------------- |
|
109 Log(_L(" 07 Clean up stack:")); |
|
110 CleanupStack::PopAndDestroy(); // iBufPond |
|
111 CActiveScheduler::Install(NULL); |
|
112 CleanupStack::PopAndDestroy(iActSch); |
|
113 |
|
114 #ifdef __CFLOG_ACTIVE |
|
115 __CFLOG_CLOSE; |
|
116 __CFLOG_DELETE; |
|
117 #endif |
|
118 __UHEAP_MARKEND; |
|
119 |
|
120 if (firstFail || secondFail) |
|
121 { |
|
122 return EFail; |
|
123 } |
|
124 |
|
125 return EPass; |
|
126 } |