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 05 for CopyIn() & CopyOut() methods with offset |
|
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 |
|
32 #include "Test05CopyInOutOffset.h" |
|
33 #include <comms-infras/commsbufpond.h> |
|
34 // constructor |
|
35 CTest05CopyInOutOffset::CTest05CopyInOutOffset() |
|
36 { |
|
37 iTestStepName = _L("MBufMgrTest05");// Store the name of this test case |
|
38 } |
|
39 |
|
40 // destructor |
|
41 CTest05CopyInOutOffset::~CTest05CopyInOutOffset() |
|
42 { |
|
43 } |
|
44 |
|
45 // |
|
46 enum TVerdict CTest05CopyInOutOffset::doTestStepL(void) |
|
47 { |
|
48 __UHEAP_MARK; |
|
49 |
|
50 //-------------- substep 0 -------------------- |
|
51 bool aTest; |
|
52 Log(_L(" 00 Read from script which test to run:")); |
|
53 TPtrC aPtrResult; |
|
54 TInt bRet = GetStringFromConfig(_L("MBufMgrTest05"), _L("test"), aPtrResult); |
|
55 if (!bRet) |
|
56 { |
|
57 return EFail; |
|
58 } |
|
59 |
|
60 if (aPtrResult==_L("CopyIn" )) |
|
61 { |
|
62 aTest = true; |
|
63 Log(_L(" ------------ Copy In Test starts ---------------:")); |
|
64 } |
|
65 else if (aPtrResult==_L("CopyOut")) |
|
66 { |
|
67 aTest = false; |
|
68 Log(_L(" ------------ Copy Out Test starts --------------:")); |
|
69 } |
|
70 else |
|
71 { |
|
72 Log(_L("Failed to read test case - there should be either CopyIn or CopyOut - case sensitive")); |
|
73 return EFail; |
|
74 } |
|
75 |
|
76 #ifdef __CFLOG_ACTIVE |
|
77 __CFLOG_CREATEL; |
|
78 __CFLOG_OPEN; |
|
79 #endif |
|
80 |
|
81 //-------------- substep 1 -------------------- |
|
82 Log(_L(" 01 Create CMBufManager and install active scheduler:")); |
|
83 CleanupStack::PushL( iActSch = new(ELeave) CActiveScheduler ); |
|
84 CActiveScheduler::Install(iActSch); |
|
85 CreateInstanceMBufMgrL(KMBufDefaultHeapSize); |
|
86 CleanupClosePushL(iBufPond); |
|
87 |
|
88 //-------------- substep 2 -------------------- |
|
89 Log(_L(" 02 Allocate two 5000-bytes long descriptors (Des1 & Des2):")); |
|
90 TBuf8<5000> *aDes1, *aDes2; |
|
91 CleanupStack::PushL( aDes1 = new(ELeave) TBuf8<5000> ); |
|
92 CleanupStack::PushL( aDes2 = new(ELeave) TBuf8<5000> ); |
|
93 aDes1->SetLength(5000); |
|
94 aDes2->SetLength(5000); |
|
95 |
|
96 //-------------- substep 3 -------------------- |
|
97 Log(_L(" 03 Allocate 5000-bytes long RMBufChain:")); |
|
98 RMBufChain aChain; |
|
99 TRAPD(ret,aChain.AllocL(5000)); |
|
100 if (ret != KErrNone) |
|
101 { |
|
102 Log(_L("Error: Couldn't allocate RMBuf:")); |
|
103 #ifdef __CFLOG_ACTIVE |
|
104 __CFLOG_CLOSE; |
|
105 __CFLOG_DELETE; |
|
106 #endif |
|
107 User::Leave(EFail); |
|
108 } |
|
109 |
|
110 //-------------- substep 4 -------------------- |
|
111 Log(_L(" 04 Fill in Des1 with a pattern:")); |
|
112 StripeDes(*aDes1, 0, 5000, '@', 'Z'); |
|
113 |
|
114 //-------------- substep 5 -------------------- |
|
115 Log(_L(" 05 Fill in Des2 with a patter different then that in Des1:")); |
|
116 StripeDes(*aDes2, 0, 5000, 'a', 'z'); |
|
117 |
|
118 //-------------- substep 6 -------------------- |
|
119 Log(_L(" 06 Fill in Chain with zeros:")); |
|
120 aChain.FillZ(); |
|
121 |
|
122 if (aTest) |
|
123 { |
|
124 //----------- CopyIn() method check only----------- |
|
125 //-------------- substep 7 -------------------- |
|
126 Log(_L(" 07 Copy in the last 4000 bytes of Des1 into the last 4000 of Chain:")); |
|
127 aChain.CopyIn(aDes1->Mid(1000),1000); |
|
128 |
|
129 //-------------- substep 8 -------------------- |
|
130 Log(_L(" 08 Copy out Chain into Des2:")); |
|
131 aChain.CopyOut(*aDes2); |
|
132 |
|
133 //-------------- substep 9 -------------------- |
|
134 Log(_L(" 09 Fill in the 1st 1000 bytes of Des1 with zeros:")); |
|
135 StripeDes(*aDes1, 0, 1000, '\0', '\0'); |
|
136 } |
|
137 else |
|
138 { |
|
139 //----------- CopyOut() method check unly----------- |
|
140 //-------------- substep 7 -------------------- |
|
141 Log(_L(" 07 Copy in Des1 into Chain:")); |
|
142 aChain.CopyIn(*aDes1); |
|
143 |
|
144 //-------------- substep 8 -------------------- |
|
145 Log(_L(" 08 Fill in the 1st 1000 bytes of Des1 & Des2 with zeros:")); |
|
146 StripeDes(*aDes1, 0, 1000, '\0', '\0'); |
|
147 StripeDes(*aDes2, 0, 1000, '\0', '\0'); |
|
148 |
|
149 //-------------- substep 9 -------------------- |
|
150 Log(_L(" 09 Copy out the last 4000 bytes of Chain into last 4000 of Des2:")); |
|
151 TPtr8 dest((TUint8*)aDes2->Ptr()+1000,4000,4000); |
|
152 aChain.CopyOut(dest, 1000); |
|
153 } |
|
154 |
|
155 //-------------- substep 10 -------------------- |
|
156 Log(_L(" 10 Compare the content of Des1 & Des2:")); |
|
157 if(aDes1->Compare(*aDes2)) |
|
158 { |
|
159 aChain.Free(); |
|
160 Log(_L("Error: The content is not the same")); |
|
161 #ifdef __CFLOG_ACTIVE |
|
162 __CFLOG_CLOSE; |
|
163 __CFLOG_DELETE; |
|
164 #endif |
|
165 User::Leave(EFail); |
|
166 } |
|
167 |
|
168 //-------------- substep 11 -------------------- |
|
169 Log(_L(" 11 Free the chain. Clean up stack:")); |
|
170 aChain.Free(); |
|
171 CleanupStack::PopAndDestroy(aDes2); |
|
172 CleanupStack::PopAndDestroy(aDes1); |
|
173 CleanupStack::PopAndDestroy(); // iBufPond |
|
174 CActiveScheduler::Install(NULL); |
|
175 CleanupStack::PopAndDestroy(iActSch); |
|
176 |
|
177 #ifdef __CFLOG_ACTIVE |
|
178 __CFLOG_CLOSE; |
|
179 __CFLOG_DELETE; |
|
180 #endif |
|
181 __UHEAP_MARKEND; |
|
182 return EPass; |
|
183 } |
|