1 /* |
|
2 * Copyright (c) 2009 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 the License "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: This file contains testclass implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // [INCLUDE FILES] - do not remove |
|
20 #include <e32svr.h> |
|
21 #include <StifParser.h> |
|
22 #include <StifTestInterface.h> |
|
23 #include <msgqlib.h> |
|
24 #include <msg_enums.h> |
|
25 #include <msgliterals.h> |
|
26 #include <stdlib.h> |
|
27 #include <msgqinternal.h> |
|
28 #include "messagequeue_api.h" |
|
29 |
|
30 // EXTERNAL DATA STRUCTURES |
|
31 //extern ?external_data; |
|
32 |
|
33 // EXTERNAL FUNCTION PROTOTYPES |
|
34 //extern ?external_function( ?arg_type,?arg_type ); |
|
35 |
|
36 // CONSTANTS |
|
37 //const ?type ?constant_var = ?constant; |
|
38 |
|
39 // MACROS |
|
40 //#define ?macro ?macro_def |
|
41 |
|
42 // LOCAL CONSTANTS AND MACROS |
|
43 //const ?type ?constant_var = ?constant; |
|
44 //#define ?macro_name ?macro_def |
|
45 |
|
46 // MODULE DATA STRUCTURES |
|
47 //enum ?declaration |
|
48 //typedef ?declaration |
|
49 |
|
50 // LOCAL FUNCTION PROTOTYPES |
|
51 //?type ?function_name( ?arg_type, ?arg_type ); |
|
52 |
|
53 // FORWARD DECLARATIONS |
|
54 //class ?FORWARD_CLASSNAME; |
|
55 |
|
56 // ============================= LOCAL FUNCTIONS =============================== |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // ?function_name ?description. |
|
60 // ?description |
|
61 // Returns: ?value_1: ?description |
|
62 // ?value_n: ?description_line1 |
|
63 // ?description_line2 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 /* |
|
67 ?type ?function_name( |
|
68 ?arg_type arg, // ?description |
|
69 ?arg_type arg) // ?description |
|
70 { |
|
71 |
|
72 ?code // ?comment |
|
73 |
|
74 // ?comment |
|
75 ?code |
|
76 } |
|
77 */ |
|
78 //----------------------------------------------------------------------------- |
|
79 // function_name : running isolation server exe |
|
80 // description : Deallocates all the data |
|
81 // Returns : None |
|
82 //----------------------------------------------------------------------------- |
|
83 int run_isoserver() |
|
84 { |
|
85 // running isoserver |
|
86 RProcess isosrv_launcher; |
|
87 TInt lunch_err = 0; |
|
88 _LIT(KProcess, "isoserver.exe"); |
|
89 lunch_err = isosrv_launcher.Create( KProcess, KNullDesC ); |
|
90 if ( KErrNone != lunch_err ) |
|
91 { |
|
92 return KErrGeneral; |
|
93 |
|
94 } |
|
95 isosrv_launcher.Resume(); |
|
96 return KErrNone; |
|
97 } |
|
98 // ============================ MEMBER FUNCTIONS =============================== |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // Cmessagequeue_api::Delete |
|
102 // Delete here all resources allocated and opened from test methods. |
|
103 // Called from destructor. |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 void Cmessagequeue_api::Delete() |
|
107 { |
|
108 |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // Cmessagequeue_api::RunMethodL |
|
113 // Run specified method. Contains also table of test mothods and their names. |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 TInt Cmessagequeue_api::RunMethodL( |
|
117 CStifItemParser& aItem ) |
|
118 { |
|
119 |
|
120 static TStifFunctionInfo const KFunctions[] = |
|
121 { |
|
122 // Copy this line for every implemented function. |
|
123 // First string is the function name used in TestScripter script file. |
|
124 // Second is the actual implementation member function. |
|
125 ENTRY( "TestMessageQCreate", Cmessagequeue_api::TestMessageQCreate ), |
|
126 ENTRY( "TestMessageQSend", Cmessagequeue_api::TestMessageQSend ), |
|
127 ENTRY( "TestMessageQDelete", Cmessagequeue_api::TestMessageQDelete ), |
|
128 ENTRY( "TestMessageQReceive", Cmessagequeue_api::TestMessageQReceive ), |
|
129 ENTRY( "TestMessageQClean", Cmessagequeue_api::TestMessageQClean ), |
|
130 ENTRY( "TestMessageQCheck", Cmessagequeue_api::TestMessageQCheck ), |
|
131 ENTRY( "TestMsgQMaxCheck", Cmessagequeue_api::TestMsgQMaxCheck ), |
|
132 //ADD NEW ENTRY HERE |
|
133 // [test cases entries] - Do not remove |
|
134 |
|
135 }; |
|
136 |
|
137 const TInt count = sizeof( KFunctions ) / |
|
138 sizeof( TStifFunctionInfo ); |
|
139 |
|
140 return RunInternalL( KFunctions, count, aItem ); |
|
141 |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // Cmessagequeue_api::ExampleL |
|
146 // Example test method function. |
|
147 // (other items were commented in a header). |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 TInt Cmessagequeue_api::TestMessageQCreate( CStifItemParser& aItem ) |
|
151 { |
|
152 char smsg[MAX_MSG_SIZE]; |
|
153 char rmsg[MAX_MSG_SIZE]; |
|
154 int index=0; |
|
155 int timeout = 100; |
|
156 int nBytes; |
|
157 int result = 0; |
|
158 int err = 0; |
|
159 int status = 0; |
|
160 int run_iso; |
|
161 FILE *fp; |
|
162 message_hdr_req *msgHdr = NULL; |
|
163 message_hdr_resp* msg_struct = NULL; |
|
164 TInt return_value = 0; |
|
165 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
166 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
167 //running isoserver |
|
168 run_iso = run_isoserver(); |
|
169 if(run_iso) |
|
170 { |
|
171 iLog->Log ( _L ( "running isolation server is failed" ) ); |
|
172 return KErrGeneral; |
|
173 } |
|
174 //create message queue for send request |
|
175 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
176 if(err) |
|
177 { |
|
178 iLog->Log ( _L ( "creating requet queue is failed" ) ); |
|
179 return KErrGeneral; |
|
180 } |
|
181 //create message queue for response request |
|
182 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
183 if(err) |
|
184 { |
|
185 iLog->Log ( _L ( "creating requet queue is failed" ) ); |
|
186 return KErrGeneral; |
|
187 } |
|
188 index=0; |
|
189 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
190 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
191 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
192 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
193 msgHdr->message_type = EKill_Process; |
|
194 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
195 index += sizeof( message_hdr_req ); |
|
196 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
197 free(msgHdr); |
|
198 return KErrNone; |
|
199 |
|
200 } |
|
201 |
|
202 |
|
203 TInt Cmessagequeue_api::TestMessageQSend( CStifItemParser& aItem ) |
|
204 { |
|
205 char smsg[MAX_MSG_SIZE]; |
|
206 char rmsg[MAX_MSG_SIZE]; |
|
207 int index=0; |
|
208 int timeout = 100; |
|
209 int nBytes; |
|
210 int result = 0; |
|
211 int err = 0; |
|
212 int status = 0; |
|
213 int run_iso; |
|
214 FILE *fp; |
|
215 message_hdr_req *msgHdr = NULL; |
|
216 message_hdr_resp* msg_struct = NULL; |
|
217 TInt return_value = 0; |
|
218 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
219 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
220 //running isoserver |
|
221 run_iso = run_isoserver(); |
|
222 if(run_iso) |
|
223 { |
|
224 iLog->Log ( _L ( "running isolation server is failed" ) ); |
|
225 return KErrGeneral; |
|
226 } |
|
227 //create message queue for send request |
|
228 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
229 if(err) |
|
230 { |
|
231 iLog->Log ( _L ( "creating requet queue is failed" ) ); |
|
232 return KErrGeneral; |
|
233 } |
|
234 //create message queue for response request |
|
235 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
236 if(err) |
|
237 { |
|
238 iLog->Log ( _L ( "creating requet queue is failed" ) ); |
|
239 return KErrGeneral; |
|
240 } |
|
241 index=0; |
|
242 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
243 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
244 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
245 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
246 msgHdr->message_type = EKill_Process; |
|
247 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
248 index += sizeof( message_hdr_req ); |
|
249 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
250 free(msgHdr); |
|
251 return KErrNone; |
|
252 |
|
253 } |
|
254 |
|
255 |
|
256 TInt Cmessagequeue_api::TestMessageQDelete( CStifItemParser& aItem ) |
|
257 { |
|
258 char smsg[MAX_MSG_SIZE]; |
|
259 char rmsg[MAX_MSG_SIZE]; |
|
260 int index=0; |
|
261 int timeout = 100; |
|
262 int nBytes; |
|
263 int result = 0; |
|
264 int err = 0; |
|
265 int status = 0; |
|
266 int run_iso; |
|
267 FILE *fp; |
|
268 message_hdr_req *msgHdr = NULL; |
|
269 message_hdr_resp* msg_struct = NULL; |
|
270 TInt return_value = 0; |
|
271 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
272 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
273 //running isoserver |
|
274 run_iso = run_isoserver(); |
|
275 if(run_iso) |
|
276 { |
|
277 iLog->Log ( _L ( "running isolation server is failed" ) ); |
|
278 return KErrGeneral; |
|
279 } |
|
280 //create message queue for send request |
|
281 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
282 if(err) |
|
283 { |
|
284 iLog->Log ( _L ( "creating requet queue is failed" ) ); |
|
285 return KErrGeneral; |
|
286 } |
|
287 //create message queue for response request |
|
288 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
289 if(err) |
|
290 { |
|
291 iLog->Log ( _L ( "creating requet queue is failed" ) ); |
|
292 return KErrGeneral; |
|
293 } |
|
294 index=0; |
|
295 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
296 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
297 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
298 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
299 msgHdr->message_type = EKill_Process; |
|
300 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
301 index += sizeof( message_hdr_req ); |
|
302 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
303 free(msgHdr); |
|
304 result=MsgQDelete( REQUEST_QUEUE, &err ); |
|
305 if(result) |
|
306 { |
|
307 iLog->Log ( _L ( "failing at message queue" ) ); |
|
308 return KErrGeneral; |
|
309 } |
|
310 return KErrNone; |
|
311 |
|
312 } |
|
313 |
|
314 TInt Cmessagequeue_api::TestMessageQReceive( CStifItemParser& aItem ) |
|
315 { |
|
316 char smsg[MAX_MSG_SIZE]; |
|
317 char rmsg[MAX_MSG_SIZE]; |
|
318 int index=0; |
|
319 int timeout = 100; |
|
320 int nBytes; |
|
321 int result = 0; |
|
322 int err = 0; |
|
323 int status = 0; |
|
324 int run_iso; |
|
325 FILE *fp; |
|
326 message_hdr_req *msgHdr = NULL; |
|
327 message_hdr_resp* msg_struct = NULL; |
|
328 TInt return_value = 0; |
|
329 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
330 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
331 |
|
332 //running isoserver |
|
333 run_iso = run_isoserver(); |
|
334 if(run_iso) |
|
335 { |
|
336 iLog->Log ( _L ( "running isolation server is failed" ) ); |
|
337 return KErrGeneral; |
|
338 } |
|
339 //create message queue for send request |
|
340 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
341 if(err) |
|
342 { |
|
343 iLog->Log ( _L ( "creating requet queue is failed" ) ); |
|
344 return KErrGeneral; |
|
345 } |
|
346 //create message queue for response request |
|
347 result = MsgQCreate(RESPONSE_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
348 if(err) |
|
349 { |
|
350 iLog->Log ( _L ( "creating requet queue is failed" ) ); |
|
351 return KErrGeneral; |
|
352 } |
|
353 //request formation |
|
354 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
355 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
356 |
|
357 //message header use |
|
358 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
359 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
360 |
|
361 msgHdr->message_type = ELogin_Request; |
|
362 |
|
363 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
364 index += sizeof( message_hdr_req ); |
|
365 /* Send Message to queueOne */ |
|
366 |
|
367 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
368 |
|
369 result = MsgQReceive(RESPONSE_QUEUE, rmsg, MAX_MSG_SIZE, timeout, &err); |
|
370 |
|
371 if (status < 0) |
|
372 { |
|
373 return KErrGeneral; |
|
374 |
|
375 } |
|
376 |
|
377 index=0; |
|
378 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
379 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
380 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
381 msgHdr->message_type = EKill_Process; |
|
382 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
383 index += sizeof( message_hdr_req ); |
|
384 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
385 free(msgHdr); |
|
386 result=MsgQDelete( REQUEST_QUEUE, &err ); |
|
387 if(result) |
|
388 { |
|
389 iLog->Log ( _L ( "failing at message queue" ) ); |
|
390 return KErrGeneral; |
|
391 } |
|
392 return KErrNone; |
|
393 |
|
394 } |
|
395 |
|
396 |
|
397 TInt Cmessagequeue_api::TestMessageQCheck( CStifItemParser& aItem ) |
|
398 { |
|
399 char smsg[MAX_MSG_SIZE]; |
|
400 char rmsg[MAX_MSG_SIZE]; |
|
401 int index=0; |
|
402 int timeout = 100; |
|
403 int nBytes; |
|
404 int result = 0,r1=0 ,r2=0; |
|
405 int err = 0; |
|
406 int status = 0; |
|
407 int run_iso; |
|
408 FILE *fp; |
|
409 message_hdr_req *msgHdr = NULL; |
|
410 message_hdr_resp* msg_struct = NULL; |
|
411 TInt return_value = 0; |
|
412 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
413 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
414 //running isoserver |
|
415 run_iso = run_isoserver(); |
|
416 if(run_iso) |
|
417 { |
|
418 iLog->Log ( _L ( "running isolation server is failed" ) ); |
|
419 return KErrGeneral; |
|
420 } |
|
421 //create message queue for send request |
|
422 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
423 if(err) |
|
424 { |
|
425 iLog->Log ( _L ( "creating requet queue is failed" ) ); |
|
426 return KErrGeneral; |
|
427 } |
|
428 |
|
429 //request formation |
|
430 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
431 |
|
432 //message header use |
|
433 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
434 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
435 |
|
436 msgHdr->message_type = ELogin_Request; |
|
437 |
|
438 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
439 index += sizeof( message_hdr_req ); |
|
440 /* Send Message to queueOne */ |
|
441 |
|
442 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
443 |
|
444 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
445 |
|
446 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
447 |
|
448 r1 = MsgQCheck(REQUEST_QUEUE,&err); |
|
449 |
|
450 result = MsgQClean(REQUEST_QUEUE,&err); |
|
451 |
|
452 r2 = MsgQCheck(REQUEST_QUEUE,&err); |
|
453 |
|
454 if(r1==r2) |
|
455 { |
|
456 iLog->Log ( _L ( "message q clean is failed" ) ); |
|
457 return KErrGeneral; |
|
458 } |
|
459 index=0; |
|
460 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
461 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
462 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
463 msgHdr->message_type = EKill_Process; |
|
464 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
465 index += sizeof( message_hdr_req ); |
|
466 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
467 free(msgHdr); |
|
468 result=MsgQDelete( REQUEST_QUEUE, &err ); |
|
469 if(result) |
|
470 { |
|
471 iLog->Log ( _L ( "failing at message queue" ) ); |
|
472 return KErrGeneral; |
|
473 } |
|
474 return KErrNone; |
|
475 |
|
476 } |
|
477 |
|
478 TInt Cmessagequeue_api::TestMessageQClean( CStifItemParser& aItem ) |
|
479 { |
|
480 char smsg[MAX_MSG_SIZE]; |
|
481 char rmsg[MAX_MSG_SIZE]; |
|
482 int index=0; |
|
483 int timeout = 100; |
|
484 int nBytes; |
|
485 int result = 0,r1=0 ,r2=0; |
|
486 int err = 0; |
|
487 int status = 0; |
|
488 int run_iso; |
|
489 FILE *fp; |
|
490 message_hdr_req *msgHdr = NULL; |
|
491 message_hdr_resp* msg_struct = NULL; |
|
492 TInt return_value = 0; |
|
493 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
494 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
495 //running isoserver |
|
496 run_iso = run_isoserver(); |
|
497 if(run_iso) |
|
498 { |
|
499 iLog->Log ( _L ( "running isolation server is failed" ) ); |
|
500 return KErrGeneral; |
|
501 } |
|
502 //create message queue for send request |
|
503 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
504 if(err) |
|
505 { |
|
506 iLog->Log ( _L ( "creating requet queue is failed" ) ); |
|
507 return KErrGeneral; |
|
508 } |
|
509 |
|
510 //request formation |
|
511 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
512 |
|
513 //message header use |
|
514 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
515 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
516 |
|
517 msgHdr->message_type = ELogin_Request; |
|
518 |
|
519 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
520 index += sizeof( message_hdr_req ); |
|
521 /* Send Message to queueOne */ |
|
522 |
|
523 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
524 |
|
525 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
526 |
|
527 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
528 |
|
529 r1 = MsgQCheck(REQUEST_QUEUE,&err); |
|
530 |
|
531 r1 = MsgQMaxCheck(REQUEST_QUEUE,&err); |
|
532 |
|
533 result = MsgQClean(REQUEST_QUEUE,&err); |
|
534 |
|
535 r2 = MsgQCheck(REQUEST_QUEUE,&err); |
|
536 |
|
537 if(r1==r2) |
|
538 { |
|
539 iLog->Log ( _L ( "message q clean is failed" ) ); |
|
540 return KErrGeneral; |
|
541 } |
|
542 index=0; |
|
543 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
544 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
545 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
546 msgHdr->message_type = EKill_Process; |
|
547 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
548 index += sizeof( message_hdr_req ); |
|
549 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
550 free(msgHdr); |
|
551 result=MsgQDelete( REQUEST_QUEUE, &err ); |
|
552 if(result) |
|
553 { |
|
554 iLog->Log ( _L ( "failing at message queue" ) ); |
|
555 return KErrGeneral; |
|
556 } |
|
557 return KErrNone; |
|
558 |
|
559 } |
|
560 |
|
561 TInt Cmessagequeue_api::TestMsgQMaxCheck( CStifItemParser& aItem ) |
|
562 { |
|
563 char smsg[MAX_MSG_SIZE]; |
|
564 char rmsg[MAX_MSG_SIZE]; |
|
565 int index=0; |
|
566 int timeout = 100; |
|
567 int nBytes; |
|
568 int result = 0,r1=0 ,r2=0; |
|
569 int err = 0; |
|
570 int status = 0; |
|
571 int run_iso; |
|
572 FILE *fp; |
|
573 message_hdr_req *msgHdr = NULL; |
|
574 message_hdr_resp* msg_struct = NULL; |
|
575 TInt return_value = 0; |
|
576 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
577 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
578 //running isoserver |
|
579 run_iso = run_isoserver(); |
|
580 if(run_iso) |
|
581 { |
|
582 iLog->Log ( _L ( "running isolation server is failed" ) ); |
|
583 return KErrGeneral; |
|
584 } |
|
585 //create message queue for send request |
|
586 result = MsgQCreate(REQUEST_QUEUE, MAX_MSG_Q_SIZE , MSG_Q_FIFO, &err); |
|
587 if(err) |
|
588 { |
|
589 iLog->Log ( _L ( "creating requet queue is failed" ) ); |
|
590 return KErrGeneral; |
|
591 } |
|
592 |
|
593 //request formation |
|
594 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
595 |
|
596 //message header use |
|
597 msgHdr = ( message_hdr_req* ) malloc( sizeof( message_hdr_req ) ); |
|
598 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
599 |
|
600 msgHdr->message_type = ELogin_Request; |
|
601 |
|
602 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
603 index += sizeof( message_hdr_req ); |
|
604 /* Send Message to queueOne */ |
|
605 |
|
606 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
607 |
|
608 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
609 |
|
610 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
611 |
|
612 r1 = MsgQCheck(REQUEST_QUEUE,&err); |
|
613 |
|
614 r1 = MsgQMaxCheck(REQUEST_QUEUE,&err); |
|
615 |
|
616 result = MsgQClean(REQUEST_QUEUE,&err); |
|
617 |
|
618 r2 = MsgQCheck(REQUEST_QUEUE,&err); |
|
619 |
|
620 if(r1==r2) |
|
621 { |
|
622 iLog->Log ( _L ( "message q clean is failed" ) ); |
|
623 return KErrGeneral; |
|
624 } |
|
625 index=0; |
|
626 memset( smsg, '\0', MAX_MSG_SIZE ); |
|
627 memset( rmsg, '\0', MAX_MSG_SIZE ); |
|
628 memset( msgHdr, '\0', sizeof( message_hdr_req ) ); |
|
629 msgHdr->message_type = EKill_Process; |
|
630 memcpy( smsg, msgHdr, sizeof( message_hdr_req ) ); |
|
631 index += sizeof( message_hdr_req ); |
|
632 result = MsgQSend(REQUEST_QUEUE, smsg, index, MSG_PRI_NORMAL, timeout, &err); |
|
633 free(msgHdr); |
|
634 result=MsgQDelete( REQUEST_QUEUE, &err ); |
|
635 if(result) |
|
636 { |
|
637 iLog->Log ( _L ( "failing at message queue" ) ); |
|
638 return KErrGeneral; |
|
639 } |
|
640 return KErrNone; |
|
641 |
|
642 } |
|
643 |
|
644 // ----------------------------------------------------------------------------- |
|
645 // Cmessagequeue_api::?member_function |
|
646 // ?implementation_description |
|
647 // (other items were commented in a header). |
|
648 // ----------------------------------------------------------------------------- |
|
649 // |
|
650 /* |
|
651 TInt Cmessagequeue_api::?member_function( |
|
652 CItemParser& aItem ) |
|
653 { |
|
654 |
|
655 ?code |
|
656 |
|
657 } |
|
658 */ |
|
659 |
|
660 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
661 // None |
|
662 |
|
663 // [End of File] - Do not remove |
|