aboutsummaryrefslogtreecommitdiff
path: root/contrib/libucl/tests
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libucl/tests')
-rw-r--r--contrib/libucl/tests/.gitignore10
-rw-r--r--contrib/libucl/tests/Makefile.am45
-rw-r--r--contrib/libucl/tests/schema/definitions.json32
-rw-r--r--contrib/libucl/tests/schema/ref.json16
-rw-r--r--contrib/libucl/tests/schema/refRemote.json76
-rw-r--r--contrib/libucl/tests/test_speed.c2
-rw-r--r--contrib/libucl/tests/test_streamline.c43
7 files changed, 52 insertions, 172 deletions
diff --git a/contrib/libucl/tests/.gitignore b/contrib/libucl/tests/.gitignore
new file mode 100644
index 000000000000..464482434f22
--- /dev/null
+++ b/contrib/libucl/tests/.gitignore
@@ -0,0 +1,10 @@
+*.log
+*.trs
+*.plist
+
+test_basic
+test_generate
+test_msgpack
+test_schema
+test_speed
+test_streamline
diff --git a/contrib/libucl/tests/Makefile.am b/contrib/libucl/tests/Makefile.am
deleted file mode 100644
index 055eb8bd85b0..000000000000
--- a/contrib/libucl/tests/Makefile.am
+++ /dev/null
@@ -1,45 +0,0 @@
-EXTRA_DIST = $(TESTS) basic schema generate.res \
- streamline.res rcl_test.json.xz
-
-TESTS = basic.test \
- generate.test \
- schema.test \
- msgpack.test \
- speed.test \
- msgpack.test
-TESTS_ENVIRONMENT = $(SH) \
- TEST_DIR=$(top_srcdir)/tests \
- TEST_OUT_DIR=$(top_builddir)/tests \
- TEST_BINARY_DIR=$(top_builddir)/tests
-
-common_test_cflags = -I$(top_srcdir)/include \
- -I$(top_srcdir)/src \
- -I$(top_srcdir)/uthash
-common_test_ldadd = $(top_builddir)/src/libucl.la
-
-test_basic_SOURCES = test_basic.c
-test_basic_LDADD = $(common_test_ldadd)
-test_basic_CFLAGS = $(common_test_cflags)
-
-test_speed_SOURCES = test_speed.c
-test_speed_LDADD = $(common_test_ldadd)
-test_speed_CFLAGS = $(common_test_cflags)
-
-test_generate_SOURCES = test_generate.c
-test_generate_LDADD = $(common_test_ldadd)
-test_generate_CFLAGS = $(common_test_cflags)
-
-test_schema_SOURCES = test_schema.c
-test_schema_LDADD = $(common_test_ldadd)
-test_schema_CFLAGS = $(common_test_cflags)
-
-test_streamline_SOURCES = test_streamline.c
-test_streamline_LDADD = $(common_test_ldadd)
-test_streamline_CFLAGS = $(common_test_cflags)
-
-test_msgpack_SOURCES = test_msgpack.c
-test_msgpack_LDADD = $(common_test_ldadd)
-test_msgpack_CFLAGS = $(common_test_cflags)
-
-check_PROGRAMS = test_basic test_speed test_generate test_schema test_streamline \
- test_msgpack \ No newline at end of file
diff --git a/contrib/libucl/tests/schema/definitions.json b/contrib/libucl/tests/schema/definitions.json
deleted file mode 100644
index 1ab9b2163c44..000000000000
--- a/contrib/libucl/tests/schema/definitions.json
+++ /dev/null
@@ -1,32 +0,0 @@
-[
- {
- "description": "valid definition",
- "schema": {"$ref": "http://highsecure.ru/ucl-schema/schema#"},
- "tests": [
- {
- "description": "valid definition schema",
- "data": {
- "definitions": {
- "foo": {"type": "integer"}
- }
- },
- "valid": true
- }
- ]
- },
- {
- "description": "invalid definition",
- "schema": {"$ref": "http://highsecure.ru/ucl-schema/schema#"},
- "tests": [
- {
- "description": "invalid definition schema",
- "data": {
- "definitions": {
- "foo": {"type": 1}
- }
- },
- "valid": false
- }
- ]
- }
-]
diff --git a/contrib/libucl/tests/schema/ref.json b/contrib/libucl/tests/schema/ref.json
index 1767769cd845..d8214bc2b30c 100644
--- a/contrib/libucl/tests/schema/ref.json
+++ b/contrib/libucl/tests/schema/ref.json
@@ -124,21 +124,5 @@
"valid": false
}
]
- },
- {
- "description": "remote ref, containing refs itself",
- "schema": {"$ref": "http://highsecure.ru/ucl-schema/schema#"},
- "tests": [
- {
- "description": "remote ref valid",
- "data": {"minLength": 1},
- "valid": true
- },
- {
- "description": "remote ref invalid",
- "data": {"minLength": -1},
- "valid": false
- }
- ]
}
]
diff --git a/contrib/libucl/tests/schema/refRemote.json b/contrib/libucl/tests/schema/refRemote.json
deleted file mode 100644
index 067c666b0ec8..000000000000
--- a/contrib/libucl/tests/schema/refRemote.json
+++ /dev/null
@@ -1,76 +0,0 @@
-[
- {
- "description": "remote ref",
- "schema": {"$ref": "http://highsecure.ru/ucl-schema/remotes/integer.json"},
- "tests": [
- {
- "description": "remote ref valid",
- "data": 1,
- "valid": true
- },
- {
- "description": "remote ref invalid",
- "data": "a",
- "valid": false
- }
- ]
- },
- {
- "description": "fragment within remote ref",
- "schema": {"$ref": "http://highsecure.ru/ucl-schema/remotes/subSchemas.json#/integer"},
- "tests": [
- {
- "description": "remote fragment valid",
- "data": 1,
- "valid": true
- },
- {
- "description": "remote fragment invalid",
- "data": "a",
- "valid": false
- }
- ]
- },
- {
- "description": "ref within remote ref",
- "schema": {
- "$ref": "http://highsecure.ru/ucl-schema/remotes/subSchemas.json#/refToInteger"
- },
- "tests": [
- {
- "description": "ref within ref valid",
- "data": 1,
- "valid": true
- },
- {
- "description": "ref within ref invalid",
- "data": "a",
- "valid": false
- }
- ]
- }
-/*
- {
- "description": "change resolution scope",
- "schema": {
- "id": "http://highsecure.ru/ucl-schema/remotes/",
- "items": {
- "id": "folder/",
- "items": {"$ref": "folderInteger.json"}
- }
- },
- "tests": [
- {
- "description": "changed scope ref valid",
- "data": [[1]],
- "valid": true
- },
- {
- "description": "changed scope ref invalid",
- "data": [["a"]],
- "valid": false
- }
- ]
- }
-*/
-]
diff --git a/contrib/libucl/tests/test_speed.c b/contrib/libucl/tests/test_speed.c
index 56f2e5abc6c7..51476c94940b 100644
--- a/contrib/libucl/tests/test_speed.c
+++ b/contrib/libucl/tests/test_speed.c
@@ -44,7 +44,7 @@ get_ticks (void)
{
double res;
-#ifdef __APPLE__
+#if defined(__APPLE__) && defined(HAVE_MACH_MACH_TIME_H)
res = mach_absolute_time () / 1000000000.;
#else
struct timespec ts;
diff --git a/contrib/libucl/tests/test_streamline.c b/contrib/libucl/tests/test_streamline.c
index 4c56c4cdcffd..37fe14f9fb97 100644
--- a/contrib/libucl/tests/test_streamline.c
+++ b/contrib/libucl/tests/test_streamline.c
@@ -26,6 +26,10 @@
#include <assert.h>
#include "ucl.h"
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+
int
main (int argc, char **argv)
{
@@ -34,7 +38,28 @@ main (int argc, char **argv)
const char *fname_out = NULL;
struct ucl_emitter_context *ctx;
struct ucl_emitter_functions *f;
- int ret = 0;
+ int ret = 0, opt, json = 0, compact = 0, yaml = 0;
+
+ while ((opt = getopt(argc, argv, "jcy")) != -1) {
+ switch (opt) {
+ case 'j':
+ json = 1;
+ break;
+ case 'c':
+ compact = 1;
+ break;
+ case 'y':
+ yaml = 1;
+ break;
+ default: /* '?' */
+ fprintf (stderr, "Usage: %s [-jcy] [out]\n",
+ argv[0]);
+ exit (EXIT_FAILURE);
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
switch (argc) {
case 2:
@@ -63,7 +88,21 @@ main (int argc, char **argv)
ucl_object_insert_key (obj, cur, "key3", 0, false);
f = ucl_object_emit_file_funcs (out);
- ctx = ucl_object_emit_streamline_new (obj, UCL_EMIT_CONFIG, f);
+
+ if (yaml) {
+ ctx = ucl_object_emit_streamline_new (obj, UCL_EMIT_YAML, f);
+ }
+ else if (json) {
+ if (compact) {
+ ctx = ucl_object_emit_streamline_new (obj, UCL_EMIT_JSON_COMPACT, f);
+ }
+ else {
+ ctx = ucl_object_emit_streamline_new (obj, UCL_EMIT_JSON, f);
+ }
+ }
+ else {
+ ctx = ucl_object_emit_streamline_new (obj, UCL_EMIT_CONFIG, f);
+ }
assert (ctx != NULL);