|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <stdio.h> |
|
20 #include <stdlib.h> |
|
21 #include <unistd.h> |
|
22 #include <string.h> |
|
23 #include <dbus/dbus.h> |
|
24 #ifndef __SYMBIAN32__ |
|
25 #include <dbus/dbus-connection-internal.h> |
|
26 #else |
|
27 #include "dbus-connection-internal.h" |
|
28 #endif //__SYMBIAN32__ |
|
29 |
|
30 #define REMOVE_CONNECTION 0 |
|
31 #define ADD_CONNECTION 1 |
|
32 #define ALLOW_REPLACEMENT DBUS_NAME_FLAG_ALLOW_REPLACEMENT |
|
33 #define REPLACE_EXISTING DBUS_NAME_FLAG_REPLACE_EXISTING |
|
34 #define DO_NOT_QUEUE DBUS_NAME_FLAG_DO_NOT_QUEUE |
|
35 |
|
36 #define PRIMARY_OWNER DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER |
|
37 #define IN_QUEUE DBUS_REQUEST_NAME_REPLY_IN_QUEUE |
|
38 #define EXISTS DBUS_REQUEST_NAME_REPLY_EXISTS |
|
39 #define ALREADY_OWNER DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER |
|
40 |
|
41 #define RELEASED DBUS_RELEASE_NAME_REPLY_RELEASED |
|
42 #define NON_EXISTANT DBUS_RELEASE_NAME_REPLY_NON_EXISTENT |
|
43 #define NOT_OWNER DBUS_RELEASE_NAME_REPLY_NOT_OWNER |
|
44 |
|
45 #define NUM_CONN 4 |
|
46 #define TEST_NAME "org.freedesktop.DBus.TestSuite.NameTest" |
|
47 #define NUM_TRIES_TIL_FAIL 15 |
|
48 |
|
49 #define LOG_FILE "c:\\logs\\name_test_log1.txt" |
|
50 #include "std_log_result.h" |
|
51 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
52 |
|
53 void create_xml(int result) |
|
54 { |
|
55 if(result) |
|
56 assert_failed = 1; |
|
57 |
|
58 testResultXml("name_test"); |
|
59 close_log_file(); |
|
60 } |
|
61 |
|
62 |
|
63 typedef struct { |
|
64 int command; |
|
65 |
|
66 int connection_number; |
|
67 dbus_uint32_t flags; |
|
68 |
|
69 dbus_uint32_t expected_result; |
|
70 |
|
71 int expected_queue[NUM_CONN]; |
|
72 } CommandAndResult; |
|
73 |
|
74 CommandAndResult test_data[] = { |
|
75 {ADD_CONNECTION, 0, ALLOW_REPLACEMENT | REPLACE_EXISTING, |
|
76 PRIMARY_OWNER, {0,-1,-1,-1}}, |
|
77 {ADD_CONNECTION, 0, REPLACE_EXISTING, |
|
78 ALREADY_OWNER, {0,-1,-1,-1}}, |
|
79 {ADD_CONNECTION, 1, ALLOW_REPLACEMENT | REPLACE_EXISTING, |
|
80 IN_QUEUE, {0,1,-1,-1}}, |
|
81 {REMOVE_CONNECTION, 0, 0, |
|
82 RELEASED, {1,-1,-1,-1}}, |
|
83 {ADD_CONNECTION, 0, REPLACE_EXISTING | DO_NOT_QUEUE, |
|
84 PRIMARY_OWNER, {0,1,-1,-1}}, |
|
85 {ADD_CONNECTION, 2, ALLOW_REPLACEMENT, |
|
86 IN_QUEUE, {0,1,2,-1}}, |
|
87 {ADD_CONNECTION, 2, ALLOW_REPLACEMENT | REPLACE_EXISTING, |
|
88 IN_QUEUE, {0,2,1,-1}}, |
|
89 {ADD_CONNECTION, 0, ALLOW_REPLACEMENT | DO_NOT_QUEUE, |
|
90 ALREADY_OWNER, {0,2,1,-1}}, |
|
91 {ADD_CONNECTION, 1, ALLOW_REPLACEMENT | REPLACE_EXISTING, |
|
92 PRIMARY_OWNER, {1,2,-1,-1}}, |
|
93 {ADD_CONNECTION, 0, REPLACE_EXISTING, |
|
94 PRIMARY_OWNER, {0,1,2,-1}}, |
|
95 {ADD_CONNECTION, 2, DO_NOT_QUEUE, |
|
96 EXISTS, {0,1,-1,-1}}, |
|
97 {REMOVE_CONNECTION, 2, 0, |
|
98 NOT_OWNER, {0,1,-1,-1}}, |
|
99 {ADD_CONNECTION, 3, 0, |
|
100 IN_QUEUE, {0,1,3,-1}}, |
|
101 {ADD_CONNECTION, 0, ALLOW_REPLACEMENT, |
|
102 ALREADY_OWNER, {0,1,3,-1}}, |
|
103 {ADD_CONNECTION, 2, ALLOW_REPLACEMENT, |
|
104 IN_QUEUE, {0,1,3,2}} |
|
105 }; |
|
106 |
|
107 static dbus_bool_t |
|
108 check_connection (DBusConnection *conn, |
|
109 int iteration, |
|
110 DBusConnection *uniq_conn[NUM_CONN]) |
|
111 { |
|
112 DBusMessage *reply; |
|
113 DBusMessage *method; |
|
114 DBusError error; |
|
115 char **list; |
|
116 int len, i; |
|
117 const char *name; |
|
118 |
|
119 reply = NULL; |
|
120 method = NULL; |
|
121 list = NULL; |
|
122 |
|
123 dbus_error_init (&error); |
|
124 |
|
125 name = TEST_NAME; |
|
126 method = dbus_message_new_method_call (DBUS_SERVICE_DBUS, |
|
127 DBUS_PATH_DBUS, |
|
128 DBUS_INTERFACE_DBUS, |
|
129 "ListQueuedOwners"); |
|
130 |
|
131 if (method == NULL) |
|
132 goto out; |
|
133 |
|
134 if (!dbus_message_append_args (method, |
|
135 DBUS_TYPE_STRING, &name, |
|
136 DBUS_TYPE_INVALID)) |
|
137 { |
|
138 fprintf (stderr, "Error appending args\n") ; |
|
139 std_log(LOG_FILENAME_LINE, "Error appending args\n"); |
|
140 goto out; |
|
141 } |
|
142 |
|
143 reply = dbus_connection_send_with_reply_and_block (conn, |
|
144 method, |
|
145 -1, |
|
146 &error); |
|
147 |
|
148 if (reply == NULL) |
|
149 { |
|
150 fprintf (stderr, "Error calling ListQueuedOwners: %s\n", error.message); |
|
151 std_log(LOG_FILENAME_LINE, "Error calling ListQueuedOwners: %s\n", error.message); |
|
152 dbus_error_free (&error); |
|
153 goto out; |
|
154 } |
|
155 |
|
156 |
|
157 |
|
158 if (!dbus_message_get_args (reply, |
|
159 &error, |
|
160 DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, |
|
161 &list, &len, |
|
162 DBUS_TYPE_INVALID)) |
|
163 { |
|
164 fprintf (stderr, "Error getting args: %s\n", error.message); |
|
165 std_log(LOG_FILENAME_LINE, "Error getting args: %s\n", error.message); |
|
166 dbus_error_free (&error); |
|
167 goto out; |
|
168 } |
|
169 |
|
170 printf ("Iteration %i: ", iteration); |
|
171 std_log(LOG_FILENAME_LINE, "Iteration %i: ", iteration); |
|
172 if (len > NUM_CONN) |
|
173 { |
|
174 fprintf (stderr, "There are %i connections in the queue," |
|
175 " we are only expecting up to %i connections!\n", |
|
176 len, |
|
177 NUM_CONN); |
|
178 std_log(LOG_FILENAME_LINE, "There are %i connections in the queue," |
|
179 " we are only expecting up to %i connections!\n", |
|
180 len, |
|
181 NUM_CONN); |
|
182 goto out; |
|
183 } |
|
184 |
|
185 for (i = 0; i < len; i++) |
|
186 { |
|
187 int expected_conn_num; |
|
188 const char *expected_uname; |
|
189 |
|
190 if (i > 0) |
|
191 printf (", "); |
|
192 |
|
193 printf ("%s", list[i]); |
|
194 std_log(LOG_FILENAME_LINE, "%s", list[i]); |
|
195 |
|
196 expected_conn_num = test_data[iteration].expected_queue[i]; |
|
197 |
|
198 if (expected_conn_num == -1) |
|
199 { |
|
200 fprintf (stderr, |
|
201 "\nDid not expect this last connection" |
|
202 " to be in the queue!\n"); |
|
203 std_log(LOG_FILENAME_LINE, "\nDid not expect this last connection" |
|
204 " to be in the queue!\n"); |
|
205 goto out; |
|
206 } |
|
207 |
|
208 expected_uname = |
|
209 dbus_bus_get_unique_name (uniq_conn[expected_conn_num]); |
|
210 |
|
211 if (strcmp (list[i], expected_uname) != 0) |
|
212 { |
|
213 fprintf (stderr, |
|
214 "\n%s expected but %s is in the queue!\n", |
|
215 expected_uname, |
|
216 list[i]); |
|
217 std_log(LOG_FILENAME_LINE, "\n%s expected but %s is in the queue!\n", |
|
218 expected_uname, |
|
219 list[i]); |
|
220 |
|
221 goto out; |
|
222 } |
|
223 } |
|
224 |
|
225 printf ("\n"); |
|
226 std_log(LOG_FILENAME_LINE, "\n"); |
|
227 dbus_message_unref (method); |
|
228 dbus_message_unref (reply); |
|
229 dbus_free_string_array (list); |
|
230 return TRUE; |
|
231 |
|
232 out: |
|
233 if (method != NULL) |
|
234 dbus_message_unref (method); |
|
235 |
|
236 if (reply != NULL) |
|
237 dbus_message_unref (reply); |
|
238 |
|
239 if (list != NULL) |
|
240 dbus_free_string_array (list); |
|
241 |
|
242 return FALSE; |
|
243 } |
|
244 |
|
245 static dbus_bool_t |
|
246 match_acquired_or_lost_signal (DBusConnection *conn, const char *member, const char *name) |
|
247 { |
|
248 int tries; |
|
249 DBusMessage *msg; |
|
250 const char *interface = "org.freedesktop.DBus"; |
|
251 |
|
252 for (tries = 0; tries < NUM_TRIES_TIL_FAIL; tries++) |
|
253 { |
|
254 _dbus_connection_lock (conn); |
|
255 _dbus_connection_do_iteration_unlocked (conn, |
|
256 DBUS_ITERATION_DO_READING | |
|
257 DBUS_ITERATION_DO_WRITING | |
|
258 DBUS_ITERATION_BLOCK, |
|
259 0); |
|
260 _dbus_connection_unlock (conn); |
|
261 msg = dbus_connection_pop_message (conn); |
|
262 if (msg != NULL) |
|
263 { |
|
264 if (dbus_message_is_signal (msg, |
|
265 interface, |
|
266 member)) |
|
267 { |
|
268 const char *n; |
|
269 DBusError error; |
|
270 dbus_error_init (&error); |
|
271 |
|
272 dbus_message_get_args (msg, &error, DBUS_TYPE_STRING, &n, DBUS_TYPE_INVALID); |
|
273 |
|
274 if (dbus_error_is_set (&error)) |
|
275 { |
|
276 fprintf (stderr, "Error getting args: %s\n", error.message); |
|
277 std_log(LOG_FILENAME_LINE, "Error getting args: %s\n", error.message); |
|
278 dbus_error_free (&error); |
|
279 dbus_message_unref (msg); |
|
280 return FALSE; |
|
281 } |
|
282 |
|
283 if (strcmp (n, name) == 0) |
|
284 { |
|
285 dbus_message_unref (msg); |
|
286 break; |
|
287 } |
|
288 } |
|
289 dbus_message_unref (msg); |
|
290 } |
|
291 } |
|
292 |
|
293 if (tries == NUM_TRIES_TIL_FAIL) |
|
294 { |
|
295 fprintf (stderr, "Did not recive the expected %s.%s signal!!!\n", interface, member); |
|
296 std_log(LOG_FILENAME_LINE, "Did not recive the expected %s.%s signal!!!\n", interface, member); |
|
297 return FALSE; |
|
298 } |
|
299 |
|
300 return TRUE; |
|
301 } |
|
302 |
|
303 static dbus_bool_t |
|
304 match_name_owner_changed_signal (DBusConnection *conn, const char *bus_name, const char *lost_name, const char *acquired_name) |
|
305 { |
|
306 int tries; |
|
307 DBusMessage *msg; |
|
308 |
|
309 for (tries = 0; tries < NUM_TRIES_TIL_FAIL; tries++) |
|
310 { |
|
311 _dbus_connection_lock (conn); |
|
312 _dbus_connection_do_iteration_unlocked (conn, |
|
313 DBUS_ITERATION_DO_READING | |
|
314 DBUS_ITERATION_DO_WRITING | |
|
315 DBUS_ITERATION_BLOCK, |
|
316 0); |
|
317 _dbus_connection_unlock (conn); |
|
318 msg = dbus_connection_pop_message (conn); |
|
319 |
|
320 if (msg != NULL) |
|
321 { |
|
322 if (dbus_message_is_signal (msg, |
|
323 "org.freedesktop.DBus", |
|
324 "NameOwnerChanged")) |
|
325 { |
|
326 const char *n; |
|
327 const char *ln; |
|
328 const char *an; |
|
329 DBusError error; |
|
330 dbus_error_init (&error); |
|
331 |
|
332 dbus_message_get_args (msg, &error, DBUS_TYPE_STRING, &n, DBUS_TYPE_STRING, &ln, DBUS_TYPE_STRING, &an, DBUS_TYPE_INVALID); |
|
333 |
|
334 if (dbus_error_is_set (&error)) |
|
335 { |
|
336 fprintf (stderr, "Error getting args: %s\n", error.message); |
|
337 std_log(LOG_FILENAME_LINE, "Error getting args: %s\n", error.message); |
|
338 dbus_error_free (&error); |
|
339 dbus_message_unref (msg); |
|
340 return FALSE; |
|
341 } |
|
342 |
|
343 if (strcmp (n, bus_name) == 0) |
|
344 { |
|
345 if ((lost_name == NULL && strcmp (ln, "") == 0) |
|
346 || strcmp (lost_name, ln) == 0) |
|
347 { |
|
348 if ((acquired_name == NULL && strcmp (an, "") == 0) |
|
349 || strcmp (acquired_name, an) == 0) |
|
350 { |
|
351 dbus_message_unref (msg); |
|
352 break; |
|
353 } |
|
354 else |
|
355 { |
|
356 fprintf (stderr, "Error: name %s was expected to be acquired but we got %s instead\n", acquired_name, an); |
|
357 std_log(LOG_FILENAME_LINE, "Error: name %s was expected to be acquired but we got %s instead\n", acquired_name, an); |
|
358 dbus_message_unref (msg); |
|
359 return FALSE; |
|
360 } |
|
361 } |
|
362 else |
|
363 { |
|
364 fprintf (stderr, "Error: name %s was expected to be lost but we got %s instead\n", lost_name, ln); |
|
365 std_log(LOG_FILENAME_LINE, "Error: name %s was expected to be lost but we got %s instead\n", lost_name, ln); |
|
366 dbus_message_unref (msg); |
|
367 return FALSE; |
|
368 } |
|
369 } |
|
370 } |
|
371 dbus_message_unref (msg); |
|
372 } |
|
373 } |
|
374 |
|
375 if (tries == NUM_TRIES_TIL_FAIL) |
|
376 { |
|
377 fprintf (stderr, "Did not recive the expected NameOwnerChanged signal!!!\n"); |
|
378 std_log(LOG_FILENAME_LINE, "Did not recive the expected NameOwnerChanged signal!!!\n"); |
|
379 return FALSE; |
|
380 } |
|
381 |
|
382 return TRUE; |
|
383 } |
|
384 |
|
385 |
|
386 static dbus_bool_t |
|
387 check_signals (DBusConnection *monitor, |
|
388 int iteration, |
|
389 DBusConnection *conn[NUM_CONN]) |
|
390 { |
|
391 DBusConnection *lost_conn = NULL; |
|
392 DBusConnection *acquired_conn = NULL; |
|
393 const char *lost_name; |
|
394 const char *acquired_name; |
|
395 |
|
396 if (iteration == 0) |
|
397 { |
|
398 int i; |
|
399 i = test_data[iteration].expected_queue[0]; |
|
400 |
|
401 if (i >= 0) |
|
402 acquired_conn = conn[i]; |
|
403 } |
|
404 else |
|
405 { |
|
406 int i; |
|
407 i = test_data[iteration - 1].expected_queue[0]; |
|
408 |
|
409 if (i >= 0) |
|
410 lost_conn = conn[i]; |
|
411 |
|
412 i = test_data[iteration].expected_queue[0]; |
|
413 |
|
414 if (i >= 0) |
|
415 acquired_conn = conn[i]; |
|
416 |
|
417 if (acquired_conn == lost_conn) |
|
418 acquired_conn = lost_conn = NULL; |
|
419 } |
|
420 |
|
421 lost_name = lost_conn == NULL? NULL : |
|
422 dbus_bus_get_unique_name (lost_conn); |
|
423 |
|
424 acquired_name = acquired_conn == NULL? NULL : |
|
425 dbus_bus_get_unique_name (acquired_conn); |
|
426 |
|
427 if (lost_name != NULL) |
|
428 if (!match_acquired_or_lost_signal (lost_conn, |
|
429 "NameLost", |
|
430 TEST_NAME)) |
|
431 return FALSE; |
|
432 |
|
433 if (acquired_name != NULL) |
|
434 if (!match_acquired_or_lost_signal (acquired_conn, |
|
435 "NameAcquired", |
|
436 TEST_NAME)) |
|
437 return FALSE; |
|
438 |
|
439 if (acquired_name != NULL || lost_name != NULL) |
|
440 if (!match_name_owner_changed_signal (monitor, |
|
441 TEST_NAME, |
|
442 lost_name, |
|
443 acquired_name)) |
|
444 return FALSE; |
|
445 |
|
446 return TRUE; |
|
447 } |
|
448 |
|
449 int |
|
450 main () |
|
451 { |
|
452 DBusConnection *conn[NUM_CONN]; |
|
453 DBusConnection *monitor; |
|
454 DBusError error; |
|
455 int i; |
|
456 int test_data_len; |
|
457 |
|
458 test_data_len = sizeof (test_data) / sizeof (CommandAndResult); |
|
459 |
|
460 dbus_error_init (&error); |
|
461 |
|
462 conn[0] = dbus_bus_get_private (DBUS_BUS_SESSION, &error); |
|
463 if (dbus_error_is_set (&error)) |
|
464 { |
|
465 fprintf (stderr, "*** Failed to open connection 0 to session bus: %s\n", |
|
466 error.message); |
|
467 std_log(LOG_FILENAME_LINE, "*** Failed to open connection 0 to session bus: %s\n", |
|
468 error.message); |
|
469 dbus_error_free (&error); |
|
470 create_xml(1); |
|
471 return 1; |
|
472 } |
|
473 |
|
474 if (!match_acquired_or_lost_signal (conn[0], |
|
475 "NameAcquired", |
|
476 dbus_bus_get_unique_name (conn[0]))) |
|
477 { |
|
478 create_xml(1); |
|
479 return 1; |
|
480 } |
|
481 |
|
482 conn[1] = dbus_bus_get_private (DBUS_BUS_SESSION, &error); |
|
483 if (dbus_error_is_set (&error)) |
|
484 { |
|
485 fprintf (stderr, "*** Failed to open connection 1 to session bus: %s\n", |
|
486 error.message); |
|
487 std_log(LOG_FILENAME_LINE, "*** Failed to open connection 1 to session bus: %s\n", |
|
488 error.message); |
|
489 dbus_error_free (&error); |
|
490 create_xml(1); |
|
491 return 1; |
|
492 } |
|
493 |
|
494 if (!match_acquired_or_lost_signal (conn[1], |
|
495 "NameAcquired", |
|
496 dbus_bus_get_unique_name (conn[1]))) |
|
497 { |
|
498 create_xml(1); |
|
499 return 1; |
|
500 } |
|
501 |
|
502 |
|
503 conn[2] = dbus_bus_get_private (DBUS_BUS_SESSION, &error); |
|
504 if (dbus_error_is_set (&error)) |
|
505 { |
|
506 fprintf (stderr, "*** Failed to open connection 2 to session bus: %s\n", |
|
507 error.message); |
|
508 std_log(LOG_FILENAME_LINE, "*** Failed to open connection 2 to session bus: %s\n", |
|
509 error.message); |
|
510 dbus_error_free (&error); |
|
511 create_xml(1); |
|
512 return 1; |
|
513 } |
|
514 |
|
515 if (!match_acquired_or_lost_signal (conn[2], |
|
516 "NameAcquired", |
|
517 dbus_bus_get_unique_name (conn[2]))) |
|
518 { |
|
519 create_xml(1); |
|
520 return 1; |
|
521 } |
|
522 |
|
523 |
|
524 conn[3] = dbus_bus_get_private (DBUS_BUS_SESSION, &error); |
|
525 if (dbus_error_is_set (&error)) |
|
526 { |
|
527 fprintf (stderr, "*** Failed to open connection 3 to session bus: %s\n", |
|
528 error.message); |
|
529 std_log(LOG_FILENAME_LINE, "*** Failed to open connection 3 to session bus: %s\n", |
|
530 error.message); |
|
531 dbus_error_free (&error); |
|
532 create_xml(1); |
|
533 return 1; |
|
534 } |
|
535 |
|
536 if (!match_acquired_or_lost_signal (conn[3], |
|
537 "NameAcquired", |
|
538 dbus_bus_get_unique_name (conn[3]))) |
|
539 { |
|
540 create_xml(1); |
|
541 return 1; |
|
542 } |
|
543 |
|
544 |
|
545 monitor = dbus_bus_get (DBUS_BUS_SESSION, &error); |
|
546 if (dbus_error_is_set (&error)) |
|
547 { |
|
548 fprintf (stderr, "*** Failed to open monitoring connection to session bus: %s\n", |
|
549 error.message); |
|
550 std_log(LOG_FILENAME_LINE, "*** Failed to open monitoring connection to session bus: %s\n", |
|
551 error.message); |
|
552 dbus_error_free (&error); |
|
553 create_xml(1); |
|
554 return 1; |
|
555 } |
|
556 |
|
557 if (!match_acquired_or_lost_signal (monitor, |
|
558 "NameAcquired", |
|
559 dbus_bus_get_unique_name (monitor))) |
|
560 { |
|
561 create_xml(1); |
|
562 return 1; |
|
563 } |
|
564 |
|
565 dbus_bus_add_match (monitor, "", &error); |
|
566 if (dbus_error_is_set (&error)) |
|
567 { |
|
568 fprintf (stderr, "*** Failed to set filter on monitoring connection: %s\n", |
|
569 error.message); |
|
570 std_log(LOG_FILENAME_LINE, "*** Failed to set filter on monitoring connection: %s\n", |
|
571 error.message); |
|
572 dbus_error_free (&error); |
|
573 create_xml(1); |
|
574 return 1; |
|
575 } |
|
576 |
|
577 |
|
578 for (i = 0; i < NUM_CONN; i++) |
|
579 dbus_connection_set_exit_on_disconnect (conn[i], FALSE); |
|
580 |
|
581 for (i = 0; i < test_data_len; i++) |
|
582 { |
|
583 dbus_uint32_t result; |
|
584 result = 0; |
|
585 |
|
586 if (test_data[i].command == ADD_CONNECTION) |
|
587 { |
|
588 result = dbus_bus_request_name (conn[test_data[i].connection_number], |
|
589 TEST_NAME, |
|
590 test_data[i].flags, |
|
591 &error); |
|
592 |
|
593 if (dbus_error_is_set (&error)) |
|
594 { |
|
595 fprintf (stderr, "Error on addition in iteration %i: %s\n", i, error.message); |
|
596 std_log(LOG_FILENAME_LINE, "Error on addition in iteration %i: %s\n", i, error.message); |
|
597 dbus_error_free (&error); |
|
598 create_xml(1); |
|
599 return 1; |
|
600 } |
|
601 } |
|
602 else if (test_data[i].command == REMOVE_CONNECTION) |
|
603 { |
|
604 result = dbus_bus_release_name (conn[test_data[i].connection_number], |
|
605 TEST_NAME, |
|
606 &error); |
|
607 if (dbus_error_is_set (&error)) |
|
608 { |
|
609 fprintf (stderr, "*** Failed to remove connection %i in iteration %i: %s\n", |
|
610 test_data[i].connection_number, |
|
611 i, |
|
612 error.message); |
|
613 std_log(LOG_FILENAME_LINE, "*** Failed to remove connection %i in iteration %i: %s\n", |
|
614 test_data[i].connection_number, |
|
615 i, |
|
616 error.message); |
|
617 dbus_error_free (&error); |
|
618 create_xml(1); |
|
619 return 1; |
|
620 } |
|
621 } |
|
622 else |
|
623 { |
|
624 fprintf (stderr, "Command #%i not a valid command!\n", test_data[i].command); |
|
625 std_log(LOG_FILENAME_LINE, "Command #%i not a valid command!\n", test_data[i].command); |
|
626 create_xml(1); |
|
627 return 1; |
|
628 } |
|
629 |
|
630 |
|
631 if (result != test_data[i].expected_result) |
|
632 { |
|
633 fprintf (stderr, "Results recived (%i) are not the expected results (%i) in iteration %i\n", |
|
634 result, |
|
635 test_data[i].expected_result, |
|
636 i); |
|
637 std_log(LOG_FILENAME_LINE, "Results recived (%i) are not the expected results (%i) in iteration %i\n", |
|
638 result, |
|
639 test_data[i].expected_result, |
|
640 i); |
|
641 create_xml(1); |
|
642 return 1; |
|
643 } |
|
644 |
|
645 if (!check_connection (monitor, i, conn)) |
|
646 { |
|
647 fprintf (stderr, "Failed at iteration %i\n", i); |
|
648 std_log(LOG_FILENAME_LINE, "Failed at iteration %i\n", i); |
|
649 create_xml(1); |
|
650 return 1; |
|
651 } |
|
652 |
|
653 if (!check_signals (monitor, i, conn)) |
|
654 { |
|
655 fprintf (stderr, "Failed at iteration %i\n", i); |
|
656 std_log(LOG_FILENAME_LINE, "Failed at iteration %i\n", i); |
|
657 create_xml(1); |
|
658 return 1; |
|
659 } |
|
660 } |
|
661 |
|
662 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
663 create_xml(0); |
|
664 return 0; |
|
665 } |