projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
collectctl: define LOCALSTATEDIR if not defined
[collectd.git]
/
src
/
utils_format_json_test.c
diff --git
a/src/utils_format_json_test.c
b/src/utils_format_json_test.c
index
6df6211
..
1400694
100644
(file)
--- a/
src/utils_format_json_test.c
+++ b/
src/utils_format_json_test.c
@@
-24,30
+24,50
@@
* Florian octo Forster <octo at collectd.org>
*/
* Florian octo Forster <octo at collectd.org>
*/
-#include "testing.h"
+/* Workaround for Solaris 10 defining label_t
+ * Issue #1301
+ */
+#if KERNEL_SOLARIS
+# ifndef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 200112L
+# endif
+# undef __EXTENSIONS__
+#endif
+
#include "collectd.h"
#include "collectd.h"
+
+#include "testing.h"
#include "utils_format_json.h"
#include "common.h" /* for STATIC_ARRAY_SIZE */
#include "utils_format_json.h"
#include "common.h" /* for STATIC_ARRAY_SIZE */
+#include <yajl/yajl_common.h>
#include <yajl/yajl_parse.h>
#include <yajl/yajl_parse.h>
-
-struct label_s
+#if HAVE_YAJL_YAJL_VERSION_H
+# include <yajl/yajl_version.h>
+#endif
+#if YAJL_MAJOR > 1
+# define HAVE_YAJL_V2 1
+#endif
+
+typedef struct
{
{
- char *key;
- char *value;
-};
-typedef struct label_s label_t;
+ char const *key;
+ char const *value;
+} label_t;
-struct test_case_s
+typedef struct
{
label_t *expected_labels;
size_t expected_labels_num;
label_t *current_label;
{
label_t *expected_labels;
size_t expected_labels_num;
label_t *current_label;
-};
-typedef struct test_case_s test_case_t;
+} test_case_t;
+#if HAVE_YAJL_V2
static int test_map_key (void *ctx, unsigned char const *key, size_t key_len)
static int test_map_key (void *ctx, unsigned char const *key, size_t key_len)
+#else
+static int test_map_key (void *ctx, unsigned char const *key, unsigned int key_len)
+#endif
{
test_case_t *c = ctx;
size_t i;
{
test_case_t *c = ctx;
size_t i;
@@
-81,7
+101,11
@@
static int expect_label (char const *name, char const *got, char const *want)
return 0;
}
return 0;
}
+#if HAVE_YAJL_V2
static int test_string (void *ctx, unsigned char const *value, size_t value_len)
static int test_string (void *ctx, unsigned char const *value, size_t value_len)
+#else
+static int test_string (void *ctx, unsigned char const *value, unsigned int value_len)
+#endif
{
test_case_t *c = ctx;
{
test_case_t *c = ctx;
@@
-116,7
+140,11
@@
static int expect_json_labels (char *json, label_t *labels, size_t labels_num)
test_case_t c = { labels, labels_num, NULL };
yajl_handle hndl;
test_case_t c = { labels, labels_num, NULL };
yajl_handle hndl;
- CHECK_NOT_NULL (hndl = yajl_alloc (&funcs, NULL, &c));
+#if HAVE_YAJL_V2
+ CHECK_NOT_NULL (hndl = yajl_alloc (&funcs, /* alloc = */ NULL, &c));
+#else
+ CHECK_NOT_NULL (hndl = yajl_alloc (&funcs, /* config = */ NULL, /* alloc = */ NULL, &c));
+#endif
OK (yajl_parse (hndl, (unsigned char *) json, strlen (json)) == yajl_status_ok);
yajl_free (hndl);
OK (yajl_parse (hndl, (unsigned char *) json, strlen (json)) == yajl_status_ok);
yajl_free (hndl);
@@
-134,7
+162,7
@@
DEF_TEST(notification)
};
/* 1448284606.125 ^= 1555083754651779072 */
};
/* 1448284606.125 ^= 1555083754651779072 */
- notification_t n = { NOTIF_WARNING, 1555083754651779072, "this is a message",
+ notification_t n = { NOTIF_WARNING, 1555083754651779072
ULL
, "this is a message",
"example.com", "unit", "", "test", "case", NULL };
char got[1024];
"example.com", "unit", "", "test", "case", NULL };
char got[1024];