Remove unneeded re-definition of EAPI
[framework/uifw/edbus.git] / src / bin / e_dbus_connman_test_api.c
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4
5 #include "E_Connman.h"
6 #include <stdio.h>
7 #include <string.h>
8
9 #define DBG(...) EINA_LOG_DBG(__VA_ARGS__)
10 #define INF(...) EINA_LOG_INFO(__VA_ARGS__)
11 #define WRN(...) EINA_LOG_WARN(__VA_ARGS__)
12 #define ERR(...) EINA_LOG_ERR(__VA_ARGS__)
13
14 static int success = 0;
15 static int failure = 0;
16 static Ecore_Timer *exiter = NULL;
17
18 static bool
19 _test_string_get(E_Connman_Element *element, const char *name, bool (*func)(const E_Connman_Element *element, const char **value))
20 {
21    const char *value;
22    bool ret;
23
24    INF("BEGIN: testing string get %s of element %s...\n", name, element->path);
25    ret = func(element, &value);
26    if (ret)
27      INF("SUCCESS: testing string get %s of element %s: %s\n",
28          name, element->path, value);
29    else
30      WRN("FAILURE: testing string get %s of element %s\n",
31          name, element->path);
32
33    return ret;
34 }
35
36 static bool
37 _test_bool_get(E_Connman_Element *element, const char *name, bool (*func)(const E_Connman_Element *element, bool *value))
38 {
39    bool value, ret;
40
41    INF("BEGIN: testing bool get %s of element %s...\n", name, element->path);
42    ret = func(element, &value);
43    if (ret)
44      INF("SUCCESS: testing bool get %s of element %s: %hhu\n",
45          name, element->path, value);
46    else
47      WRN("FAILURE: testing bool get %s of element %s\n",
48          name, element->path);
49
50    return ret;
51 }
52
53 static bool
54 _test_uchar_get(E_Connman_Element *element, const char *name, bool (*func)(const E_Connman_Element *element, unsigned char *value))
55 {
56    unsigned char value;
57    bool ret;
58
59    INF("BEGIN: testing uchar get %s of element %s...\n", name, element->path);
60    ret = func(element, &value);
61    if (ret)
62      INF("SUCCESS: testing uchar get %s of element %s: %hhu\n",
63          name, element->path, value);
64    else
65      WRN("FAILURE: testing uchar get %s of element %s\n",
66          name, element->path);
67
68    return ret;
69 }
70
71 static bool
72 _test_ushort_get(E_Connman_Element *element, const char *name, bool (*func)(const E_Connman_Element *element, unsigned short *value))
73 {
74    unsigned short value;
75    bool ret;
76
77    INF("BEGIN: testing ushort get %s of element %s...\n", name, element->path);
78    ret = func(element, &value);
79    if (ret)
80      INF("SUCCESS: testing ushort get %s of element %s: %hu\n",
81          name, element->path, value);
82    else
83      WRN("FAILURE: testing ushort get %s of element %s\n",
84          name, element->path);
85
86    return ret;
87 }
88
89 static bool
90 _test_uchar_array_get(E_Connman_Element *element, const char *name, bool (*func)(const E_Connman_Element *element, unsigned int *count, unsigned char **value))
91 {
92    unsigned char *value;
93    unsigned int count;
94    bool ret;
95
96    INF("BEGIN: testing ushort get %s of element %s...\n", name, element->path);
97    ret = func(element, &count, &value);
98    if (ret)
99      {
100         INF("SUCCESS: testing ushort get %s of element %s: %p\n",
101             name, element->path, value);
102         free(value);
103      }
104    else
105      WRN("FAILURE: testing ushort get %s of element %s\n",
106          name, element->path);
107
108    return ret;
109 }
110
111 static bool
112 _test_element_get(E_Connman_Element *element, const char *name, bool (*func)(const E_Connman_Element *element, E_Connman_Element **value))
113 {
114    E_Connman_Element *value;
115    bool ret;
116
117    INF("BEGIN: testing element get %s of element %s...\n", name, element->path);
118    ret = func(element, &value);
119    if (ret)
120      INF("SUCCESS: testing element get %s of element %s: %p\n",
121          name, element->path, value);
122    else
123      WRN("FAILURE: testing element get %s of element %s\n",
124          name, element->path);
125
126    return ret;
127 }
128
129 static bool
130 _test_elements_get(E_Connman_Element *element, const char *name, bool (*func)(const E_Connman_Element *element, unsigned int *count, E_Connman_Element ***elements))
131 {
132    E_Connman_Element **value;
133    unsigned int count;
134    bool ret;
135
136    INF("BEGIN: testing elements get %s of element %s...\n",
137        name, element->path);
138    ret = func(element, &count, &value);
139    if (ret)
140      {
141         INF("SUCCESS: testing elements get %s of element %s: %p\n",
142             name, element->path, value);
143         free(value);
144      }
145    else
146      WRN("FAILURE: testing elements get %s of element %s\n",
147          name, element->path);
148
149    return ret;
150 }
151
152 static bool
153 _test_element_get_global(const char *name, bool (*func)(E_Connman_Element **value))
154 {
155    E_Connman_Element *value;
156    bool ret;
157
158    INF("BEGIN: testing element get %s\n", name);
159    ret = func(&value);
160    if (ret)
161      INF("SUCCESS: testing element get %s: %p\n", name, value);
162    else
163      WRN("FAILURE: testing element get %s\n", name);
164
165    return ret;
166 }
167
168 static bool
169 _test_elements_get_global(const char *name, bool (*func)(unsigned int *count, E_Connman_Element ***elements))
170 {
171    E_Connman_Element **value;
172    unsigned int count;
173    bool ret;
174
175    INF("BEGIN: testing elements get %s\n", name);
176    ret = func(&count, &value);
177    if (ret)
178      {
179         INF("SUCCESS: testing elements get %s: %p\n", name, value);
180         free(value);
181      }
182    else
183      WRN("FAILURE: testing elements get %s\n", name);
184
185    return ret;
186 }
187
188 static bool
189 _test_string_get_global(const char *name, bool (*func)(const char **value))
190 {
191    const char *value;
192    bool ret;
193
194    INF("BEGIN: testing string get %s...\n", name);
195    ret = func(&value);
196    if (ret)
197      INF("SUCCESS: testing string get %s: %s\n", name, value);
198    else
199      WRN("FAILURE: testing string get %s\n", name);
200
201    return ret;
202 }
203
204 static bool
205 _test_bool_get_global(const char *name, bool (*func)(bool *value))
206 {
207    bool value, ret;
208
209    INF("BEGIN: testing bool get %s...\n", name);
210    ret = func(&value);
211    if (ret)
212      INF("SUCCESS: testing bool get %s: %hhu\n", name, value);
213    else
214      WRN("FAILURE: testing bool get %s\n", name);
215
216    return ret;
217 }
218
219 static bool
220 _test_strings_get_global(const char *name, bool (*func)(unsigned int *count, const char ***elements))
221 {
222    const char **value;
223    unsigned int count;
224    bool ret;
225
226    INF("BEGIN: testing strings get %s\n", name);
227    ret = func(&count, &value);
228    if (ret)
229      {
230         INF("SUCCESS: testing strings get %s: %p\n", name, value);
231         free(value);
232      }
233    else
234      WRN("FAILURE: testing strings get %s\n", name);
235
236    return ret;
237 }
238
239
240 struct test_desc
241 {
242    const char *name;
243    enum {
244      TEST_DESC_TYPE_STRING_GET,
245      TEST_DESC_TYPE_BOOL_GET,
246      TEST_DESC_TYPE_UCHAR_GET,
247      TEST_DESC_TYPE_USHORT_GET,
248      TEST_DESC_TYPE_UCHAR_ARRAY_GET,
249      TEST_DESC_TYPE_ELEMENT_GET,
250      TEST_DESC_TYPE_ELEMENTS_GET,
251      TEST_DESC_TYPE_ELEMENT_GET_GLOBAL,
252      TEST_DESC_TYPE_ELEMENTS_GET_GLOBAL,
253      TEST_DESC_TYPE_STRING_GET_GLOBAL,
254      TEST_DESC_TYPE_BOOL_GET_GLOBAL,
255      TEST_DESC_TYPE_STRINGS_GET_GLOBAL,
256      TEST_DESC_TYPE_LAST
257    } type;
258    union {
259       bool (*string_get)(const E_Connman_Element *element, const char **value);
260       bool (*bool_get)(const E_Connman_Element *element, bool *value);
261       bool (*uchar_get)(const E_Connman_Element *element, unsigned char *value);
262       bool (*ushort_get)(const E_Connman_Element *element, unsigned short*value);
263       bool (*uchar_array_get)(const E_Connman_Element *element, unsigned int *count, unsigned char **value);
264       bool (*element_get)(const E_Connman_Element *element, E_Connman_Element **value);
265       bool (*elements_get)(const E_Connman_Element *element, unsigned int *count, E_Connman_Element ***elements);
266       bool (*element_get_global)(E_Connman_Element **element);
267       bool (*elements_get_global)(unsigned int *count, E_Connman_Element ***elements);
268       bool (*string_get_global)(const char **value);
269       bool (*bool_get_global)(bool *value);
270       bool (*strings_get_global)(unsigned int *count, const char ***strings);
271       void *dummy;
272    } func;
273    bool may_fail;
274 };
275
276 #define TEST_DESC_STRING_GET(_func, may_fail)                           \
277   {#_func, TEST_DESC_TYPE_STRING_GET, .func.string_get=_func, may_fail}
278 #define TEST_DESC_BOOL_GET(_func, may_fail)                             \
279   {#_func, TEST_DESC_TYPE_BOOL_GET, .func.bool_get=_func, may_fail}
280 #define TEST_DESC_UCHAR_GET(_func, may_fail)                            \
281   {#_func, TEST_DESC_TYPE_UCHAR_GET, .func.uchar_get=_func, may_fail}
282 #define TEST_DESC_USHORT_GET(_func, may_fail)                           \
283   {#_func, TEST_DESC_TYPE_USHORT_GET, .func.ushort_get=_func, may_fail}
284 #define TEST_DESC_UCHAR_ARRAY_GET(_func, may_fail)                      \
285   {#_func, TEST_DESC_TYPE_UCHAR_ARRAY_GET, .func.uchar_array_get=_func, may_fail}
286 #define TEST_DESC_ELEMENT_GET(_func, may_fail)                          \
287   {#_func, TEST_DESC_TYPE_ELEMENT_GET, .func.element_get=_func, may_fail}
288 #define TEST_DESC_ELEMENTS_GET(_func, may_fail)                         \
289   {#_func, TEST_DESC_TYPE_ELEMENTS_GET, .func.elements_get=_func, may_fail}
290 #define TEST_DESC_ELEMENT_GET_GLOBAL(_func, may_fail)                   \
291   {#_func, TEST_DESC_TYPE_ELEMENT_GET_GLOBAL, .func.element_get_global=_func, may_fail}
292 #define TEST_DESC_ELEMENTS_GET_GLOBAL(_func, may_fail)                  \
293   {#_func, TEST_DESC_TYPE_ELEMENTS_GET_GLOBAL, .func.elements_get_global=_func, may_fail}
294 #define TEST_DESC_STRING_GET_GLOBAL(_func, may_fail)                    \
295   {#_func, TEST_DESC_TYPE_STRING_GET_GLOBAL, .func.string_get_global=_func, may_fail}
296 #define TEST_DESC_BOOL_GET_GLOBAL(_func, may_fail)                      \
297   {#_func, TEST_DESC_TYPE_BOOL_GET_GLOBAL, .func.bool_get_global=_func, may_fail}
298 #define TEST_DESC_STRINGS_GET_GLOBAL(_func, may_fail)                   \
299   {#_func, TEST_DESC_TYPE_STRINGS_GET_GLOBAL, .func.strings_get_global=_func, may_fail}
300 #define TEST_DESC_SENTINEL {NULL, TEST_DESC_TYPE_LAST, .func.dummy=NULL}
301
302 static bool
303 _test_element(E_Connman_Element *element, const struct test_desc *test_descs)
304 {
305    const struct test_desc *itr;
306    int total, ok = 0, fail = 0;
307    bool ret = 1;
308
309    for (itr = test_descs; itr->type != TEST_DESC_TYPE_LAST; itr++)
310      {
311         bool r;
312
313         switch (itr->type)
314           {
315            case TEST_DESC_TYPE_STRING_GET:
316               r = _test_string_get(element, itr->name, itr->func.string_get);
317               break;
318            case TEST_DESC_TYPE_BOOL_GET:
319               r = _test_bool_get(element, itr->name, itr->func.bool_get);
320               break;
321            case TEST_DESC_TYPE_UCHAR_GET:
322               r = _test_uchar_get(element, itr->name, itr->func.uchar_get);
323               break;
324            case TEST_DESC_TYPE_USHORT_GET:
325               r = _test_ushort_get(element, itr->name, itr->func.ushort_get);
326               break;
327            case TEST_DESC_TYPE_UCHAR_ARRAY_GET:
328               r = _test_uchar_array_get
329                 (element, itr->name, itr->func.uchar_array_get);
330               break;
331            case TEST_DESC_TYPE_ELEMENT_GET:
332               r = _test_element_get
333                 (element, itr->name, itr->func.element_get);
334               break;
335            case TEST_DESC_TYPE_ELEMENTS_GET:
336               r = _test_elements_get
337                 (element, itr->name, itr->func.elements_get);
338               break;
339            case TEST_DESC_TYPE_ELEMENT_GET_GLOBAL:
340               r = _test_element_get_global
341                 (itr->name, itr->func.element_get_global);
342               break;
343            case TEST_DESC_TYPE_ELEMENTS_GET_GLOBAL:
344               r = _test_elements_get_global
345                 (itr->name, itr->func.elements_get_global);
346               break;
347            case TEST_DESC_TYPE_STRING_GET_GLOBAL:
348               r = _test_string_get_global
349                 (itr->name, itr->func.string_get_global);
350               break;
351            case TEST_DESC_TYPE_BOOL_GET_GLOBAL:
352               r = _test_bool_get_global
353                 (itr->name, itr->func.bool_get_global);
354               break;
355            case TEST_DESC_TYPE_STRINGS_GET_GLOBAL:
356               r = _test_strings_get_global
357                 (itr->name, itr->func.strings_get_global);
358               break;
359            default:
360               ERR("unknown test type %d (%s)\n", itr->type, itr->name);
361               r = 0;
362               break;
363           }
364
365         if (r || itr->may_fail)
366           ok++;
367         else
368           {
369              ERR("test failed %s, element %s [%s]\n",
370                  itr->name, element->path, element->interface);
371              fail++;
372              ret = 0;
373           }
374      }
375
376    total = ok + failure;
377    success += ok;
378    failure += fail;
379    if (total == 0)
380      {
381         INF("no tests for %s [%s]\n", element->path, element->interface);
382         return 1;
383      }
384
385    INF("testing %s success: %d, failure: %d: %d%% [%s]\n",
386        element->path, ok, fail, (ok * 100) / total,
387        element->interface);
388
389    return ret;
390 }
391
392 static const struct test_desc test_desc_manager[] = {
393   TEST_DESC_STRING_GET_GLOBAL(e_connman_manager_state_get, 0),
394   TEST_DESC_BOOL_GET_GLOBAL(e_connman_manager_offline_mode_get, 0),
395   //TEST_DESC_STRING_SET_GLOBAL(e_connman_manager_request_scan, 0),
396   //TEST_DESC_BOOL_SET_GLOBAL(e_connman_manager_offline_mode_set, 0),
397   TEST_DESC_ELEMENTS_GET_GLOBAL(e_connman_manager_profiles_get, 0),
398   TEST_DESC_ELEMENTS_GET_GLOBAL(e_connman_manager_services_get, 1),
399   TEST_DESC_STRING_GET_GLOBAL(e_connman_manager_technology_default_get, 0),
400   TEST_DESC_STRINGS_GET_GLOBAL(e_connman_manager_technologies_available_get, 0),
401   TEST_DESC_STRINGS_GET_GLOBAL(e_connman_manager_technologies_enabled_get, 0),
402   TEST_DESC_STRINGS_GET_GLOBAL(e_connman_manager_technologies_connected_get, 0),
403   TEST_DESC_ELEMENT_GET_GLOBAL(e_connman_manager_profile_active_get, 0),
404   TEST_DESC_SENTINEL
405 };
406
407 static const struct test_desc test_desc_device[] = {
408   TEST_DESC_STRING_GET(e_connman_device_address_get, 0),
409   TEST_DESC_STRING_GET(e_connman_device_name_get, 0),
410   TEST_DESC_STRING_GET(e_connman_device_type_get, 0),
411   TEST_DESC_STRING_GET(e_connman_device_interface_get, 0),
412   TEST_DESC_BOOL_GET(e_connman_device_powered_get, 0),
413   //TEST_DESC_BOOL_SET(e_connman_device_powered_set, 0),
414   TEST_DESC_USHORT_GET(e_connman_device_scan_interval_get, 1),
415   //TEST_DESC_USHORT_SET(e_connman_device_scan_interval_set, 1),
416   TEST_DESC_BOOL_GET(e_connman_device_scanning_get, 1),
417   TEST_DESC_ELEMENTS_GET(e_connman_device_networks_get, 1),
418   TEST_DESC_SENTINEL
419 };
420
421 static const struct test_desc test_desc_profile[] = {
422   TEST_DESC_STRING_GET(e_connman_profile_name_get, 1),
423   //TEST_DESC_STRING_SET(e_connman_profile_name_set, 1),
424   TEST_DESC_BOOL_GET(e_connman_profile_offline_mode_get, 0),
425   //TEST_DESC_BOOL_SET(e_connman_profile_offline_mode_set, 0),
426   TEST_DESC_ELEMENTS_GET(e_connman_profile_services_get, 1),
427   TEST_DESC_SENTINEL
428 };
429
430 static const struct test_desc test_desc_network[] = {
431   TEST_DESC_STRING_GET(e_connman_network_address_get, 0),
432   TEST_DESC_STRING_GET(e_connman_network_name_get, 0),
433   TEST_DESC_BOOL_GET(e_connman_network_connected_get, 0),
434   TEST_DESC_UCHAR_GET(e_connman_network_strength_get, 1),
435   TEST_DESC_USHORT_GET(e_connman_network_frequency_get, 1),
436   TEST_DESC_ELEMENT_GET(e_connman_network_device_get, 0),
437   TEST_DESC_UCHAR_ARRAY_GET(e_connman_network_wifi_ssid_get, 1),
438   TEST_DESC_STRING_GET(e_connman_network_wifi_mode_get, 1),
439   TEST_DESC_STRING_GET(e_connman_network_wifi_security_get, 1),
440   TEST_DESC_STRING_GET(e_connman_network_wifi_passphrase_get, 1),
441   TEST_DESC_USHORT_GET(e_connman_network_wifi_channel_get, 1),
442   TEST_DESC_STRING_GET(e_connman_network_wifi_eap_get, 1),
443   TEST_DESC_SENTINEL
444 };
445
446 static const struct test_desc test_desc_service[] = {
447   /* TODO: need to check exactly what properties may fail */
448   TEST_DESC_STRING_GET(e_connman_service_state_get, 1),
449   TEST_DESC_STRING_GET(e_connman_service_error_get, 1),
450   TEST_DESC_STRING_GET(e_connman_service_name_get, 0),
451   TEST_DESC_STRING_GET(e_connman_service_type_get, 0),
452   TEST_DESC_STRING_GET(e_connman_service_mode_get, 1),
453   TEST_DESC_STRING_GET(e_connman_service_security_get, 1),
454   TEST_DESC_STRING_GET(e_connman_service_passphrase_get, 1),
455   //TEST_DESC_STRING_SET(e_connman_service_passphrase_set, 1),
456   TEST_DESC_BOOL_GET(e_connman_service_passphrase_required_get, 1),
457   TEST_DESC_UCHAR_GET(e_connman_service_strength_get, 1),
458   TEST_DESC_BOOL_GET(e_connman_service_favorite_get, 0),
459   TEST_DESC_BOOL_GET(e_connman_service_immutable_get, 0),
460   TEST_DESC_BOOL_GET(e_connman_service_auto_connect_get, 0),
461   //TEST_DESC_BOOL_SET(e_connman_service_auto_connect_set, 1),
462   TEST_DESC_BOOL_GET(e_connman_service_setup_required_get, 1),
463   TEST_DESC_STRING_GET(e_connman_service_apn_get, 1),
464   //TEST_DESC_STRING_SET(e_connman_service_apn_set, 1),
465   TEST_DESC_STRING_GET(e_connman_service_mcc_get, 1),
466   TEST_DESC_STRING_GET(e_connman_service_mnc_get, 1),
467   TEST_DESC_BOOL_GET(e_connman_service_roaming_get, 1),
468   TEST_DESC_STRING_GET(e_connman_service_ipv4_method_get, 1),
469   TEST_DESC_STRING_GET(e_connman_service_ipv4_address_get, 1),
470   TEST_DESC_STRING_GET(e_connman_service_ipv4_gateway_get, 1),
471   TEST_DESC_STRING_GET(e_connman_service_ipv4_netmask_get, 1),
472   TEST_DESC_STRING_GET(e_connman_service_ipv4_configuration_method_get, 1),
473   TEST_DESC_STRING_GET(e_connman_service_ipv4_configuration_address_get, 1),
474   TEST_DESC_STRING_GET(e_connman_service_ipv4_configuration_gateway_get, 1),
475   TEST_DESC_STRING_GET(e_connman_service_ipv4_configuration_netmask_get, 1),
476   TEST_DESC_STRING_GET(e_connman_service_ethernet_method_get, 1),
477   TEST_DESC_STRING_GET(e_connman_service_ethernet_address_get, 1),
478   TEST_DESC_USHORT_GET(e_connman_service_ethernet_mtu_get, 1),
479   TEST_DESC_STRING_GET(e_connman_service_ethernet_netmask_get, 1),
480   TEST_DESC_SENTINEL
481 };
482
483 static Eina_Bool
484 _quit(__UNUSED__ void *data)
485 {
486    ecore_main_loop_quit();
487    return ECORE_CALLBACK_CANCEL;
488 }
489
490 static Eina_Bool
491 _on_exiter(__UNUSED__ void *data)
492 {
493    e_connman_system_shutdown();
494    ecore_idle_enterer_add(_quit, NULL);
495    exiter = NULL;
496    return ECORE_CALLBACK_CANCEL;
497 }
498
499 static void
500 _exiter_reschedule(void)
501 {
502    if (exiter)
503      ecore_timer_del(exiter);
504    exiter = ecore_timer_add(10, _on_exiter, NULL);
505 }
506
507 struct test_element_timer_data
508 {
509    E_Connman_Element *element;
510    Ecore_Timer *timer;
511 };
512
513 static Eina_Bool
514 _test_element_timer(void *data)
515 {
516    struct test_element_timer_data *d = data;
517    E_Connman_Element *element = d->element;
518
519    if (e_connman_element_is_device(element))
520      _test_element(element, test_desc_device);
521    else if (e_connman_element_is_profile(element))
522      _test_element(element, test_desc_profile);
523    else if (e_connman_element_is_network(element))
524      _test_element(element, test_desc_network);
525    else if (e_connman_element_is_manager(element))
526      _test_element(element, test_desc_manager);
527    else if (e_connman_element_is_service(element))
528      _test_element(element, test_desc_service);
529    else
530      ERR("!!! don't know how to test %s [%s]\n",
531          element->path, element->interface);
532
533    _exiter_reschedule();
534
535    d->timer = NULL;
536    return ECORE_CALLBACK_CANCEL;
537 }
538
539 static void
540 _element_listener(void *data, __UNUSED__ const E_Connman_Element *element)
541 {
542    struct test_element_timer_data *d = data;
543    if (d->timer)
544      ecore_timer_del(d->timer);
545    d->timer = ecore_timer_add(1.0, _test_element_timer, d);
546    _exiter_reschedule();
547 }
548
549 static void
550 _element_listener_free(void *data)
551 {
552    struct test_element_timer_data *d = data;
553    if (d->timer)
554      ecore_timer_del(d->timer);
555    free(d);
556 }
557
558 static Eina_Bool
559 _on_element_add(__UNUSED__ void *data, __UNUSED__ int type, void *info)
560 {
561    E_Connman_Element *element = info;
562    struct test_element_timer_data *d;
563
564    d = malloc(sizeof(*d));
565    if (!d)
566      return ECORE_CALLBACK_PASS_ON;
567
568    d->element = element;
569    d->timer = ecore_timer_add(1.0, _test_element_timer, d);
570    e_connman_element_listener_add
571      (element, _element_listener, d, _element_listener_free);
572
573    return ECORE_CALLBACK_PASS_ON;
574 }
575
576 static Eina_Bool
577 _on_element_del(__UNUSED__ void *data, __UNUSED__ int type, __UNUSED__ void *info)
578 {
579    return ECORE_CALLBACK_PASS_ON;
580 }
581
582 static Eina_Bool
583 _on_element_updated(__UNUSED__ void *data, __UNUSED__ int type, __UNUSED__ void *info)
584 {
585    return ECORE_CALLBACK_PASS_ON;
586 }
587
588 int
589 main(__UNUSED__ int argc, __UNUSED__ char *argv[])
590 {
591    E_DBus_Connection *c;
592    int total;
593
594    ecore_init();
595    e_dbus_init();
596    eina_init();
597
598    c = e_dbus_bus_get(DBUS_BUS_SYSTEM);
599    if (!c) {
600       printf("ERROR: can't connect to system session\n");
601       return -1;
602    }
603
604    e_connman_system_init(c);
605    ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_ADD, _on_element_add, NULL);
606    ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_DEL, _on_element_del, NULL);
607    ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_UPDATED,
608                            _on_element_updated, NULL);
609
610    _exiter_reschedule();
611
612    ecore_main_loop_begin();
613
614    e_dbus_connection_close(c);
615    eina_stringshare_dump();
616    eina_shutdown();
617    e_dbus_shutdown();
618    ecore_shutdown();
619
620    total = success + failure;
621    if (total == 0)
622      fputs("DBG: clean exit, no tests executed.\n", stderr);
623    else
624      fprintf(stderr, "DBG: clean exit, success: %d, failure: %d, %d%%\n",
625              success, failure, (success * 100) / total);
626
627    return 0;
628 }