|
1 // Copyright (c) 2008-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 // Test Suit for RTP SCPR and Rtp Flows. |
|
15 // @file |
|
16 // @internalAll |
|
17 // |
|
18 // |
|
19 |
|
20 #include "te_cfrtpsuiteserver.h" |
|
21 #include "cfrtp_basictests.h" |
|
22 |
|
23 _LIT(KServerName,"te_cfrtpsuite"); |
|
24 CTe_CfrtpSuite* CTe_CfrtpSuite::NewL() |
|
25 /** |
|
26 * @return - Instance of the test server |
|
27 * Same code for Secure and non-secure variants |
|
28 * Called inside the MainL() function to create and start the |
|
29 * CTestServer derived server. |
|
30 */ |
|
31 { |
|
32 CTe_CfrtpSuite * server = new (ELeave) CTe_CfrtpSuite(); |
|
33 CleanupStack::PushL(server); |
|
34 // CServer base class call which can be either StartL or ConstructL, |
|
35 // the later will permit Server Logging. |
|
36 |
|
37 server->StartL(KServerName); |
|
38 //server->ConstructL(KServerName); |
|
39 CleanupStack::Pop(server); |
|
40 return server; |
|
41 } |
|
42 |
|
43 #if (!defined EKA2) |
|
44 LOCAL_C void MainL() |
|
45 /** |
|
46 * Non-secure variant. |
|
47 * REQUIRES semaphore to sync with client as the Rendezvous() |
|
48 * calls are not available |
|
49 */ |
|
50 { |
|
51 CActiveScheduler* sched=NULL; |
|
52 sched=new(ELeave) CActiveScheduler; |
|
53 CleanupStack::PushL(sched); |
|
54 CActiveScheduler::Install(sched); |
|
55 CTe_CfrtpSuite* server = NULL; |
|
56 // Create the CTestServer derived server |
|
57 TRAPD(err,server = CTe_CfrtpSuite::NewL()); |
|
58 if(!err) |
|
59 { |
|
60 CleanupStack::PushL(server); |
|
61 RSemaphore sem; |
|
62 // The client API will already have created the semaphore |
|
63 User::LeaveIfError(sem.OpenGlobal(KServerName)); |
|
64 CleanupStack::Pop(server); |
|
65 // Sync with the client then enter the active scheduler |
|
66 sem.Signal(); |
|
67 sem.Close(); |
|
68 sched->Start(); |
|
69 } |
|
70 CleanupStack::Pop(sched); |
|
71 delete server; |
|
72 delete sched; |
|
73 } |
|
74 #else |
|
75 |
|
76 // Secure variants much simpler |
|
77 // For EKA2, just an E32Main and a MainL() |
|
78 LOCAL_C void MainL() |
|
79 /** |
|
80 * Secure variant |
|
81 * Much simpler, uses the new Rendezvous() call to sync with the client |
|
82 */ |
|
83 { |
|
84 // Leave the hooks in for platform security |
|
85 #if (defined __DATA_CAGING__) |
|
86 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
87 RProcess().DataCaging(RProcess::ESecureApiOn); |
|
88 #endif |
|
89 CActiveScheduler* sched=NULL; |
|
90 sched=new(ELeave) CActiveScheduler; |
|
91 CActiveScheduler::Install(sched); |
|
92 CTe_CfrtpSuite* server = NULL; |
|
93 // Create the CTestServer derived server |
|
94 TRAPD(err,server = CTe_CfrtpSuite::NewL()); |
|
95 if(!err) |
|
96 { |
|
97 // Sync with the client and enter the active scheduler |
|
98 RProcess::Rendezvous(KErrNone); |
|
99 sched->Start(); |
|
100 } |
|
101 delete server; |
|
102 delete sched; |
|
103 } |
|
104 |
|
105 #endif |
|
106 |
|
107 #if (defined __WINS__ && !defined EKA2) |
|
108 // Non-secure variants |
|
109 GLDEF_C TInt E32Dll(enum TDllReason) |
|
110 { |
|
111 return 0; |
|
112 } |
|
113 #else |
|
114 |
|
115 GLDEF_C TInt E32Main() |
|
116 /** |
|
117 * @return - Standard Epoc error code on process exit |
|
118 * Secure variant only |
|
119 * Process entry point. Called by client using RProcess API |
|
120 */ |
|
121 { |
|
122 __UHEAP_MARK; |
|
123 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
124 if(!cleanup) |
|
125 { |
|
126 return KErrNoMemory; |
|
127 } |
|
128 TRAPD(err,MainL()); |
|
129 delete cleanup; |
|
130 __UHEAP_MARKEND; |
|
131 return err; |
|
132 } |
|
133 #endif |
|
134 |
|
135 #if (defined __WINS__ && !defined EKA2) |
|
136 |
|
137 TInt ThreadFunc (TAny* /*aParam*/) |
|
138 /** |
|
139 * @return - Server exit code |
|
140 * @param - unused |
|
141 * Non-secure only |
|
142 * Server Thread function. Guts of the code in the MainL() function |
|
143 */ |
|
144 { |
|
145 __UHEAP_MARK; |
|
146 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
147 if(!cleanup) |
|
148 { |
|
149 return KErrNoMemory; |
|
150 } |
|
151 TRAPD(err,MainL()); |
|
152 delete cleanup; |
|
153 __UHEAP_MARKEND; |
|
154 return err; |
|
155 } |
|
156 |
|
157 EXPORT_C TInt NewServer() |
|
158 /** |
|
159 * @return - Standard Epoc error codes |
|
160 * Non-secure variant only |
|
161 * 1st and only ordinal, called by the client API to initialise the server |
|
162 */ |
|
163 { |
|
164 _LIT(KThread,"Thread"); |
|
165 RThread thread; |
|
166 TBuf<KMaxTestExecuteNameLength> threadName(KServerName); |
|
167 // Create a hopefully unique thread name and use the ThreadFunc |
|
168 threadName.Append(KThread); |
|
169 const TInt KMaxHeapSize = 0x1000000; //< Allow a 1Mb max heap |
|
170 TInt err = thread.Create(threadName, ThreadFunc, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, NULL, EOwnerProcess); |
|
171 if(err) |
|
172 return err; |
|
173 thread.Resume(); |
|
174 thread.Close(); |
|
175 return KErrNone; |
|
176 } |
|
177 |
|
178 #endif |
|
179 |
|
180 CTestStep* CTe_CfrtpSuite::CreateTestStep(const TDesC& aStepName) |
|
181 /** |
|
182 * @return - A CTestStep derived instance |
|
183 * Secure and non-secure variants |
|
184 * Implementation of CTestServer pure virtual |
|
185 */ |
|
186 { |
|
187 CTestStep* testStep = NULL; |
|
188 // They are created "just in time" when the worker thread is created |
|
189 // More test steps can be added below |
|
190 if(aStepName == KSubConTestStep) |
|
191 { |
|
192 testStep = new CSubConStep(); |
|
193 } |
|
194 if(aStepName == KRtpSockTestStep) |
|
195 { |
|
196 testStep = new CRtpSockTest(); |
|
197 } |
|
198 if(aStepName == KRtcpSockTestStep) |
|
199 { |
|
200 testStep = new CRtcpSockTest(); |
|
201 } |
|
202 if(aStepName == KRtpSendRecvStep) |
|
203 { |
|
204 testStep = new CRtpSendRecv(); |
|
205 } |
|
206 if(aStepName == KRtcpSendRecvTestStep) |
|
207 { |
|
208 testStep = new CRtcpSendRecv(); |
|
209 } |
|
210 if(aStepName == KRtpConnectTestStep) |
|
211 { |
|
212 testStep = new CRtpConnect(); |
|
213 } |
|
214 if(aStepName == KRtcpConnectTestStep) |
|
215 { |
|
216 testStep = new CRtcpConnect(); |
|
217 } |
|
218 if(aStepName == KRtpNoBindTestStep) |
|
219 { |
|
220 testStep = new CRtpNoBind(); |
|
221 } |
|
222 if(aStepName == KRtpBindTestStep) |
|
223 { |
|
224 testStep = new CRtpBind(); |
|
225 } |
|
226 if(aStepName == KRtpSockOptTestStep) |
|
227 { |
|
228 testStep = new CRtpSockOpt(); |
|
229 } |
|
230 if(aStepName == KRtcpSockOptTestStep) |
|
231 { |
|
232 testStep = new CRtcpSockOpt(); |
|
233 } |
|
234 if(aStepName == KRtpIoctlTestStep) |
|
235 { |
|
236 testStep = new CRtpIoctl(); |
|
237 } |
|
238 if(aStepName == KBigSendRecvRtp) |
|
239 { |
|
240 testStep = new CBigSendRecvRtp(); |
|
241 } |
|
242 if(aStepName == KRtpNegTests_01TestStep) |
|
243 { |
|
244 testStep = new CRtpNegTests_01(); |
|
245 } |
|
246 if(aStepName == KRtpNegTests_02TestStep) |
|
247 { |
|
248 testStep = new CRtpNegTests_02(); |
|
249 } |
|
250 if(aStepName == KRtpNegTests_03TestStep) |
|
251 { |
|
252 testStep = new CRtpNegTests_03(); |
|
253 } |
|
254 if(aStepName == KRtpNegTests_04TestStep) |
|
255 { |
|
256 testStep = new CRtpNegTests_04(); |
|
257 } |
|
258 if(aStepName == KRtpNegTests_05TestStep) |
|
259 { |
|
260 testStep = new CRtpNegTests_05(); |
|
261 } |
|
262 if(aStepName == KRtpNegTests_FailNoBearer) |
|
263 { |
|
264 testStep = new CRtpNegTestsFailNoBearer(); |
|
265 } |
|
266 if(aStepName == KRtpShutDownImmediate) |
|
267 { |
|
268 testStep = new CRtpShutDownImmediate(); |
|
269 } |
|
270 if(aStepName == KRtcpShutDownImmediate) |
|
271 { |
|
272 testStep = new CRtcpShutDownImmediate(); |
|
273 } |
|
274 if(aStepName == KShutDownImmediate) |
|
275 { |
|
276 testStep = new CShutDownImmediate(); |
|
277 } |
|
278 return testStep; |
|
279 } |