Browse Source

update from upstream

master
Alexandros Theodotou 11 months ago
parent
commit
c4e9d4b3e2
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 18
      CHANGES.md
  2. 2
      LICENSE
  3. 31
      Makefile
  4. 10
      README.md
  5. 25
      docs/guide.md
  6. 2
      examples/planner/main.c
  7. 753
      test/units/errs.c
  8. 32
      test/units/file.c
  9. 18
      test/units/free.c
  10. 493
      test/units/load.c
  11. 278
      test/units/save.c
  12. 24
      test/units/test.c
  13. 82
      test/units/ttest.h
  14. 18
      test/units/utf8.c
  15. 30
      test/units/util.c

18
CHANGES.md

@ -1,6 +1,24 @@ @@ -1,6 +1,24 @@
LibCYAML: Change Log
====================
## LibCYAML v1.2.0
* **Loading**:
* Allow mappings with zero fields in the schema.
* Improved logging of errors.
* `CYAML_BOOL` type now treats "Off" as false.
* Allow loading of float values that overflow or underflow unless
`CYAML_FLAG_STRICT` set.
* Added line and column numbers to backtraces.
* **General**:
* Update tests to handle libyaml 0.2.5 output format change.
* Buildsystem improvements.
* Made public header C++ compatible.
* Test runner supports running individual tests.
No changes are required for client applications to upgrade.
## LibCYAML v1.1.0
* **Loading**:

2
LICENSE

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
Copyright (c) 2017-2018, Michael Drake
Copyright (c) 2017-2021, Michael Drake
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice

31
Makefile

@ -1,12 +1,12 @@ @@ -1,12 +1,12 @@
# SPDX-License-Identifier: ISC
#
# Copyright (C) 2017-2020 Michael Drake <tlsa@netsurf-browser.org>
# Copyright (C) 2017-2021 Michael Drake <tlsa@netsurf-browser.org>
# CYAML's versioning is <MAJOR>.<MINOR>.<PATCH>[-DEVEL]
# Master branch will always be DEVEL. The release process will be to make
# the release branch, set VESION_DEVEL to 0, and tag the release.
VERSION_MAJOR = 1
VERSION_MINOR = 1
VERSION_MINOR = 2
VERSION_PATCH = 0
VERSION_DEVEL = 1
VERSION_STR = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
@ -39,6 +39,8 @@ PREFIX ?= /usr/local @@ -39,6 +39,8 @@ PREFIX ?= /usr/local
LIBDIR ?= lib
INCLUDEDIR ?= include
Q ?= @
CC ?= gcc
AR ?= ar
MKDIR = mkdir -p
@ -60,6 +62,7 @@ CFLAGS += -std=c11 -Wall -Wextra -pedantic \ @@ -60,6 +62,7 @@ CFLAGS += -std=c11 -Wall -Wextra -pedantic \
-Wconversion -Wwrite-strings -Wcast-align -Wpointer-arith \
-Winit-self -Wshadow -Wstrict-prototypes -Wmissing-prototypes \
-Wredundant-decls -Wundef -Wvla -Wdeclaration-after-statement
CFLAGS += -MMD -MP
LDFLAGS += $(LIBYAML_LIBS)
LDFLAGS_SHARED += -Wl,-soname=$(LIB_SH_MAJ) -shared
@ -88,8 +91,11 @@ BUILDDIR_STATIC = $(BUILDDIR)/static @@ -88,8 +91,11 @@ BUILDDIR_STATIC = $(BUILDDIR)/static
LIB_SRC_FILES = mem.c free.c load.c save.c util.c utf8.c
LIB_SRC := $(addprefix src/,$(LIB_SRC_FILES))
LIB_OBJ = $(patsubst %.c,%.o, $(addprefix $(BUILDDIR)/,$(LIB_SRC)))
LIB_DEP = $(patsubst %.c,%.d, $(addprefix $(BUILDDIR)/,$(LIB_SRC)))
LIB_OBJ_SHARED = $(patsubst $(BUILDDIR)%,$(BUILDDIR_SHARED)%,$(LIB_OBJ))
LIB_OBJ_STATIC = $(patsubst $(BUILDDIR)%,$(BUILDDIR_STATIC)%,$(LIB_OBJ))
LIB_DEP_SHARED = $(patsubst $(BUILDDIR)%,$(BUILDDIR_SHARED)%,$(LIB_DEP))
LIB_DEP_STATIC = $(patsubst $(BUILDDIR)%,$(BUILDDIR_STATIC)%,$(LIB_DEP))
LIB_PATH = LD_LIBRARY_PATH=$(BUILDDIR)
@ -97,6 +103,7 @@ TEST_SRC_FILES = units/free.c units/load.c units/test.c units/util.c \ @@ -97,6 +103,7 @@ TEST_SRC_FILES = units/free.c units/load.c units/test.c units/util.c \
units/errs.c units/file.c units/save.c units/utf8.c
TEST_SRC := $(addprefix test/,$(TEST_SRC_FILES))
TEST_OBJ = $(patsubst %.c,%.o, $(addprefix $(BUILDDIR)/,$(TEST_SRC)))
TEST_DEP = $(patsubst %.c,%.d, $(addprefix $(BUILDDIR)/,$(TEST_SRC)))
TEST_BINS = \
$(BUILDDIR)/test/units/cyaml-shared \
@ -105,16 +112,16 @@ TEST_BINS = \ @@ -105,16 +112,16 @@ TEST_BINS = \
all: $(BUILDDIR)/$(LIB_SH_MAJ) $(BUILDDIR)/$(LIB_STATIC) examples
coverage: test-verbose
@$(MKDIR) $(BUILDDIR)
@gcovr -e 'test/.*' -r .
@gcovr -e 'test/.*' -x -o build/coverage.xml -r .
@gcovr -e 'test/.*' --html --html-details -o build/coverage.html -r .
$(Q)$(MKDIR) $(BUILDDIR)
$(Q)gcovr -e 'test/.*' -r .
$(Q)gcovr -e 'test/.*' -x -o build/coverage.xml -r .
$(Q)gcovr -e 'test/.*' --html --html-details -o build/coverage.html -r .
test test-quiet test-verbose test-debug: $(TEST_BINS)
@for i in $(^); do $(LIB_PATH) $$i $(subst test-,--,$@) || exit; done
$(Q)for i in $(^); do $(LIB_PATH) $$i $(subst test,,$(subst test-,--,$@)) "$(TESTLIST)" || exit; done
valgrind valgrind-quiet valgrind-verbose valgrind-debug: $(TEST_BINS)
@for i in $(^); do $(LIB_PATH) $(VALGRIND) $$i $(subst valgrind-,--,$@) || exit; done
$(Q)for i in $(^); do $(LIB_PATH) $(VALGRIND) $$i $(subst valgrind,,$(subst valgrind-,--,$@)) "$(TESTLIST)" || exit; done
check: test
@ -133,11 +140,11 @@ $(BUILDDIR)/$(LIB_SH_MAJ): $(LIB_OBJ_SHARED) @@ -133,11 +140,11 @@ $(BUILDDIR)/$(LIB_SH_MAJ): $(LIB_OBJ_SHARED)
$(CC) -o $@ $^ $(LDFLAGS) $(LDFLAGS_COV) $(LDFLAGS_SHARED)
$(LIB_OBJ_STATIC): $(BUILDDIR_STATIC)/%.o : %.c
@$(MKDIR) $(BUILDDIR_STATIC)/src
$(Q)$(MKDIR) $(dir $@)
$(CC) $(CFLAGS) $(CFLAGS_COV) -c -o $@ $<
$(LIB_OBJ_SHARED): $(BUILDDIR_SHARED)/%.o : %.c
@$(MKDIR) $(BUILDDIR_SHARED)/src
$(Q)$(MKDIR) $(dir $@)
$(CC) $(CFLAGS) -fPIC $(CFLAGS_COV) -c -o $@ $<
docs:
@ -169,6 +176,8 @@ $(BUILDDIR)/planner: examples/planner/main.c $(BUILDDIR)/$(LIB_STATIC) @@ -169,6 +176,8 @@ $(BUILDDIR)/planner: examples/planner/main.c $(BUILDDIR)/$(LIB_STATIC)
$(BUILDDIR)/numerical: examples/numerical/main.c $(BUILDDIR)/$(LIB_STATIC)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
-include $(LIB_DEP_SHARED) $(LIB_DEP_STATIC) $(TEST_DEP)
.PHONY: all test test-quiet test-verbose test-debug \
valgrind valgrind-quiet valgrind-verbose valgrind-debug \
clean coverage docs install examples check
@ -180,5 +189,5 @@ $(BUILDDIR)/test/units/cyaml-shared: $(TEST_OBJ) $(BUILDDIR)/$(LIB_SH_MAJ) @@ -180,5 +189,5 @@ $(BUILDDIR)/test/units/cyaml-shared: $(TEST_OBJ) $(BUILDDIR)/$(LIB_SH_MAJ)
$(CC) $(LDFLAGS_COV) -o $@ $^ $(LDFLAGS)
$(TEST_OBJ): $(BUILDDIR)/%.o : %.c
@$(MKDIR) $(BUILDDIR)/test/units
$(Q)$(MKDIR) $(dir $@)
$(CC) $(CFLAGS) $(CFLAGS_COV) -c -o $@ $<

10
README.md

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
LibCYAML: Schema-based YAML parsing and serialisation
=====================================================
[![Build Status](https://github.com/tlsa/libcyaml/workflows/CI/badge.svg)](https://github.com/tlsa/libcyaml/actions) [![Code Coverage](https://codecov.io/gh/tlsa/libcyaml/branch/master/graph/badge.svg)](https://codecov.io/gh/tlsa/libcyaml) [![Code Quality](https://img.shields.io/lgtm/grade/cpp/g/tlsa/libcyaml.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/tlsa/libcyaml/alerts/)
[![Build Status](https://github.com/tlsa/libcyaml/workflows/CI/badge.svg)](https://github.com/tlsa/libcyaml/actions) [![Code Coverage](https://codecov.io/gh/tlsa/libcyaml/branch/main/graph/badge.svg)](https://codecov.io/gh/tlsa/libcyaml) [![Code Quality](https://img.shields.io/lgtm/grade/cpp/g/tlsa/libcyaml.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/tlsa/libcyaml/alerts/)
LibCYAML is a C library for reading and writing structured YAML documents.
It is written in ISO C11 and licensed under the ISC licence.
@ -82,6 +82,12 @@ To run the tests under `valgrind`, a similar set of targets is available: @@ -82,6 +82,12 @@ To run the tests under `valgrind`, a similar set of targets is available:
make valgrind-verbose
make valgrind-debug
To run a single test or a subset of tests, use the `TESTLIST` variable, which
expects a space and/or comma separated list of test names:
make test-debug TESTLIST=test_load_mapping_without_any_fields
make valgrind-debug TESTLIST="test_load_no_log test_util_state_invalid"
To generate a test coverage report, `gcovr` is required:
make coverage
@ -95,7 +101,7 @@ internals, `doxygen` is required: @@ -95,7 +101,7 @@ internals, `doxygen` is required:
make docs
Alternatively, the read the API documentation directly from the
[cyaml.h](https://github.com/tlsa/libcyaml/blob/master/include/cyaml/cyaml.h)
[cyaml.h](https://github.com/tlsa/libcyaml/blob/main/include/cyaml/cyaml.h)
header file.
There is also a [tutorial](docs/guide.md).

25
docs/guide.md

@ -51,11 +51,18 @@ struct numbers { @@ -51,11 +51,18 @@ struct numbers {
Then we need to define a CYAML schema to describe these to LibCYAML.
> **Note**: Use the doxygen API documentation, or else the documentation in
> [cyaml.h](https://github.com/tlsa/libcyaml/blob/master/include/cyaml/cyaml.h)
> [cyaml.h](https://github.com/tlsa/libcyaml/blob/main/include/cyaml/cyaml.h)
> in conjunction with this guide.
At the top level of the YAML is a mapping with two fields, "name" and
"data". The the first field is just a simple scalar value (it's neither
"data".
```yaml
name:
data:
```
The first field is just a simple scalar value (it's neither
a mapping nor a sequence). The second field has a sequence value.
We'll start by defining the CYAML schema for the "data" sequence,
@ -82,12 +89,10 @@ field in the mapping. @@ -82,12 +89,10 @@ field in the mapping.
```c
/* CYAML mapping schema fields array for the top level mapping. */
static const cyaml_schema_field_t top_mapping_schema[] = {
CYAML_FIELD_STRING_PTR("name", CYAML_FLAG_POINTER,
struct numbers, name,
0, CYAML_UNLIMITED),
CYAML_FIELD_SEQUENCE("data", CYAML_FLAG_POINTER,
struct numbers, data, &data_entry,
0, CYAML_UNLIMITED),
CYAML_FIELD_STRING_PTR(
"name", CYAML_FLAG_POINTER, struct numbers, name, 0, CYAML_UNLIMITED),
CYAML_FIELD_SEQUENCE(
"data", CYAML_FLAG_POINTER, struct numbers, data, &data_entry, 0, CYAML_UNLIMITED),
CYAML_FIELD_END
};
```
@ -109,8 +114,8 @@ the LibCYAML. @@ -109,8 +114,8 @@ the LibCYAML.
```c
/* CYAML value schema for the top level mapping. */
static const cyaml_schema_value_t top_schema = {
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER,
struct numbers, top_mapping_schema),
CYAML_VALUE_MAPPING(
CYAML_FLAG_POINTER, struct numbers, top_mapping_schema),
};
```

2
examples/planner/main.c

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: ISC
*
* Copyright (C) 2018 Michael Drake <tlsa@netsurf-browser.org>
* Copyright (C) 2019 Michael Drake <tlsa@netsurf-browser.org>
*/
#include <stdlib.h>

753
test/units/errs.c

File diff suppressed because it is too large Load Diff

32
test/units/file.c

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: ISC
*
* Copyright (C) 2018 Michael Drake <tlsa@netsurf-browser.org>
* Copyright (C) 2018-2021 Michael Drake <tlsa@netsurf-browser.org>
*/
#include <stdbool.h>
@ -69,8 +69,11 @@ static bool test_file_load_bad_path( @@ -69,8 +69,11 @@ static bool test_file_load_bad_path(
.schema = &top_schema,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_load_file("/cyaml/path/shouldn't/exist.yaml",
config, &top_schema, (cyaml_data_t **) &data_tgt, NULL);
@ -108,8 +111,11 @@ static bool test_file_save_bad_path( @@ -108,8 +111,11 @@ static bool test_file_save_bad_path(
.schema = &top_schema,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_file("/cyaml/path/shouldn't/exist.yaml",
config, &top_schema, data, 0);
@ -179,8 +185,11 @@ static bool test_file_load_basic( @@ -179,8 +185,11 @@ static bool test_file_load_basic(
.schema = &top_schema,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_load_file("test/data/basic.yaml", config, &top_schema,
(cyaml_data_t **) &data_tgt, NULL);
@ -250,8 +259,11 @@ static bool test_file_load_save_basic( @@ -250,8 +259,11 @@ static bool test_file_load_save_basic(
.schema = &top_schema,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_load_file("test/data/basic.yaml", config, &top_schema,
(cyaml_data_t **) &data_tgt, NULL);
@ -328,8 +340,11 @@ static bool test_file_load_basic_invalid( @@ -328,8 +340,11 @@ static bool test_file_load_basic_invalid(
.schema = &top_schema,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_load_file("test/data/basic.yaml", config, &top_schema,
(cyaml_data_t **) &data_tgt, NULL);
@ -376,8 +391,11 @@ static bool test_file_save_basic_invalid( @@ -376,8 +391,11 @@ static bool test_file_save_basic_invalid(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_file("build/save.yaml", config, &top_schema, &data, 0);
if (err != CYAML_ERR_INVALID_DATA_SIZE) {

18
test/units/free.c

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: ISC
*
* Copyright (C) 2017-2018 Michael Drake <tlsa@netsurf-browser.org>
* Copyright (C) 2017-2021 Michael Drake <tlsa@netsurf-browser.org>
*/
#include <stdbool.h>
@ -40,7 +40,9 @@ static bool test_free_null_data( @@ -40,7 +40,9 @@ static bool test_free_null_data(
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER,
struct target_struct, mapping_schema),
};
ttest_ctx_t tc = ttest_start(report, __func__, NULL, NULL);
ttest_ctx_t tc;
if (!ttest_start(report, __func__, NULL, NULL, &tc)) return true;
err = cyaml_free(config, &top_schema, NULL, 0);
if (err != CYAML_OK) {
@ -62,7 +64,9 @@ static bool test_free_null_config( @@ -62,7 +64,9 @@ static bool test_free_null_config(
const cyaml_config_t *config)
{
cyaml_err_t err;
ttest_ctx_t tc = ttest_start(report, __func__, NULL, NULL);
ttest_ctx_t tc;
if (!ttest_start(report, __func__, NULL, NULL, &tc)) return true;
UNUSED(config);
@ -87,7 +91,9 @@ static bool test_free_null_mem_fn( @@ -87,7 +91,9 @@ static bool test_free_null_mem_fn(
{
cyaml_err_t err;
cyaml_config_t cfg = *config;
ttest_ctx_t tc = ttest_start(report, __func__, NULL, NULL);
ttest_ctx_t tc;
if (!ttest_start(report, __func__, NULL, NULL, &tc)) return true;
cfg.mem_fn = NULL;
@ -111,7 +117,9 @@ static bool test_free_null_schema( @@ -111,7 +117,9 @@ static bool test_free_null_schema(
const cyaml_config_t *config)
{
cyaml_err_t err;
ttest_ctx_t tc = ttest_start(report, __func__, NULL, NULL);
ttest_ctx_t tc;
if (!ttest_start(report, __func__, NULL, NULL, &tc)) return true;
err = cyaml_free(config, NULL, NULL, 0);
if (err != CYAML_ERR_BAD_PARAM_NULL_SCHEMA) {

493
test/units/load.c

File diff suppressed because it is too large Load Diff

278
test/units/save.c

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: ISC
*
* Copyright (C) 2018-2019 Michael Drake <tlsa@netsurf-browser.org>
* Copyright (C) 2018-2021 Michael Drake <tlsa@netsurf-browser.org>
*/
#include <stdbool.h>
@ -79,8 +79,11 @@ static bool test_save_mapping_entry_uint( @@ -79,8 +79,11 @@ static bool test_save_mapping_entry_uint(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -135,8 +138,11 @@ static bool test_save_mapping_entry_float( @@ -135,8 +138,11 @@ static bool test_save_mapping_entry_float(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -191,8 +197,11 @@ static bool test_save_mapping_entry_double( @@ -191,8 +197,11 @@ static bool test_save_mapping_entry_double(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -247,8 +256,11 @@ static bool test_save_mapping_entry_string( @@ -247,8 +256,11 @@ static bool test_save_mapping_entry_string(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -303,8 +315,11 @@ static bool test_save_mapping_entry_int_pos( @@ -303,8 +315,11 @@ static bool test_save_mapping_entry_int_pos(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -359,8 +374,11 @@ static bool test_save_mapping_entry_int_neg( @@ -359,8 +374,11 @@ static bool test_save_mapping_entry_int_neg(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -415,8 +433,11 @@ static bool test_save_mapping_entry_int_64( @@ -415,8 +433,11 @@ static bool test_save_mapping_entry_int_64(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -471,8 +492,11 @@ static bool test_save_mapping_entry_bool_true( @@ -471,8 +492,11 @@ static bool test_save_mapping_entry_bool_true(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -527,8 +551,11 @@ static bool test_save_mapping_entry_bool_false( @@ -527,8 +551,11 @@ static bool test_save_mapping_entry_bool_false(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -584,8 +611,11 @@ static bool test_save_mapping_entry_string_ptr( @@ -584,8 +611,11 @@ static bool test_save_mapping_entry_string_ptr(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -649,8 +679,11 @@ static bool test_save_mapping_entry_enum_strict( @@ -649,8 +679,11 @@ static bool test_save_mapping_entry_enum_strict(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -714,8 +747,11 @@ static bool test_save_mapping_entry_enum_number( @@ -714,8 +747,11 @@ static bool test_save_mapping_entry_enum_number(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -785,8 +821,11 @@ static bool test_save_mapping_entry_enum_sparse( @@ -785,8 +821,11 @@ static bool test_save_mapping_entry_enum_sparse(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -856,8 +895,11 @@ static bool test_save_mapping_entry_mapping( @@ -856,8 +895,11 @@ static bool test_save_mapping_entry_mapping(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -927,8 +969,11 @@ static bool test_save_mapping_entry_mapping_ptr( @@ -927,8 +969,11 @@ static bool test_save_mapping_entry_mapping_ptr(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -998,8 +1043,11 @@ static bool test_save_mapping_entry_flags_strict( @@ -998,8 +1043,11 @@ static bool test_save_mapping_entry_flags_strict(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -1070,8 +1118,11 @@ static bool test_save_mapping_entry_flags_number( @@ -1070,8 +1118,11 @@ static bool test_save_mapping_entry_flags_number(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -1143,8 +1194,11 @@ static bool test_save_mapping_entry_flags_sparse( @@ -1143,8 +1194,11 @@ static bool test_save_mapping_entry_flags_sparse(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -1212,8 +1266,11 @@ static bool test_save_mapping_entry_bitfield( @@ -1212,8 +1266,11 @@ static bool test_save_mapping_entry_bitfield(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -1281,8 +1338,11 @@ static bool test_save_mapping_entry_bitfield_sparse( @@ -1281,8 +1338,11 @@ static bool test_save_mapping_entry_bitfield_sparse(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -1349,8 +1409,11 @@ static bool test_save_mapping_entry_sequence_int( @@ -1349,8 +1409,11 @@ static bool test_save_mapping_entry_sequence_int(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -1417,8 +1480,11 @@ static bool test_save_mapping_entry_sequence_uint( @@ -1417,8 +1480,11 @@ static bool test_save_mapping_entry_sequence_uint(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -1494,8 +1560,11 @@ static bool test_save_mapping_entry_sequence_enum( @@ -1494,8 +1560,11 @@ static bool test_save_mapping_entry_sequence_enum(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -1564,8 +1633,11 @@ static bool test_save_mapping_entry_sequence_bool( @@ -1564,8 +1633,11 @@ static bool test_save_mapping_entry_sequence_bool(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -1654,8 +1726,11 @@ static bool test_save_mapping_entry_sequence_flags( @@ -1654,8 +1726,11 @@ static bool test_save_mapping_entry_sequence_flags(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -1727,8 +1802,11 @@ static bool test_save_mapping_entry_sequence_string( @@ -1727,8 +1802,11 @@ static bool test_save_mapping_entry_sequence_string(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -1800,8 +1878,11 @@ static bool test_save_mapping_entry_sequence_string_ptr( @@ -1800,8 +1878,11 @@ static bool test_save_mapping_entry_sequence_string_ptr(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -1881,8 +1962,11 @@ static bool test_save_mapping_entry_sequence_mapping( @@ -1881,8 +1962,11 @@ static bool test_save_mapping_entry_sequence_mapping(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -1966,8 +2050,11 @@ static bool test_save_mapping_entry_sequence_mapping_ptr( @@ -1966,8 +2050,11 @@ static bool test_save_mapping_entry_sequence_mapping_ptr(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -2050,8 +2137,11 @@ static bool test_save_mapping_entry_sequence_sequence_fixed_int( @@ -2050,8 +2137,11 @@ static bool test_save_mapping_entry_sequence_sequence_fixed_int(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -2140,8 +2230,11 @@ static bool test_save_mapping_entry_sequence_sequence_fixed_ptr_int( @@ -2140,8 +2230,11 @@ static bool test_save_mapping_entry_sequence_sequence_fixed_ptr_int(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -2239,8 +2332,11 @@ static bool test_save_mapping_entry_sequence_sequence_fixed_flat_int( @@ -2239,8 +2332,11 @@ static bool test_save_mapping_entry_sequence_sequence_fixed_flat_int(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -2308,8 +2404,11 @@ static bool test_save_mapping_entry_sequence_ptr_int( @@ -2308,8 +2404,11 @@ static bool test_save_mapping_entry_sequence_ptr_int(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -2377,8 +2476,11 @@ static bool test_save_mapping_entry_sequence_ptr_uint( @@ -2377,8 +2476,11 @@ static bool test_save_mapping_entry_sequence_ptr_uint(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -2459,8 +2561,11 @@ static bool test_save_mapping_entry_sequence_ptr_enum( @@ -2459,8 +2561,11 @@ static bool test_save_mapping_entry_sequence_ptr_enum(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -2533,8 +2638,11 @@ static bool test_save_mapping_entry_sequence_ptr_bool( @@ -2533,8 +2638,11 @@ static bool test_save_mapping_entry_sequence_ptr_bool(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -2625,8 +2733,11 @@ static bool test_save_mapping_entry_sequence_ptr_flags( @@ -2625,8 +2733,11 @@ static bool test_save_mapping_entry_sequence_ptr_flags(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -2699,8 +2810,11 @@ static bool test_save_mapping_entry_sequence_ptr_string( @@ -2699,8 +2810,11 @@ static bool test_save_mapping_entry_sequence_ptr_string(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -2774,8 +2888,11 @@ static bool test_save_mapping_entry_sequence_ptr_string_ptr( @@ -2774,8 +2888,11 @@ static bool test_save_mapping_entry_sequence_ptr_string_ptr(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -2857,8 +2974,11 @@ static bool test_save_mapping_entry_sequence_ptr_mapping( @@ -2857,8 +2974,11 @@ static bool test_save_mapping_entry_sequence_ptr_mapping(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -2944,8 +3064,11 @@ static bool test_save_mapping_entry_sequence_ptr_mapping_ptr( @@ -2944,8 +3064,11 @@ static bool test_save_mapping_entry_sequence_ptr_mapping_ptr(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -3029,8 +3152,11 @@ static bool test_save_mapping_entry_sequence_ptr_sequence_fixed_int( @@ -3029,8 +3152,11 @@ static bool test_save_mapping_entry_sequence_ptr_sequence_fixed_int(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -3120,8 +3246,11 @@ static bool test_save_mapping_entry_sequence_ptr_sequence_fixed_ptr_int( @@ -3120,8 +3246,11 @@ static bool test_save_mapping_entry_sequence_ptr_sequence_fixed_ptr_int(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -3220,8 +3349,11 @@ static bool test_save_mapping_entry_sequence_ptr_sequence_fixed_flat_int( @@ -3220,8 +3349,11 @@ static bool test_save_mapping_entry_sequence_ptr_sequence_fixed_flat_int(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -3276,8 +3408,11 @@ static bool test_save_mapping_entry_optional_uint( @@ -3276,8 +3408,11 @@ static bool test_save_mapping_entry_optional_uint(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -3334,8 +3469,11 @@ static bool test_save_mapping_entry_optional_uint_ptr( @@ -3334,8 +3469,11 @@ static bool test_save_mapping_entry_optional_uint_ptr(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -3390,8 +3528,11 @@ static bool test_save_mapping_entry_optional_uint_ptr_null( @@ -3390,8 +3528,11 @@ static bool test_save_mapping_entry_optional_uint_ptr_null(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -3447,8 +3588,11 @@ static bool test_save_mapping_entry_ignored( @@ -3447,8 +3588,11 @@ static bool test_save_mapping_entry_ignored(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -3522,7 +3666,9 @@ static bool test_save_sequence_null_values_int( @@ -3522,7 +3666,9 @@ static bool test_save_sequence_null_values_int(
ttest_ctx_t tc;
cfg.flags |= CYAML_CFG_STYLE_BLOCK;
tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, &cfg, &top_schema, data,
CYAML_ARRAY_LEN(data));
@ -3585,7 +3731,9 @@ static bool test_save_sequence_null_str_values_int( @@ -3585,7 +3731,9 @@ static bool test_save_sequence_null_str_values_int(
ttest_ctx_t tc;
cfg.flags |= CYAML_CFG_STYLE_BLOCK;
tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, &cfg, &top_schema, data,
CYAML_ARRAY_LEN(data));
@ -3636,8 +3784,11 @@ static bool test_save_schema_top_level_sequence_fixed( @@ -3636,8 +3784,11 @@ static bool test_save_schema_top_level_sequence_fixed(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema, data, 0);
if (err != CYAML_OK) {
@ -3688,7 +3839,9 @@ static bool test_save_sequence_config_flow_style( @@ -3688,7 +3839,9 @@ static bool test_save_sequence_config_flow_style(
ttest_ctx_t tc;
cfg.flags |= CYAML_CFG_STYLE_FLOW;
tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, &cfg, &top_schema, data, 3);
if (err != CYAML_OK) {
@ -3742,7 +3895,9 @@ static bool test_save_sequence_config_block_style( @@ -3742,7 +3895,9 @@ static bool test_save_sequence_config_block_style(
ttest_ctx_t tc;
cfg.flags |= CYAML_CFG_STYLE_BLOCK;
tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, &cfg, &top_schema, data, 3);
if (err != CYAML_OK) {
@ -3804,8 +3959,11 @@ static bool test_save_mapping_value_flow_style( @@ -3804,8 +3959,11 @@ static bool test_save_mapping_value_flow_style(
.config = &cfg,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -3870,8 +4028,11 @@ static bool test_save_mapping_value_block_style( @@ -3870,8 +4028,11 @@ static bool test_save_mapping_value_block_style(
.config = config,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
err = cyaml_save_data(&buffer, &len, config, &top_schema,
&data, 0);
@ -3925,8 +4086,11 @@ static bool test_save_no_document_delimiters( @@ -3925,8 +4086,11 @@ static bool test_save_no_document_delimiters(
.config = &cfg,
};
cyaml_err_t err;
ttest_ctx_t tc;
ttest_ctx_t tc = ttest_start(report, __func__, cyaml_cleanup, &td);
if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) {
return true;
}
cfg.flags &= ~((unsigned)CYAML_CFG_DOCUMENT_DELIM);
err = cyaml_save_data(&buffer, &len, &cfg, &top_schema, &data, 0);

24
test/units/test.c

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: ISC
*
* Copyright (C) 2017-2018 Michael Drake <tlsa@netsurf-browser.org>
* Copyright (C) 2017-2021 Michael Drake <tlsa@netsurf-browser.org>
*/
#include <stdbool.h>
@ -37,11 +37,13 @@ int main(int argc, char *argv[]) @@ -37,11 +37,13 @@ int main(int argc, char *argv[])
bool pass = true;
bool quiet = false;
ttest_report_ctx_t rc;
const char *test_list = NULL;
cyaml_log_fn_t log_fn = cyaml_log;
cyaml_log_t log_level = CYAML_LOG_ERROR;
enum {
ARG_PROG_NAME,
ARG_VERBOSE,
ARG_TEST_LIST,
ARG__COUNT,
};
@ -49,21 +51,25 @@ int main(int argc, char *argv[]) @@ -49,21 +51,25 @@ int main(int argc, char *argv[])
usage(argv[ARG_PROG_NAME]);
return EXIT_FAILURE;
} else if (argc > ARG_VERBOSE) {
if ((strcmp(argv[ARG_VERBOSE], "-q") == 0) ||
(strcmp(argv[ARG_VERBOSE], "--quiet") == 0)) {
}
for (int i = 1; i < argc; i++) {
if ((strcmp(argv[i], "-q") == 0) ||
(strcmp(argv[i], "--quiet") == 0)) {
quiet = true;
log_fn = NULL;
} else if ((strcmp(argv[ARG_VERBOSE], "-v") == 0) ||
(strcmp(argv[ARG_VERBOSE], "--verbose") == 0)) {
} else if ((strcmp(argv[i], "-v") == 0) ||
(strcmp(argv[i], "--verbose") == 0)) {
log_level = CYAML_LOG_INFO;
} else if ((strcmp(argv[ARG_VERBOSE], "-d") == 0) ||
(strcmp(argv[ARG_VERBOSE], "--debug") == 0)) {
} else if ((strcmp(argv[i], "-d") == 0) ||
(strcmp(argv[i], "--debug") == 0)) {
log_level = CYAML_LOG_DEBUG;
} else {
test_list = argv[i];
}
}
rc = ttest_init(quiet);
rc = ttest_init(test_list, quiet);
pass &= utf8_tests(&rc, log_level, log_fn);
pass &= util_tests(&rc, log_level, log_fn);

82
test/units/ttest.h

@ -1,12 +1,14 @@ @@ -1,12 +1,14 @@
/*
* SPDX-License-Identifier: ISC
*
* Copyright (C) 2013 Michael Drake <tlsa@netsurf-browser.org>
* Copyright (C) 2013-2019 Michael Drake <tlsa@netsurf-browser.org>
*/
#ifndef TTEST_H
#define TTEST_H
#include <string.h>
/**
* Test cleanup client callback.
*
@ -26,6 +28,10 @@ typedef void (*ttest_cleanup_fn)(void *data); @@ -26,6 +28,10 @@ typedef void (*ttest_cleanup_fn)(void *data);
* of utilisation.
*/
typedef struct ttest_report_ctx {
/** Space/comma separated list of tests to run. */
const char *test_list;
size_t test_list_len;
bool quiet; /**< Whether to print only the report summary. */
unsigned tests; /**< Number of tests started. */
unsigned todo; /**< Number of tests marked as unimplemented. */
@ -49,19 +55,63 @@ typedef struct ttest_ctx { @@ -49,19 +55,63 @@ typedef struct ttest_ctx {
/**
* Initialise a tlsa-test report context.
*
* \param[in] quiet Whether report should be a minimal summary.
* \param[in] test_list Space/comma separated list of tests to run.
* \param[in] quiet Whether report should be a minimal summary.
* \return initialised tlsa-test report context.
*/
static inline ttest_report_ctx_t ttest_init(
const char *test_list,
bool quiet)
{
ttest_report_ctx_t rc = {
.test_list = test_list,
.test_list_len = 0,
.quiet = quiet,
};
if (test_list != NULL) {
rc.test_list_len = strlen(test_list);
}
return rc;
}
/**
* Determine whether test of given name should be run.
*
* \param[in] report The tlsa-test report context.
* \param[in] name The name of the test to consider.
* \return true if test should be run, false otherwise.