Merge lp:geis/2.x into lp:geis

Proposed by Stephen M. Webb
Status: Merged
Merged at revision: 89
Proposed branch: lp:geis/2.x
Merge into: lp:geis
Diff against target: 940 lines (+743/-6)
15 files modified
ChangeLog (+38/-0)
configure.ac (+2/-1)
include/geis/geis.h (+107/-1)
libutouch-geis/Makefile.am (+4/-2)
libutouch-geis/geis.c (+30/-0)
libutouch-geis/geis_attr.c (+324/-0)
libutouch-geis/geis_attr.h (+65/-0)
libutouch-geis/libutouch-geis.ver (+8/-0)
testsuite/geis2/Makefile.am (+1/-0)
testsuite/geis2/check_config.c (+61/-0)
testsuite/geis2/check_geis2_api.c (+2/-0)
testsuite/libutouch-geis/Makefile.am (+3/-1)
testsuite/libutouch-geis/check_attr.c (+95/-0)
testsuite/libutouch-geis/check_error_reporting.c (+1/-1)
testsuite/libutouch-geis/check_geis2_internals.c (+2/-0)
To merge this branch: bzr merge lp:geis/2.x
Reviewer Review Type Date Requested Status
Chase Douglas (community) Approve
Mohamed IKBEL Boulabiar (community) Approve
Review via email: mp+41980@code.launchpad.net

Description of the change

Two more function groups: Geis configuration and Geis attributes.

To post a comment you must log in.
Revision history for this message
Mohamed IKBEL Boulabiar (boulabiar) wrote :

in libutouch-geis/geis.c I have just found this line commented
/* status = GEIS_STATUS_SUCCESS; */
and as said in IRC about GEIS_STATUS_NO_SUPPORTED in the comments.

It Looks good. Nice work !

review: Approve
Revision history for this message
Chase Douglas (chasedouglas) wrote :

I'm not sure what Ikbel is getting at, but I also find GEIS_STATUS_NO_SUPPORTED to be odd. Shouldn't it be GEIS_STATUS_NOT_SUPPORTED? Or GEIS_STATUS_NO_SUPPORT?

Otherwise, looks good. I'll approve, but under the condition that GEIS_STATUS_NO_SUPPORTED is transmutated into something better :).

review: Approve
lp:geis/2.x updated
105. By Stephen M. Webb

Silence some compile-time warnings.

106. By Stephen M. Webb

Added GEIS Subscritpion construction and accessors.

107. By Stephen M. Webb

Fixed typo in Doxygen documentation.

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-24 17:19:26 +0000
3+++ ChangeLog 2010-11-26 20:47:53 +0000
4@@ -1,3 +1,41 @@
5+2010-11-26 Stephen M. Webb <stephen.webb@canonical.com>
6+
7+ Added Geis Attr functions.
8+
9+ * libutouch-geis/geis_attr.c: new file
10+ * libutouch-geis/geis_attr.h: new file
11+ * testsuite/libutouch-geis/check_attr.c: new unit test suite
12+ * include/geis/geis.h (GeisAttr): new type
13+ (geis_attr_name): new function
14+ (geis_attr_type): new function
15+ (geis_attr_value_to_boolean): new function
16+ (geis_attr_value_to_float): new function
17+ (geis_attr_value_to_integer): new function
18+ (geis_attr_value_to_string): new function
19+ * libutouch-geis/Makefile.am: added new files
20+ * libutouch-geis/libutouch-geis.ver: added new symbols
21+ * testsuite/libutouch-geis/Makefile.am: added new test suite
22+ * testsuite/libutouch-geis/check_error_reporting.c: renamed test suite
23+ * testsuite/libutouch-geis/check_geis2_internals.c: added new test suite
24+
25+2010-11-24 Stephen M. Webb <stephen.webb@canonical.com>
26+
27+ Added Geis configuration functions.
28+
29+ * include/geis/geis.h (geis_get_config): new function
30+ (geis_set_config): new function
31+ * libutouch-geis/geis.c: added stubs for new functions
32+ * libutouch-geis/libutouch-geis.ver: added symbols for new functions
33+ * testsuite/geis2/check_config.c: new test suite for new functions
34+ * testsuite/geis2/Makefile.am: added above new file
35+
36+2010-11-24 Stephen M. Webb <stephen.webb@canonical.com>
37+
38+ Added silent rules to build.
39+
40+ * configure.ac (AM_INIT_AUTOMAKE): required minimum version 1.11
41+ (AM_SILENT_RULES): new macros to set silent build rules on by default
42+
43 2010-11-24 Stephen M. Webb <stephen.webb@canonical.com>
44
45 Fixed a "make distcheck" problem.
46
47=== modified file 'configure.ac'
48--- configure.ac 2010-11-24 16:59:34 +0000
49+++ configure.ac 2010-11-26 20:47:53 +0000
50@@ -26,7 +26,8 @@
51 AC_CONFIG_HEADERS([geis_config.h])
52 AC_CONFIG_AUX_DIR([config.aux])
53 AC_CONFIG_MACRO_DIR([m4])
54-AM_INIT_AUTOMAKE([gnu -Wall])
55+AM_INIT_AUTOMAKE([1.11 gnu -Wall color-tests])
56+AM_SILENT_RULES([yes])
57
58 # Checks for programs.
59 AM_PROG_CC_C_O
60
61=== modified file 'include/geis/geis.h'
62--- include/geis/geis.h 2010-11-23 23:33:37 +0000
63+++ include/geis/geis.h 2010-11-26 20:47:53 +0000
64@@ -267,7 +267,7 @@
65 /* @} */
66
67 /**
68- * @defgroup geis_config Configuration and Control
69+ * @defgroup geis_config Configuration and Control (GEIS v1.0)
70 * @{
71 */
72
73@@ -327,6 +327,60 @@
74
75 /* @} */
76
77+/**
78+ * @defgroup geis2_config Configuration (GEIS v2.0)
79+ * @{
80+ */
81+
82+#define GEIS_CONFIGURATION_FD "org.libgeis.configuration.fd"
83+
84+/**
85+ * Gets a feature configuration value.
86+ *
87+ * @param[in] geis An opaque GEIS API object.
88+ * @param[in] configuration_item_name Selects the configuration value to return.
89+ * @param[out] configuration_item_value Points to a buffer to contain the output
90+ * value. The actual type of this buffer
91+ * depends on the
92+ * @p configuration_value_name.
93+ *
94+ * @retval GEIS_STATUS_BAD_ARGUMENT an invalid argument value was passed
95+ * @retval GEIS_STATUS_NO_SUPPORTED the configuration value is not supported
96+ * @retval GEIS_STATUS_SUCCESS normal successful completion
97+ */
98+GEIS_API GeisStatus geis_get_configuration(Geis geis,
99+ GeisString configuration_item_name,
100+ void *configuration_item_value);
101+
102+/**
103+ * Sets a feature configuration value.
104+ *
105+ * @param[in] geis An opaque GEIS API object.
106+ * @param[in] configuration_value Selects the configuration value to return.
107+ * @param[in] configuration_item_name Selects the configuration value to return.
108+ * @param[in] configuration_item_value Points to a buffer to contain the output
109+ * configuration value. The actual type of
110+ * this buffer depends on the
111+ * @p configuration_value_name.
112+ *
113+ * @retval GEIS_STATUS_BAD_ARGUMENT an invalid argument value was passed
114+ * @retval GEIS_STATUS_NO_SUPPORTED the configuration value is not supported
115+ * @retval GEIS_STATUS_SUCCESS normal successful completion
116+ */
117+GEIS_API GeisStatus geis_set_configuration(Geis geis,
118+ GeisString configuration_item_name,
119+ void *configuration_item_value);
120+
121+/* @} */
122+
123+/**
124+ * @defgroup geis2_attrs Attributes
125+ *
126+ * Attributes are named values associated with various GEIS entities, including
127+ * input devices, gesture types, and gesture events.
128+ *
129+ * @{
130+ */
131 typedef enum GeisAttrType
132 {
133 GEIS_ATTR_TYPE_UNKNOWN,
134@@ -337,6 +391,58 @@
135 } GeisAttrType;
136
137 /**
138+ * An opaque type that encapsulates a GEIS attribute.
139+ *
140+ * GeisAttr objects may not be created or destroyed by the application, they may
141+ * only have their data examined or extracted.
142+ */
143+typedef struct _GeisAttr *GeisAttr;
144+
145+/**
146+ * Gets the name of an attribute.
147+ *
148+ * @param[in] attr Identifies the attribute.
149+ */
150+GEIS_API GeisString geis_attr_name(GeisAttr attr);
151+
152+/**
153+ * Gets the type of an attribute value.
154+ *
155+ * @param[in] attr Identifies the attribute.
156+ */
157+GEIS_API GeisAttrType geis_attr_type(GeisAttr attr);
158+
159+/**
160+ * Gets the value of an attribute as a GeisBoolean.
161+ *
162+ * @param[in] attr Identifies the attribute.
163+ */
164+GEIS_API GeisBoolean geis_attr_value_to_boolean(GeisAttr attr);
165+
166+/**
167+ * Gets the value of an attribute as a GeisFloat.
168+ *
169+ * @param[in] attr Identifies the attribute.
170+ */
171+GEIS_API GeisFloat geis_attr_value_to_float(GeisAttr attr);
172+
173+/**
174+ * Gets the value of an attribute as a GeisInteger.
175+ *
176+ * @param[in] attr Identifies the attribute.
177+ */
178+GEIS_API GeisInteger geis_attr_value_to_integer(GeisAttr attr);
179+
180+/**geis_attr_value_to_integer
181+ * Gets the value of an attribute as a GeisString.
182+ *
183+ * @param[in] attr Identifies the attribute.
184+ */
185+GEIS_API GeisString geis_attr_value_to_string(GeisAttr attr);
186+
187+/* @} */
188+
189+/**
190 * @defgroup geis_input Input Devices
191 * @{
192 */
193
194=== modified file 'libutouch-geis/Makefile.am'
195--- libutouch-geis/Makefile.am 2010-11-23 23:33:37 +0000
196+++ libutouch-geis/Makefile.am 2010-11-26 20:47:53 +0000
197@@ -23,6 +23,7 @@
198 lib_LTLIBRARIES = libutouch-geis.la
199
200 libutouch_geis_la_SOURCES = \
201+ geis_attr.h geis_attr.c \
202 geis_error.h geis_error.c \
203 geis_logging.h geis_logging.c \
204 geis_private.h geis.c
205@@ -38,10 +39,11 @@
206 libutouch_geis_la_LDFLAGS = \
207 -Wl,-z,defs -Wl,--as-needed \
208 -version-info 2:0:1 \
209- -Wl,--version-script=$(version_script)
210+ -Wl,--version-script=$(version_script) \
211+ -lm
212
213 libutouch_geis_la_LIBADD = \
214- $(top_builddir)/libutouch-geis-xcb/libutouch-geis.la
215+ $(top_builddir)/libutouch-geis-xcb/libutouch-geis.la
216
217 EXTRA_DIST = $(version_script)
218
219
220=== modified file 'libutouch-geis/geis.c'
221--- libutouch-geis/geis.c 2010-11-23 23:33:37 +0000
222+++ libutouch-geis/geis.c 2010-11-26 20:47:53 +0000
223@@ -24,6 +24,7 @@
224 #include "geis_error.h"
225 #include "geis_logging.h"
226 #include <stdarg.h>
227+#include <string.h>
228
229
230
231@@ -101,4 +102,33 @@
232 }
233
234
235+/**
236+ * Gets a named configuration item.
237+ */
238+GeisStatus
239+geis_get_configuration(Geis geis,
240+ GeisString configuration_item_name,
241+ void *configuration_item_value)
242+{
243+ GeisStatus status = GEIS_STATUS_NOT_SUPPORTED;
244+
245+ if (0 == strcmp(configuration_item_name, GEIS_CONFIGURATION_FD))
246+ {
247+ /* status = GEIS_STATUS_SUCCESS; */
248+ };
249+
250+ return status;
251+}
252+
253+
254+/**
255+ * Sets a named configuration item.
256+ */
257+GeisStatus
258+geis_set_configuration(Geis geis,
259+ GeisString configuration_item_name,
260+ void *configuration_item_value)
261+{
262+ return GEIS_STATUS_UNKNOWN_ERROR;
263+}
264
265
266=== added file 'libutouch-geis/geis_attr.c'
267--- libutouch-geis/geis_attr.c 1970-01-01 00:00:00 +0000
268+++ libutouch-geis/geis_attr.c 2010-11-26 20:47:53 +0000
269@@ -0,0 +1,324 @@
270+/**
271+ * @file geis_attr.c
272+ * @brief internal uTouch GeisAttr facilities
273+ *
274+ * Copyright 2010 Canonical Ltd.
275+ *
276+ * This library is free software; you can redistribute it and/or modify it under
277+ * the terms of the GNU Lesser General Public License as published by the Free
278+ * Software Foundation; either version 3 of the License, or (at your option) any
279+ * later version.
280+ *
281+ * This library is distributed in the hope that it will be useful, but WITHOUT
282+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
283+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
284+ * details.
285+ *
286+ * You should have received a copy of the GNU Lesser General Public License
287+ * along with this program; if not, write to the Free Software Foundation, Inc.,
288+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
289+ */
290+#include "geis_attr.h"
291+
292+#include "geis_logging.h"
293+#include <math.h>
294+#include <stdio.h>
295+#include <stdlib.h>
296+#include <string.h>
297+
298+
299+struct _GeisAttr
300+{
301+ GeisString attr_name;
302+ GeisAttrType attr_type;
303+ union
304+ {
305+ GeisBoolean b_value;
306+ GeisFloat f_value;
307+ GeisInteger i_value;
308+ GeisString s_value;
309+ void *v_value;
310+ };
311+};
312+
313+
314+struct _GeisAttrBag
315+{
316+ GeisAttr *attr_store;
317+ GeisSize attr_store_size;
318+ GeisSize attr_count;
319+};
320+
321+static const float attr_bag_growth_constant = 1.5f;
322+
323+
324+GeisAttrBag
325+geis_attr_bag_new(GeisSize size_hint)
326+{
327+ GeisAttrBag bag = calloc(1, sizeof(struct _GeisAttrBag));
328+ if (!bag)
329+ {
330+ geis_error("failed to allocate attr bag");
331+ }
332+ else
333+ {
334+ GeisSize min_size = size_hint > 2 ? size_hint : 2;
335+ bag->attr_count = 0;
336+ bag->attr_store_size = min_size;
337+ bag->attr_store = calloc(bag->attr_store_size, sizeof(GeisAttr));
338+ if (!bag->attr_store)
339+ {
340+ geis_error("failed to allocate attr bag store");
341+ free(bag);
342+ bag = NULL;
343+ }
344+ }
345+
346+ return bag;
347+}
348+
349+
350+void
351+geis_attr_bag_delete(GeisAttrBag bag)
352+{
353+ GeisSize i;
354+ for (i = 0; i < bag->attr_count; ++i)
355+ {
356+ geis_attr_delete(bag->attr_store[i]);
357+ }
358+ free(bag);
359+}
360+
361+
362+GeisSize
363+geis_attr_bag_count(GeisAttrBag bag)
364+{
365+ return bag->attr_count;
366+}
367+
368+
369+GeisStatus
370+geis_attr_bag_insert(GeisAttrBag bag, GeisAttr attr)
371+{
372+ GeisStatus status = GEIS_STATUS_UNKNOWN_ERROR;
373+ if (bag->attr_count >= bag->attr_store_size)
374+ {
375+ GeisSize new_store_size = ceilf(bag->attr_store_size
376+ * attr_bag_growth_constant);
377+ GeisAttr *new_store = realloc(bag->attr_store, new_store_size);
378+ if (!new_store)
379+ {
380+ geis_error("failed to reallocate attr bag");
381+ goto error_exit;
382+ }
383+ bag->attr_store = new_store;
384+ bag->attr_store_size = new_store_size;
385+ }
386+ bag->attr_store[bag->attr_count++] = attr;
387+ status = GEIS_STATUS_SUCCESS;
388+
389+error_exit:
390+ return status;
391+}
392+
393+
394+GeisAttr
395+geis_attr_bag_find(GeisAttrBag bag, GeisString attr_name)
396+{
397+ GeisAttr attr = NULL;
398+ GeisSize i;
399+ for (i = 0; i < bag->attr_count; ++i)
400+ {
401+ if (0 == strcmp(bag->attr_store[i]->attr_name, attr_name))
402+ {
403+ attr = bag->attr_store[i];
404+ break;
405+ }
406+ }
407+ return attr;
408+}
409+
410+
411+GeisAttr
412+geis_attr_new(GeisString attr_name, GeisAttrType attr_type, void* attr_value)
413+{
414+ GeisAttr attr = calloc(1, sizeof(struct _GeisAttr));
415+ if (!attr)
416+ {
417+ geis_error("failed to allocate attr");
418+ }
419+ else
420+ {
421+ attr->attr_name = strdup(attr_name);
422+ attr->attr_type = attr_type;
423+ switch (attr_type)
424+ {
425+ case GEIS_ATTR_TYPE_BOOLEAN:
426+ attr->b_value = *(GeisBoolean*)attr_value;
427+ break;
428+
429+ case GEIS_ATTR_TYPE_FLOAT:
430+ attr->f_value = *(GeisFloat*)attr_value;
431+ break;
432+
433+ case GEIS_ATTR_TYPE_INTEGER:
434+ attr->i_value = *(GeisInteger*)attr_value;
435+ break;
436+
437+ case GEIS_ATTR_TYPE_STRING:
438+ attr->s_value = (GeisString)attr_value;
439+ break;
440+
441+ default:
442+ attr->v_value = attr_value;
443+ }
444+ }
445+ return attr;
446+}
447+
448+
449+void
450+geis_attr_delete(GeisAttr attr)
451+{
452+ free((void *)attr->attr_name);
453+ free(attr);
454+}
455+
456+
457+GeisString
458+geis_attr_name(GeisAttr attr)
459+{
460+ return attr->attr_name;
461+}
462+
463+
464+GeisAttrType
465+geis_attr_type(GeisAttr attr)
466+{
467+ return attr->attr_type;
468+}
469+
470+
471+GeisBoolean
472+geis_attr_value_to_boolean(GeisAttr attr)
473+{
474+ GeisBoolean b_value = GEIS_FALSE;
475+ switch (attr->attr_type)
476+ {
477+ case GEIS_ATTR_TYPE_BOOLEAN:
478+ b_value = attr->b_value;
479+ break;
480+
481+ case GEIS_ATTR_TYPE_FLOAT:
482+ b_value = attr->f_value != 0.0f;
483+ break;
484+
485+ case GEIS_ATTR_TYPE_INTEGER:
486+ b_value = attr->i_value != 0;
487+ break;
488+
489+ case GEIS_ATTR_TYPE_STRING:
490+ b_value = (0 == strlen(attr->s_value)
491+ || 0 == strcmp(attr->s_value, "false"));
492+ break;
493+
494+ default:
495+ break;
496+ }
497+ return b_value;
498+}
499+
500+
501+GeisFloat
502+geis_attr_value_to_float(GeisAttr attr)
503+{
504+ GeisFloat f_value = 0.0f;
505+ switch (attr->attr_type)
506+ {
507+ case GEIS_ATTR_TYPE_BOOLEAN:
508+ f_value = attr->b_value ? 1.0f : 0.0f;
509+ break;
510+
511+ case GEIS_ATTR_TYPE_FLOAT:
512+ f_value = attr->f_value;
513+ break;
514+
515+ case GEIS_ATTR_TYPE_INTEGER:
516+ f_value = attr->i_value;
517+ break;
518+
519+ case GEIS_ATTR_TYPE_STRING:
520+ sscanf(attr->s_value, "%f", &f_value);
521+ break;
522+
523+ default:
524+ break;
525+ }
526+ return f_value;
527+}
528+
529+
530+GeisInteger
531+geis_attr_value_to_integer(GeisAttr attr)
532+{
533+ GeisInteger i_value = 0;
534+ switch (attr->attr_type)
535+ {
536+ case GEIS_ATTR_TYPE_BOOLEAN:
537+ i_value = attr->b_value ? 1 : 0;
538+ break;
539+
540+ case GEIS_ATTR_TYPE_FLOAT:
541+ i_value = attr->f_value;
542+ break;
543+
544+ case GEIS_ATTR_TYPE_INTEGER:
545+ i_value = attr->i_value;
546+ break;
547+
548+ case GEIS_ATTR_TYPE_STRING:
549+ sscanf(attr->s_value, "%d", &i_value);
550+ break;
551+
552+ default:
553+ break;
554+ }
555+ return i_value;
556+}
557+
558+
559+GeisString
560+geis_attr_value_to_string(GeisAttr attr)
561+{
562+ GeisString s_value = "";
563+ static char buf[32];
564+ switch (attr->attr_type)
565+ {
566+ case GEIS_ATTR_TYPE_BOOLEAN:
567+ sprintf(buf, "%s", attr->b_value ? "true" : "false"); /* i18n */
568+ s_value = buf;
569+ break;
570+
571+ case GEIS_ATTR_TYPE_FLOAT:
572+ sprintf(buf, "%f", attr->f_value);
573+ s_value = buf;
574+ break;
575+
576+ case GEIS_ATTR_TYPE_INTEGER:
577+ sprintf(buf, "%d", attr->i_value);
578+ s_value = buf;
579+ break;
580+
581+ case GEIS_ATTR_TYPE_STRING:
582+ s_value = attr->s_value;
583+ break;
584+
585+ default:
586+ sprintf(buf, "%p", attr->v_value);
587+ s_value = buf;
588+ break;
589+ }
590+ return s_value;
591+}
592+
593+
594
595=== added file 'libutouch-geis/geis_attr.h'
596--- libutouch-geis/geis_attr.h 1970-01-01 00:00:00 +0000
597+++ libutouch-geis/geis_attr.h 2010-11-26 20:47:53 +0000
598@@ -0,0 +1,65 @@
599+/**
600+ * @file geis_attr.h
601+ * @brief internal uTouch GeisAttr facilities
602+ *
603+ * Copyright 2010 Canonical Ltd.
604+ *
605+ * This library is free software; you can redistribute it and/or modify it under
606+ * the terms of the GNU Lesser General Public License as published by the Free
607+ * Software Foundation; either version 3 of the License, or (at your option) any
608+ * later version.
609+ *
610+ * This library is distributed in the hope that it will be useful, but WITHOUT
611+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
612+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
613+ * details.
614+ *
615+ * You should have received a copy of the GNU Lesser General Public License
616+ * along with this program; if not, write to the Free Software Foundation, Inc.,
617+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
618+ */
619+#ifndef GEIS_ATTR_H_
620+#define GEIS_ATTR_H_
621+
622+#include <geis/geis.h>
623+
624+
625+typedef struct _GeisAttrBag *GeisAttrBag;
626+
627+
628+/**
629+ * Creates a new Geis Attribute container.
630+ */
631+GeisAttrBag geis_attr_bag_new(GeisSize size_hint);
632+
633+/**
634+ * Destroys a Geis Attribute container.
635+ */
636+void geis_attr_bag_delete(GeisAttrBag bag);
637+
638+/**
639+ * Tells how any entires in a Geis Attribute container.
640+ */
641+GeisSize geis_attr_bag_count(GeisAttrBag bag);
642+
643+/**
644+ * Inserts an attribute in an attribute container.
645+ */
646+GeisStatus geis_attr_bag_insert(GeisAttrBag bag, GeisAttr attr);
647+
648+/**
649+ * Looks for an attribute in an attribute container.
650+ */
651+GeisAttr geis_attr_bag_find(GeisAttrBag bag, GeisString attr_name);
652+
653+/**
654+ * Creates a Geis Attribute object.
655+ */
656+GeisAttr geis_attr_new(GeisString attr_name, GeisAttrType attr_type, void* attr_value);
657+
658+/**
659+ * Destroys a Geis Attribute object.
660+ */
661+void geis_attr_delete(GeisAttr attr);
662+
663+#endif /* GEIS_ATTR_H_ */
664
665=== modified file 'libutouch-geis/libutouch-geis.ver'
666--- libutouch-geis/libutouch-geis.ver 2010-11-23 23:33:37 +0000
667+++ libutouch-geis/libutouch-geis.ver 2010-11-26 20:47:53 +0000
668@@ -13,11 +13,19 @@
669
670 GEIS_2.0 {
671 global:
672+ geis_attr_name;
673+ geis_attr_type;
674+ geis_attr_value_to_boolean;
675+ geis_attr_value_to_float;
676+ geis_attr_value_to_integer;
677+ geis_attr_value_to_string;
678 geis_delete;
679 geis_error_count;
680 geis_error_code;
681 geis_error_message;
682+ geis_get_configuration;
683 geis_new;
684+ geis_set_configuration;
685
686 local:
687 *;
688
689=== modified file 'testsuite/geis2/Makefile.am'
690--- testsuite/geis2/Makefile.am 2010-11-23 14:59:40 +0000
691+++ testsuite/geis2/Makefile.am 2010-11-26 20:47:53 +0000
692@@ -14,6 +14,7 @@
693 check_PROGRAMS = $(test_targets)
694
695 check_geis2_api_SOURCES = \
696+ check_config.c \
697 check_error_codes.c \
698 check_geis_new.c \
699 check_general_types.c \
700
701=== added file 'testsuite/geis2/check_config.c'
702--- testsuite/geis2/check_config.c 1970-01-01 00:00:00 +0000
703+++ testsuite/geis2/check_config.c 2010-11-26 20:47:53 +0000
704@@ -0,0 +1,61 @@
705+/**
706+ * unit tests for the geis_geis_config module
707+ */
708+#include <check.h>
709+
710+#include "geis/geis.h"
711+
712+/* fixtures */
713+static Geis geis;
714+
715+/* fixture setup */
716+static void
717+construct_geis()
718+{
719+ geis = geis_new("geis-test-fixture", NULL);
720+}
721+
722+/* fixture teardown */
723+static void
724+destroy_geis()
725+{
726+ geis_delete(geis);
727+}
728+
729+START_TEST(get_success)
730+{
731+ int fd = -1;
732+ GeisStatus status = geis_get_configuration(geis, GEIS_CONFIGURATION_FD, &fd);
733+ fail_unless(status == GEIS_STATUS_SUCCESS,
734+ "unexpected return status from geis_get_configuration()");
735+ fail_unless(fd >= 0, "invalid Unix FD returned");
736+}
737+END_TEST
738+
739+
740+/* verify table find operation (negative results) */
741+START_TEST(get_fail)
742+{
743+ int fd = -1;
744+ GeisStatus status = geis_get_configuration(geis, 1234, &fd);
745+ fail_unless(status == GEIS_STATUS_NOT_SUPPORTED,
746+ "unexpected return status from geis_get_configuration()");
747+}
748+END_TEST
749+
750+
751+/* boilerplate */
752+Suite *
753+geis2_config_suite_new()
754+{
755+ Suite *s = suite_create("geis2_configuration");
756+
757+ TCase *usage = tcase_create("table-usage");
758+ tcase_add_checked_fixture(usage, construct_geis, destroy_geis);
759+ tcase_add_test(usage, get_success);
760+ tcase_add_test(usage, get_fail);
761+ suite_add_tcase(s, usage);
762+
763+ return s;
764+}
765+
766
767=== modified file 'testsuite/geis2/check_geis2_api.c'
768--- testsuite/geis2/check_geis2_api.c 2010-11-24 16:59:34 +0000
769+++ testsuite/geis2/check_geis2_api.c 2010-11-26 20:47:53 +0000
770@@ -8,6 +8,7 @@
771 extern Suite *geis2_general_types_suite_new();
772 extern Suite *geis2_error_codes_suite_new();
773 extern Suite *geis2_geis_new_suite_new();
774+extern Suite *geis2_config_suite_new();
775
776 int
777 main(int argc, char* argv[])
778@@ -21,6 +22,7 @@
779 srunner_add_suite(sr, geis2_general_types_suite_new());
780 srunner_add_suite(sr, geis2_error_codes_suite_new());
781 srunner_add_suite(sr, geis2_geis_new_suite_new());
782+ srunner_add_suite(sr, geis2_config_suite_new());
783
784 srunner_set_log(sr, "geis2_api.log");
785 srunner_run_all(sr, CK_NORMAL);
786
787=== modified file 'testsuite/libutouch-geis/Makefile.am'
788--- testsuite/libutouch-geis/Makefile.am 2010-11-24 17:19:26 +0000
789+++ testsuite/libutouch-geis/Makefile.am 2010-11-26 20:47:53 +0000
790@@ -31,6 +31,7 @@
791 check_PROGRAMS = $(test_targets)
792
793 check_geis2_internals_SOURCES = \
794+ check_attr.c \
795 check_error_reporting.c \
796 check_geis2_internals.c
797
798@@ -45,7 +46,8 @@
799 #
800 check_geis2_internals_LDADD = \
801 $(top_builddir)/libutouch-geis/.libs/libutouch-geis.a \
802- $(CHECK_LIBS)
803+ $(CHECK_LIBS) \
804+ -lm
805
806 MOSTLYCLEANFILES = \
807 geis2_internals.log \
808
809=== added file 'testsuite/libutouch-geis/check_attr.c'
810--- testsuite/libutouch-geis/check_attr.c 1970-01-01 00:00:00 +0000
811+++ testsuite/libutouch-geis/check_attr.c 2010-11-26 20:47:53 +0000
812@@ -0,0 +1,95 @@
813+/**
814+ * unit tests for the geis_attr_bag module
815+ */
816+#include <check.h>
817+
818+#include "libutouch-geis/geis_attr.h"
819+
820+
821+/* fixtures */
822+static GeisAttrBag g_attr_bag;
823+static const GeisString test_attr_string = "zot!";
824+
825+/* fixture setup */
826+static void
827+construct_bag()
828+{
829+ g_attr_bag = geis_attr_bag_new(1);
830+}
831+
832+/* fixture teardown */
833+static void
834+destroy_bag()
835+{
836+ geis_attr_bag_delete(g_attr_bag);
837+}
838+
839+
840+/* verify bag construction/destruction */
841+START_TEST(construction)
842+{
843+ GeisAttrBag bag = geis_attr_bag_new(1);
844+ fail_unless(bag != NULL, "failed to create attr bag");
845+ geis_attr_bag_delete(bag);
846+}
847+END_TEST
848+
849+
850+/* verify bag insertion */
851+START_TEST(insertion)
852+{
853+ GeisAttr attr = geis_attr_new("test-attr",
854+ GEIS_ATTR_TYPE_STRING,
855+ (void*)test_attr_string);
856+ geis_attr_bag_insert(g_attr_bag, attr);
857+ fail_unless(geis_attr_bag_count(g_attr_bag) == 1,
858+ "unexpected bag size after insertion");
859+}
860+END_TEST
861+
862+
863+/* verify bag find operation (positive results) */
864+START_TEST(find_success)
865+{
866+ GeisAttr dst_attr;
867+ GeisAttr src_attr = geis_attr_new("test-attr",
868+ GEIS_ATTR_TYPE_STRING,
869+ (void*)test_attr_string);
870+ geis_attr_bag_insert(g_attr_bag, src_attr);
871+ dst_attr = geis_attr_bag_find(g_attr_bag, "test-attr");
872+ fail_if(dst_attr == NULL, "expected instance not found");
873+ fail_unless(0 == strcmp(geis_attr_value_to_string(dst_attr), test_attr_string),
874+ "unexpected attribute value returned");
875+}
876+END_TEST
877+
878+
879+/* verify bag find operation (negative results) */
880+START_TEST(find_fail)
881+{
882+ GeisAttr attr = geis_attr_bag_find(g_attr_bag, "bogus");
883+ fail_unless(attr == NULL, "unexpected instance found");
884+}
885+END_TEST
886+
887+
888+/* boilerplate */
889+Suite *
890+make_attr_suite()
891+{
892+ Suite *s = suite_create("utouch-geis2-attrs");
893+
894+ TCase *create = tcase_create("attr-bag-creation");
895+ tcase_add_test(create, construction);
896+ suite_add_tcase(s, create);
897+
898+ TCase *usage = tcase_create("attr-bag-usage");
899+ tcase_add_checked_fixture(usage, construct_bag, destroy_bag);
900+ tcase_add_test(usage, insertion);
901+ tcase_add_test(usage, find_success);
902+ tcase_add_test(usage, find_fail);
903+ suite_add_tcase(s, usage);
904+
905+ return s;
906+}
907+
908
909=== modified file 'testsuite/libutouch-geis/check_error_reporting.c'
910--- testsuite/libutouch-geis/check_error_reporting.c 2010-11-24 16:59:34 +0000
911+++ testsuite/libutouch-geis/check_error_reporting.c 2010-11-26 20:47:53 +0000
912@@ -28,7 +28,7 @@
913 Suite *
914 make_error_reporting_suite()
915 {
916- Suite *s = suite_create("geis2-error-reporting");
917+ Suite *s = suite_create("utouch-geis2-error-reporting");
918
919 TCase *create = tcase_create("error-reporting");
920 tcase_add_test(create, global_error_stack);
921
922=== modified file 'testsuite/libutouch-geis/check_geis2_internals.c'
923--- testsuite/libutouch-geis/check_geis2_internals.c 2010-11-24 16:59:34 +0000
924+++ testsuite/libutouch-geis/check_geis2_internals.c 2010-11-26 20:47:53 +0000
925@@ -4,6 +4,7 @@
926 #include <check.h>
927
928 extern Suite *make_error_reporting_suite();
929+extern Suite *make_attr_suite();
930
931
932 int
933@@ -15,6 +16,7 @@
934
935 SRunner *sr = srunner_create(s);
936 srunner_add_suite(sr, make_error_reporting_suite());
937+ srunner_add_suite(sr, make_attr_suite());
938
939 srunner_set_log(sr, "geis2_internals.log");
940 srunner_run_all(sr, CK_NORMAL);

Subscribers

People subscribed via source and target branches

to all changes: