coverage and test: Add tests
[src/app-framework-binder.git] / coverage / bin / bug.c
1 #include <errno.h>
2 #include <stdint.h>
3 static int ok()
4 {
5         return 0;
6 }
7 static int bug()
8 {
9         errno = 0;
10         return ((int(*)())(intptr_t)0)();
11 }
12 static int err()
13 {
14         errno = EAGAIN;
15         return -1;
16 }
17 /**************************************************************************/
18 /**************************************************************************/
19 /***           BINDINGS V2                                              ***/
20 /**************************************************************************/
21 /**************************************************************************/
22 #if defined(BUG1)  /* incomplete exports: afbBindingV2data miss */
23
24 #define AFB_BINDING_VERSION 0
25 #include <afb/afb-binding.h>
26 const struct afb_binding_v2 afbBindingV2;
27
28 #endif
29 /**************************************************************************/
30 #if defined(BUG2)  /* incomplete exports: afbBindingV2 miss */
31
32 #define AFB_BINDING_VERSION 0
33 #include <afb/afb-binding.h>
34 struct afb_binding_data_v2 afbBindingV2data;
35
36 #endif
37 /**************************************************************************/
38 #if defined(BUG3)  /* zero filled structure */
39
40 #define AFB_BINDING_VERSION 0
41 #include <afb/afb-binding.h>
42 const struct afb_binding_v2 afbBindingV2;
43 struct afb_binding_data_v2 afbBindingV2data;
44
45 #endif
46 /**************************************************************************/
47 #if defined(BUG4)  /* no verb definition */
48
49 #define AFB_BINDING_VERSION 2
50 #include <afb/afb-binding.h>
51
52 const struct afb_binding_v2 afbBindingV2 = {
53         .api = "bug4",
54         .preinit = (void*)ok,
55         .init = (void*)ok
56 };
57 #endif
58 /**************************************************************************/
59 #if defined(BUG5)  /* preinit buggy */
60
61 #define AFB_BINDING_VERSION 2
62 #include <afb/afb-binding.h>
63
64 struct afb_verb_v2 verbs[] = {
65         { NULL }
66 };
67 const struct afb_binding_v2 afbBindingV2 = {
68         .api = "bug5",
69         .verbs = verbs,
70         .preinit = (void*)bug,
71         .init = (void*)ok
72 };
73 #endif
74 /**************************************************************************/
75 #if defined(BUG6)  /* buggy init */
76
77 #define AFB_BINDING_VERSION 2
78 #include <afb/afb-binding.h>
79
80 struct afb_verb_v2 verbs[] = {
81         { NULL }
82 };
83 const struct afb_binding_v2 afbBindingV2 = {
84         .api = "bug6",
85         .verbs = verbs,
86         .preinit = (void*)ok,
87         .init = (void*)bug
88 };
89 #endif
90 /**************************************************************************/
91 #if defined(BUG7)  /* error in preinit */
92
93 #define AFB_BINDING_VERSION 2
94 #include <afb/afb-binding.h>
95
96 struct afb_verb_v2 verbs[] = {
97         { NULL }
98 };
99 const struct afb_binding_v2 afbBindingV2 = {
100         .api = "bug7",
101         .verbs = verbs,
102         .preinit = (void*)err,
103         .init = (void*)ok
104 };
105 #endif
106 /**************************************************************************/
107 #if defined(BUG8)  /* error in init */
108
109 #define AFB_BINDING_VERSION 2
110 #include <afb/afb-binding.h>
111
112 struct afb_verb_v2 verbs[] = {
113         { NULL }
114 };
115 const struct afb_binding_v2 afbBindingV2 = {
116         .api = "bug8",
117         .verbs = verbs,
118         .preinit = (void*)ok,
119         .init = (void*)err
120 };
121 #endif
122 /**************************************************************************/
123 #if defined(BUG9)  /* no api name */
124
125 #define AFB_BINDING_VERSION 2
126 #include <afb/afb-binding.h>
127
128 struct afb_verb_v2 verbs[] = {
129         { NULL }
130 };
131 const struct afb_binding_v2 afbBindingV2 = {
132         .verbs = verbs,
133         .preinit = (void*)ok,
134         .init = (void*)ok
135 };
136 #endif
137 /**************************************************************************/
138 #if defined(BUG10)  /* bad api name */
139
140 #define AFB_BINDING_VERSION 2
141 #include <afb/afb-binding.h>
142
143 struct afb_verb_v2 verbs[] = {
144         { NULL }
145 };
146 const struct afb_binding_v2 afbBindingV2 = {
147         .api = "bug 10",
148         .verbs = verbs,
149         .preinit = (void*)ok,
150         .init = (void*)err
151 };
152 #endif
153 /**************************************************************************/
154 /**************************************************************************/
155 /***           BINDINGS V3                                              ***/
156 /**************************************************************************/
157 /**************************************************************************/
158 #if defined(BUG11) /* make a SEGV */
159
160 #define AFB_BINDING_VERSION 3
161 #include <afb/afb-binding.h>
162 int afbBindingEntry(afb_api_t api)
163 {
164         return ((int(*)())(intptr_t)0)();
165 }
166 #endif
167 /**************************************************************************/
168 #if defined(BUG12) /* no afbBindingV3 nor afbBindingV3entry */
169
170 #define AFB_BINDING_VERSION 0
171 #include <afb/afb-binding.h>
172 struct afb_api_x3 *afbBindingV3root;
173
174 #endif
175 /**************************************************************************/
176 #if defined(BUG13) /* no afbBindingV3root nor afbBindingV3entry */
177
178 #define AFB_BINDING_VERSION 0
179 #include <afb/afb-binding.h>
180 const struct afb_binding_v3 afbBindingV3;
181 int afbBindingV3entry(struct afb_api_x3 *rootapi) { return 0; }
182
183 #endif
184 /**************************************************************************/
185 #if defined(BUG14) /* no api name */
186
187 #define AFB_BINDING_VERSION 3
188 #include <afb/afb-binding.h>
189
190 const struct afb_binding_v3 afbBindingV3;
191
192 #endif
193 /**************************************************************************/
194 #if defined(BUG15) /* bad api name */
195
196 #define AFB_BINDING_VERSION 3
197 #include <afb/afb-binding.h>
198
199 const struct afb_binding_v3 afbBindingV3 = {
200         .api = "bug 15"
201 };
202
203 #endif
204 /**************************************************************************/
205 #if defined(BUG16) /* both entry and preinit */
206
207 #define AFB_BINDING_VERSION 3
208 #include <afb/afb-binding.h>
209
210 int afbBindingV3entry(struct afb_api_x3 *rootapi) { return 0; }
211 const struct afb_binding_v3 afbBindingV3 = {
212         .api = "bug16",
213         .preinit = afbBindingV3entry
214 };
215
216 #endif
217 /**************************************************************************/
218 #if defined(BUG17) /* entry fails */
219
220 #define AFB_BINDING_VERSION 3
221 #include <afb/afb-binding.h>
222
223 int afbBindingV3entry(struct afb_api_x3 *rootapi) { errno = EAGAIN; return -1; }
224 #endif
225 /**************************************************************************/
226 #if defined(BUG18) /* preinit fails */
227
228 #define AFB_BINDING_VERSION 3
229 #include <afb/afb-binding.h>
230
231 const struct afb_binding_v3 afbBindingV3 = {
232         .api = "bug18",
233         .preinit = (void*)err
234 };
235
236 #endif
237 /**************************************************************************/
238 #if defined(BUG19) /* preinit SEGV */
239
240 #define AFB_BINDING_VERSION 3
241 #include <afb/afb-binding.h>
242
243 const struct afb_binding_v3 afbBindingV3 = {
244         .api = "bug19",
245         .preinit = (void*)bug
246 };
247
248 #endif
249 /**************************************************************************/
250 #if defined(BUG20) /* init fails */
251
252 #define AFB_BINDING_VERSION 3
253 #include <afb/afb-binding.h>
254
255 const struct afb_binding_v3 afbBindingV3 = {
256         .api = "bug20",
257         .init = (void*)err
258 };
259
260 #endif
261 /**************************************************************************/
262 #if defined(BUG21) /* init SEGV */
263
264 #define AFB_BINDING_VERSION 3
265 #include <afb/afb-binding.h>
266
267 const struct afb_binding_v3 afbBindingV3 = {
268         .api = "bug21",
269         .init = (void*)bug,
270         .provide_class = "a b c",
271         .require_class = "x y z",
272         .require_api = "bug4 bug5",
273 };
274
275 #endif
276 /**************************************************************************/