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 // This contains CTestCaseRootServer |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 |
|
21 // Test system includes |
|
22 #include <networking/log.h> |
|
23 #include <networking/teststep.h> |
|
24 #include <networking/testsuite.h> |
|
25 |
|
26 #include "TestStepRootServer.h" |
|
27 #include "TestSuiteRootServer.h" |
|
28 #include "TestAsynchHandler.h" |
|
29 |
|
30 // const (times in ms) |
|
31 const TInt CTestStepRootServer::isTestServerLifeTime = 3000; |
|
32 const TInt CTestStepRootServer::isTestServerWaitTime = |
|
33 2 * CTestStepRootServer::isTestServerLifeTime; |
|
34 const TInt CTestStepRootServer::isRendezvousDelayTime = 1000; |
|
35 |
|
36 |
|
37 |
|
38 // constructor |
|
39 CTestStepRootServer::CTestStepRootServer() |
|
40 { |
|
41 } |
|
42 |
|
43 // destructor |
|
44 CTestStepRootServer::~CTestStepRootServer() |
|
45 { |
|
46 } |
|
47 |
|
48 |
|
49 //------------------------ |
|
50 TVerdict CTestStepRootServer::doTestStepPreambleL( void ) |
|
51 { |
|
52 TInt ret; |
|
53 |
|
54 // kick off the RootServer thread |
|
55 Log(_L("Attempting to start RootServer")); |
|
56 ret = iRootServerSuite->StartRootServer(); |
|
57 if (KErrNone != ret) |
|
58 { |
|
59 Log(_L("Failed to start RootServer: err %d"), ret); |
|
60 return EInconclusive; |
|
61 } |
|
62 |
|
63 return EPass; |
|
64 } |
|
65 |
|
66 |
|
67 //------------------------ |
|
68 TVerdict CTestStepRootServer::doTestStepPostambleL( void ) |
|
69 { |
|
70 Log(_L("Attempting to shutdown RootServer")); |
|
71 if (!iRootServerSuite->ShutdownRootServer()) |
|
72 { |
|
73 Log(_L("Failed to shutdown RootServer")); |
|
74 return EInconclusive; |
|
75 } |
|
76 return EPass; |
|
77 } |
|
78 |
|
79 |
|
80 //------------------------ |
|
81 void CTestStepRootServer::GetTestStepServerName(const TDesC &aNamePostFix, |
|
82 TDes &aServerName) |
|
83 { |
|
84 aServerName.Copy(_L("TS_")); |
|
85 aServerName.Append(iTestStepName); |
|
86 aServerName.Append(_L("_")); |
|
87 aServerName.AppendNum(iRootServerSuite->NextServerNumber()); |
|
88 if (aNamePostFix.Length() > 0) |
|
89 { |
|
90 aServerName.Append(_L("_")); |
|
91 aServerName.Append(aNamePostFix); |
|
92 } |
|
93 } |
|
94 |
|
95 |
|
96 void CTestStepRootServer::DefaultStartParams(TRSStartModuleParams& aStartParams, TTestModuleIniData& aIniData) |
|
97 { |
|
98 aStartParams.iParams.iFilename = _L("testcpm.cpm"); |
|
99 aStartParams.iParams.iPriority = EPriorityNormal; |
|
100 aStartParams.iParams.iStackSize = 8192; |
|
101 aStartParams.iParams.iHeapType = ENewHeap; |
|
102 aStartParams.iParams.iMinHeapSize = 65536; |
|
103 aStartParams.iParams.iMaxHeapSize = 262144; |
|
104 aStartParams.iParams.iShareHeapWith = KNullDesC8; |
|
105 aStartParams.iParams.iThreadFunctionOrdinal = 1; |
|
106 aStartParams.iParams.iIsSticky = EFalse; |
|
107 aStartParams.iParams.iIsServer = EFalse; |
|
108 |
|
109 aIniData.iParams.iInitDelay = 0; |
|
110 aIniData.iParams.iDeathDelay = NO_PREMATURE_DEATH; |
|
111 aIniData.iParams.iDiscoveryDelay = 0; |
|
112 aIniData.iParams.iBindDelay = 0; |
|
113 aIniData.iParams.iUnbindDelay = 0; |
|
114 aIniData.iParams.iShutdownDelay = 0; |
|
115 } |
|
116 |
|
117 void CTestStepRootServer::LoadNormalModuleL(CTestAsynchHandler* aHandler, const TDesC8& aModule, TThreadPriority aPriority) |
|
118 { |
|
119 TRSStartModuleParams startParams; |
|
120 TTestModuleIniData iniData; |
|
121 DefaultStartParams(startParams, iniData); |
|
122 startParams.iParams.iName = aModule; |
|
123 startParams.iParams.iPriority = aPriority; |
|
124 |
|
125 aHandler->TryLoad( startParams, iniData); |
|
126 |
|
127 CActiveScheduler::Start(); |
|
128 if (aHandler->iStatus != KErrNone) |
|
129 { |
|
130 Log(_L("Error: load returned %d"), aHandler->iStatus.Int()); |
|
131 User::Leave(aHandler->iStatus.Int()); |
|
132 } |
|
133 } |
|
134 |
|
135 TInt CTestStepRootServer::TryHierachicalBind(CTestAsynchHandler* aHandler, |
|
136 const TDesC8& aTopModule, const TDesC8& aTopSubModule, |
|
137 const TDesC8& aBottomModule, const TDesC8& aBottomSubModule) |
|
138 { |
|
139 TRSBindingInfo bindInfo; |
|
140 bindInfo.iParams.iType = EHierarchical; |
|
141 bindInfo.iParams.iAddress1.SetModule(aTopModule); |
|
142 bindInfo.iParams.iAddress1.SetSubModule(aTopSubModule); |
|
143 bindInfo.iParams.iAddress2.SetModule(aBottomModule); |
|
144 bindInfo.iParams.iAddress2.SetSubModule(aBottomSubModule); |
|
145 bindInfo.iParams.iState1 = KErrNone; |
|
146 bindInfo.iParams.iState2 = KErrNone; |
|
147 bindInfo.iParams.iForwardQLength = TRSBindingInfo::EMinQueueLength; |
|
148 bindInfo.iParams.iReverseQLength = TRSBindingInfo::EMinQueueLength; |
|
149 |
|
150 aHandler->TryBind( bindInfo ); |
|
151 CActiveScheduler::Start(); |
|
152 return aHandler->iStatus.Int(); |
|
153 } |
|
154 |
|
155 _LIT(KSingleDesFmt, "%S"); |
|
156 |
|
157 void CTestStepRootServer::Log( TRefByValue<const TDesC8> aFormat, ... ) |
|
158 { |
|
159 // Although a memory-spendthrift approach it's ok for the case of TS_ROOTSERVER |
|
160 TBuf8<EMaxLogLength> buf8; |
|
161 VA_LIST list; |
|
162 VA_START(list, aFormat); |
|
163 buf8.FormatList(aFormat, list); |
|
164 TBuf16<EMaxLogLength> buf16; |
|
165 buf16.Copy(buf8); |
|
166 CTestStep::Log(KSingleDesFmt, &buf16); |
|
167 } |
|
168 |
|
169 void CTestStepRootServer::Log( TInt aSeverity, TRefByValue<const TDesC8> aFormat, ... ) |
|
170 { |
|
171 // Although a memory-spendthrift approach it's ok for the case of TS_ROOTSERVER |
|
172 TBuf8<EMaxLogLength> buf8; |
|
173 VA_LIST list; |
|
174 VA_START(list, aFormat); |
|
175 buf8.FormatList(aFormat, list); |
|
176 TBuf16<EMaxLogLength> buf16; |
|
177 buf16.Copy(buf8); |
|
178 CTestStep::Log(aSeverity, KSingleDesFmt, &buf16); |
|
179 } |
|
180 |
|
181 void CTestStepRootServer::LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity, TRefByValue<const TDesC8> aFormat,...) |
|
182 { |
|
183 // Although a memory-spendthrift approach it's ok for the case of TS_ROOTSERVER |
|
184 TBuf8<EMaxLogLength> buf8; |
|
185 VA_LIST list; |
|
186 VA_START(list, aFormat); |
|
187 buf8.FormatList(aFormat, list); |
|
188 TBuf16<EMaxLogLength> buf16; |
|
189 buf16.Copy(buf8); |
|
190 CTestStep::LogExtra(aFile, aLine, aSeverity, KSingleDesFmt, &buf16); |
|
191 } |
|
192 |
|
193 void CTestStepRootServer::Log( TRefByValue<const TDesC16> aFormat, ... ) |
|
194 { |
|
195 // Although a memory-spendthrift approach it's ok for the case of TS_ROOTSERVER |
|
196 TBuf16<EMaxLogLength> buf16; |
|
197 VA_LIST list; |
|
198 VA_START(list, aFormat); |
|
199 buf16.FormatList(aFormat, list); |
|
200 CTestStep::Log(KSingleDesFmt, &buf16); |
|
201 } |
|
202 |
|
203 void CTestStepRootServer::Log( TInt aSeverity, TRefByValue<const TDesC16> aFormat, ... ) |
|
204 { |
|
205 // Although a memory-spendthrift approach it's ok for the case of TS_ROOTSERVER |
|
206 TBuf16<EMaxLogLength> buf16; |
|
207 VA_LIST list; |
|
208 VA_START(list, aFormat); |
|
209 buf16.FormatList(aFormat, list); |
|
210 CTestStep::Log(aSeverity, KSingleDesFmt, &buf16); |
|
211 } |
|
212 |
|
213 void CTestStepRootServer::LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity, |
|
214 TRefByValue<const TDesC> aFormat,...) |
|
215 { |
|
216 // Although a memory-spendthrift approach it's ok for the case of TS_ROOTSERVER |
|
217 TBuf16<EMaxLogLength> buf16; |
|
218 VA_LIST list; |
|
219 VA_START(list, aFormat); |
|
220 buf16.FormatList(aFormat, list); |
|
221 CTestStep::LogExtra(aFile, aLine, aSeverity, KSingleDesFmt, &buf16); |
|
222 } |
|
223 |
|