Status: | Merged |
---|---|
Merged at revision: | 92 |
Proposed branch: | lp:geis/2.x |
Merge into: | lp:geis |
Diff against target: |
1288 lines (+956/-39) 22 files modified
ChangeLog (+49/-0) doc/Doxyfile (+1/-1) include/geis/geis.h (+61/-6) libutouch-geis/Makefile.am (+9/-5) libutouch-geis/geis.c (+79/-11) libutouch-geis/geis_backend.c (+65/-0) libutouch-geis/geis_backend.h (+56/-0) libutouch-geis/geis_backend_multiplexor.c (+203/-0) libutouch-geis/geis_backend_multiplexor.h (+129/-0) libutouch-geis/geis_backend_protected.h (+61/-0) libutouch-geis/geis_backend_test_fixture.c (+63/-0) libutouch-geis/geis_backend_test_fixture.h (+35/-0) libutouch-geis/geis_error.c (+4/-4) libutouch-geis/geis_private.h (+4/-7) testsuite/geis2/check_config.c (+2/-2) testsuite/geis2/check_error_codes.c (+2/-0) testsuite/geis2/check_geis_new.c (+1/-1) testsuite/geis2/check_subscription.c (+1/-1) testsuite/libutouch-geis/Makefile.am (+1/-0) testsuite/libutouch-geis/check_backend_multiplexor.c (+127/-0) testsuite/libutouch-geis/check_geis2_internals.c (+2/-0) testsuite/libutouch-geis/check_subscription.c (+1/-1) |
To merge this branch: | bzr merge lp:geis/2.x |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mohamed IKBEL Boulabiar (community) | Approve | ||
Henrik Rydberg (community) | Approve | ||
Review via email: mp+42536@code.launchpad.net |
Commit message
Description of the change
This change is some basic infrastructure required for configurable back ends (eg. DBus client, local grail, maverick-style XCB).
To post a comment you must log in.
Revision history for this message
Henrik Rydberg (rydberg) wrote : | # |
Revision history for this message
Henrik Rydberg (rydberg) wrote : | # |
> Looks ok. Things are getting closer. :-)
review:
Approve
Revision history for this message
Chase Douglas (chasedouglas) wrote : | # |
Do we want to be able to specify a timeout value for geis_backend_
Otherwise, looks good to me.
Revision history for this message
Mohamed IKBEL Boulabiar (boulabiar) wrote : | # |
Looks Good !
("teh", "isn;t" in the comments detected :P)
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ChangeLog' | |||
2 | --- ChangeLog 2010-11-29 14:32:34 +0000 | |||
3 | +++ ChangeLog 2010-12-02 19:24:57 +0000 | |||
4 | @@ -1,3 +1,52 @@ | |||
5 | 1 | 2010-12-02 Stephen M. Webb <stephen.webb@canonical.com> | ||
6 | 2 | |||
7 | 3 | Added a back end base and test fixture. | ||
8 | 4 | |||
9 | 5 | * libutouch-geis/geis_backend.c: new file | ||
10 | 6 | * libutouch-geis/geis_backend.h: new file | ||
11 | 7 | * libutouch-geis/geis_backend_protected.h: new file | ||
12 | 8 | * libutouch-geis/geis_backend_test_fixture.c: new file | ||
13 | 9 | * libutouch-geis/geis_backend_test_fixture.h: new file | ||
14 | 10 | * include/geis/geis.h (GEIS_INIT_SERVICE_PROVIDER): changed constant value | ||
15 | 11 | (GEIS_INIT_UTOUCH_MOCK_ENGINE): added new constant | ||
16 | 12 | * libutouch-geis/Makefile.am: added new files | ||
17 | 13 | * libutouch-geis/geis.c (struct _Geis): replaced is_test_fixture with backend | ||
18 | 14 | (geis_set_valist): created new test fixture backend | ||
19 | 15 | (geis_delete): destroyed backend | ||
20 | 16 | * testsuite/geis2/check_config.c: used new name for test fixture back end | ||
21 | 17 | * testsuite/geis2/check_geis_new.c: same | ||
22 | 18 | * testsuite/geis2/check_subscription.c: idem | ||
23 | 19 | * testsuite/libutouch-geis/check_subscription.c: ditto | ||
24 | 20 | |||
25 | 21 | 2010-12-02 Stephen M. Webb <stephen.webb@canonical.com> | ||
26 | 22 | |||
27 | 23 | Added a back end multiplexor. | ||
28 | 24 | |||
29 | 25 | * libutouch-geis/geis_backend_multiplexor.c: new file | ||
30 | 26 | * libutouch-geis/geis_backend_multiplexor.h: new file | ||
31 | 27 | * testsuite/libutouch-geis/check_backend_multiplexor.c: new testsuite | ||
32 | 28 | * include/geis/geis.h (GeisStatus): added new status codes | ||
33 | 29 | GEIS_STATUS_CONTINUE and GEIS_STATUS_EMPTY | ||
34 | 30 | (GEIS_CONFIG_UTOUCH_MAX_EVENTS): new configuration item | ||
35 | 31 | * libutouch-geis/Makefile.am: added new files | ||
36 | 32 | * libutouch-geis/geis.c (struct _Geis): added backend_multiplexor field | ||
37 | 33 | (geis_new_empty): initialized it | ||
38 | 34 | (geis_delete): destroyed it | ||
39 | 35 | (geis_get_configuration): retrieved its file descriptor and config value | ||
40 | 36 | (geis_set_configuration): set its configuration value | ||
41 | 37 | * testsuite/geis2/check_error_codes.c: checked new status codes | ||
42 | 38 | * testsuite/libutouch-geis/Makefile.am | ||
43 | 39 | * testsuite/libutouch-geis/check_geis2_internals.c | ||
44 | 40 | |||
45 | 41 | 2010-11-29 Stephen M. Webb <stephen.webb@canonical.com> | ||
46 | 42 | |||
47 | 43 | Refactored geis_private.h to provide improved data encapsulation. | ||
48 | 44 | |||
49 | 45 | * libutouch-geis/geis_private.h (struct _Geis): moved to geis.c | ||
50 | 46 | (geis_error_stack): new function | ||
51 | 47 | * libutouch-geis/geis.c: implemented new function | ||
52 | 48 | * libutouch-geis/geis_error.c: used new function | ||
53 | 49 | |||
54 | 1 | 2010-11-29 Stephen M. Webb <stephen.webb@canonical.com> | 50 | 2010-11-29 Stephen M. Webb <stephen.webb@canonical.com> |
55 | 2 | 51 | ||
56 | 3 | Fixed a typo in the Doxygen comments in geis.h. | 52 | Fixed a typo in the Doxygen comments in geis.h. |
57 | 4 | 53 | ||
58 | === modified file 'doc/Doxyfile' | |||
59 | --- doc/Doxyfile 2010-08-06 21:16:55 +0000 | |||
60 | +++ doc/Doxyfile 2010-12-02 19:24:57 +0000 | |||
61 | @@ -590,7 +590,7 @@ | |||
62 | 590 | # directories like "/usr/src/myproject". Separate the files or directories | 590 | # directories like "/usr/src/myproject". Separate the files or directories |
63 | 591 | # with spaces. | 591 | # with spaces. |
64 | 592 | 592 | ||
66 | 593 | INPUT = ../geis | 593 | INPUT = ../include/geis |
67 | 594 | 594 | ||
68 | 595 | # This tag can be used to specify the character encoding of the source files | 595 | # This tag can be used to specify the character encoding of the source files |
69 | 596 | # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is | 596 | # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is |
70 | 597 | 597 | ||
71 | === modified file 'include/geis/geis.h' | |||
72 | --- include/geis/geis.h 2010-11-29 14:32:34 +0000 | |||
73 | +++ include/geis/geis.h 2010-12-02 19:24:57 +0000 | |||
74 | @@ -120,6 +120,10 @@ | |||
75 | 120 | typedef enum GeisStatus | 120 | typedef enum GeisStatus |
76 | 121 | { | 121 | { |
77 | 122 | GEIS_STATUS_SUCCESS = 0, /**< normal successful completion */ | 122 | GEIS_STATUS_SUCCESS = 0, /**< normal successful completion */ |
78 | 123 | GEIS_STATUS_CONTINUE = 20, /**< normal successful completion | ||
79 | 124 | with data still remaining */ | ||
80 | 125 | GEIS_STATUS_EMPTY = 21, /**< normal successful completion | ||
81 | 126 | with no data retrieved */ | ||
82 | 123 | GEIS_STATUS_NOT_SUPPORTED = 10, /**< a requested feature is not supported */ | 127 | GEIS_STATUS_NOT_SUPPORTED = 10, /**< a requested feature is not supported */ |
83 | 124 | GEIS_BAD_ARGUMENT = 1000, /**< a bad argument value was passed */ | 128 | GEIS_BAD_ARGUMENT = 1000, /**< a bad argument value was passed */ |
84 | 125 | GEIS_UNKNOWN_ERROR = 9999, /**< any other error condition */ | 129 | GEIS_UNKNOWN_ERROR = 9999, /**< any other error condition */ |
85 | @@ -190,12 +194,40 @@ | |||
86 | 190 | /* @} */ | 194 | /* @} */ |
87 | 191 | 195 | ||
88 | 192 | /** | 196 | /** |
95 | 193 | * @defgroup geis_2_geis The Geis API Object | 197 | * @defgroup geis_2_geis The Geis API Object (GEIS v2.0) |
96 | 194 | * | 198 | * |
97 | 195 | * @{ | 199 | * @{ |
98 | 196 | */ | 200 | */ |
99 | 197 | 201 | ||
100 | 198 | #define GEIS_INIT_SERVICE_PROVIDER "geis-init-server" | 202 | /** |
101 | 203 | * @defgroup geis_2_geis_init_args Specified Initialization Arguments | ||
102 | 204 | * | ||
103 | 205 | * These initialization arguments are defined by the GEIS specification. | ||
104 | 206 | * | ||
105 | 207 | * @{ | ||
106 | 208 | */ | ||
107 | 209 | |||
108 | 210 | /** | ||
109 | 211 | * Enables GEIS to provide a networked service. | ||
110 | 212 | * | ||
111 | 213 | * This initialization argument takes no parameters. | ||
112 | 214 | */ | ||
113 | 215 | #define GEIS_INIT_SERVICE_PROVIDER "org.libgeis.init.server" | ||
114 | 216 | |||
115 | 217 | /* @} */ | ||
116 | 218 | |||
117 | 219 | /** | ||
118 | 220 | * @defgroup geis_2_geis_init_vendor Vendor-defined Initialization Arguments | ||
119 | 221 | * | ||
120 | 222 | * These initialization arguments are not a part of te GEIS specification and | ||
121 | 223 | * may change. | ||
122 | 224 | * | ||
123 | 225 | * @{ | ||
124 | 226 | */ | ||
125 | 227 | |||
126 | 228 | #define GEIS_INIT_UTOUCH_MOCK_ENGINE "com.canonical.utouch.mock.engine" | ||
127 | 229 | |||
128 | 230 | /* @} */ | ||
129 | 199 | 231 | ||
130 | 200 | 232 | ||
131 | 201 | typedef struct _Geis *Geis; | 233 | typedef struct _Geis *Geis; |
132 | @@ -332,8 +364,31 @@ | |||
133 | 332 | * @{ | 364 | * @{ |
134 | 333 | */ | 365 | */ |
135 | 334 | 366 | ||
136 | 367 | /** | ||
137 | 368 | * @defgroup geis2_config_spec Required Configuration Items | ||
138 | 369 | * | ||
139 | 370 | * These configuration items are defined by the GEIS specification. | ||
140 | 371 | * | ||
141 | 372 | * @{ | ||
142 | 373 | */ | ||
143 | 374 | |||
144 | 335 | #define GEIS_CONFIGURATION_FD "org.libgeis.configuration.fd" | 375 | #define GEIS_CONFIGURATION_FD "org.libgeis.configuration.fd" |
145 | 336 | 376 | ||
146 | 377 | /* @} */ | ||
147 | 378 | |||
148 | 379 | /** | ||
149 | 380 | * @defgroup geis2_config_vendor Vendor-defined Configuration Items | ||
150 | 381 | * | ||
151 | 382 | * These configuration items are not a part of the GEIS specification and may | ||
152 | 383 | * change. | ||
153 | 384 | * | ||
154 | 385 | * @{ | ||
155 | 386 | */ | ||
156 | 387 | |||
157 | 388 | #define GEIS_CONFIG_UTOUCH_MAX_EVENTS "com.canonical.utouch.max_events" | ||
158 | 389 | |||
159 | 390 | /* @} */ | ||
160 | 391 | |||
161 | 337 | /** | 392 | /** |
162 | 338 | * Gets a feature configuration value. | 393 | * Gets a feature configuration value. |
163 | 339 | * | 394 | * |
164 | 340 | 395 | ||
165 | === modified file 'libutouch-geis/Makefile.am' | |||
166 | --- libutouch-geis/Makefile.am 2010-11-29 02:16:02 +0000 | |||
167 | +++ libutouch-geis/Makefile.am 2010-12-02 19:24:57 +0000 | |||
168 | @@ -23,11 +23,15 @@ | |||
169 | 23 | lib_LTLIBRARIES = libutouch-geis.la | 23 | lib_LTLIBRARIES = libutouch-geis.la |
170 | 24 | 24 | ||
171 | 25 | libutouch_geis_la_SOURCES = \ | 25 | libutouch_geis_la_SOURCES = \ |
177 | 26 | geis_attr.h geis_attr.c \ | 26 | geis_attr.h geis_attr.c \ |
178 | 27 | geis_error.h geis_error.c \ | 27 | geis_backend.h geis_backend.c \ |
179 | 28 | geis_logging.h geis_logging.c \ | 28 | geis_backend_protected.h \ |
180 | 29 | geis_subscription.h geis_subscription.c \ | 29 | geis_backend_test_fixture.h geis_backend_test_fixture.c \ |
181 | 30 | geis_private.h geis.c | 30 | geis_backend_multiplexor.h geis_backend_multiplexor.c \ |
182 | 31 | geis_error.h geis_error.c \ | ||
183 | 32 | geis_logging.h geis_logging.c \ | ||
184 | 33 | geis_subscription.h geis_subscription.c \ | ||
185 | 34 | geis_private.h geis.c | ||
186 | 31 | 35 | ||
187 | 32 | libutouch_geis_la_CPPFLAGS = \ | 36 | libutouch_geis_la_CPPFLAGS = \ |
188 | 33 | -Wall -Wextra \ | 37 | -Wall -Wextra \ |
189 | 34 | 38 | ||
190 | === modified file 'libutouch-geis/geis.c' | |||
191 | --- libutouch-geis/geis.c 2010-11-29 02:16:02 +0000 | |||
192 | +++ libutouch-geis/geis.c 2010-12-02 19:24:57 +0000 | |||
193 | @@ -21,12 +21,23 @@ | |||
194 | 21 | #include "geis_config.h" | 21 | #include "geis_config.h" |
195 | 22 | #include "geis_private.h" | 22 | #include "geis_private.h" |
196 | 23 | 23 | ||
197 | 24 | #include "geis_backend.h" | ||
198 | 25 | #include "geis_backend_test_fixture.h" | ||
199 | 26 | #include "geis_backend_multiplexor.h" | ||
200 | 24 | #include "geis_error.h" | 27 | #include "geis_error.h" |
201 | 25 | #include "geis_logging.h" | 28 | #include "geis_logging.h" |
202 | 26 | #include <stdarg.h> | 29 | #include <stdarg.h> |
203 | 27 | #include <string.h> | 30 | #include <string.h> |
204 | 28 | 31 | ||
205 | 29 | 32 | ||
206 | 33 | struct _Geis | ||
207 | 34 | { | ||
208 | 35 | GeisErrorStack error_stack; | ||
209 | 36 | GeisSubBag subscription_bag; | ||
210 | 37 | GeisBackendMultiplexor backend_multiplexor; | ||
211 | 38 | GeisBackend backend; | ||
212 | 39 | }; | ||
213 | 40 | |||
214 | 30 | 41 | ||
215 | 31 | /** | 42 | /** |
216 | 32 | * Creates a new empty Geis API instance. | 43 | * Creates a new empty Geis API instance. |
217 | @@ -40,7 +51,7 @@ | |||
218 | 40 | { | 51 | { |
219 | 41 | geis_error_push(NULL, GEIS_STATUS_UNKNOWN_ERROR); | 52 | geis_error_push(NULL, GEIS_STATUS_UNKNOWN_ERROR); |
220 | 42 | geis_error("calloc failed"); | 53 | geis_error("calloc failed"); |
222 | 43 | goto error_exit; | 54 | goto final_exit; |
223 | 44 | } | 55 | } |
224 | 45 | 56 | ||
225 | 46 | geis->subscription_bag = geis_subscription_bag_new(1); | 57 | geis->subscription_bag = geis_subscription_bag_new(1); |
226 | @@ -50,10 +61,26 @@ | |||
227 | 50 | geis_error("creation of subscroption bag failed"); | 61 | geis_error("creation of subscroption bag failed"); |
228 | 51 | free(geis); | 62 | free(geis); |
229 | 52 | geis = NULL; | 63 | geis = NULL; |
234 | 53 | goto error_exit; | 64 | goto unwind_geis; |
235 | 54 | } | 65 | } |
236 | 55 | 66 | ||
237 | 56 | error_exit: | 67 | geis->backend_multiplexor = geis_backend_multiplexor_new(); |
238 | 68 | if (!geis->backend_multiplexor) | ||
239 | 69 | { | ||
240 | 70 | geis_error_push(NULL, GEIS_STATUS_UNKNOWN_ERROR); | ||
241 | 71 | geis_error("creation of back end multiplexor failed"); | ||
242 | 72 | goto unwind_subscription_bag; | ||
243 | 73 | } | ||
244 | 74 | goto final_exit; | ||
245 | 75 | |||
246 | 76 | unwind_subscription_bag: | ||
247 | 77 | geis_subscription_bag_delete(geis->subscription_bag); | ||
248 | 78 | |||
249 | 79 | unwind_geis: | ||
250 | 80 | free(geis); | ||
251 | 81 | geis = NULL; | ||
252 | 82 | |||
253 | 83 | final_exit: | ||
254 | 57 | return geis; | 84 | return geis; |
255 | 58 | } | 85 | } |
256 | 59 | 86 | ||
257 | @@ -70,14 +97,27 @@ | |||
258 | 70 | { | 97 | { |
259 | 71 | geis_debug("initializing GEIS server"); | 98 | geis_debug("initializing GEIS server"); |
260 | 72 | } | 99 | } |
262 | 73 | else if (0 == strcmp(init_arg_name, "geis-test-fixture")) | 100 | else if (0 == strcmp(init_arg_name, GEIS_INIT_UTOUCH_MOCK_ENGINE)) |
263 | 74 | { | 101 | { |
266 | 75 | geis_debug("initializing GEIS test fixture"); | 102 | if (NULL != geis->backend) |
267 | 76 | geis->is_test_fixture = GEIS_TRUE; | 103 | { |
268 | 104 | geis_error("multiple back ends requested, only using %s",\ | ||
269 | 105 | geis_backend_name(geis->backend)); | ||
270 | 106 | } | ||
271 | 107 | else | ||
272 | 108 | { | ||
273 | 109 | geis_debug("initializing GEIS test fixture"); | ||
274 | 110 | geis->backend = geis_backend_new_test_fixture(geis); | ||
275 | 111 | } | ||
276 | 77 | } | 112 | } |
277 | 78 | 113 | ||
278 | 79 | init_arg_name = va_arg(varargs, GeisString); | 114 | init_arg_name = va_arg(varargs, GeisString); |
279 | 80 | } | 115 | } |
280 | 116 | |||
281 | 117 | if (NULL == geis->backend) | ||
282 | 118 | { | ||
283 | 119 | geis_debug("initializing default GEIS back end"); | ||
284 | 120 | } | ||
285 | 81 | } | 121 | } |
286 | 82 | 122 | ||
287 | 83 | 123 | ||
288 | @@ -110,6 +150,11 @@ | |||
289 | 110 | { | 150 | { |
290 | 111 | return GEIS_STATUS_BAD_ARGUMENT; | 151 | return GEIS_STATUS_BAD_ARGUMENT; |
291 | 112 | } | 152 | } |
292 | 153 | |||
293 | 154 | if (geis->backend) | ||
294 | 155 | geis_backend_delete(geis->backend); | ||
295 | 156 | geis_backend_multiplexor_delete(geis->backend_multiplexor); | ||
296 | 157 | geis_subscription_bag_delete(geis->subscription_bag); | ||
297 | 113 | free(geis); | 158 | free(geis); |
298 | 114 | return GEIS_STATUS_SUCCESS; | 159 | return GEIS_STATUS_SUCCESS; |
299 | 115 | } | 160 | } |
300 | @@ -127,8 +172,16 @@ | |||
301 | 127 | 172 | ||
302 | 128 | if (0 == strcmp(configuration_item_name, GEIS_CONFIGURATION_FD)) | 173 | if (0 == strcmp(configuration_item_name, GEIS_CONFIGURATION_FD)) |
303 | 129 | { | 174 | { |
306 | 130 | /* status = GEIS_STATUS_SUCCESS; */ | 175 | *(int*)configuration_item_value |
307 | 131 | }; | 176 | = geis_backend_multiplexor_fd(geis->backend_multiplexor); |
308 | 177 | status = GEIS_STATUS_SUCCESS; | ||
309 | 178 | } | ||
310 | 179 | else if (0 == strcmp(configuration_item_name, GEIS_CONFIG_UTOUCH_MAX_EVENTS)) | ||
311 | 180 | { | ||
312 | 181 | *(int*)configuration_item_value | ||
313 | 182 | = geis_backend_multiplexor_max_events_per_pump(geis->backend_multiplexor); | ||
314 | 183 | status = GEIS_STATUS_SUCCESS; | ||
315 | 184 | } | ||
316 | 132 | 185 | ||
317 | 133 | return status; | 186 | return status; |
318 | 134 | } | 187 | } |
319 | @@ -142,7 +195,22 @@ | |||
320 | 142 | GeisString configuration_item_name, | 195 | GeisString configuration_item_name, |
321 | 143 | void *configuration_item_value) | 196 | void *configuration_item_value) |
322 | 144 | { | 197 | { |
324 | 145 | return GEIS_STATUS_UNKNOWN_ERROR; | 198 | GeisStatus status = GEIS_STATUS_NOT_SUPPORTED; |
325 | 199 | |||
326 | 200 | if (0 == strcmp(configuration_item_name, GEIS_CONFIG_UTOUCH_MAX_EVENTS)) | ||
327 | 201 | { | ||
328 | 202 | int max_events = *(int *)configuration_item_value; | ||
329 | 203 | geis_backend_multiplexor_set_max_events_per_pump(geis->backend_multiplexor, | ||
330 | 204 | max_events); | ||
331 | 205 | status = GEIS_STATUS_SUCCESS; | ||
332 | 206 | } | ||
333 | 207 | return status; | ||
334 | 208 | } | ||
335 | 209 | |||
336 | 210 | |||
337 | 211 | GeisErrorStack *geis_error_stack(Geis geis) | ||
338 | 212 | { | ||
339 | 213 | return &geis->error_stack; | ||
340 | 146 | } | 214 | } |
341 | 147 | 215 | ||
342 | 148 | 216 | ||
343 | 149 | 217 | ||
344 | === added file 'libutouch-geis/geis_backend.c' | |||
345 | --- libutouch-geis/geis_backend.c 1970-01-01 00:00:00 +0000 | |||
346 | +++ libutouch-geis/geis_backend.c 2010-12-02 19:24:57 +0000 | |||
347 | @@ -0,0 +1,65 @@ | |||
348 | 1 | /** | ||
349 | 2 | * @file geis_backend.c | ||
350 | 3 | * @brief internal GEIS back end base class implementation | ||
351 | 4 | * | ||
352 | 5 | * Copyright 2010 Canonical Ltd. | ||
353 | 6 | * | ||
354 | 7 | * This library is free software; you can redistribute it and/or modify it under | ||
355 | 8 | * the terms of the GNU Lesser General Public License as published by the Free | ||
356 | 9 | * Software Foundation; either version 3 of the License, or (at your option) any | ||
357 | 10 | * later version. | ||
358 | 11 | * | ||
359 | 12 | * This library is distributed in the hope that it will be useful, but WITHOUT | ||
360 | 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
361 | 14 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
362 | 15 | * details. | ||
363 | 16 | * | ||
364 | 17 | * You should have received a copy of the GNU Lesser General Public License | ||
365 | 18 | * along with this program; if not, write to the Free Software Foundation, Inc., | ||
366 | 19 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
367 | 20 | */ | ||
368 | 21 | #include "geis_backend.h" | ||
369 | 22 | #include "geis_backend_protected.h" | ||
370 | 23 | |||
371 | 24 | #include "geis_logging.h" | ||
372 | 25 | #include <stdlib.h> | ||
373 | 26 | #include <string.h> | ||
374 | 27 | |||
375 | 28 | |||
376 | 29 | /* | ||
377 | 30 | * Initializes the base portion of the back end. | ||
378 | 31 | */ | ||
379 | 32 | void | ||
380 | 33 | geis_backend_init_base(GeisBackend be_base, | ||
381 | 34 | GeisBackendVtable be_vtbl, | ||
382 | 35 | GeisString be_name) | ||
383 | 36 | { | ||
384 | 37 | be_base->be_name = strdup(be_name); | ||
385 | 38 | be_base->be_vtbl = be_vtbl; | ||
386 | 39 | } | ||
387 | 40 | |||
388 | 41 | |||
389 | 42 | /* | ||
390 | 43 | * Destroys the back end. | ||
391 | 44 | */ | ||
392 | 45 | void | ||
393 | 46 | geis_backend_delete(GeisBackend be) | ||
394 | 47 | { | ||
395 | 48 | if (be) | ||
396 | 49 | { | ||
397 | 50 | free((char *)be->be_name); | ||
398 | 51 | be->be_vtbl->finalize(be); | ||
399 | 52 | } | ||
400 | 53 | geis_debug("%s back end destroyed", geis_backend_name(be)); | ||
401 | 54 | } | ||
402 | 55 | |||
403 | 56 | |||
404 | 57 | /* | ||
405 | 58 | * Gets the name of the back end (RTTI). | ||
406 | 59 | */ | ||
407 | 60 | GeisString | ||
408 | 61 | geis_backend_name(GeisBackend be) | ||
409 | 62 | { | ||
410 | 63 | return be->be_name; | ||
411 | 64 | } | ||
412 | 65 | |||
413 | 0 | 66 | ||
414 | === added file 'libutouch-geis/geis_backend.h' | |||
415 | --- libutouch-geis/geis_backend.h 1970-01-01 00:00:00 +0000 | |||
416 | +++ libutouch-geis/geis_backend.h 2010-12-02 19:24:57 +0000 | |||
417 | @@ -0,0 +1,56 @@ | |||
418 | 1 | /** | ||
419 | 2 | * @file geis_backend.h | ||
420 | 3 | * @brief internal GEIS back end base class public interface | ||
421 | 4 | * | ||
422 | 5 | * Copyright 2010 Canonical Ltd. | ||
423 | 6 | * | ||
424 | 7 | * This library is free software; you can redistribute it and/or modify it under | ||
425 | 8 | * the terms of the GNU Lesser General Public License as published by the Free | ||
426 | 9 | * Software Foundation; either version 3 of the License, or (at your option) any | ||
427 | 10 | * later version. | ||
428 | 11 | * | ||
429 | 12 | * This library is distributed in the hope that it will be useful, but WITHOUT | ||
430 | 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
431 | 14 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
432 | 15 | * details. | ||
433 | 16 | * | ||
434 | 17 | * You should have received a copy of the GNU Lesser General Public License | ||
435 | 18 | * along with this program; if not, write to the Free Software Foundation, Inc., | ||
436 | 19 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
437 | 20 | */ | ||
438 | 21 | #ifndef GEIS_BACKEND_H_ | ||
439 | 22 | #define GEIS_BACKEND_H_ | ||
440 | 23 | |||
441 | 24 | #include "geis/geis.h" | ||
442 | 25 | |||
443 | 26 | /** | ||
444 | 27 | * Provides a virtual "base class" for various GEIS back ends. | ||
445 | 28 | * | ||
446 | 29 | * The GEIS is an API that implements the facade pattern over some number of | ||
447 | 30 | * actual "back end" implementations. Most internal operations of teh API are | ||
448 | 31 | * performed through this "virtual base class" interface rather than through the | ||
449 | 32 | * concrete back ends (isn;t object-oriented programming great?). | ||
450 | 33 | */ | ||
451 | 34 | typedef struct _GeisBackend *GeisBackend; | ||
452 | 35 | |||
453 | 36 | |||
454 | 37 | /** | ||
455 | 38 | * Destroys the back end. | ||
456 | 39 | * | ||
457 | 40 | * @parameter[in] be The back end. | ||
458 | 41 | * | ||
459 | 42 | * This function behaves like a virtual destructor and chains through to the | ||
460 | 43 | * concrete destructor call. | ||
461 | 44 | */ | ||
462 | 45 | void geis_backend_delete(GeisBackend be); | ||
463 | 46 | |||
464 | 47 | /** | ||
465 | 48 | * Gets the name of the back end. | ||
466 | 49 | * | ||
467 | 50 | * @parameter[in] be The back end. | ||
468 | 51 | * | ||
469 | 52 | * This accessor is useful for diagnostics. | ||
470 | 53 | */ | ||
471 | 54 | GeisString geis_backend_name(GeisBackend be); | ||
472 | 55 | |||
473 | 56 | #endif /* GEIS_BACKEND_H_ */ | ||
474 | 0 | 57 | ||
475 | === added file 'libutouch-geis/geis_backend_multiplexor.c' | |||
476 | --- libutouch-geis/geis_backend_multiplexor.c 1970-01-01 00:00:00 +0000 | |||
477 | +++ libutouch-geis/geis_backend_multiplexor.c 2010-12-02 19:24:57 +0000 | |||
478 | @@ -0,0 +1,203 @@ | |||
479 | 1 | /** | ||
480 | 2 | * @file geis_backend_multiplexor.c | ||
481 | 3 | * @brief internal GEIS backend multiplexor implementation | ||
482 | 4 | * | ||
483 | 5 | * Copyright 2010 Canonical Ltd. | ||
484 | 6 | * | ||
485 | 7 | * This library is free software; you can redistribute it and/or modify it under | ||
486 | 8 | * the terms of the GNU Lesser General Public License as published by the Free | ||
487 | 9 | * Software Foundation; either version 3 of the License, or (at your option) any | ||
488 | 10 | * later version. | ||
489 | 11 | * | ||
490 | 12 | * This library is distributed in the hope that it will be useful, but WITHOUT | ||
491 | 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
492 | 14 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
493 | 15 | * details. | ||
494 | 16 | * | ||
495 | 17 | * You should have received a copy of the GNU Lesser General Public License | ||
496 | 18 | * along with this program; if not, write to the Free Software Foundation, Inc., | ||
497 | 19 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
498 | 20 | */ | ||
499 | 21 | #include "geis_config.h" | ||
500 | 22 | #include "geis_backend_multiplexor.h" | ||
501 | 23 | |||
502 | 24 | #include <errno.h> | ||
503 | 25 | #include "geis_logging.h" | ||
504 | 26 | #include <stdlib.h> | ||
505 | 27 | #include <string.h> | ||
506 | 28 | #include <sys/epoll.h> | ||
507 | 29 | |||
508 | 30 | |||
509 | 31 | struct _GeisBackendMultiplexor | ||
510 | 32 | { | ||
511 | 33 | int mx_fd; | ||
512 | 34 | int mx_max_events_per_pump; | ||
513 | 35 | }; | ||
514 | 36 | |||
515 | 37 | typedef struct _CallbackInfo | ||
516 | 38 | { | ||
517 | 39 | int fd; | ||
518 | 40 | GeisBackendFdEventCallback callback; | ||
519 | 41 | void *context; | ||
520 | 42 | } *CallbackInfo; | ||
521 | 43 | |||
522 | 44 | |||
523 | 45 | /** | ||
524 | 46 | * Creates a new backend multiplexor. | ||
525 | 47 | */ | ||
526 | 48 | GeisBackendMultiplexor | ||
527 | 49 | geis_backend_multiplexor_new() | ||
528 | 50 | { | ||
529 | 51 | GeisBackendMultiplexor mx = calloc(1, sizeof(struct _GeisBackendMultiplexor)); | ||
530 | 52 | if (!mx) | ||
531 | 53 | { | ||
532 | 54 | geis_error("failed to allocate backend multiplexor"); | ||
533 | 55 | } | ||
534 | 56 | else | ||
535 | 57 | { | ||
536 | 58 | mx->mx_fd = epoll_create1(EPOLL_CLOEXEC); | ||
537 | 59 | if (mx->mx_fd < 0) | ||
538 | 60 | { | ||
539 | 61 | geis_error("error %d creating backend multiplexor: %s", | ||
540 | 62 | errno, strerror(errno)); | ||
541 | 63 | free(mx); | ||
542 | 64 | } | ||
543 | 65 | mx->mx_max_events_per_pump = GEIS_BE_MX_DEFAULT_EVENTS_PER_PUMP; | ||
544 | 66 | } | ||
545 | 67 | |||
546 | 68 | return mx; | ||
547 | 69 | } | ||
548 | 70 | |||
549 | 71 | |||
550 | 72 | /** | ||
551 | 73 | * Destroys an backend multiplexor. | ||
552 | 74 | */ | ||
553 | 75 | void | ||
554 | 76 | geis_backend_multiplexor_delete(GeisBackendMultiplexor mx) | ||
555 | 77 | { | ||
556 | 78 | free(mx); | ||
557 | 79 | } | ||
558 | 80 | |||
559 | 81 | |||
560 | 82 | /** | ||
561 | 83 | * Adds a file descriptor to an backend multiplexor. | ||
562 | 84 | */ | ||
563 | 85 | void | ||
564 | 86 | geis_backend_multiplexor_add_fd(GeisBackendMultiplexor mx, | ||
565 | 87 | int fd, | ||
566 | 88 | GeisBackendFdEventCallback callback, | ||
567 | 89 | void *context) | ||
568 | 90 | { | ||
569 | 91 | int status; | ||
570 | 92 | struct epoll_event ev; | ||
571 | 93 | |||
572 | 94 | CallbackInfo callback_info = calloc(1, sizeof(struct _CallbackInfo)); | ||
573 | 95 | if (!callback_info) | ||
574 | 96 | { | ||
575 | 97 | geis_error("failed to allocate callback info structure"); | ||
576 | 98 | return; | ||
577 | 99 | } | ||
578 | 100 | |||
579 | 101 | callback_info->fd = fd; | ||
580 | 102 | callback_info->callback = callback; | ||
581 | 103 | callback_info->context = context; | ||
582 | 104 | |||
583 | 105 | ev.events = EPOLLIN; | ||
584 | 106 | ev.data.ptr = callback_info; | ||
585 | 107 | status = epoll_ctl(mx->mx_fd, EPOLL_CTL_ADD, fd, &ev); | ||
586 | 108 | if (status < 0) | ||
587 | 109 | { | ||
588 | 110 | geis_error("error %d multiplexing fd %d: %s", | ||
589 | 111 | errno, fd, strerror(errno)); | ||
590 | 112 | } | ||
591 | 113 | } | ||
592 | 114 | |||
593 | 115 | |||
594 | 116 | /** | ||
595 | 117 | * Removes a file descriptor from a backend multiplexor. | ||
596 | 118 | * | ||
597 | 119 | * @todo free callback_info | ||
598 | 120 | */ | ||
599 | 121 | void | ||
600 | 122 | geis_backend_multiplexor_remove_fd(GeisBackendMultiplexor mx, int fd) | ||
601 | 123 | { | ||
602 | 124 | int status = epoll_ctl(mx->mx_fd, EPOLL_CTL_DEL, fd, NULL); | ||
603 | 125 | if (status < 0) | ||
604 | 126 | { | ||
605 | 127 | geis_error("error %d multiplexing fd %d: %s", | ||
606 | 128 | errno, fd, strerror(errno)); | ||
607 | 129 | } | ||
608 | 130 | } | ||
609 | 131 | |||
610 | 132 | |||
611 | 133 | /** | ||
612 | 134 | * Gets the single file descriptor of the backend multiplexir itself. | ||
613 | 135 | */ | ||
614 | 136 | int | ||
615 | 137 | geis_backend_multiplexor_fd(GeisBackendMultiplexor mx) | ||
616 | 138 | { | ||
617 | 139 | return mx->mx_fd; | ||
618 | 140 | } | ||
619 | 141 | |||
620 | 142 | |||
621 | 143 | /** | ||
622 | 144 | * gets the maximum number of fd events per pump. | ||
623 | 145 | */ | ||
624 | 146 | int | ||
625 | 147 | geis_backend_multiplexor_max_events_per_pump(GeisBackendMultiplexor mx) | ||
626 | 148 | { | ||
627 | 149 | return mx->mx_max_events_per_pump; | ||
628 | 150 | } | ||
629 | 151 | |||
630 | 152 | |||
631 | 153 | /** | ||
632 | 154 | * Sets the maximum number of fd events processed per pump. | ||
633 | 155 | */ | ||
634 | 156 | void | ||
635 | 157 | geis_backend_multiplexor_set_max_events_per_pump(GeisBackendMultiplexor mx, | ||
636 | 158 | int max_events_per_pump) | ||
637 | 159 | { | ||
638 | 160 | mx->mx_max_events_per_pump = max_events_per_pump; | ||
639 | 161 | } | ||
640 | 162 | |||
641 | 163 | |||
642 | 164 | /** | ||
643 | 165 | * Dispatches events on the multiplexed file descriptors. | ||
644 | 166 | */ | ||
645 | 167 | GeisStatus | ||
646 | 168 | geis_backend_multiplexor_pump(GeisBackendMultiplexor mx) | ||
647 | 169 | { | ||
648 | 170 | GeisStatus status = GEIS_STATUS_UNKNOWN_ERROR; | ||
649 | 171 | int i; | ||
650 | 172 | int processed_event_count = 0; | ||
651 | 173 | int available_event_count = 1; | ||
652 | 174 | struct epoll_event events[4]; | ||
653 | 175 | |||
654 | 176 | while (available_event_count > 0 | ||
655 | 177 | && processed_event_count < mx->mx_max_events_per_pump) | ||
656 | 178 | { | ||
657 | 179 | available_event_count = epoll_wait(mx->mx_fd, events, 4, 0); | ||
658 | 180 | if (available_event_count < 0) | ||
659 | 181 | { | ||
660 | 182 | geis_error("error %d in epoll_wait: %s", errno, strerror(errno)); | ||
661 | 183 | goto error_exit; | ||
662 | 184 | } | ||
663 | 185 | |||
664 | 186 | for (i = 0; i < available_event_count; ++i) | ||
665 | 187 | { | ||
666 | 188 | CallbackInfo callback_info = (CallbackInfo)events[i].data.ptr; | ||
667 | 189 | callback_info->callback(callback_info->fd, | ||
668 | 190 | GEIS_BE_MX_READ_AVAILABLE, | ||
669 | 191 | callback_info->context); | ||
670 | 192 | ++processed_event_count; | ||
671 | 193 | } | ||
672 | 194 | } | ||
673 | 195 | if (available_event_count) | ||
674 | 196 | status = GEIS_STATUS_CONTINUE; | ||
675 | 197 | else | ||
676 | 198 | status = GEIS_STATUS_SUCCESS; | ||
677 | 199 | |||
678 | 200 | error_exit: | ||
679 | 201 | return status; | ||
680 | 202 | } | ||
681 | 203 | |||
682 | 0 | 204 | ||
683 | === added file 'libutouch-geis/geis_backend_multiplexor.h' | |||
684 | --- libutouch-geis/geis_backend_multiplexor.h 1970-01-01 00:00:00 +0000 | |||
685 | +++ libutouch-geis/geis_backend_multiplexor.h 2010-12-02 19:24:57 +0000 | |||
686 | @@ -0,0 +1,129 @@ | |||
687 | 1 | /** | ||
688 | 2 | * @file geis_backend_multiplexor.h | ||
689 | 3 | * @brief internal GEIS backend multiplexor interface | ||
690 | 4 | * | ||
691 | 5 | * Copyright 2010 Canonical Ltd. | ||
692 | 6 | * | ||
693 | 7 | * This library is free software; you can redistribute it and/or modify it under | ||
694 | 8 | * the terms of the GNU Lesser General Public License as published by the Free | ||
695 | 9 | * Software Foundation; either version 3 of the License, or (at your option) any | ||
696 | 10 | * later version. | ||
697 | 11 | * | ||
698 | 12 | * This library is distributed in the hope that it will be useful, but WITHOUT | ||
699 | 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
700 | 14 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
701 | 15 | * details. | ||
702 | 16 | * | ||
703 | 17 | * You should have received a copy of the GNU Lesser General Public License | ||
704 | 18 | * along with this program; if not, write to the Free Software Foundation, Inc., | ||
705 | 19 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
706 | 20 | */ | ||
707 | 21 | #ifndef GEIS_BACKEND_MULTIPLEXOR_H_ | ||
708 | 22 | #define GEIS_BACKEND_MULTIPLEXOR_H_ | ||
709 | 23 | |||
710 | 24 | #include "geis/geis.h" | ||
711 | 25 | |||
712 | 26 | |||
713 | 27 | /** | ||
714 | 28 | * Multiplexes back end events into a single notification file descriptor. | ||
715 | 29 | * | ||
716 | 30 | * The GEIS API presents a single file descriptor to the application to watch | ||
717 | 31 | * for activity notification. A back end may be monitoring activity on more | ||
718 | 32 | * than one file descriptor. The multiplexor combines these requirements. | ||
719 | 33 | */ | ||
720 | 34 | typedef struct _GeisBackendMultiplexor *GeisBackendMultiplexor; | ||
721 | 35 | |||
722 | 36 | /** | ||
723 | 37 | * Indicates the type of fd event that occurred on a multiplexed descriptor. | ||
724 | 38 | */ | ||
725 | 39 | typedef enum _GeisBackendMultiplexorEvent | ||
726 | 40 | { | ||
727 | 41 | GEIS_BE_MX_READ_AVAILABLE, | ||
728 | 42 | GEIS_BE_MX_WRITE_AVAILABLE | ||
729 | 43 | } GeisBackendMultiplexorEvent; | ||
730 | 44 | |||
731 | 45 | /** | ||
732 | 46 | * Handles events occurring on multiplexed file descriptors. | ||
733 | 47 | * | ||
734 | 48 | * Back ends must provide a callback with this signature to the multiplexor. | ||
735 | 49 | */ | ||
736 | 50 | typedef void (*GeisBackendFdEventCallback)(int fd, | ||
737 | 51 | GeisBackendMultiplexorEvent event, | ||
738 | 52 | void *context); | ||
739 | 53 | |||
740 | 54 | /** | ||
741 | 55 | * Constructs a new back end multiplexor. | ||
742 | 56 | */ | ||
743 | 57 | GeisBackendMultiplexor geis_backend_multiplexor_new(); | ||
744 | 58 | |||
745 | 59 | /** | ||
746 | 60 | * A reasonable default value for the max_events_per_pump parameter to | ||
747 | 61 | * geis_backend_multiplexor_new(). | ||
748 | 62 | */ | ||
749 | 63 | #define GEIS_BE_MX_DEFAULT_EVENTS_PER_PUMP 16 | ||
750 | 64 | |||
751 | 65 | /** | ||
752 | 66 | * Destroys a back end multiplexor. | ||
753 | 67 | * | ||
754 | 68 | * @param[in] mx The back end multiplexor to destroy. | ||
755 | 69 | */ | ||
756 | 70 | void geis_backend_multiplexor_delete(GeisBackendMultiplexor mx); | ||
757 | 71 | |||
758 | 72 | /** | ||
759 | 73 | * Adds a file descriptor to a back end multiplexor. | ||
760 | 74 | * | ||
761 | 75 | * @param[in] mx The back end multiplexor. | ||
762 | 76 | * @param[in] fd The file descriptor to add. | ||
763 | 77 | */ | ||
764 | 78 | void geis_backend_multiplexor_add_fd(GeisBackendMultiplexor mx, | ||
765 | 79 | int fd, | ||
766 | 80 | GeisBackendFdEventCallback callback, | ||
767 | 81 | void *context); | ||
768 | 82 | |||
769 | 83 | /** | ||
770 | 84 | * Removes a file descriptor from a back end multiplexor. | ||
771 | 85 | * | ||
772 | 86 | * @param[in] mx The back end multiplexor. | ||
773 | 87 | * @param[in] fd The file descriptor to remove. | ||
774 | 88 | */ | ||
775 | 89 | void geis_backend_multiplexor_remove_fd(GeisBackendMultiplexor mx, | ||
776 | 90 | int fd); | ||
777 | 91 | |||
778 | 92 | /** | ||
779 | 93 | * Gets the file descriptor of the back end multiplexor. | ||
780 | 94 | * | ||
781 | 95 | * @param[in] mx The back end multiplexor. | ||
782 | 96 | */ | ||
783 | 97 | int geis_backend_multiplexor_fd(GeisBackendMultiplexor mx); | ||
784 | 98 | |||
785 | 99 | /** | ||
786 | 100 | * Gets the maximum number of fd events per pump. | ||
787 | 101 | * | ||
788 | 102 | * @param[in] mx The back end multiplexor. | ||
789 | 103 | */ | ||
790 | 104 | int geis_backend_multiplexor_max_events_per_pump(GeisBackendMultiplexor mx); | ||
791 | 105 | |||
792 | 106 | /** | ||
793 | 107 | * Sets the maximum fd events per pump of the multiplexor. | ||
794 | 108 | * | ||
795 | 109 | * @param[in] mx The back end multiplexor. | ||
796 | 110 | * @param[in] max_events_per_pump The maximum number of fd events pumped | ||
797 | 111 | * per call of geis_backend_multiplexor_pump(). | ||
798 | 112 | * | ||
799 | 113 | * This value is tunable to accommodate different back ends and | ||
800 | 114 | * application/toolkit requirements. | ||
801 | 115 | */ | ||
802 | 116 | void geis_backend_multiplexor_set_max_events_per_pump(GeisBackendMultiplexor mx, | ||
803 | 117 | int max_events_per_pump); | ||
804 | 118 | |||
805 | 119 | /** | ||
806 | 120 | * Exercises the back end multiplexor. | ||
807 | 121 | * | ||
808 | 122 | * @param[in] mx The back end multiplexor. | ||
809 | 123 | * | ||
810 | 124 | * Dispatches any events on multiplexed file descriptors to their assciated | ||
811 | 125 | * handlers. | ||
812 | 126 | */ | ||
813 | 127 | GeisStatus geis_backend_multiplexor_pump(GeisBackendMultiplexor mx); | ||
814 | 128 | |||
815 | 129 | #endif /* GEIS_BACKEND_MULTIPLEXOR_H_ */ | ||
816 | 0 | 130 | ||
817 | === added file 'libutouch-geis/geis_backend_protected.h' | |||
818 | --- libutouch-geis/geis_backend_protected.h 1970-01-01 00:00:00 +0000 | |||
819 | +++ libutouch-geis/geis_backend_protected.h 2010-12-02 19:24:57 +0000 | |||
820 | @@ -0,0 +1,61 @@ | |||
821 | 1 | /** | ||
822 | 2 | * @file geis_backend_protected.h | ||
823 | 3 | * @brief internal GEIS back end base class "protected" interface | ||
824 | 4 | * | ||
825 | 5 | * This file contains the implementation interface for the various GEIS v2 back | ||
826 | 6 | * ends. | ||
827 | 7 | */ | ||
828 | 8 | |||
829 | 9 | /* | ||
830 | 10 | * Copyright 2010 Canonical Ltd. | ||
831 | 11 | * | ||
832 | 12 | * This library is free software; you can redistribute it and/or modify it under | ||
833 | 13 | * the terms of the GNU Lesser General Public License as published by the Free | ||
834 | 14 | * Software Foundation; either version 3 of the License, or (at your option) any | ||
835 | 15 | * later version. | ||
836 | 16 | * | ||
837 | 17 | * This library is distributed in the hope that it will be useful, but WITHOUT | ||
838 | 18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
839 | 19 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
840 | 20 | * details. | ||
841 | 21 | * | ||
842 | 22 | * You should have received a copy of the GNU Lesser General Public License | ||
843 | 23 | * along with this program; if not, write to the Free Software Foundation, Inc., | ||
844 | 24 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
845 | 25 | */ | ||
846 | 26 | #ifndef GEIS_BACKEND_PROTECTED_H_ | ||
847 | 27 | #define GEIS_BACKEND_PROTECTED_H_ | ||
848 | 28 | |||
849 | 29 | #include "geis/geis.h" | ||
850 | 30 | #include "geis_backend.h" | ||
851 | 31 | |||
852 | 32 | |||
853 | 33 | /** | ||
854 | 34 | * The custom dispatch table for "derived" GEIS v2 backends. | ||
855 | 35 | */ | ||
856 | 36 | typedef struct _GeisBackendVtable | ||
857 | 37 | { | ||
858 | 38 | void (* finalize)(GeisBackend); | ||
859 | 39 | } *GeisBackendVtable; | ||
860 | 40 | |||
861 | 41 | /** | ||
862 | 42 | * The "base" class of all the GEIS v2 backends. | ||
863 | 43 | */ | ||
864 | 44 | struct _GeisBackend { | ||
865 | 45 | GeisString be_name; | ||
866 | 46 | GeisBackendVtable be_vtbl; | ||
867 | 47 | }; | ||
868 | 48 | |||
869 | 49 | |||
870 | 50 | /** | ||
871 | 51 | * Initializes the base portion of the GEIS v2 backends. | ||
872 | 52 | * | ||
873 | 53 | * @param[in] be_base The GeisBackend portion of the back end object. | ||
874 | 54 | * @param[in] be_vtbl An initialized GeisBackendVtable. | ||
875 | 55 | * @param[in] be_name The name of the back end. | ||
876 | 56 | */ | ||
877 | 57 | void geis_backend_init_base(GeisBackend be_base, | ||
878 | 58 | GeisBackendVtable be_vtbl, | ||
879 | 59 | GeisString be_name); | ||
880 | 60 | |||
881 | 61 | #endif /* GEIS_BACKEND_PROTECTED_H_ */ | ||
882 | 0 | 62 | ||
883 | === added file 'libutouch-geis/geis_backend_test_fixture.c' | |||
884 | --- libutouch-geis/geis_backend_test_fixture.c 1970-01-01 00:00:00 +0000 | |||
885 | +++ libutouch-geis/geis_backend_test_fixture.c 2010-12-02 19:24:57 +0000 | |||
886 | @@ -0,0 +1,63 @@ | |||
887 | 1 | /** | ||
888 | 2 | * @file geis_backend_test_fixture.c | ||
889 | 3 | * @brief GEIS mock back end test fixture implementation | ||
890 | 4 | * | ||
891 | 5 | * Copyright 2010 Canonical Ltd. | ||
892 | 6 | * | ||
893 | 7 | * This library is free software; you can redistribute it and/or modify it under | ||
894 | 8 | * the terms of the GNU Lesser General Public License as published by the Free | ||
895 | 9 | * Software Foundation; either version 3 of the License, or (at your option) any | ||
896 | 10 | * later version. | ||
897 | 11 | * | ||
898 | 12 | * This library is distributed in the hope that it will be useful, but WITHOUT | ||
899 | 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
900 | 14 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
901 | 15 | * details. | ||
902 | 16 | * | ||
903 | 17 | * You should have received a copy of the GNU Lesser General Public License | ||
904 | 18 | * along with this program; if not, write to the Free Software Foundation, Inc., | ||
905 | 19 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
906 | 20 | */ | ||
907 | 21 | #include "geis_backend.h" | ||
908 | 22 | #include "geis_backend_protected.h" | ||
909 | 23 | |||
910 | 24 | #include "geis_logging.h" | ||
911 | 25 | #include <stdlib.h> | ||
912 | 26 | |||
913 | 27 | |||
914 | 28 | typedef struct _GeisBackendTestFixture | ||
915 | 29 | { | ||
916 | 30 | struct _GeisBackend tf_base; | ||
917 | 31 | } *GeisBackendTestFixture; | ||
918 | 32 | |||
919 | 33 | |||
920 | 34 | static void | ||
921 | 35 | geis_backend_finalize(GeisBackend be) | ||
922 | 36 | { | ||
923 | 37 | GeisBackendTestFixture tf __attribute__((unused)) = (GeisBackendTestFixture)be; | ||
924 | 38 | } | ||
925 | 39 | |||
926 | 40 | |||
927 | 41 | static struct _GeisBackendVtable tf_vtbl = { | ||
928 | 42 | geis_backend_finalize | ||
929 | 43 | }; | ||
930 | 44 | |||
931 | 45 | GeisBackend | ||
932 | 46 | geis_backend_new_test_fixture(Geis geis __attribute__((unused))) | ||
933 | 47 | { | ||
934 | 48 | GeisBackendTestFixture tf = calloc(1, sizeof(struct _GeisBackendTestFixture)); | ||
935 | 49 | if (!tf) | ||
936 | 50 | { | ||
937 | 51 | geis_error("failed to allocate GEIS back end test fixture"); | ||
938 | 52 | goto nomem; | ||
939 | 53 | } | ||
940 | 54 | |||
941 | 55 | geis_backend_init_base(&tf->tf_base, &tf_vtbl, "GEIS2 test fixture"); | ||
942 | 56 | |||
943 | 57 | geis_debug("%s back end created", geis_backend_name(&tf->tf_base)); | ||
944 | 58 | |||
945 | 59 | nomem: | ||
946 | 60 | return (GeisBackend)tf; | ||
947 | 61 | } | ||
948 | 62 | |||
949 | 63 | |||
950 | 0 | 64 | ||
951 | === added file 'libutouch-geis/geis_backend_test_fixture.h' | |||
952 | --- libutouch-geis/geis_backend_test_fixture.h 1970-01-01 00:00:00 +0000 | |||
953 | +++ libutouch-geis/geis_backend_test_fixture.h 2010-12-02 19:24:57 +0000 | |||
954 | @@ -0,0 +1,35 @@ | |||
955 | 1 | /** | ||
956 | 2 | * @file geis_backend_test_fixture.h | ||
957 | 3 | * @brief internal GEIS test fixture back end class | ||
958 | 4 | * | ||
959 | 5 | * Copyright 2010 Canonical Ltd. | ||
960 | 6 | * | ||
961 | 7 | * This library is free software; you can redistribute it and/or modify it under | ||
962 | 8 | * the terms of the GNU Lesser General Public License as published by the Free | ||
963 | 9 | * Software Foundation; either version 3 of the License, or (at your option) any | ||
964 | 10 | * later version. | ||
965 | 11 | * | ||
966 | 12 | * This library is distributed in the hope that it will be useful, but WITHOUT | ||
967 | 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
968 | 14 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
969 | 15 | * details. | ||
970 | 16 | * | ||
971 | 17 | * You should have received a copy of the GNU Lesser General Public License | ||
972 | 18 | * along with this program; if not, write to the Free Software Foundation, Inc., | ||
973 | 19 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
974 | 20 | */ | ||
975 | 21 | #ifndef GEIS_BACKEND_TEST_FIXTURE_H_ | ||
976 | 22 | #define GEIS_BACKEND_TEST_FIXTURE_H_ | ||
977 | 23 | |||
978 | 24 | #include "geis/geis.h" | ||
979 | 25 | |||
980 | 26 | /** | ||
981 | 27 | * Constructs a new GEIS Test Fuixture back end. | ||
982 | 28 | * | ||
983 | 29 | * @param[in] geis The API instance the back end will run in. | ||
984 | 30 | * | ||
985 | 31 | * The Test Fixture back end is used in unit tests. | ||
986 | 32 | */ | ||
987 | 33 | GeisBackend geis_backend_new_test_fixture(Geis geis); | ||
988 | 34 | |||
989 | 35 | #endif /* GEIS_BACKEND_TEST_FIXTURE_H_ */ | ||
990 | 0 | 36 | ||
991 | === modified file 'libutouch-geis/geis_error.c' | |||
992 | --- libutouch-geis/geis_error.c 2010-11-28 00:41:24 +0000 | |||
993 | +++ libutouch-geis/geis_error.c 2010-12-02 19:24:57 +0000 | |||
994 | @@ -74,7 +74,7 @@ | |||
995 | 74 | { | 74 | { |
996 | 75 | if (geis) | 75 | if (geis) |
997 | 76 | { | 76 | { |
999 | 77 | geis_error_stack_clear(&geis->error_stack); | 77 | geis_error_stack_clear(geis_error_stack(geis)); |
1000 | 78 | } | 78 | } |
1001 | 79 | else | 79 | else |
1002 | 80 | { | 80 | { |
1003 | @@ -88,7 +88,7 @@ | |||
1004 | 88 | { | 88 | { |
1005 | 89 | if (geis) | 89 | if (geis) |
1006 | 90 | { | 90 | { |
1008 | 91 | geis_error_stack_push(&geis->error_stack, code); | 91 | geis_error_stack_push(geis_error_stack(geis), code); |
1009 | 92 | } | 92 | } |
1010 | 93 | else | 93 | else |
1011 | 94 | { | 94 | { |
1012 | @@ -102,7 +102,7 @@ | |||
1013 | 102 | { | 102 | { |
1014 | 103 | if (geis) | 103 | if (geis) |
1015 | 104 | { | 104 | { |
1017 | 105 | return geis->error_stack.error_count; | 105 | return geis_error_stack(geis)->error_count; |
1018 | 106 | } | 106 | } |
1019 | 107 | else | 107 | else |
1020 | 108 | { | 108 | { |
1021 | @@ -117,7 +117,7 @@ | |||
1022 | 117 | GeisStatus status = GEIS_STATUS_UNKNOWN_ERROR; | 117 | GeisStatus status = GEIS_STATUS_UNKNOWN_ERROR; |
1023 | 118 | if (geis) | 118 | if (geis) |
1024 | 119 | { | 119 | { |
1026 | 120 | status = geis_error_stack_get(&geis->error_stack, index); | 120 | status = geis_error_stack_get(geis_error_stack(geis), index); |
1027 | 121 | } | 121 | } |
1028 | 122 | else | 122 | else |
1029 | 123 | { | 123 | { |
1030 | 124 | 124 | ||
1031 | === modified file 'libutouch-geis/geis_private.h' | |||
1032 | --- libutouch-geis/geis_private.h 2010-11-29 02:16:02 +0000 | |||
1033 | +++ libutouch-geis/geis_private.h 2010-12-02 19:24:57 +0000 | |||
1034 | @@ -27,13 +27,10 @@ | |||
1035 | 27 | #include "geis_subscription.h" | 27 | #include "geis_subscription.h" |
1036 | 28 | 28 | ||
1037 | 29 | 29 | ||
1045 | 30 | struct _Geis | 30 | /** |
1046 | 31 | { | 31 | * Gets the error stack drom the geis object. |
1047 | 32 | GeisBoolean is_test_fixture; | 32 | */ |
1048 | 33 | GeisErrorStack error_stack; | 33 | GeisErrorStack *geis_error_stack(Geis geis); |
1042 | 34 | GeisSubBag subscription_bag; | ||
1043 | 35 | }; | ||
1044 | 36 | |||
1049 | 37 | 34 | ||
1050 | 38 | /** | 35 | /** |
1051 | 39 | * Gets the subscription container from the geis object. | 36 | * Gets the subscription container from the geis object. |
1052 | 40 | 37 | ||
1053 | === modified file 'testsuite/geis2/check_config.c' | |||
1054 | --- testsuite/geis2/check_config.c 2010-11-25 03:14:17 +0000 | |||
1055 | +++ testsuite/geis2/check_config.c 2010-12-02 19:24:57 +0000 | |||
1056 | @@ -12,7 +12,7 @@ | |||
1057 | 12 | static void | 12 | static void |
1058 | 13 | construct_geis() | 13 | construct_geis() |
1059 | 14 | { | 14 | { |
1061 | 15 | geis = geis_new("geis-test-fixture", NULL); | 15 | geis = geis_new(GEIS_INIT_UTOUCH_MOCK_ENGINE, NULL); |
1062 | 16 | } | 16 | } |
1063 | 17 | 17 | ||
1064 | 18 | /* fixture teardown */ | 18 | /* fixture teardown */ |
1065 | @@ -37,7 +37,7 @@ | |||
1066 | 37 | START_TEST(get_fail) | 37 | START_TEST(get_fail) |
1067 | 38 | { | 38 | { |
1068 | 39 | int fd = -1; | 39 | int fd = -1; |
1070 | 40 | GeisStatus status = geis_get_configuration(geis, 1234, &fd); | 40 | GeisStatus status = geis_get_configuration(geis, "no such configuration", &fd); |
1071 | 41 | fail_unless(status == GEIS_STATUS_NOT_SUPPORTED, | 41 | fail_unless(status == GEIS_STATUS_NOT_SUPPORTED, |
1072 | 42 | "unexpected return status from geis_get_configuration()"); | 42 | "unexpected return status from geis_get_configuration()"); |
1073 | 43 | } | 43 | } |
1074 | 44 | 44 | ||
1075 | === modified file 'testsuite/geis2/check_error_codes.c' | |||
1076 | --- testsuite/geis2/check_error_codes.c 2010-11-21 17:00:48 +0000 | |||
1077 | +++ testsuite/geis2/check_error_codes.c 2010-12-02 19:24:57 +0000 | |||
1078 | @@ -9,6 +9,8 @@ | |||
1079 | 9 | START_TEST(error_codes) | 9 | START_TEST(error_codes) |
1080 | 10 | { | 10 | { |
1081 | 11 | GeisStatus error = GEIS_STATUS_SUCCESS ; | 11 | GeisStatus error = GEIS_STATUS_SUCCESS ; |
1082 | 12 | error = GEIS_STATUS_CONTINUE; | ||
1083 | 13 | error = GEIS_STATUS_EMPTY; | ||
1084 | 12 | error = GEIS_STATUS_NOT_SUPPORTED; | 14 | error = GEIS_STATUS_NOT_SUPPORTED; |
1085 | 13 | error = GEIS_STATUS_BAD_ARGUMENT; | 15 | error = GEIS_STATUS_BAD_ARGUMENT; |
1086 | 14 | error = GEIS_STATUS_UNKNOWN_ERROR; | 16 | error = GEIS_STATUS_UNKNOWN_ERROR; |
1087 | 15 | 17 | ||
1088 | === modified file 'testsuite/geis2/check_geis_new.c' | |||
1089 | --- testsuite/geis2/check_geis_new.c 2010-11-23 03:31:21 +0000 | |||
1090 | +++ testsuite/geis2/check_geis_new.c 2010-12-02 19:24:57 +0000 | |||
1091 | @@ -8,7 +8,7 @@ | |||
1092 | 8 | /* compile-time test to ensure required types are defined */ | 8 | /* compile-time test to ensure required types are defined */ |
1093 | 9 | START_TEST(geis_new_and_delete) | 9 | START_TEST(geis_new_and_delete) |
1094 | 10 | { | 10 | { |
1096 | 11 | Geis geis = geis_new("geis-test-fixture", NULL); | 11 | Geis geis = geis_new(GEIS_INIT_UTOUCH_MOCK_ENGINE, NULL); |
1097 | 12 | fail_unless(geis != NULL, "failed to create GEIS v2.0 API instance"); | 12 | fail_unless(geis != NULL, "failed to create GEIS v2.0 API instance"); |
1098 | 13 | 13 | ||
1099 | 14 | GeisStatus status = geis_delete(geis); | 14 | GeisStatus status = geis_delete(geis); |
1100 | 15 | 15 | ||
1101 | === modified file 'testsuite/geis2/check_subscription.c' | |||
1102 | --- testsuite/geis2/check_subscription.c 2010-11-29 02:16:02 +0000 | |||
1103 | +++ testsuite/geis2/check_subscription.c 2010-12-02 19:24:57 +0000 | |||
1104 | @@ -14,7 +14,7 @@ | |||
1105 | 14 | static void | 14 | static void |
1106 | 15 | construct_geis() | 15 | construct_geis() |
1107 | 16 | { | 16 | { |
1109 | 17 | g_geis = geis_new("geis-test-fixture", NULL); | 17 | g_geis = geis_new(GEIS_INIT_UTOUCH_MOCK_ENGINE, NULL); |
1110 | 18 | } | 18 | } |
1111 | 19 | 19 | ||
1112 | 20 | /* fixture teardown */ | 20 | /* fixture teardown */ |
1113 | 21 | 21 | ||
1114 | === modified file 'testsuite/libutouch-geis/Makefile.am' | |||
1115 | --- testsuite/libutouch-geis/Makefile.am 2010-11-29 02:16:02 +0000 | |||
1116 | +++ testsuite/libutouch-geis/Makefile.am 2010-12-02 19:24:57 +0000 | |||
1117 | @@ -32,6 +32,7 @@ | |||
1118 | 32 | 32 | ||
1119 | 33 | check_geis2_internals_SOURCES = \ | 33 | check_geis2_internals_SOURCES = \ |
1120 | 34 | check_attr.c \ | 34 | check_attr.c \ |
1121 | 35 | check_backend_multiplexor.c \ | ||
1122 | 35 | check_error_reporting.c \ | 36 | check_error_reporting.c \ |
1123 | 36 | check_subscription.c \ | 37 | check_subscription.c \ |
1124 | 37 | check_geis2_internals.c | 38 | check_geis2_internals.c |
1125 | 38 | 39 | ||
1126 | === added file 'testsuite/libutouch-geis/check_backend_multiplexor.c' | |||
1127 | --- testsuite/libutouch-geis/check_backend_multiplexor.c 1970-01-01 00:00:00 +0000 | |||
1128 | +++ testsuite/libutouch-geis/check_backend_multiplexor.c 2010-12-02 19:24:57 +0000 | |||
1129 | @@ -0,0 +1,127 @@ | |||
1130 | 1 | /** | ||
1131 | 2 | * internal unit tests for the uTouch GEIS v2.0 backend_multiplexor module | ||
1132 | 3 | */ | ||
1133 | 4 | #include <check.h> | ||
1134 | 5 | |||
1135 | 6 | #include "geis/geis.h" | ||
1136 | 7 | #include "libutouch-geis/geis_backend_multiplexor.h" | ||
1137 | 8 | #include <stdio.h> | ||
1138 | 9 | #include <sys/select.h> | ||
1139 | 10 | #include <unistd.h> | ||
1140 | 11 | |||
1141 | 12 | |||
1142 | 13 | /* fixtures */ | ||
1143 | 14 | static GeisBackendMultiplexor g_mx; | ||
1144 | 15 | |||
1145 | 16 | /* fixture setup */ | ||
1146 | 17 | static void | ||
1147 | 18 | construct_mx() | ||
1148 | 19 | { | ||
1149 | 20 | g_mx = geis_backend_multiplexor_new(); | ||
1150 | 21 | } | ||
1151 | 22 | |||
1152 | 23 | /* fixture teardown */ | ||
1153 | 24 | static void | ||
1154 | 25 | destroy_mx() | ||
1155 | 26 | { | ||
1156 | 27 | geis_backend_multiplexor_delete(g_mx); | ||
1157 | 28 | } | ||
1158 | 29 | |||
1159 | 30 | static void | ||
1160 | 31 | testcase_event_callback(int fd, GeisBackendMultiplexorEvent event, void *context) | ||
1161 | 32 | { | ||
1162 | 33 | char buf[2]; | ||
1163 | 34 | (void)read(fd, buf, 1); | ||
1164 | 35 | *(int *)context += 1; | ||
1165 | 36 | } | ||
1166 | 37 | |||
1167 | 38 | |||
1168 | 39 | /* verify bag construction/destruction */ | ||
1169 | 40 | START_TEST(construction) | ||
1170 | 41 | { | ||
1171 | 42 | construct_mx(); | ||
1172 | 43 | fail_unless(g_mx != NULL, "failed to create backend_multiplexor"); | ||
1173 | 44 | fail_unless(geis_backend_multiplexor_fd(g_mx) >= 0, "invalid MX fd"); | ||
1174 | 45 | fail_unless(geis_backend_multiplexor_max_events_per_pump(g_mx) == GEIS_BE_MX_DEFAULT_EVENTS_PER_PUMP, "unexpected max fd per pump value"); | ||
1175 | 46 | destroy_mx(); | ||
1176 | 47 | } | ||
1177 | 48 | END_TEST | ||
1178 | 49 | |||
1179 | 50 | |||
1180 | 51 | /* verify multiplexor wait */ | ||
1181 | 52 | START_TEST(mx_wait) | ||
1182 | 53 | { | ||
1183 | 54 | int pfd[2]; | ||
1184 | 55 | int mx_fd = geis_backend_multiplexor_fd(g_mx); | ||
1185 | 56 | int called = 0; | ||
1186 | 57 | int status = 0; | ||
1187 | 58 | int first_time = 1; | ||
1188 | 59 | |||
1189 | 60 | (void)pipe(pfd); | ||
1190 | 61 | geis_backend_multiplexor_add_fd(g_mx, pfd[0], testcase_event_callback, &called); | ||
1191 | 62 | |||
1192 | 63 | while (1) | ||
1193 | 64 | { | ||
1194 | 65 | fd_set fds; | ||
1195 | 66 | FD_ZERO(&fds); | ||
1196 | 67 | FD_SET(mx_fd, &fds); | ||
1197 | 68 | |||
1198 | 69 | struct timeval tm; | ||
1199 | 70 | tm.tv_sec = 0; | ||
1200 | 71 | tm.tv_usec = 5000; | ||
1201 | 72 | |||
1202 | 73 | status = select(mx_fd+1, &fds, NULL, NULL, &tm); | ||
1203 | 74 | fail_if(status < 0, "error in select"); | ||
1204 | 75 | if (status < 0) | ||
1205 | 76 | { | ||
1206 | 77 | break; | ||
1207 | 78 | } | ||
1208 | 79 | else if (0 == status) | ||
1209 | 80 | { | ||
1210 | 81 | fprintf(stderr, "select timeout\n"); | ||
1211 | 82 | fail_unless(first_time, "select timed out before read"); | ||
1212 | 83 | if (!first_time) | ||
1213 | 84 | { | ||
1214 | 85 | break; | ||
1215 | 86 | } | ||
1216 | 87 | first_time = 0; | ||
1217 | 88 | (void)write(pfd[1], "1", 1); | ||
1218 | 89 | } | ||
1219 | 90 | else | ||
1220 | 91 | { | ||
1221 | 92 | geis_backend_multiplexor_pump(g_mx); | ||
1222 | 93 | break; | ||
1223 | 94 | } | ||
1224 | 95 | } | ||
1225 | 96 | |||
1226 | 97 | fail_if(called == 0, "MX event callback not called"); | ||
1227 | 98 | fail_if(called > 1, "MX event callback called too many times"); | ||
1228 | 99 | } | ||
1229 | 100 | END_TEST | ||
1230 | 101 | |||
1231 | 102 | START_TEST(mx_config) | ||
1232 | 103 | { | ||
1233 | 104 | geis_backend_multiplexor_set_max_events_per_pump(g_mx, 24); | ||
1234 | 105 | fail_unless(geis_backend_multiplexor_max_events_per_pump(g_mx) == 24, | ||
1235 | 106 | "unexpected max fd per pump value"); | ||
1236 | 107 | } | ||
1237 | 108 | END_TEST | ||
1238 | 109 | |||
1239 | 110 | /* boilerplate */ | ||
1240 | 111 | Suite * | ||
1241 | 112 | make_backend_multiplexor_suite() | ||
1242 | 113 | { | ||
1243 | 114 | Suite *s = suite_create("utouch-geis2-backend-multiplexor"); | ||
1244 | 115 | |||
1245 | 116 | TCase *create = tcase_create("backend-multiplexor-creation"); | ||
1246 | 117 | tcase_add_test(create, construction); | ||
1247 | 118 | suite_add_tcase(s, create); | ||
1248 | 119 | |||
1249 | 120 | TCase *usage = tcase_create("backend-multiplexor-usage"); | ||
1250 | 121 | tcase_add_checked_fixture(usage, construct_mx, destroy_mx); | ||
1251 | 122 | tcase_add_test(usage, mx_wait); | ||
1252 | 123 | suite_add_tcase(s, usage); | ||
1253 | 124 | |||
1254 | 125 | return s; | ||
1255 | 126 | } | ||
1256 | 127 | |||
1257 | 0 | 128 | ||
1258 | === modified file 'testsuite/libutouch-geis/check_geis2_internals.c' | |||
1259 | --- testsuite/libutouch-geis/check_geis2_internals.c 2010-11-29 02:16:02 +0000 | |||
1260 | +++ testsuite/libutouch-geis/check_geis2_internals.c 2010-12-02 19:24:57 +0000 | |||
1261 | @@ -6,6 +6,7 @@ | |||
1262 | 6 | extern Suite *make_error_reporting_suite(); | 6 | extern Suite *make_error_reporting_suite(); |
1263 | 7 | extern Suite *make_attr_suite(); | 7 | extern Suite *make_attr_suite(); |
1264 | 8 | extern Suite *make_subscription_suite(); | 8 | extern Suite *make_subscription_suite(); |
1265 | 9 | extern Suite *make_backend_multiplexor_suite(); | ||
1266 | 9 | 10 | ||
1267 | 10 | 11 | ||
1268 | 11 | int | 12 | int |
1269 | @@ -19,6 +20,7 @@ | |||
1270 | 19 | srunner_add_suite(sr, make_error_reporting_suite()); | 20 | srunner_add_suite(sr, make_error_reporting_suite()); |
1271 | 20 | srunner_add_suite(sr, make_attr_suite()); | 21 | srunner_add_suite(sr, make_attr_suite()); |
1272 | 21 | srunner_add_suite(sr, make_subscription_suite()); | 22 | srunner_add_suite(sr, make_subscription_suite()); |
1273 | 23 | srunner_add_suite(sr, make_backend_multiplexor_suite()); | ||
1274 | 22 | 24 | ||
1275 | 23 | srunner_set_log(sr, "geis2_internals.log"); | 25 | srunner_set_log(sr, "geis2_internals.log"); |
1276 | 24 | srunner_run_all(sr, CK_NORMAL); | 26 | srunner_run_all(sr, CK_NORMAL); |
1277 | 25 | 27 | ||
1278 | === modified file 'testsuite/libutouch-geis/check_subscription.c' | |||
1279 | --- testsuite/libutouch-geis/check_subscription.c 2010-11-29 02:16:02 +0000 | |||
1280 | +++ testsuite/libutouch-geis/check_subscription.c 2010-12-02 19:24:57 +0000 | |||
1281 | @@ -16,7 +16,7 @@ | |||
1282 | 16 | static void | 16 | static void |
1283 | 17 | construct_bag() | 17 | construct_bag() |
1284 | 18 | { | 18 | { |
1286 | 19 | g_geis = geis_new("geis-test-fixture", NULL); | 19 | g_geis = geis_new(GEIS_INIT_UTOUCH_MOCK_ENGINE, NULL); |
1287 | 20 | g_sub_bag = geis_subscription_bag_new(1); | 20 | g_sub_bag = geis_subscription_bag_new(1); |
1288 | 21 | } | 21 | } |
1289 | 22 | 22 |
Looks ok. Things are getting closer. :-)