|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <unistd.h> |
|
19 #include "TestHarness.h" |
|
20 #include "commsmessage.h" |
|
21 #include "commsclientendpoint.h" |
|
22 #include "logger.h" |
|
23 |
|
24 #include "testserver.h" |
|
25 |
|
26 using namespace java::comms; |
|
27 using namespace std; |
|
28 using java::util::Uid; |
|
29 |
|
30 const int TIMEOUT = 10; |
|
31 |
|
32 TEST_GROUP(TckRunner) |
|
33 { |
|
34 TestServer server; |
|
35 TEST_SETUP() |
|
36 { |
|
37 server.start(); |
|
38 } |
|
39 |
|
40 TEST_TEARDOWN() |
|
41 { |
|
42 server.stop(); |
|
43 } |
|
44 }; |
|
45 |
|
46 /** |
|
47 * Test normal TCK run |
|
48 * 1: install operation |
|
49 * 2: install result |
|
50 * 3: uninstall operation |
|
51 * 4: launch request check |
|
52 * 5: uninstall result |
|
53 */ |
|
54 TEST(TckRunner, ok_case) |
|
55 { |
|
56 // 1: install operation |
|
57 { |
|
58 CommsMessage msg; |
|
59 msg.setMessageId(MSG_ID_GET_NEXT_OPERATION); |
|
60 |
|
61 CommsMessage message; |
|
62 int rc = server.getJavaInstaller().sendReceive(msg, message, TIMEOUT); |
|
63 |
|
64 int oper; |
|
65 string url; |
|
66 message >> oper >> url; |
|
67 CHECK(rc == 0); |
|
68 CHECK(oper == OPERATION_INSTALL); |
|
69 CHECK(url.compare("unittest:\\\\tckrunner_tester") == 0); |
|
70 } |
|
71 // 2: install result |
|
72 { |
|
73 CommsMessage msg; |
|
74 msg.setMessageId(MSG_ID_OPERATION_RESULT); |
|
75 msg << OPERATION_INSTALL << 0 << 3 << "uid1" << "uid2" << "uid3"; |
|
76 server.getJavaInstaller().send(msg); |
|
77 } |
|
78 // 3: uninstall operation |
|
79 { |
|
80 CommsMessage msg; |
|
81 msg.setMessageId(MSG_ID_GET_NEXT_OPERATION); |
|
82 |
|
83 CommsMessage message; |
|
84 int rc = server.getJavaInstaller().sendReceive(msg, message, TIMEOUT); |
|
85 |
|
86 int oper; |
|
87 string uid; |
|
88 message >> oper >> uid; |
|
89 CHECK(rc == 0); |
|
90 CHECK(oper == OPERATION_UNINSTALL); |
|
91 CHECK(uid.compare("uid1") == 0); |
|
92 } |
|
93 // 4: launch request check |
|
94 { |
|
95 CHECK(server.mLaunchReqs.size() == 3); |
|
96 CHECK(server.mLaunchReqs.front().compare("uid1") == 0); |
|
97 server.mLaunchReqs.pop(); |
|
98 CHECK(server.mLaunchReqs.front().compare("uid2") == 0); |
|
99 server.mLaunchReqs.pop(); |
|
100 CHECK(server.mLaunchReqs.front().compare("uid3") == 0); |
|
101 server.mLaunchReqs.pop(); |
|
102 } |
|
103 // 5: uninstall result |
|
104 { |
|
105 CommsMessage msg; |
|
106 msg.setMessageId(MSG_ID_OPERATION_RESULT); |
|
107 msg << OPERATION_UNINSTALL << 0; |
|
108 server.getJavaInstaller().send(msg); |
|
109 } |
|
110 } |
|
111 |
|
112 /** |
|
113 * Installation fails |
|
114 * 1: install operation |
|
115 * 2: install result nok |
|
116 * 3: check no launch requests |
|
117 */ |
|
118 TEST(TckRunner, installfail) |
|
119 { |
|
120 int i = 0; |
|
121 do |
|
122 { |
|
123 // 1: install operation |
|
124 { |
|
125 CommsMessage msg; |
|
126 msg.setMessageId(MSG_ID_GET_NEXT_OPERATION); |
|
127 |
|
128 CommsMessage message; |
|
129 int rc = server.getJavaInstaller().sendReceive(msg, message, TIMEOUT); |
|
130 |
|
131 int oper; |
|
132 string url; |
|
133 message >> oper >> url; |
|
134 CHECK(rc == 0); |
|
135 CHECK(oper == OPERATION_INSTALL); |
|
136 CHECK(url.compare("unittest:\\\\tckrunner_tester") == 0); |
|
137 } |
|
138 // 2: install result |
|
139 { |
|
140 CommsMessage msg; |
|
141 msg.setMessageId(MSG_ID_OPERATION_RESULT); |
|
142 msg << OPERATION_INSTALL << -1 << 3 << "uid1" << "uid2" << "uid3"; |
|
143 server.getJavaInstaller().send(msg); |
|
144 } |
|
145 sleep(1); |
|
146 // 3: check no launch requests |
|
147 { |
|
148 CHECK(server.mLaunchReqs.size() == 0); |
|
149 } |
|
150 } |
|
151 while (i++ < 3); |
|
152 } |
|
153 |
|
154 |
|
155 /** |
|
156 * Application launch fails |
|
157 * 1: install operation |
|
158 * 2: install result |
|
159 * 3: uninstall operation |
|
160 * 4: launch request check |
|
161 * 5: uninstall result |
|
162 */ |
|
163 TEST(TckRunner, launchfail) |
|
164 { |
|
165 // 1: install operation |
|
166 { |
|
167 CommsMessage msg; |
|
168 msg.setMessageId(MSG_ID_GET_NEXT_OPERATION); |
|
169 |
|
170 CommsMessage message; |
|
171 int rc = server.getJavaInstaller().sendReceive(msg, message, TIMEOUT); |
|
172 |
|
173 int oper; |
|
174 string url; |
|
175 message >> oper >> url; |
|
176 CHECK(rc == 0); |
|
177 CHECK(oper == OPERATION_INSTALL); |
|
178 CHECK(url.compare("unittest:\\\\tckrunner_tester") == 0); |
|
179 } |
|
180 // 2: install result |
|
181 { |
|
182 CommsMessage msg; |
|
183 msg.setMessageId(MSG_ID_OPERATION_RESULT); |
|
184 msg << OPERATION_INSTALL << 0 << 3 << "fail" << "fail" << "fail"; |
|
185 server.getJavaInstaller().send(msg); |
|
186 } |
|
187 // 3: uninstall operation |
|
188 { |
|
189 CommsMessage msg; |
|
190 msg.setMessageId(MSG_ID_GET_NEXT_OPERATION); |
|
191 |
|
192 CommsMessage message; |
|
193 int rc = server.getJavaInstaller().sendReceive(msg, message, TIMEOUT); |
|
194 |
|
195 int oper; |
|
196 string uid; |
|
197 message >> oper >> uid; |
|
198 CHECK(rc == 0); |
|
199 CHECK(oper == OPERATION_UNINSTALL); |
|
200 CHECK(uid.compare("fail") == 0); |
|
201 } |
|
202 // 4: launch request check |
|
203 { |
|
204 CHECK(server.mLaunchReqs.size() == 3); |
|
205 CHECK(server.mLaunchReqs.front().compare("fail") == 0); |
|
206 server.mLaunchReqs.pop(); |
|
207 CHECK(server.mLaunchReqs.front().compare("fail") == 0); |
|
208 server.mLaunchReqs.pop(); |
|
209 CHECK(server.mLaunchReqs.front().compare("fail") == 0); |
|
210 server.mLaunchReqs.pop(); |
|
211 } |
|
212 // 5: uninstall result |
|
213 { |
|
214 CommsMessage msg; |
|
215 msg.setMessageId(MSG_ID_OPERATION_RESULT); |
|
216 msg << OPERATION_UNINSTALL << 0; |
|
217 server.getJavaInstaller().send(msg); |
|
218 } |
|
219 } |
|
220 |
|
221 /** |
|
222 * Uninstallation fails |
|
223 * 1: install operation |
|
224 * 2: install result |
|
225 * 3: uninstall operation |
|
226 * 4: launch request check |
|
227 * 5: uninstall result nok |
|
228 */ |
|
229 TEST(TckRunner, uninstallfail) |
|
230 { |
|
231 // 1: install operation |
|
232 { |
|
233 CommsMessage msg; |
|
234 msg.setMessageId(MSG_ID_GET_NEXT_OPERATION); |
|
235 |
|
236 CommsMessage message; |
|
237 int rc = server.getJavaInstaller().sendReceive(msg, message, TIMEOUT); |
|
238 |
|
239 int oper; |
|
240 string url; |
|
241 message >> oper >> url; |
|
242 CHECK(rc == 0); |
|
243 CHECK(oper == OPERATION_INSTALL); |
|
244 CHECK(url.compare("unittest:\\\\tckrunner_tester") == 0); |
|
245 } |
|
246 // 2: install result |
|
247 { |
|
248 CommsMessage msg; |
|
249 msg.setMessageId(MSG_ID_OPERATION_RESULT); |
|
250 msg << OPERATION_INSTALL << 0 << 1 << "uid1"; |
|
251 server.getJavaInstaller().send(msg); |
|
252 } |
|
253 // 3: uninstall operation |
|
254 { |
|
255 CommsMessage msg; |
|
256 msg.setMessageId(MSG_ID_GET_NEXT_OPERATION); |
|
257 |
|
258 CommsMessage message; |
|
259 int rc = server.getJavaInstaller().sendReceive(msg, message, TIMEOUT); |
|
260 |
|
261 int oper; |
|
262 string uid; |
|
263 message >> oper >> uid; |
|
264 CHECK(rc == 0); |
|
265 CHECK(oper == OPERATION_UNINSTALL); |
|
266 CHECK(uid.compare("uid1") == 0); |
|
267 } |
|
268 // 4: launch request check |
|
269 { |
|
270 CHECK(server.mLaunchReqs.size() == 1); |
|
271 CHECK(server.mLaunchReqs.front().compare("uid1") == 0); |
|
272 server.mLaunchReqs.pop(); |
|
273 } |
|
274 // 5: uninstall result |
|
275 { |
|
276 CommsMessage msg; |
|
277 msg.setMessageId(MSG_ID_OPERATION_RESULT); |
|
278 msg << OPERATION_UNINSTALL << -1; |
|
279 server.getJavaInstaller().send(msg); |
|
280 } |
|
281 } |
|
282 |
|
283 |
|
284 /** |
|
285 * Retry count exceeded |
|
286 * 1: install operation |
|
287 * 2: install result nok |
|
288 */ |
|
289 TEST(TckRunner, retrycount) |
|
290 { |
|
291 int rc = 0; |
|
292 int i = 0; |
|
293 |
|
294 int MAX_RETRY_COUNT = 100; //needs to be bigger than in actual limit |
|
295 do |
|
296 { |
|
297 // 1: install operation |
|
298 CommsMessage msg; |
|
299 msg.setMessageId(MSG_ID_GET_NEXT_OPERATION); |
|
300 |
|
301 CommsMessage message; |
|
302 rc = server.getJavaInstaller().sendReceive(msg, message, TIMEOUT); |
|
303 |
|
304 if (rc == 0) |
|
305 { |
|
306 int oper; |
|
307 string url; |
|
308 message >> oper >> url; |
|
309 CHECK(oper == OPERATION_INSTALL || oper == OPERATION_EXIT); |
|
310 // 2: install result |
|
311 msg.reset(); |
|
312 msg.setMessageId(MSG_ID_OPERATION_RESULT); |
|
313 msg << OPERATION_INSTALL << -1 << 0; |
|
314 server.getJavaInstaller().send(msg); |
|
315 } |
|
316 } |
|
317 while (rc == 0 && i++ < MAX_RETRY_COUNT); |
|
318 |
|
319 CHECK(i < MAX_RETRY_COUNT); |
|
320 } |
|
321 |
|
322 |
|
323 /** |
|
324 * Stability test |
|
325 * 1: install operation |
|
326 * 2: install result |
|
327 * 3: uninstall operation |
|
328 * 4: uninstall result |
|
329 * 5: launch request check |
|
330 */ |
|
331 TEST(TckRunner, stabilitytest) |
|
332 { |
|
333 int TCK_RUN_LIMIT = 1000; |
|
334 int i = 0; |
|
335 do |
|
336 { |
|
337 |
|
338 // 1: install operation |
|
339 { |
|
340 CommsMessage msg; |
|
341 msg.setMessageId(MSG_ID_GET_NEXT_OPERATION); |
|
342 |
|
343 CommsMessage message; |
|
344 int rc = server.getJavaInstaller().sendReceive(msg, message, TIMEOUT); |
|
345 |
|
346 int oper; |
|
347 string url; |
|
348 message >> oper >> url; |
|
349 CHECK(rc == 0); |
|
350 CHECK(oper == OPERATION_INSTALL); |
|
351 CHECK(url.compare("unittest:\\\\tckrunner_tester") == 0); |
|
352 } |
|
353 // 2: install result |
|
354 { |
|
355 CommsMessage msg; |
|
356 msg.setMessageId(MSG_ID_OPERATION_RESULT); |
|
357 msg << OPERATION_INSTALL << 0 << 1 << "uid1"; |
|
358 server.getJavaInstaller().send(msg); |
|
359 } |
|
360 // 3: uninstall operation |
|
361 { |
|
362 CommsMessage msg; |
|
363 msg.setMessageId(MSG_ID_GET_NEXT_OPERATION); |
|
364 |
|
365 CommsMessage message; |
|
366 int rc2 = server.getJavaInstaller().sendReceive(msg, message, TIMEOUT); |
|
367 |
|
368 int oper; |
|
369 string uid; |
|
370 message >> oper >> uid; |
|
371 CHECK(rc2 == 0); |
|
372 CHECK(oper == OPERATION_UNINSTALL); |
|
373 CHECK(uid.compare("uid1") == 0); |
|
374 } |
|
375 |
|
376 // 4: uninstall result |
|
377 { |
|
378 CommsMessage msg; |
|
379 msg.setMessageId(MSG_ID_OPERATION_RESULT); |
|
380 msg << OPERATION_UNINSTALL << 0; |
|
381 server.getJavaInstaller().send(msg); |
|
382 } |
|
383 } |
|
384 while (++i < TCK_RUN_LIMIT); |
|
385 |
|
386 // 5: launch request check |
|
387 { |
|
388 ELOG1(ETckRunner, "server.mLaunchReqs.size()=%d", server.mLaunchReqs.size()); |
|
389 CHECK(server.mLaunchReqs.size() == TCK_RUN_LIMIT); |
|
390 while (!server.mLaunchReqs.empty()) |
|
391 { |
|
392 server.mLaunchReqs.pop(); |
|
393 } |
|
394 } |
|
395 } |
|
396 |
|
397 |
|
398 |
|
399 |