6be3c144e37f3cc2466f1ffa840a408c4e12a0ce
1 /*
2 * SysDB - t/unit/core/store_json_test.c
3 * Copyright (C) 2014 Sebastian 'tokkee' Harl <sh@tokkee.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
28 #if HAVE_CONFIG_H
29 # include "config.h"
30 #endif
32 #include "core/plugin.h"
33 #include "core/store.h"
34 #include "testutils.h"
36 #include <check.h>
37 #include <stdlib.h>
39 /* Make SDB_INTERVAL_SECOND a constant initializer. */
40 #undef SDB_INTERVAL_SECOND
41 #define SDB_INTERVAL_SECOND 1000000000L
43 static void
44 populate(void)
45 {
46 sdb_data_t datum;
48 sdb_store_init();
50 sdb_plugin_store_host("h1", 1 * SDB_INTERVAL_SECOND);
51 sdb_plugin_store_host("h2", 3 * SDB_INTERVAL_SECOND);
53 datum.type = SDB_TYPE_STRING;
54 datum.data.string = "v1";
55 sdb_plugin_store_attribute("h1", "k1", &datum, 1 * SDB_INTERVAL_SECOND);
56 datum.data.string = "v2";
57 sdb_plugin_store_attribute("h1", "k2", &datum, 2 * SDB_INTERVAL_SECOND);
58 datum.data.string = "v3";
59 sdb_plugin_store_attribute("h1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
61 /* make sure that older updates don't overwrite existing values */
62 datum.data.string = "fail";
63 sdb_plugin_store_attribute("h1", "k2", &datum, 1 * SDB_INTERVAL_SECOND);
64 sdb_plugin_store_attribute("h1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
66 sdb_plugin_store_metric("h1", "m1", /* store */ NULL, 2 * SDB_INTERVAL_SECOND);
67 sdb_plugin_store_metric("h1", "m2", /* store */ NULL, 1 * SDB_INTERVAL_SECOND);
68 sdb_plugin_store_metric("h2", "m1", /* store */ NULL, 1 * SDB_INTERVAL_SECOND);
70 sdb_plugin_store_service("h2", "s1", 1 * SDB_INTERVAL_SECOND);
71 sdb_plugin_store_service("h2", "s2", 2 * SDB_INTERVAL_SECOND);
73 datum.type = SDB_TYPE_INTEGER;
74 datum.data.integer = 42;
75 sdb_plugin_store_metric_attribute("h1", "m1", "k3",
76 &datum, 2 * SDB_INTERVAL_SECOND);
78 datum.data.integer = 123;
79 sdb_plugin_store_service_attribute("h2", "s2", "k1",
80 &datum, 2 * SDB_INTERVAL_SECOND);
81 datum.data.integer = 4711;
82 sdb_plugin_store_service_attribute("h2", "s2", "k2",
83 &datum, 1 * SDB_INTERVAL_SECOND);
85 /* don't overwrite k1 */
86 datum.data.integer = 666;
87 sdb_plugin_store_service_attribute("h2", "s2", "k1",
88 &datum, 2 * SDB_INTERVAL_SECOND);
89 } /* populate */
91 static int
92 scan_tojson(sdb_store_obj_t *obj,
93 sdb_store_matcher_t __attribute__((unused)) *filter,
94 void *user_data)
95 {
96 sdb_store_json_formatter_t *f = user_data;
97 return sdb_store_json_emit(f, obj);
98 } /* scan_tojson */
100 static int
101 scan_tojson_full(sdb_store_obj_t *obj, sdb_store_matcher_t *filter,
102 void *user_data)
103 {
104 sdb_store_json_formatter_t *f = user_data;
105 return sdb_store_json_emit_full(f, obj, filter);
106 } /* scan_tojson_full */
108 static void
109 verify_json_output(sdb_strbuf_t *buf, const char *expected)
110 {
111 const char *got = sdb_strbuf_string(buf);
112 size_t len1 = strlen(got);
113 size_t len2 = strlen(expected);
115 size_t i;
116 int pos = -1;
118 if (len1 != len2)
119 pos = (int)SDB_MIN(len1, len2);
121 for (i = 0; i < SDB_MIN(len1, len2); ++i) {
122 if (got[i] != expected[i]) {
123 pos = (int)i;
124 break;
125 }
126 }
128 fail_unless(pos == -1,
129 "Serializing hosts to JSON returned unexpected result\n"
130 " got: %s\n %*s\n expected: %s",
131 got, pos + 1, "^", expected);
132 } /* verify_json_output */
134 struct {
135 struct {
136 sdb_store_matcher_t *(*m)(sdb_store_expr_t *, sdb_store_expr_t *);
137 int field;
138 sdb_data_t value;
139 } filter;
140 int type;
141 int (*f)(sdb_store_obj_t *, sdb_store_matcher_t *, void *);
142 const char *expected;
143 } store_tojson_data[] = {
144 { { NULL, 0, SDB_DATA_INIT },
145 SDB_HOST, scan_tojson_full,
146 "["
147 "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", "
148 "\"update_interval\": \"0s\", \"backends\": [], "
149 "\"attributes\": ["
150 "{\"name\": \"k1\", \"value\": \"v1\", "
151 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
152 "\"update_interval\": \"0s\", \"backends\": []},"
153 "{\"name\": \"k2\", \"value\": \"v2\", "
154 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
155 "\"update_interval\": \"0s\", \"backends\": []},"
156 "{\"name\": \"k3\", \"value\": \"v3\", "
157 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
158 "\"update_interval\": \"0s\", \"backends\": []}"
159 "], "
160 "\"metrics\": ["
161 "{\"name\": \"m1\", "
162 "\"timeseries\": false, "
163 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
164 "\"update_interval\": \"0s\", \"backends\": [], "
165 "\"attributes\": ["
166 "{\"name\": \"hostname\", \"value\": \"h1\", "
167 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
168 "\"update_interval\": \"0s\", \"backends\": []},"
169 "{\"name\": \"k3\", \"value\": 42, "
170 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
171 "\"update_interval\": \"0s\", \"backends\": []}"
172 "]},"
173 "{\"name\": \"m2\", "
174 "\"timeseries\": false, "
175 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
176 "\"update_interval\": \"0s\", \"backends\": [], "
177 "\"attributes\": ["
178 "{\"name\": \"hostname\", \"value\": \"h1\", "
179 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
180 "\"update_interval\": \"0s\", \"backends\": []}"
181 "]}"
182 "]},"
183 "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
184 "\"update_interval\": \"0s\", \"backends\": [], "
185 "\"metrics\": ["
186 "{\"name\": \"m1\", "
187 "\"timeseries\": false, "
188 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
189 "\"update_interval\": \"0s\", \"backends\": [], "
190 "\"attributes\": ["
191 "{\"name\": \"hostname\", \"value\": \"h2\", "
192 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
193 "\"update_interval\": \"0s\", \"backends\": []}"
194 "]}"
195 "], "
196 "\"services\": ["
197 "{\"name\": \"s1\", "
198 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
199 "\"update_interval\": \"0s\", \"backends\": [], "
200 "\"attributes\": ["
201 "{\"name\": \"hostname\", \"value\": \"h2\", "
202 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
203 "\"update_interval\": \"0s\", \"backends\": []}"
204 "]},"
205 "{\"name\": \"s2\", "
206 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
207 "\"update_interval\": \"0s\", \"backends\": [], "
208 "\"attributes\": ["
209 "{\"name\": \"hostname\", \"value\": \"h2\", "
210 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
211 "\"update_interval\": \"0s\", \"backends\": []},"
212 "{\"name\": \"k1\", \"value\": 123, "
213 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
214 "\"update_interval\": \"0s\", \"backends\": []},"
215 "{\"name\": \"k2\", \"value\": 4711, "
216 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
217 "\"update_interval\": \"0s\", \"backends\": []}"
218 "]}"
219 "]}"
220 "]" },
221 { { NULL, 0, SDB_DATA_INIT },
222 SDB_HOST, scan_tojson,
223 "["
224 "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", "
225 "\"update_interval\": \"0s\", \"backends\": []},"
226 "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
227 "\"update_interval\": \"0s\", \"backends\": []}"
228 "]" },
229 { { sdb_store_eq_matcher, SDB_FIELD_NAME,
230 { SDB_TYPE_STRING, { .string = "h1" } } },
231 SDB_HOST, scan_tojson_full,
232 "["
233 "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", "
234 "\"update_interval\": \"0s\", \"backends\": []}"
235 "]" },
236 { { sdb_store_gt_matcher, SDB_FIELD_LAST_UPDATE,
237 { SDB_TYPE_DATETIME, { .datetime = 1 * SDB_INTERVAL_SECOND } } },
238 SDB_HOST, scan_tojson_full,
239 "["
240 "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
241 "\"update_interval\": \"0s\", \"backends\": [], "
242 "\"services\": ["
243 "{\"name\": \"s2\", "
244 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
245 "\"update_interval\": \"0s\", \"backends\": [], "
246 "\"attributes\": ["
247 "{\"name\": \"hostname\", \"value\": \"h2\", "
248 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
249 "\"update_interval\": \"0s\", \"backends\": []},"
250 "{\"name\": \"k1\", \"value\": 123, "
251 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
252 "\"update_interval\": \"0s\", \"backends\": []}"
253 "]}"
254 "]}"
255 "]" },
256 { { sdb_store_le_matcher, SDB_FIELD_LAST_UPDATE,
257 { SDB_TYPE_DATETIME, { .datetime = 1 * SDB_INTERVAL_SECOND } } },
258 SDB_HOST, scan_tojson_full,
259 "["
260 "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", "
261 "\"update_interval\": \"0s\", \"backends\": [], "
262 "\"attributes\": ["
263 "{\"name\": \"k1\", \"value\": \"v1\", "
264 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
265 "\"update_interval\": \"0s\", \"backends\": []}"
266 "], "
267 "\"metrics\": ["
268 "{\"name\": \"m2\", "
269 "\"timeseries\": false, "
270 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
271 "\"update_interval\": \"0s\", \"backends\": [], "
272 "\"attributes\": ["
273 "{\"name\": \"hostname\", \"value\": \"h1\", "
274 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
275 "\"update_interval\": \"0s\", \"backends\": []}"
276 "]}"
277 "]}"
278 "]" },
279 { { sdb_store_ge_matcher, SDB_FIELD_LAST_UPDATE,
280 { SDB_TYPE_DATETIME, { .datetime = 3 * SDB_INTERVAL_SECOND } } },
281 SDB_HOST, scan_tojson_full,
282 "["
283 "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
284 "\"update_interval\": \"0s\", \"backends\": []}"
285 "]" },
286 { { sdb_store_lt_matcher, SDB_FIELD_LAST_UPDATE,
287 { SDB_TYPE_DATETIME, { .datetime = 0 } } },
288 SDB_HOST, scan_tojson_full,
289 "[]" },
291 { { NULL, 0, SDB_DATA_INIT },
292 SDB_SERVICE, scan_tojson_full,
293 "["
294 "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
295 "\"update_interval\": \"0s\", \"backends\": [], "
296 "\"services\": ["
297 "{\"name\": \"s1\", "
298 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
299 "\"update_interval\": \"0s\", \"backends\": [], "
300 "\"attributes\": ["
301 "{\"name\": \"hostname\", \"value\": \"h2\", "
302 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
303 "\"update_interval\": \"0s\", \"backends\": []}"
304 "]},"
305 "{\"name\": \"s2\", "
306 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
307 "\"update_interval\": \"0s\", \"backends\": [], "
308 "\"attributes\": ["
309 "{\"name\": \"hostname\", \"value\": \"h2\", "
310 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
311 "\"update_interval\": \"0s\", \"backends\": []},"
312 "{\"name\": \"k1\", \"value\": 123, "
313 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
314 "\"update_interval\": \"0s\", \"backends\": []},"
315 "{\"name\": \"k2\", \"value\": 4711, "
316 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
317 "\"update_interval\": \"0s\", \"backends\": []}"
318 "]}"
319 "]}"
320 "]" },
321 { { NULL, 0, SDB_DATA_INIT },
322 SDB_SERVICE, scan_tojson,
323 "["
324 "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
325 "\"update_interval\": \"0s\", \"backends\": [], "
326 "\"services\": ["
327 "{\"name\": \"s1\", "
328 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
329 "\"update_interval\": \"0s\", \"backends\": []},"
330 "{\"name\": \"s2\", "
331 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
332 "\"update_interval\": \"0s\", \"backends\": []}"
333 "]}"
334 "]" },
335 { { sdb_store_gt_matcher, SDB_FIELD_LAST_UPDATE,
336 { SDB_TYPE_DATETIME, { .datetime = 1 * SDB_INTERVAL_SECOND } } },
337 SDB_SERVICE, scan_tojson_full,
338 "["
339 "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
340 "\"update_interval\": \"0s\", \"backends\": [], "
341 "\"services\": ["
342 "{\"name\": \"s2\", "
343 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
344 "\"update_interval\": \"0s\", \"backends\": [], "
345 "\"attributes\": ["
346 "{\"name\": \"hostname\", \"value\": \"h2\", "
347 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
348 "\"update_interval\": \"0s\", \"backends\": []},"
349 "{\"name\": \"k1\", \"value\": 123, "
350 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
351 "\"update_interval\": \"0s\", \"backends\": []}"
352 "]}"
353 "]}"
354 "]" },
355 { { sdb_store_lt_matcher, SDB_FIELD_LAST_UPDATE,
356 { SDB_TYPE_DATETIME, { .datetime = 0 } } },
357 SDB_SERVICE, scan_tojson_full,
358 "[]" },
359 { { NULL, 0, SDB_DATA_INIT },
360 SDB_METRIC, scan_tojson_full,
361 "["
362 "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", "
363 "\"update_interval\": \"0s\", \"backends\": [], "
364 "\"metrics\": ["
365 "{\"name\": \"m1\", "
366 "\"timeseries\": false, "
367 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
368 "\"update_interval\": \"0s\", \"backends\": [], "
369 "\"attributes\": ["
370 "{\"name\": \"hostname\", \"value\": \"h1\", "
371 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
372 "\"update_interval\": \"0s\", \"backends\": []},"
373 "{\"name\": \"k3\", \"value\": 42, "
374 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
375 "\"update_interval\": \"0s\", \"backends\": []}"
376 "]},"
377 "{\"name\": \"m2\", "
378 "\"timeseries\": false, "
379 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
380 "\"update_interval\": \"0s\", \"backends\": [], "
381 "\"attributes\": ["
382 "{\"name\": \"hostname\", \"value\": \"h1\", "
383 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
384 "\"update_interval\": \"0s\", \"backends\": []}"
385 "]}"
386 "]},"
387 "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
388 "\"update_interval\": \"0s\", \"backends\": [], "
389 "\"metrics\": ["
390 "{\"name\": \"m1\", "
391 "\"timeseries\": false, "
392 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
393 "\"update_interval\": \"0s\", \"backends\": [], "
394 "\"attributes\": ["
395 "{\"name\": \"hostname\", \"value\": \"h2\", "
396 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
397 "\"update_interval\": \"0s\", \"backends\": []}"
398 "]}"
399 "]}"
400 "]" },
401 { { NULL, 0, SDB_DATA_INIT },
402 SDB_METRIC, scan_tojson,
403 "["
404 "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", "
405 "\"update_interval\": \"0s\", \"backends\": [], "
406 "\"metrics\": ["
407 "{\"name\": \"m1\", "
408 "\"timeseries\": false, "
409 "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
410 "\"update_interval\": \"0s\", \"backends\": []},"
411 "{\"name\": \"m2\", "
412 "\"timeseries\": false, "
413 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
414 "\"update_interval\": \"0s\", \"backends\": []}"
415 "]},"
416 "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
417 "\"update_interval\": \"0s\", \"backends\": [], "
418 "\"metrics\": ["
419 "{\"name\": \"m1\", "
420 "\"timeseries\": false, "
421 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
422 "\"update_interval\": \"0s\", \"backends\": []}"
423 "]}"
424 "]" },
425 { { sdb_store_le_matcher, SDB_FIELD_LAST_UPDATE,
426 { SDB_TYPE_DATETIME, { .datetime = 1 * SDB_INTERVAL_SECOND } } },
427 SDB_METRIC, scan_tojson_full,
428 "["
429 "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", "
430 "\"update_interval\": \"0s\", \"backends\": [], "
431 "\"metrics\": ["
432 "{\"name\": \"m2\", "
433 "\"timeseries\": false, "
434 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
435 "\"update_interval\": \"0s\", \"backends\": [], "
436 "\"attributes\": ["
437 "{\"name\": \"hostname\", \"value\": \"h1\", "
438 "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
439 "\"update_interval\": \"0s\", \"backends\": []}"
440 "]}"
441 "]}"
442 "]" },
443 { { sdb_store_lt_matcher, SDB_FIELD_LAST_UPDATE,
444 { SDB_TYPE_DATETIME, { .datetime = 0 } } },
445 SDB_METRIC, scan_tojson_full,
446 "[]" },
447 };
449 START_TEST(test_store_tojson)
450 {
451 sdb_strbuf_t *buf = sdb_strbuf_create(0);
452 sdb_store_matcher_t *filter = NULL;
453 sdb_store_json_formatter_t *f;
454 int status;
456 if (store_tojson_data[_i].filter.m) {
457 sdb_store_expr_t *field;
458 sdb_store_expr_t *value;
460 field = sdb_store_expr_fieldvalue(store_tojson_data[_i].filter.field);
461 fail_unless(field != NULL,
462 "INTERNAL ERROR: sdb_store_expr_fieldvalue() = NULL");
463 value = sdb_store_expr_constvalue(&store_tojson_data[_i].filter.value);
464 fail_unless(value != NULL,
465 "INTERNAL ERROR: sdb_store_expr_constvalue() = NULL");
467 filter = store_tojson_data[_i].filter.m(field, value);
468 fail_unless(filter != NULL,
469 "INTERNAL ERROR: sdb_store_*_matcher() = NULL");
471 sdb_object_deref(SDB_OBJ(field));
472 sdb_object_deref(SDB_OBJ(value));
473 }
475 sdb_strbuf_clear(buf);
476 f = sdb_store_json_formatter(buf,
477 store_tojson_data[_i].type, SDB_WANT_ARRAY);
478 ck_assert(f != NULL);
480 status = sdb_store_scan(store_tojson_data[_i].type,
481 /* m = */ NULL, filter, store_tojson_data[_i].f, f);
482 fail_unless(status == 0,
483 "sdb_store_scan(HOST, ..., tojson) = %d; expected: 0",
484 status);
485 sdb_store_json_finish(f);
487 verify_json_output(buf, store_tojson_data[_i].expected);
489 sdb_object_deref(SDB_OBJ(filter));
490 sdb_object_deref(SDB_OBJ(f));
491 sdb_strbuf_destroy(buf);
492 }
493 END_TEST
495 TEST_MAIN("core::store_json")
496 {
497 TCase *tc = tcase_create("core");
498 TC_ADD_LOOP_TEST(tc, store_tojson);
499 tcase_add_unchecked_fixture(tc, populate, sdb_store_clear);
500 ADD_TCASE(tc);
501 }
502 TEST_MAIN_END
504 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */