|
1 // Copyright (c) 2003-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 // |
|
15 |
|
16 /** |
|
17 @file TestSteps.cpp |
|
18 */ |
|
19 |
|
20 |
|
21 #include <e32math.h> |
|
22 #include <c32comm.h> |
|
23 #include <in_sock.h> |
|
24 |
|
25 #include "ss_pman.h" |
|
26 #include "TestMgr.h" |
|
27 #include "es_mbman.h" |
|
28 |
|
29 |
|
30 #include <testexecutelog.h> |
|
31 #include "TestSteps.h" |
|
32 #include "main.h" |
|
33 |
|
34 // |
|
35 // Construction/Destruction |
|
36 // |
|
37 |
|
38 CPPPANVL::CPPPANVL() |
|
39 { |
|
40 SetTestStepName(KPPPANVL); |
|
41 } |
|
42 |
|
43 CPPPANVL::~CPPPANVL() |
|
44 { } |
|
45 |
|
46 #if defined (__WINS__) |
|
47 #define PDD_NAME _L("ECDRV") |
|
48 #define LDD_NAME _L("ECOMM") |
|
49 #define LDD_FNAME _L("ECOMM") |
|
50 #else |
|
51 #define PDD_NAME _L("EUART1") |
|
52 #define LDD_NAME _L("ECOMM") |
|
53 #define LDD_FNAME _L("FCOMM") |
|
54 #endif |
|
55 |
|
56 void CPPPANVL::CommInitL(TBool aEnhanced) |
|
57 { |
|
58 TInt err=User::LoadPhysicalDevice(PDD_NAME); |
|
59 if (!(err==KErrNone || err==KErrAlreadyExists)) |
|
60 { |
|
61 ERR_PRINTF1(_L("Failed load physical device")); |
|
62 User::Leave(err); |
|
63 } |
|
64 |
|
65 #if defined PDD2_NAME |
|
66 # if defined (__EPOC32__) |
|
67 TMachineInfoV1Buf info; |
|
68 TEST_CHECKL(UserHal::MachineInfo(info),KErrNone,_L("Failed load physical device")); |
|
69 if (info().iMachineName.Compare(_L("PROTEA_RACKC"))==0 |
|
70 || info().iMachineName.Compare(_L("PROTEA_RACKD"))==0) |
|
71 { |
|
72 # endif //__EPOC32__ |
|
73 err = User::LoadPhysicalDevice(PDD2_NAME); |
|
74 if (err!=KErrNone && err!=KErrAlreadyExists) |
|
75 User::Leave(err); |
|
76 # if defined (__EPOC32__) |
|
77 } |
|
78 # endif //__EPOC32__ |
|
79 #endif //PDD2_NAME |
|
80 |
|
81 if (aEnhanced) |
|
82 err=User::LoadLogicalDevice(LDD_FNAME); |
|
83 else |
|
84 err=User::LoadLogicalDevice(LDD_NAME); |
|
85 if (err!=KErrNone && err!=KErrAlreadyExists) |
|
86 { |
|
87 ERR_PRINTF2(_L("Failed load physical device: %s"), aEnhanced ? LDD_FNAME : LDD_NAME); |
|
88 User::Leave(err); |
|
89 } |
|
90 |
|
91 _LIT(KPhbkSyncCMI, "phbsync.cmi"); |
|
92 err = StartC32WithCMISuppressions(KPhbkSyncCMI); |
|
93 if (err!=KErrNone && err!=KErrAlreadyExists) |
|
94 { |
|
95 ERR_PRINTF1(_L("Failed to start comm process")); |
|
96 User::Leave(err); |
|
97 } |
|
98 } |
|
99 |
|
100 void CPPPANVL::StartClientL() |
|
101 { |
|
102 CTestMgr* pMgr= CTestMgr::NewL(Logger(), this); |
|
103 CleanupStack::PushL(pMgr); |
|
104 pMgr->StartEngineL(); |
|
105 // set the mgr going |
|
106 CActiveScheduler::Start(); |
|
107 CleanupStack::PopAndDestroy(); // pMgr |
|
108 } |
|
109 |
|
110 TVerdict CPPPANVL::doTestStepL() |
|
111 { |
|
112 SetTestStepResult(EPass); |
|
113 INFO_PRINTF1(_L("------------------------------------------")); |
|
114 INFO_PRINTF1(_L("-------- PPP <-> ANVL test -----------")); |
|
115 INFO_PRINTF1(_L("------------------------------------------")); |
|
116 |
|
117 INFO_PRINTF1(_L("Initialising test environment")); |
|
118 |
|
119 CTrapCleanup* pTrapCleanup=CTrapCleanup::New(); |
|
120 if (!pTrapCleanup) |
|
121 { |
|
122 INFO_PRINTF1(_L("Failed to allocate CTrapCleanup object")); |
|
123 return EFail; |
|
124 } |
|
125 // initialise serial comms |
|
126 TInt err=KErrNone; |
|
127 TRAP(err, CommInitL(EFalse)); |
|
128 |
|
129 TEST(err == KErrNone); |
|
130 if (err) |
|
131 { |
|
132 INFO_PRINTF1(_L("Failed to init Comm")); |
|
133 return EFail; |
|
134 } |
|
135 |
|
136 CActiveScheduler* pActiveScheduler=new CActiveScheduler; |
|
137 if (!pActiveScheduler) |
|
138 { |
|
139 INFO_PRINTF1(_L("Failed to allocate CActiveScheduler object")); |
|
140 return EFail; |
|
141 } |
|
142 CActiveScheduler::Install(pActiveScheduler); |
|
143 |
|
144 TRAP(err, doCreateMBufL()) |
|
145 |
|
146 delete pActiveScheduler; |
|
147 delete pTrapCleanup; |
|
148 return TestStepResult(); |
|
149 } |
|
150 |
|
151 static const TInt KMBuf_MaxAvail = 393216; |
|
152 static const TInt KMBuf_MBufSize = 128; |
|
153 static const TInt KMBuf_MBufSizeBig = 1600; |
|
154 static const TInt KMBuf_InitialAllocation = 128; |
|
155 static const TInt KMBuf_MinGrowth = 64; |
|
156 static const TInt KMBuf_GrowthThreshold = 40; |
|
157 void CPPPANVL::doCreateMBufL() |
|
158 { |
|
159 TInt err; |
|
160 |
|
161 // Initialize the MBuf manager |
|
162 MMBufSizeAllocator *mBufSizeAllocator; |
|
163 CMBufManager *mbufMgr = CMBufManager::NewL(KMBuf_MaxAvail, mBufSizeAllocator); |
|
164 CleanupStack::PushL(mbufMgr); |
|
165 |
|
166 if (mbufMgr && mBufSizeAllocator) |
|
167 { |
|
168 // configure the mbuf size allocation info |
|
169 mBufSizeAllocator->AddL(KMBuf_MBufSize, KMBuf_InitialAllocation, KMBuf_MinGrowth, KMBuf_GrowthThreshold); |
|
170 mBufSizeAllocator->AddL(KMBuf_MBufSizeBig, KMBuf_InitialAllocation, KMBuf_MinGrowth, KMBuf_GrowthThreshold); |
|
171 } |
|
172 |
|
173 // Go go!!! |
|
174 TRAP(err, StartClientL()); |
|
175 TEST(err == KErrNone); |
|
176 if (err) |
|
177 { |
|
178 INFO_PRINTF1(_L("Leave in StartClientL()")); |
|
179 } |
|
180 |
|
181 INFO_PRINTF1(_L("Cleaning up test environment")); |
|
182 |
|
183 CleanupStack::PopAndDestroy(mbufMgr); |
|
184 } |