summaryrefslogtreecommitdiff
path: root/legacy/eeze
diff options
context:
space:
mode:
Diffstat (limited to 'legacy/eeze')
-rw-r--r--legacy/eeze/Makefile.am37
-rw-r--r--legacy/eeze/configure.ac9
-rw-r--r--legacy/eeze/m4/efl_tests.m465
-rw-r--r--legacy/eeze/src/Makefile.am2
-rw-r--r--legacy/eeze/src/tests/Makefile.am16
-rw-r--r--legacy/eeze/src/tests/eeze_suite.c554
6 files changed, 681 insertions, 2 deletions
diff --git a/legacy/eeze/Makefile.am b/legacy/eeze/Makefile.am
index 4d9f2c5390..8f2609cdf9 100644
--- a/legacy/eeze/Makefile.am
+++ b/legacy/eeze/Makefile.am
@@ -42,3 +42,40 @@ m4/efl_doxygen.m4
42doc: all 42doc: all
43 @echo "entering doc/" 43 @echo "entering doc/"
44 $(MAKE) -C doc doc 44 $(MAKE) -C doc doc
45
46# Unit tests
47
48if EFL_ENABLE_TESTS
49
50lcov-reset:
51 @rm -rf $(top_builddir)/coverage
52 @find $(top_builddir) -name "*.gcda" -delete
53 @lcov --zerocounters --directory $(top_builddir)
54
55lcov-report:
56 @mkdir $(top_builddir)/coverage
57 lcov --capture --compat-libtool --output-file $(top_builddir)/coverage/coverage.info --directory $(top_builddir)
58 lcov --remove $(top_builddir)/coverage/coverage.info '*.h' --output-file $(top_builddir)/coverage/coverage.cleaned.info
59 genhtml -t "$(PACKAGE_STRING)" -o $(top_builddir)/coverage/html $(top_builddir)/coverage/coverage.cleaned.info
60 @echo "Coverage Report at $(top_builddir)/coverage/html"
61
62check-local:
63 @$(MAKE) lcov-reset
64 @./src/tests/eeze_suite
65 @$(MAKE) lcov-report
66
67else
68
69lcov-reset:
70 @echo "reconfigure with --enable-tests"
71
72lcov-report:
73 @echo "reconfigure with --enable-tests"
74
75check-local:
76 @echo "reconfigure with --enable-tests"
77
78endif
79
80clean-local:
81 @rm -rf coverage
diff --git a/legacy/eeze/configure.ac b/legacy/eeze/configure.ac
index ea23ea8d45..d9b7726589 100644
--- a/legacy/eeze/configure.ac
+++ b/legacy/eeze/configure.ac
@@ -240,6 +240,10 @@ fi
240EFL_COMPILER_FLAG([-Wshadow]) 240EFL_COMPILER_FLAG([-Wshadow])
241 241
242 242
243### Unit tests, coverage and benchmarking
244
245EFL_CHECK_TESTS([eeze], [enable_tests="yes"], [enable_tests="no"])
246
243### Binary 247### Binary
244 248
245EFL_ENABLE_BIN([eeze-udev-test], ["yes"]) 249EFL_ENABLE_BIN([eeze-udev-test], ["yes"])
@@ -260,6 +264,7 @@ doc/Doxyfile
260src/Makefile 264src/Makefile
261src/lib/Makefile 265src/lib/Makefile
262src/bin/Makefile 266src/bin/Makefile
267src/tests/Makefile
263eeze.pc 268eeze.pc
264eeze.spec 269eeze.spec
265]) 270])
@@ -283,7 +288,9 @@ if test "x$eeze_mount" = "xyes";then
283 echo "Eject..................: ${with_eject}" 288 echo "Eject..................: ${with_eject}"
284 echo 289 echo
285fi 290fi
286echo "Tests..................: ${have_eeze_udev_test}" 291echo "Udev Tests.............: ${have_eeze_udev_test}"
292echo
293echo "Tests..............: ${enable_tests} (Coverage: ${efl_enable_coverage})"
287echo 294echo
288echo "Demos..................:" 295echo "Demos..................:"
289echo " eeze_mount...........: ${have_eeze_mount}" 296echo " eeze_mount...........: ${have_eeze_mount}"
diff --git a/legacy/eeze/m4/efl_tests.m4 b/legacy/eeze/m4/efl_tests.m4
new file mode 100644
index 0000000000..d8554e1539
--- /dev/null
+++ b/legacy/eeze/m4/efl_tests.m4
@@ -0,0 +1,65 @@
1dnl Copyright (C) 2008-2012 Vincent Torri <vtorri at univ-evry dot fr>
2dnl That code is public domain and can be freely used or copied.
3
4dnl Macro that check if tests programs are wanted and if yes, if
5dnl the Check library is available.
6dnl the lcov program is available.
7
8dnl Usage: EFL_CHECK_TESTS(EFL[, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
9dnl Define the automake conditionnal EFL_ENABLE_TESTS
10
11AC_DEFUN([EFL_CHECK_TESTS],
12[
13m4_pushdef([UPEFL], m4_translit([$1], [-a-z], [_A-Z]))dnl
14
15dnl configure option
16
17AC_ARG_ENABLE([tests],
18 [AC_HELP_STRING([--enable-tests], [enable tests @<:@default=disabled@:>@])],
19 [
20 if test "x${enableval}" = "xyes" ; then
21 _efl_enable_tests="yes"
22 else
23 _efl_enable_tests="no"
24 fi
25 ],
26 [_efl_enable_tests="no"])
27
28AC_MSG_CHECKING([whether tests are built])
29AC_MSG_RESULT([${_efl_enable_tests}])
30
31AC_REQUIRE([PKG_PROG_PKG_CONFIG])
32
33if test "x${_efl_enable_tests}" = "xyes" ; then
34 PKG_CHECK_MODULES([CHECK],
35 [check >= 0.9.5],
36 [dummy="yes"],
37 [_efl_enable_tests="no"])
38fi
39
40efl_enable_coverage="no"
41if test "x${_efl_enable_tests}" = "xyes" ; then
42 AC_CHECK_PROG(have_lcov, [lcov], [yes], [no])
43 if test "x$have_lcov" = "xyes" ; then
44 m4_defn([UPEFL])[]_CFLAGS="${m4_defn([UPEFL])[]_CFLAGS} -fprofile-arcs -ftest-coverage"
45 m4_defn([UPEFL])[]_LIBS="${m4_defn([UPEFL])[]_LIBS} -lgcov"
46# remove any optimisation flag and force debug symbols
47 if test "x${prefer_assert}" = "xno"; then
48 m4_defn([UPEFL])[]_CFLAGS="${m4_defn([UPEFL])[]_CFLAGS} -DNDEBUG"
49 else
50 m4_defn([UPEFL])[]_CFLAGS="${m4_defn([UPEFL])[]_CFLAGS} -g -O0 -DDEBUG"
51 fi
52 efl_enable_coverage="yes"
53 else
54 AC_MSG_WARN([lcov is not found, disable profiling instrumentation])
55 fi
56fi
57
58AM_CONDITIONAL(EFL_ENABLE_TESTS, test "x${_efl_enable_tests}" = "xyes")
59
60AS_IF([test "x$_efl_enable_tests" = "xyes"], [$2], [$3])
61
62m4_popdef([UPEFL])
63])
64
65dnl End of efl_tests.m4
diff --git a/legacy/eeze/src/Makefile.am b/legacy/eeze/src/Makefile.am
index 97baf85931..f918327e28 100644
--- a/legacy/eeze/src/Makefile.am
+++ b/legacy/eeze/src/Makefile.am
@@ -1,2 +1,2 @@
1MAINTAINERCLEANFILES = Makefile.in 1MAINTAINERCLEANFILES = Makefile.in
2SUBDIRS = lib bin 2SUBDIRS = lib bin tests
diff --git a/legacy/eeze/src/tests/Makefile.am b/legacy/eeze/src/tests/Makefile.am
new file mode 100644
index 0000000000..cd1c59afd8
--- /dev/null
+++ b/legacy/eeze/src/tests/Makefile.am
@@ -0,0 +1,16 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_srcdir)/src/lib \
5-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests\" \
6@CHECK_CFLAGS@ \
7@EEZE_CFLAGS@
8
9if EFL_ENABLE_TESTS
10
11check_PROGRAMS = eeze_suite
12
13eeze_suite_SOURCES = eeze_suite.c
14eeze_suite_LDADD = $(top_builddir)/src/lib/libeeze.la @EEZE_LIBS@ @CHECK_LIBS@
15
16endif
diff --git a/legacy/eeze/src/tests/eeze_suite.c b/legacy/eeze/src/tests/eeze_suite.c
new file mode 100644
index 0000000000..4559610d04
--- /dev/null
+++ b/legacy/eeze/src/tests/eeze_suite.c
@@ -0,0 +1,554 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include <Eina.h>
9
10#include <check.h>
11
12#include <Eeze.h>
13#include <Eeze_Sensor.h>
14#include <Eeze_Net.h>
15
16START_TEST(eeze_test_init)
17{
18 int ret;
19
20 ret = eeze_init();
21 fail_if(ret != 1);
22
23 ret = eeze_shutdown();
24 fail_if(ret != 0);
25}
26END_TEST
27
28static void
29catch_events(const char *device EINA_UNUSED, Eeze_Udev_Event event EINA_UNUSED,
30 void *data EINA_UNUSED, Eeze_Udev_Watch *watch EINA_UNUSED)
31{
32}
33
34// FIXME split udev tests into pieces here
35START_TEST(eeze_test_udev_types)
36{
37 Eina_List *type;
38
39 eeze_init();
40
41 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_NONE, NULL);
42 type = eeze_udev_find_unlisted_similar(type);
43 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_KEYBOARD, NULL);
44 type = eeze_udev_find_unlisted_similar(type);
45 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_MOUSE, NULL);
46 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_TOUCHPAD, NULL);
47 type = eeze_udev_find_unlisted_similar(type);
48 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_MOUNTABLE, NULL);
49 type = eeze_udev_find_unlisted_similar(type);
50 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
51 type = eeze_udev_find_unlisted_similar(type);
52 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_REMOVABLE, NULL);
53 type = eeze_udev_find_unlisted_similar(type);
54 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_CDROM, NULL);
55 type = eeze_udev_find_unlisted_similar(type);
56 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_POWER_AC, NULL);
57 type = eeze_udev_find_unlisted_similar(type);
58 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_POWER_BAT, NULL);
59 type = eeze_udev_find_unlisted_similar(type);
60 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR, NULL);
61 type = eeze_udev_find_unlisted_similar(type);
62 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_NET, NULL);
63 type = eeze_udev_find_unlisted_similar(type);
64 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_V4L, NULL);
65 type = eeze_udev_find_unlisted_similar(type);
66 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_BLUETOOTH, NULL);
67 type = eeze_udev_find_unlisted_similar(type);
68 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_JOYSTICK, NULL);
69 type = eeze_udev_find_unlisted_similar(type);
70 type = eeze_udev_find_by_type(0, NULL);
71 type = eeze_udev_find_unlisted_similar(type);
72
73 eeze_shutdown();
74}
75END_TEST
76
77START_TEST(eeze_test_udev_watch)
78{
79 Eeze_Udev_Watch *watch;
80
81 ecore_init();
82 eeze_init();
83
84 /* watch never gets triggered as this is run without user interaction */
85 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_KEYBOARD, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
86 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_DRIVE_INTERNAL, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
87 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_POWER_AC, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
88 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_NET, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
89 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
90 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_V4L, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
91 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_BLUETOOTH, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
92 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_NONE, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
93 eeze_udev_watch_del(watch);
94
95 eeze_shutdown();
96 ecore_shutdown();
97}
98END_TEST
99
100START_TEST(eeze_test_udev_syspath)
101{
102 Eina_List *type, *l;
103 const char *name, *check;
104
105 eeze_init();
106
107 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_KEYBOARD, NULL);
108 type = eeze_udev_find_unlisted_similar(type);
109 EINA_LIST_FOREACH(type, l, name)
110 {
111 check = eeze_udev_syspath_get_devpath(name);
112 eeze_udev_find_similar_from_syspath(name);
113 eeze_udev_find_similar_from_syspath(NULL);
114 eeze_udev_syspath_get_parent(name);
115 eeze_udev_syspath_get_parent(NULL);
116 eeze_udev_syspath_get_parents(name);
117 eeze_udev_syspath_get_parents(NULL);
118 eeze_udev_syspath_get_devname(name);
119 eeze_udev_syspath_get_devname(NULL);
120 eeze_udev_syspath_get_subsystem(name);
121 eeze_udev_syspath_get_sysattr(name, "manufacturer");
122 eeze_udev_syspath_is_mouse(name);
123 eeze_udev_syspath_is_kbd(name);
124 eeze_udev_syspath_is_touchpad(name);
125 eeze_udev_syspath_is_joystick(name);
126 eeze_udev_walk_get_sysattr(name, "manufacturer");
127 eeze_udev_find_by_sysattr("manufacturer", NULL);
128 eeze_udev_find_by_sysattr(NULL, NULL);
129 eeze_udev_walk_check_sysattr(name, "manufacturer", NULL);
130 eeze_udev_walk_check_sysattr(name, "manufacturer", "foo");
131 eeze_udev_walk_get_sysattr(NULL, "manufacturer");
132 eeze_udev_walk_get_sysattr(name, NULL);
133 }
134
135 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_MOUSE, NULL);
136 type = eeze_udev_find_unlisted_similar(type);
137 EINA_LIST_FOREACH(type, l, name)
138 {
139 eeze_udev_syspath_is_mouse(name);
140 eeze_udev_syspath_is_touchpad(name);
141 eeze_udev_syspath_is_joystick(name);
142 }
143
144 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_TOUCHPAD, NULL);
145 type = eeze_udev_find_unlisted_similar(type);
146 EINA_LIST_FOREACH(type, l, name)
147 {
148 eeze_udev_syspath_is_touchpad(name);
149 }
150
151 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_JOYSTICK, NULL);
152 type = eeze_udev_find_unlisted_similar(type);
153 EINA_LIST_FOREACH(type, l, name)
154 {
155 eeze_udev_syspath_is_joystick(name);
156 }
157
158 eeze_udev_devpath_get_syspath("/dev/null");
159
160 eeze_shutdown();
161}
162END_TEST
163
164START_TEST(eeze_test_udev_attr)
165{
166 Eina_List *type;
167 const char *name, *check, *check2;
168
169 eeze_init();
170
171 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
172 type = eeze_udev_find_unlisted_similar(type);
173 eeze_udev_find_by_filter("backlight", NULL, NULL);
174
175 eeze_udev_find_by_filter(NULL, NULL, NULL);
176
177 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_NET, NULL);
178 type = eeze_udev_find_unlisted_similar(type);
179 EINA_LIST_FREE(type, name)
180 {
181 check = eeze_udev_syspath_get_property(name, "INTERFACE");
182 }
183
184 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
185 type = eeze_udev_find_unlisted_similar(type);
186 EINA_LIST_FREE(type, name)
187 {
188 check = eeze_udev_syspath_get_property(name, "ID_SERIAL");
189 }
190
191 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_REMOVABLE, NULL);
192 type = eeze_udev_find_unlisted_similar(type);
193 EINA_LIST_FREE(type, name)
194 {
195 if ((check = eeze_udev_syspath_get_sysattr(name, "model")))
196 {
197 check2 = eeze_udev_syspath_get_subsystem(name);
198 }
199 }
200
201 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_V4L, NULL);
202 type = eeze_udev_find_unlisted_similar(type);
203 EINA_LIST_FREE(type, name)
204 {
205 if ((check = eeze_udev_syspath_get_property(name, "DEVNAME")))
206 {
207 if ((check2 = eeze_udev_syspath_get_sysattr(name, "name")))
208 {
209 eina_stringshare_del(check2);
210 }
211 eina_stringshare_del(check);
212 }
213 eina_stringshare_del(name);
214 }
215
216 eeze_shutdown();
217}
218END_TEST
219
220START_TEST(eeze_test_net_list)
221{
222 int ret;
223 Eina_List *list = NULL;
224
225 ret = eeze_init();
226 fail_if(ret != 1);
227
228 list = eeze_net_list();
229 fail_if(list == NULL);
230
231 ret = eeze_shutdown();
232 fail_if(ret != 0);
233}
234END_TEST
235
236START_TEST(eeze_test_net_attr)
237{
238 int ret;
239 int idx = 0;
240 Eeze_Net *net = NULL;
241 const char *tmp = NULL;
242
243 ret = eeze_init();
244 fail_if(ret != 1);
245
246 net = eeze_net_new("lo");
247 fail_if(net == NULL);
248
249 tmp = eeze_net_mac_get(net);
250 fail_if(tmp == NULL);
251 tmp = NULL;
252
253 idx = eeze_net_idx_get(net);
254 fail_if(!idx);
255
256 eeze_net_scan(net);
257
258 tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_IP);
259 fail_if(tmp == NULL);
260 tmp = NULL;
261
262 tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_BROADCAST);
263 fail_if(tmp == NULL);
264 tmp = NULL;
265
266 tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_NETMASK);
267 fail_if(tmp == NULL);
268 tmp = NULL;
269
270 tmp = eeze_net_attribute_get(net, "carrier");
271 fail_if(tmp == NULL);
272 tmp = NULL;
273
274 tmp = eeze_net_syspath_get(net);
275 fail_if(tmp == NULL);
276
277 eeze_net_free(net);
278
279 ret = eeze_shutdown();
280 fail_if(ret != 0);
281}
282END_TEST
283
284#ifdef HAVE_IPV6
285START_TEST(eeze_test_net_attr_ipv6)
286{
287 int ret;
288 Eeze_Net *net = NULL;
289 const char *tmp = NULL;
290
291 ret = eeze_init();
292 fail_if(ret != 1);
293
294 net = eeze_net_new("lo");
295 fail_if(net == NULL);
296
297 tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_IP6);
298 fail_if(tmp == NULL);
299 tmp = NULL;
300
301 tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_BROADCAST6);
302 fail_if(tmp == NULL);
303 tmp = NULL;
304
305 tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_NETMASK6);
306 fail_if(tmp == NULL);
307
308 eeze_net_free(net);
309
310 ret = eeze_shutdown();
311 fail_if(ret != 0);
312}
313END_TEST
314#endif
315
316START_TEST(eeze_test_sensor_handle_get)
317{
318 Eeze_Sensor *handle;
319 int ret;
320
321 ret = eeze_init();
322 fail_if(ret != 1);
323
324 handle = eeze_sensor_handle_get();
325 fail_if(handle == NULL);
326
327 ret = eeze_shutdown();
328 fail_if(ret != 0);
329}
330END_TEST
331
332START_TEST(eeze_test_sensor_read)
333{
334 Eeze_Sensor_Obj *sens = NULL;
335 int ret = 0;
336 float x, y, z;
337 int acc;
338 unsigned long long timestamp;
339 Eina_Bool rc = EINA_FALSE;
340
341 ecore_init();
342 ret = eeze_init();
343 fail_if(ret != 1);
344
345 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ACCELEROMETER);
346 fail_if(sens == NULL);
347 rc = eeze_sensor_read(sens);
348 fail_if(rc == EINA_FALSE);
349 rc = eeze_sensor_accuracy_get(sens, &acc);
350 fail_if(rc == EINA_FALSE);
351 rc = eeze_sensor_timestamp_get(sens, &timestamp);
352 fail_if(rc == EINA_FALSE);
353
354 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_MAGNETIC);
355 fail_if(sens == NULL);
356 rc = eeze_sensor_read(sens);
357 fail_if(rc == EINA_FALSE);
358 rc = eeze_sensor_accuracy_get(sens, &acc);
359 fail_if(rc == EINA_FALSE);
360 rc = eeze_sensor_timestamp_get(sens, &timestamp);
361 fail_if(rc == EINA_FALSE);
362
363 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ORIENTATION);
364 fail_if(sens == NULL);
365 rc = eeze_sensor_read(sens);
366 fail_if(rc == EINA_FALSE);
367 rc = eeze_sensor_accuracy_get(sens, &acc);
368 fail_if(rc == EINA_FALSE);
369 rc = eeze_sensor_timestamp_get(sens, &timestamp);
370 fail_if(rc == EINA_FALSE);
371
372 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_GYROSCOPE);
373 fail_if(sens == NULL);
374 rc = eeze_sensor_read(sens);
375 fail_if(rc == EINA_FALSE);
376 rc = eeze_sensor_accuracy_get(sens, &acc);
377 fail_if(rc == EINA_FALSE);
378 rc = eeze_sensor_timestamp_get(sens, &timestamp);
379 fail_if(rc == EINA_FALSE);
380
381 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_PROXIMITY);
382 fail_if(sens == NULL);
383 rc = eeze_sensor_read(sens);
384 fail_if(rc == EINA_FALSE);
385 rc = eeze_sensor_accuracy_get(sens, &acc);
386 fail_if(rc == EINA_FALSE);
387 rc = eeze_sensor_timestamp_get(sens, &timestamp);
388 fail_if(rc == EINA_FALSE);
389
390 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
391 fail_if(sens == NULL);
392 rc = eeze_sensor_read(sens);
393 fail_if(rc == EINA_FALSE);
394 rc = eeze_sensor_accuracy_get(sens, &acc);
395 fail_if(rc == EINA_FALSE);
396 rc = eeze_sensor_timestamp_get(sens, &timestamp);
397 fail_if(rc == EINA_FALSE);
398
399 eeze_sensor_free(sens);
400
401 ret = eeze_shutdown();
402 fail_if(ret != 0);
403}
404END_TEST
405
406static Eina_Bool
407event_cb(void *data EINA_UNUSED, int ev_type, void *event)
408{
409 Eeze_Sensor_Obj *sens = NULL;
410 int acc;
411 unsigned long long timestamp;
412 Eina_Bool rc = EINA_FALSE;
413
414 sens = event;
415 fail_if(sens == NULL);
416 rc = eeze_sensor_accuracy_get(sens, &acc);
417 fail_if(rc == EINA_FALSE);
418 rc = eeze_sensor_timestamp_get(sens, &timestamp);
419 fail_if(rc == EINA_FALSE);
420
421 return ECORE_CALLBACK_PASS_ON;
422}
423
424START_TEST(eeze_test_sensor_async_read)
425{
426 Eeze_Sensor_Obj *sens = NULL;
427 int ret = 0;
428 Eina_Bool rc = EINA_FALSE;
429
430 ecore_init();
431 ret = eeze_init();
432 fail_if(ret != 1);
433
434 ecore_event_handler_add(EEZE_SENSOR_EVENT_ACCELEROMETER, event_cb, NULL);
435 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ACCELEROMETER);
436 fail_if(sens == NULL);
437 rc = eeze_sensor_async_read(sens, NULL);
438 fail_if(rc == EINA_FALSE);
439
440 ecore_event_handler_add(EEZE_SENSOR_EVENT_MAGNETIC, event_cb, NULL);
441 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_MAGNETIC);
442 fail_if(sens == NULL);
443 rc = eeze_sensor_async_read(sens, NULL);
444 fail_if(rc == EINA_FALSE);
445
446 ecore_event_handler_add(EEZE_SENSOR_EVENT_ORIENTATION, event_cb, NULL);
447 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ORIENTATION);
448 fail_if(sens == NULL);
449 rc = eeze_sensor_async_read(sens, NULL);
450 fail_if(rc == EINA_FALSE);
451
452 ecore_event_handler_add(EEZE_SENSOR_EVENT_GYROSCOPE, event_cb, NULL);
453 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_GYROSCOPE);
454 fail_if(sens == NULL);
455 rc = eeze_sensor_async_read(sens, NULL);
456 fail_if(rc == EINA_FALSE);
457
458 ecore_event_handler_add(EEZE_SENSOR_EVENT_PROXIMITY, event_cb, NULL);
459 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_PROXIMITY);
460 fail_if(sens == NULL);
461 rc = eeze_sensor_async_read(sens, NULL);
462 fail_if(rc == EINA_FALSE);
463
464 ecore_event_handler_add(EEZE_SENSOR_EVENT_LIGHT, event_cb, NULL);
465 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
466 fail_if(sens == NULL);
467 rc = eeze_sensor_async_read(sens, NULL);
468 fail_if(rc == EINA_FALSE);
469
470 eeze_sensor_free(sens);
471
472 ret = eeze_shutdown();
473 fail_if(ret != 0);
474}
475END_TEST
476
477START_TEST(eeze_test_sensor_obj_get)
478{
479 Eeze_Sensor_Obj *obj = NULL, *obj_tmp = NULL;
480 int ret = 0;
481
482 ecore_init();
483 ret = eeze_init();
484 fail_if(ret != 1);
485
486 obj = calloc(1, sizeof(Eeze_Sensor_Obj));
487 fail_if(obj == NULL);
488
489 obj_tmp = obj;
490
491 obj = eeze_sensor_obj_get(EEZE_SENSOR_TYPE_ACCELEROMETER);
492 fail_if(obj == obj_tmp);
493
494 free(obj);
495
496 ret = eeze_shutdown();
497 fail_if(ret != 0);
498}
499END_TEST
500
501Suite *
502eeze_suite(void)
503{
504 Suite *s;
505 TCase *tc;
506
507 s = suite_create("Eeze");
508
509 tc = tcase_create("Eeze_Init");
510 tcase_add_test(tc, eeze_test_init);
511 suite_add_tcase(s, tc);
512
513 tc = tcase_create("Eeze_Udev");
514 tcase_add_test(tc, eeze_test_udev_types);
515 tcase_add_test(tc, eeze_test_udev_watch);
516 tcase_add_test(tc, eeze_test_udev_syspath);
517 tcase_add_test(tc, eeze_test_udev_attr);
518 suite_add_tcase(s, tc);
519
520 tc = tcase_create("Eeze_Net");
521 tcase_add_test(tc, eeze_test_net_list);
522 tcase_add_test(tc, eeze_test_net_attr);
523#ifdef HAVE_IPV6
524 //FIXME Figure out why we fail for the ipv6 tests here (code or test)
525 //tcase_add_test(tc, eeze_test_net_attr_ipv6);
526#endif
527 suite_add_tcase(s, tc);
528
529 tc = tcase_create("Eeze Sensor");
530 tcase_add_test(tc, eeze_test_sensor_handle_get);
531 tcase_add_test(tc, eeze_test_sensor_read);
532 tcase_add_test(tc, eeze_test_sensor_async_read);
533 tcase_add_test(tc, eeze_test_sensor_obj_get);
534 suite_add_tcase(s, tc);
535
536 return s;
537}
538
539int
540main(void)
541{
542 Suite *s;
543 SRunner *sr;
544 int failed_count;
545
546 s = eeze_suite();
547 sr = srunner_create(s);
548 srunner_run_all(sr, CK_ENV);
549 failed_count = srunner_ntests_failed(sr);
550 srunner_free(sr);
551
552 return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
553}
554