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