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