From c4e9d4b3e20ccce6a7c0e7a257b5ae57ecb7286a Mon Sep 17 00:00:00 2001 From: Alexandros Theodotou Date: Mon, 16 Aug 2021 23:57:59 +0100 Subject: [PATCH] update from upstream --- CHANGES.md | 18 + LICENSE | 2 +- Makefile | 31 +- README.md | 10 +- docs/guide.md | 25 +- examples/planner/main.c | 2 +- test/units/errs.c | 753 ++++++++++++++++++++++++++++++++++------ test/units/file.c | 32 +- test/units/free.c | 18 +- test/units/load.c | 493 ++++++++++++++++++++------ test/units/save.c | 278 ++++++++++++--- test/units/test.c | 24 +- test/units/ttest.h | 82 ++++- test/units/utf8.c | 18 +- test/units/util.c | 30 +- 15 files changed, 1481 insertions(+), 335 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 186507a..6997bfb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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**: diff --git a/LICENSE b/LICENSE index 7a987d9..60b5698 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/Makefile b/Makefile index 488a6b0..5229996 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ # SPDX-License-Identifier: ISC # -# Copyright (C) 2017-2020 Michael Drake +# Copyright (C) 2017-2021 Michael Drake # CYAML's versioning is ..[-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 LIBDIR ?= lib INCLUDEDIR ?= include +Q ?= @ + CC ?= gcc AR ?= ar MKDIR = mkdir -p @@ -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 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 \ 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 = \ 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) $(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) $(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) $(CC) $(LDFLAGS_COV) -o $@ $^ $(LDFLAGS) $(TEST_OBJ): $(BUILDDIR)/%.o : %.c - @$(MKDIR) $(BUILDDIR)/test/units + $(Q)$(MKDIR) $(dir $@) $(CC) $(CFLAGS) $(CFLAGS_COV) -c -o $@ $< diff --git a/README.md b/README.md index 6db7677..dbe08b0 100644 --- a/README.md +++ b/README.md @@ -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: 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: 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). diff --git a/docs/guide.md b/docs/guide.md index 4420a74..1573728 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -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. ```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. ```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), }; ``` diff --git a/examples/planner/main.c b/examples/planner/main.c index 64456ba..614b522 100644 --- a/examples/planner/main.c +++ b/examples/planner/main.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: ISC * - * Copyright (C) 2018 Michael Drake + * Copyright (C) 2019 Michael Drake */ #include diff --git a/test/units/errs.c b/test/units/errs.c index 89356f8..260b074 100644 --- a/test/units/errs.c +++ b/test/units/errs.c @@ -1,12 +1,13 @@ /* * SPDX-License-Identifier: ISC * - * Copyright (C) 2018-2019 Michael Drake + * Copyright (C) 2018-2021 Michael Drake */ #include #include #include +#include #include #include @@ -82,8 +83,11 @@ static bool test_err_load_null_data( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) NULL, NULL); @@ -127,8 +131,11 @@ static bool test_err_save_null_data( .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_data(&buffer, &len, config, &top_schema, NULL, 0); if (err != CYAML_ERR_BAD_PARAM_NULL_DATA) { @@ -161,8 +168,11 @@ static bool test_err_load_null_config( .schema = NULL, }; 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_data(yaml, YAML_LEN(yaml), NULL, NULL, (cyaml_data_t **) NULL, NULL); @@ -209,8 +219,11 @@ static bool test_err_save_null_config( .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, NULL, &top_schema, &data, 0); if (err != CYAML_ERR_BAD_PARAM_NULL_CONFIG) { @@ -248,7 +261,9 @@ static bool test_err_load_null_mem_fn( cfg.mem_fn = NULL; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, NULL, (cyaml_data_t **) NULL, NULL); @@ -300,7 +315,9 @@ static bool test_err_save_null_mem_fn( cfg.mem_fn = NULL; - 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, 0); if (err != CYAML_ERR_BAD_CONFIG_NULL_MEMFN) { @@ -333,8 +350,11 @@ static bool test_err_load_null_schema( .schema = NULL, }; 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_data(yaml, YAML_LEN(yaml), config, NULL, (cyaml_data_t **) NULL, NULL); @@ -372,8 +392,11 @@ static bool test_err_save_null_schema( .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, NULL, &data, 0); if (err != CYAML_ERR_BAD_PARAM_NULL_SCHEMA) { @@ -410,8 +433,11 @@ static bool test_err_load_schema_top_level_non_pointer( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &value, NULL); @@ -452,8 +478,11 @@ static bool test_err_save_schema_top_level_non_pointer( .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_ERR_TOP_LEVEL_NON_PTR) { @@ -497,8 +526,11 @@ static bool test_err_load_schema_top_level_sequence_no_count( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -538,8 +570,11 @@ static bool test_err_load_schema_top_level_not_sequence_count( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &value, &count); @@ -580,8 +615,11 @@ static bool test_err_save_schema_top_level_not_sequence_count( .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, 42); if (err != CYAML_ERR_BAD_PARAM_SEQ_COUNT) { @@ -633,8 +671,11 @@ static bool test_err_load_schema_bad_type( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -688,8 +729,11 @@ static bool test_err_save_schema_bad_type( .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_ERR_BAD_TYPE_IN_SCHEMA) { @@ -735,8 +779,11 @@ static bool test_err_load_schema_string_min_max( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -782,8 +829,11 @@ static bool test_err_load_non_scalar_mapping_key( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -836,8 +886,11 @@ static bool test_err_load_schema_bad_data_size_1( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -890,8 +943,11 @@ static bool test_err_load_schema_bad_data_size_2( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -956,8 +1012,11 @@ static bool test_err_load_schema_bad_data_size_3( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1025,8 +1084,11 @@ static bool test_err_load_schema_bad_data_size_4( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1094,8 +1156,11 @@ static bool test_err_load_schema_bad_data_size_5( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1163,8 +1228,11 @@ static bool test_err_load_schema_bad_data_size_6( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1217,8 +1285,11 @@ static bool test_err_load_schema_bad_data_size_7( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1287,8 +1358,11 @@ static bool test_err_load_schema_bad_data_size_8( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1353,8 +1427,11 @@ static bool test_err_load_schema_bad_data_size_9( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1408,8 +1485,11 @@ static bool test_err_save_schema_bad_data_size_1( .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_ERR_INVALID_DATA_SIZE) { @@ -1462,8 +1542,11 @@ static bool test_err_save_schema_bad_data_size_2( .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_ERR_INVALID_DATA_SIZE) { @@ -1516,8 +1599,11 @@ static bool test_err_save_schema_bad_data_size_3( .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_ERR_INVALID_DATA_SIZE) { @@ -1583,8 +1669,11 @@ static bool test_err_save_schema_bad_data_size_4( .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_ERR_INVALID_DATA_SIZE) { @@ -1637,8 +1726,11 @@ static bool test_err_save_schema_bad_data_size_5( .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_ERR_INVALID_DATA_SIZE) { @@ -1708,8 +1800,11 @@ static bool test_err_save_schema_bad_data_size_6( .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_ERR_INVALID_DATA_SIZE) { @@ -1774,8 +1869,11 @@ static bool test_err_save_schema_bad_data_size_7( .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_ERR_INVALID_DATA_SIZE) { @@ -1840,8 +1938,11 @@ static bool test_err_save_schema_bad_data_size_8( .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); @@ -1907,8 +2008,11 @@ static bool test_err_load_schema_sequence_min_max( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1972,8 +2076,11 @@ static bool test_err_save_schema_sequence_min_max( .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_ERR_SEQUENCE_FIXED_COUNT) { @@ -2025,8 +2132,11 @@ static bool test_err_load_schema_bad_data_size_float( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2074,8 +2184,11 @@ static bool test_err_load_schema_sequence_in_sequence( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &seq, &count); @@ -2121,8 +2234,11 @@ static bool test_err_save_schema_sequence_in_sequence( .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, 2); if (err != CYAML_ERR_SEQUENCE_IN_SEQUENCE) { @@ -2167,8 +2283,11 @@ static bool test_err_load_schema_invalid_value_uint( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2206,8 +2325,11 @@ static bool test_err_load_schema_invalid_value_string( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &value, NULL); @@ -2269,8 +2391,11 @@ static bool test_err_load_schema_invalid_value_flags_1( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2336,8 +2461,11 @@ static bool test_err_load_schema_invalid_value_flags_2( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2403,8 +2531,11 @@ static bool test_err_load_schema_invalid_value_flags_3( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2451,7 +2582,9 @@ static bool test_err_save_schema_invalid_value_null_ptr( 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)); @@ -2498,8 +2631,11 @@ static bool test_err_load_schema_invalid_value_bitfield_1( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2550,8 +2686,11 @@ static bool test_err_load_schema_invalid_value_bitfield_2( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2602,8 +2741,11 @@ static bool test_err_load_schema_invalid_value_bitfield_3( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2654,8 +2796,11 @@ static bool test_err_load_schema_invalid_value_bitfield_4( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2706,8 +2851,11 @@ static bool test_err_load_schema_invalid_value_bitfield_5( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2758,8 +2906,11 @@ static bool test_err_load_schema_invalid_value_bitfield_6( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2810,8 +2961,11 @@ static bool test_err_load_schema_bad_bitfield( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2862,8 +3016,11 @@ static bool test_err_save_schema_bad_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); @@ -2910,8 +3067,11 @@ static bool test_err_load_schema_invalid_value_float_range1( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2958,8 +3118,11 @@ static bool test_err_load_schema_invalid_value_float_range2( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3006,8 +3169,11 @@ static bool test_err_load_schema_invalid_value_float_range3( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3054,8 +3220,11 @@ static bool test_err_load_schema_invalid_value_float_range4( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3101,8 +3270,11 @@ static bool test_err_load_schema_invalid_value_float_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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3149,8 +3321,11 @@ static bool test_err_load_schema_invalid_value_double_range1( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3197,8 +3372,11 @@ static bool test_err_load_schema_invalid_value_double_range2( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3244,8 +3422,11 @@ static bool test_err_load_schema_invalid_value_double_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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3291,8 +3472,11 @@ static bool test_err_load_schema_invalid_value_int_range_1( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3338,8 +3522,11 @@ static bool test_err_load_schema_invalid_value_int_range_2( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3385,8 +3572,11 @@ static bool test_err_load_schema_invalid_value_int_range_3( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3432,8 +3622,11 @@ static bool test_err_load_schema_invalid_value_int_range_4( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3479,8 +3672,11 @@ static bool test_err_load_schema_invalid_value_int_range_5( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3526,8 +3722,11 @@ static bool test_err_load_schema_invalid_value_uint_range_1( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3573,8 +3772,11 @@ static bool test_err_load_schema_invalid_value_uint_range_2( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3620,8 +3822,11 @@ static bool test_err_load_schema_invalid_value_uint_range_3( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3667,8 +3872,11 @@ static bool test_err_load_schema_invalid_value_uint_range_4( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3714,8 +3922,11 @@ static bool test_err_load_schema_invalid_value_uint_range_5( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3761,8 +3972,11 @@ static bool test_err_load_schema_string_min_length( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3808,8 +4022,11 @@ static bool test_err_load_schema_string_max_length( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3856,8 +4073,11 @@ static bool test_err_load_schema_duplicate_mapping_field( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3902,8 +4122,11 @@ static bool test_err_load_schema_missing_mapping_field( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3949,8 +4172,11 @@ static bool test_err_load_schema_unknown_mapping_field( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4003,8 +4229,11 @@ static bool test_err_load_schema_sequence_min_entries( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4058,8 +4287,11 @@ static bool test_err_load_schema_sequence_max_entries( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4127,8 +4359,11 @@ static bool test_err_load_schema_flags_mapping( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4186,8 +4421,11 @@ static bool test_err_load_schema_enum_bad_string( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4253,8 +4491,11 @@ static bool test_err_load_schema_flags_bad_string( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4313,8 +4554,11 @@ static bool test_err_save_schema_strict_enum_bad_value( .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); @@ -4372,8 +4616,11 @@ static bool test_err_load_schema_strict_enum_bad_string( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4438,8 +4685,11 @@ static bool test_err_save_schema_strict_flags_bad_value( .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); @@ -4505,8 +4755,11 @@ static bool test_err_load_schema_strict_flags_bad_string( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4553,8 +4806,11 @@ static bool test_err_load_schema_expect_int_read_seq( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4600,8 +4856,11 @@ static bool test_err_load_schema_expect_int_read_end_1( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4648,8 +4907,11 @@ static bool test_err_load_schema_expect_int_read_end_2( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4704,8 +4966,11 @@ static bool test_err_load_schema_expect_flags_read_scalar( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4759,8 +5024,11 @@ static bool test_err_load_schema_expect_mapping_read_scalar( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4811,8 +5079,11 @@ static bool test_err_load_schema_expect_sequence_read_scalar( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4838,7 +5109,11 @@ static bool test_err_free_null( ttest_report_ctx_t *report, const cyaml_config_t *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; + } UNUSED(config); @@ -4977,8 +5252,11 @@ static bool test_err_load_alloc_oom_1( struct test_cyaml_mem_ctx mem_ctx = { .required = 0, }; + 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; + } /* * First we load the YAML with the counting allocation function, @@ -5136,8 +5414,11 @@ static bool test_err_load_alloc_oom_2( .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; + } /* * First we load the YAML with the counting allocation function, @@ -5252,8 +5533,11 @@ static bool test_err_save_alloc_oom_1( .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; + } /* First we load the YAML, so we have something to test saving. */ err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, @@ -5404,8 +5688,11 @@ static bool test_err_save_alloc_oom_2( .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; + } /* First we load the YAML, so we have something to test saving. */ err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, @@ -5512,7 +5799,9 @@ static bool test_err_load_flag_value_alias( cfg.flags |= CYAML_CFG_NO_ALIAS; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5583,7 +5872,9 @@ static bool test_err_load_bitfield_value_alias_1( cfg.flags |= CYAML_CFG_NO_ALIAS; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5654,7 +5945,9 @@ static bool test_err_load_bitfield_value_alias_2( cfg.flags |= CYAML_CFG_NO_ALIAS; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5714,7 +6007,9 @@ static bool test_err_load_mapping_key_alias( cfg.flags |= CYAML_CFG_NO_ALIAS; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5774,7 +6069,9 @@ static bool test_err_load_mapping_value_alias_1( cfg.flags |= CYAML_CFG_NO_ALIAS; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5831,7 +6128,9 @@ static bool test_err_load_mapping_value_alias_2( cfg.flags |= CYAML_CFG_NO_ALIAS | CYAML_CFG_IGNORE_UNKNOWN_KEYS; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5885,7 +6184,9 @@ static bool test_err_load_mapping_value_alias_3( cfg.flags |= CYAML_CFG_NO_ALIAS; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5934,8 +6235,11 @@ static bool test_err_load_invalid_alias( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5996,8 +6300,11 @@ static bool test_err_load_incomplete_alias( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -6008,6 +6315,239 @@ static bool test_err_load_incomplete_alias( return ttest_pass(&tc); } +/** Structure for log messages checking. */ +struct log_check { + unsigned string_count_expected; /**< Number of expected log messages. */ + const char *const *strings; /**< Array of expected log messages. */ + unsigned string_count; /**< Number of log messages captured. */ + bool error; /**< Whether a logging error has been found. */ +}; + +/** + * Initialise a log check structure for a given log string vector. + * + * \param[in] lc The log check structure to initialise. + * \param[in] strv A string vector containing expected log messages. + * \return true on success, false otherwise. + */ +static inline bool log_check_init( + struct log_check *lc, + const char *const *strv) +{ + if (lc == NULL) { + return false; + } + + lc->string_count_expected = 0; + lc->string_count = 0; + lc->strings = strv; + lc->error = false; + + while (strv[lc->string_count_expected] != NULL) { + lc->string_count_expected++; + } + + return true; +} + +static struct log_check lc; + +/** + * CYAML log function, for checking logs. + * + * Uses the lc static state. + * + * \param[in] level Log level of message to log. + * \param[in] ctx Client's private logging context. + * \param[in] fmt Format string for message to log. + * \param[in] args Additional arguments used by fmt. + */ +static void cyaml_log_check( + cyaml_log_t level, + void *ctx, + const char *fmt, + va_list args) +{ + int ret; + size_t len; + char buffer[128]; + + (void)(ctx); + + if (level < CYAML_LOG_ERROR) { + /* We only care that critical log messages emerge. */ + return; + } + + ret = vsnprintf(buffer, sizeof(buffer), fmt, args); + if (ret <= 0) { + fprintf(stderr, "TEST ERROR: Logging error\n"); + return; + } + len = (unsigned)ret; + if (len >= sizeof(buffer)) { + fprintf(stderr, "TEST ERROR: Buffer too small\n"); + assert(len < sizeof(buffer)); + return; + } + + if (lc.string_count >= lc.string_count_expected) { + fprintf(stderr, "ERROR: More log messages than expected\n"); + fprintf(stderr, " got: %s", buffer); + lc.error |= true; + goto out; + } + + if (strcmp(lc.strings[lc.string_count], buffer) != 0) { + fprintf(stderr, "ERROR: Unexpected log message\n"); + fprintf(stderr, " got: %s", buffer); + fprintf(stderr, "expected: %s", lc.strings[lc.string_count]); + lc.error |= true; + goto out; + } + +out: + lc.string_count++; +} + +/** + * Check that the logging contains the expected information. + * + * \param[in] report The test report context. + * \param[in] config The CYAML config to use for the test. + * \return true if test passes, false otherwise. + */ +static bool test_err_load_log( + ttest_report_ctx_t *report, + const cyaml_config_t *config) +{ + enum test_f { + NONE = 0, + FIRST = (1 << 0), + SECOND = (1 << 1), + THIRD = (1 << 2), + FOURTH = (1 << 3), + }; + static const char * const expected_log[] = { + "Load: Invalid INT value: 'foo'\n", + "Load: Backtrace:\n", + " in sequence entry '2' (line: 5, column: 26)\n", + " in mapping field 'position' (line: 5, column: 17)\n", + " in sequence entry '1' (line: 2, column: 5)\n", + " in mapping field 'animals' (line: 23, column: 3)\n", + NULL + }; + static const cyaml_strval_t strings[] = { + { "first", (1 << 0) }, + { "second", (1 << 1) }, + { "third", (1 << 2) }, + { "fourth", (1 << 3) }, + }; + cyaml_config_t cfg = *config; + static const unsigned char yaml[] = + "anchors:\n" + " - &a1 {\n" + " kind: cat,\n" + " sound: meow,\n" + " position: &a2 [ 1, &my_value foo, 1],\n" + " flags: &a3 [\n" + " first,\n" + " &a4 second,\n" + " third,\n" + " fourth,\n" + " ]\n" + " }\n" + " - kind: snake\n" + " sound: &a5 hiss\n" + " position: &a6 [ 3, 1, 0]\n" + " flags: &a7 [\n" + " first,\n" + " second,\n" + " third,\n" + " fourth,\n" + " ]\n" + "animals:\n" + " - *a1\n" + " - kind: snake\n" + " sound: *a5\n" + " position: *a6\n" + " flags: *a7\n" + " value: *my_value\n"; + struct animal_s { + char *kind; + char *sound; + int **position; + unsigned position_count; + enum test_f *flags; + int value; + }; + struct target_struct { + struct animal_s **animal; + uint32_t animal_count; + } *data_tgt = NULL; + static const struct cyaml_schema_value position_entry_schema = { + CYAML_VALUE_INT(CYAML_FLAG_POINTER, int), + }; + static const struct cyaml_schema_field animal_schema[] = { + CYAML_FIELD_STRING_PTR("kind", CYAML_FLAG_POINTER, + struct animal_s, kind, 0, CYAML_UNLIMITED), + CYAML_FIELD_STRING_PTR("sound", CYAML_FLAG_POINTER, + struct animal_s, sound, 0, CYAML_UNLIMITED), + CYAML_FIELD_SEQUENCE("position", CYAML_FLAG_POINTER, + struct animal_s, position, + &position_entry_schema, 0, CYAML_UNLIMITED), + CYAML_FIELD_FLAGS("flags", + CYAML_FLAG_STRICT | CYAML_FLAG_POINTER, + struct animal_s, flags, strings, 4), + CYAML_FIELD_INT("value", CYAML_FLAG_OPTIONAL, + struct animal_s, value), + CYAML_FIELD_END + }; + static const struct cyaml_schema_value animal_entry_schema = { + CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, **(data_tgt->animal), + animal_schema), + }; + static const struct cyaml_schema_field mapping_schema[] = { + CYAML_FIELD_IGNORE("anchors", CYAML_FLAG_OPTIONAL), + CYAML_FIELD_SEQUENCE("animals", CYAML_FLAG_POINTER, + struct target_struct, animal, + &animal_entry_schema, 0, CYAML_UNLIMITED), + CYAML_FIELD_END + }; + static const struct cyaml_schema_value top_schema = { + CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, + struct target_struct, mapping_schema), + }; + test_data_t td = { + .data = (cyaml_data_t **) &data_tgt, + .config = &cfg, + .schema = &top_schema, + }; + cyaml_err_t err; + ttest_ctx_t tc; + + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } + + log_check_init(&lc, expected_log); + cfg.log_fn = cyaml_log_check; + err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, + (cyaml_data_t **) &data_tgt, NULL); + if (err == CYAML_OK) { + return ttest_fail(&tc, cyaml_strerror(err)); + } + + if (lc.error == true) { + return ttest_fail(&tc, "Unexpected log message"); + } + if (lc.string_count_expected > lc.string_count) { + return ttest_fail(&tc, "Missing log message(s)"); + } + + return ttest_pass(&tc); +} + /** * Run the CYAML error unit tests. * @@ -6154,6 +6694,7 @@ bool errs_tests( ttest_heading(rc, "Memory allocation handling tests"); + pass &= test_err_load_log(rc, &config); pass &= test_err_free_null(rc, &config); pass &= test_err_load_alloc_oom_1(rc, &config); pass &= test_err_load_alloc_oom_2(rc, &config); diff --git a/test/units/file.c b/test/units/file.c index 4f9e4a7..f7b8f08 100644 --- a/test/units/file.c +++ b/test/units/file.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: ISC * - * Copyright (C) 2018 Michael Drake + * Copyright (C) 2018-2021 Michael Drake */ #include @@ -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( .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( .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( .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( .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( .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) { diff --git a/test/units/free.c b/test/units/free.c index 9bac03b..b0721d4 100644 --- a/test/units/free.c +++ b/test/units/free.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: ISC * - * Copyright (C) 2017-2018 Michael Drake + * Copyright (C) 2017-2021 Michael Drake */ #include @@ -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( 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( { 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( 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) { diff --git a/test/units/load.c b/test/units/load.c index dfb8cb4..579b4a4 100644 --- a/test/units/load.c +++ b/test/units/load.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: ISC * - * Copyright (C) 2017-2019 Michael Drake + * Copyright (C) 2017-2021 Michael Drake */ #include @@ -82,8 +82,11 @@ static bool test_load_mapping_entry_int_pos( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -130,8 +133,11 @@ static bool test_load_mapping_entry_int_neg( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -178,8 +184,11 @@ static bool test_load_mapping_entry_int_pos_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -226,8 +235,11 @@ static bool test_load_mapping_entry_int_neg_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -274,8 +286,11 @@ static bool test_load_mapping_entry_uint( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -322,8 +337,11 @@ static bool test_load_mapping_entry_uint_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -370,8 +388,11 @@ static bool test_load_mapping_entry_float( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -420,8 +441,11 @@ static bool test_load_mapping_entry_float_underflow( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -470,8 +494,11 @@ static bool test_load_mapping_entry_float_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -520,8 +547,11 @@ static bool test_load_mapping_entry_double( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -570,8 +600,11 @@ static bool test_load_mapping_entry_double_underflow( .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; + } value *= 10; err = cyaml_load_data(yaml, YAML_LEN(yaml), config, &top_schema, @@ -621,8 +654,11 @@ static bool test_load_mapping_entry_double_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -671,8 +707,11 @@ static bool test_load_mapping_entry_bool_true( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -719,8 +758,11 @@ static bool test_load_mapping_entry_bool_false( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -767,8 +809,11 @@ static bool test_load_mapping_entry_bool_true_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -815,8 +860,11 @@ static bool test_load_mapping_entry_bool_false_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -874,8 +922,11 @@ static bool test_load_mapping_entry_enum( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -933,8 +984,11 @@ static bool test_load_mapping_entry_enum_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -993,8 +1047,11 @@ static bool test_load_mapping_entry_enum_sparse( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1053,8 +1110,11 @@ static bool test_load_mapping_entry_enum_fallback( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1101,8 +1161,11 @@ static bool test_load_mapping_entry_string( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1160,8 +1223,11 @@ static bool test_load_mapping_entry_string_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1209,8 +1275,11 @@ static bool test_load_mapping_entry_string_ptr_empty( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1259,8 +1328,11 @@ static bool test_load_mapping_entry_string_ptr_null_str( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1308,8 +1380,11 @@ static bool test_load_mapping_entry_string_ptr_null_empty( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1358,8 +1433,11 @@ static bool test_load_mapping_entry_ignore_deep( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1404,8 +1482,11 @@ static bool test_load_mapping_entry_ignore_scalar( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1473,8 +1554,11 @@ static bool test_load_mapping_entry_flags( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1544,8 +1628,11 @@ static bool test_load_mapping_entry_flags_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1612,8 +1699,11 @@ static bool test_load_mapping_entry_flags_empty( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1682,8 +1772,11 @@ static bool test_load_mapping_entry_flags_sparse( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1745,8 +1838,11 @@ static bool test_load_mapping_entry_bitfield( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1808,8 +1904,11 @@ static bool test_load_mapping_entry_bitfield_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1875,7 +1974,9 @@ static bool test_load_mapping_entry_mapping( value.a = 123; value.b = 9999; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1939,7 +2040,9 @@ static bool test_load_mapping_entry_mapping_ptr( value.a = 123; value.b = 9999; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -1997,8 +2100,11 @@ static bool test_load_mapping_entry_sequence_int( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2072,8 +2178,11 @@ static bool test_load_mapping_entry_sequence_enum( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2139,8 +2248,11 @@ static bool test_load_mapping_entry_sequence_uint( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2208,8 +2320,11 @@ static bool test_load_mapping_entry_sequence_bool( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2297,8 +2412,11 @@ static bool test_load_mapping_entry_sequence_flags( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2369,8 +2487,11 @@ static bool test_load_mapping_entry_sequence_string( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2440,8 +2561,11 @@ static bool test_load_mapping_entry_sequence_string_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2524,7 +2648,9 @@ static bool test_load_mapping_entry_sequence_mapping( ref[2].a = 1; ref[2].b = 765; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2599,8 +2725,11 @@ static bool test_load_mapping_entry_sequence_mapping_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2675,8 +2804,11 @@ static bool test_load_mapping_entry_sequence_sequence_fixed_int( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2756,8 +2888,11 @@ static bool test_load_mapping_entry_sequence_sequence_fixed_ptr_int( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2850,8 +2985,11 @@ static bool test_load_mapping_entry_sequence_sequence_fixed_flat_int( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -2926,8 +3064,11 @@ static bool test_load_mapping_entry_sequence_ptr_int( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3001,8 +3142,11 @@ static bool test_load_mapping_entry_sequence_ptr_enum( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3068,8 +3212,11 @@ static bool test_load_mapping_entry_sequence_ptr_uint( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3137,8 +3284,11 @@ static bool test_load_mapping_entry_sequence_ptr_bool( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3226,8 +3376,11 @@ static bool test_load_mapping_entry_sequence_ptr_flags( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3298,8 +3451,11 @@ static bool test_load_mapping_entry_sequence_ptr_string( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3370,8 +3526,11 @@ static bool test_load_mapping_entry_sequence_ptr_string_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3448,8 +3607,11 @@ static bool test_load_mapping_entry_sequence_ptr_mapping( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3530,8 +3692,11 @@ static bool test_load_mapping_entry_sequence_ptr_mapping_ptr( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3607,8 +3772,11 @@ static bool test_load_mapping_entry_sequence_ptr_sequence_fixed_int( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3689,8 +3857,11 @@ static bool test_load_mapping_entry_sequence_ptr_sequence_fixed_ptr_int( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3784,8 +3955,11 @@ static bool test_load_mapping_entry_sequence_ptr_sequence_fixed_flat_int( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -3859,8 +4033,11 @@ static bool test_load_sequence_null_str_values_int( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &value, &count); @@ -3937,8 +4114,11 @@ static bool test_load_sequence_null_values_int( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &value, &count); @@ -4016,8 +4196,11 @@ static bool test_load_sequence_null_str_values_uint( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &value, &count); @@ -4113,8 +4296,11 @@ static bool test_load_sequence_null_str_values_mapping( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &value, &count); @@ -4193,8 +4379,11 @@ static bool test_load_mapping_entry_sequence_count_1( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4261,8 +4450,11 @@ static bool test_load_mapping_entry_sequence_count_2( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4329,8 +4521,11 @@ static bool test_load_mapping_entry_sequence_count_3( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4397,8 +4592,11 @@ static bool test_load_mapping_entry_sequence_count_4( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4465,8 +4663,11 @@ static bool test_load_mapping_entry_sequence_count_5( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4533,8 +4734,11 @@ static bool test_load_mapping_entry_sequence_count_6( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4601,8 +4805,11 @@ static bool test_load_mapping_entry_sequence_count_7( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4669,8 +4876,11 @@ static bool test_load_mapping_entry_sequence_count_8( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4717,8 +4927,11 @@ static bool test_load_schema_top_level_scalar( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &value, NULL); @@ -4760,8 +4973,11 @@ static bool test_load_schema_top_level_string( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &value, NULL); @@ -4811,8 +5027,11 @@ static bool test_load_schema_top_level_sequence( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &value, &count); @@ -4864,8 +5083,11 @@ static bool test_load_schema_top_level_sequence_fixed( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &value, NULL); @@ -4920,8 +5142,11 @@ static bool test_load_multiple_documents_ignored( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -4990,8 +5215,11 @@ static bool test_load_mapping_with_multiple_fields( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5110,8 +5338,11 @@ static bool test_load_mapping_with_optional_fields( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5205,8 +5436,11 @@ static bool test_load_mapping_only_optional_fields( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5251,8 +5485,11 @@ static bool test_load_mapping_without_any_fields( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5265,7 +5502,7 @@ static bool test_load_mapping_without_any_fields( } if (data_tgt->i != 0) { - return ttest_fail(&tc, "Value should be initialied to 0"); + return ttest_fail(&tc, "Value should be initialised to 0"); } return ttest_pass(&tc); @@ -5323,8 +5560,11 @@ static bool test_load_mapping_ignored_unknown_keys( .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; + } cfg.flags |= CYAML_CFG_IGNORE_UNKNOWN_KEYS; err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, @@ -5390,8 +5630,11 @@ static bool test_load_sequence_without_max_entries( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5464,7 +5707,9 @@ static bool test_load_no_log( ttest_ctx_t tc; cfg.log_fn = NULL; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5527,8 +5772,11 @@ static bool test_load_duplicate_ignored( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5586,8 +5834,11 @@ static bool test_load_schema_sequence_entry_count_member( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5649,7 +5900,9 @@ static bool test_load_enum_insensitive( ttest_ctx_t tc; cfg.flags |= CYAML_CFG_CASE_INSENSITIVE; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5703,7 +5956,9 @@ static bool test_load_flags_insensitive( ttest_ctx_t tc; cfg.flags |= CYAML_CFG_CASE_INSENSITIVE; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5776,7 +6031,9 @@ static bool test_load_mapping_fields_cfg_insensitive_1( ttest_ctx_t tc; cfg.flags |= CYAML_CFG_CASE_INSENSITIVE; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5861,7 +6118,9 @@ static bool test_load_mapping_fields_cfg_insensitive_2( ttest_ctx_t tc; cfg.flags |= CYAML_CFG_CASE_INSENSITIVE; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -5946,7 +6205,9 @@ static bool test_load_mapping_fields_cfg_insensitive_3( ttest_ctx_t tc; cfg.flags |= CYAML_CFG_CASE_INSENSITIVE; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -6032,7 +6293,9 @@ static bool test_load_mapping_fields_value_sensitive_1( ttest_ctx_t tc; cfg.flags |= CYAML_CFG_CASE_INSENSITIVE; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -6119,7 +6382,9 @@ static bool test_load_mapping_fields_value_insensitive_1( ttest_ctx_t tc; cfg.flags |= CYAML_CFG_CASE_INSENSITIVE; - tc = ttest_start(report, __func__, cyaml_cleanup, &td); + if (!ttest_start(report, __func__, cyaml_cleanup, &td, &tc)) { + return true; + } err = cyaml_load_data(yaml, YAML_LEN(yaml), &cfg, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -6184,8 +6449,11 @@ static bool test_load_unused_anchor( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -6244,8 +6512,11 @@ static bool test_load_anchor_scalar_int( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -6304,8 +6575,11 @@ static bool test_load_anchor_scalar_string( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -6373,8 +6647,11 @@ static bool test_load_anchor_multiple_scalars( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -6456,8 +6733,11 @@ static bool test_load_anchor_mapping( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -6526,8 +6806,11 @@ static bool test_load_anchor_sequence( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -6624,8 +6907,11 @@ static bool test_load_anchor_deep_mapping_sequence( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); @@ -6714,8 +7000,11 @@ static bool test_load_anchor_updated_anchor( .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_data(yaml, YAML_LEN(yaml), config, &top_schema, (cyaml_data_t **) &data_tgt, NULL); diff --git a/test/units/save.c b/test/units/save.c index 4c9b8d5..eb96423 100644 --- a/test/units/save.c +++ b/test/units/save.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: ISC * - * Copyright (C) 2018-2019 Michael Drake + * Copyright (C) 2018-2021 Michael Drake */ #include @@ -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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( .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( 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( 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( .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( 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( 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( .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( .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( .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); diff --git a/test/units/test.c b/test/units/test.c index ec655bb..4fc35c1 100644 --- a/test/units/test.c +++ b/test/units/test.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: ISC * - * Copyright (C) 2017-2018 Michael Drake + * Copyright (C) 2017-2021 Michael Drake */ #include @@ -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[]) 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); diff --git a/test/units/ttest.h b/test/units/ttest.h index 9c0c283..5d9d3af 100644 --- a/test/units/ttest.h +++ b/test/units/ttest.h @@ -1,12 +1,14 @@ /* * SPDX-License-Identifier: ISC * - * Copyright (C) 2013 Michael Drake + * Copyright (C) 2013-2019 Michael Drake */ #ifndef TTEST_H #define TTEST_H +#include + /** * Test cleanup client callback. * @@ -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 { /** * 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. + */ +static inline bool ttest__run_test( + ttest_report_ctx_t *report, + const char *name) +{ + size_t len; + size_t pos = 0; + size_t name_len; + + if (report->test_list == NULL || report->test_list_len == 0) { + return true; + } + + name_len = strlen(name); + while (pos < report->test_list_len) { + /* Skip commas and spaces. */ + pos += strspn(report->test_list + pos, ", "); + + len = strcspn(report->test_list + pos, ", "); + if (len == name_len) { + if (memcmp(report->test_list + pos, name, len) == 0) { + return true; + } + } + pos += len; + } + + return false; +} + /** * Start a unit test. * @@ -72,14 +122,17 @@ static inline ttest_report_ctx_t ttest_init( * \param[in] name Name for this unit test. * \param[in] cleanup Cleanup function to call on test completion. * \param[in] cleanup_data Pointer to client cleanup context. - * \return Returns the unit test context. The test context must be passed to - * the test completion function. + * \param[out] test_ctx_out Returns the unit test context on success. + * The test context must be passed to the test + * completion function. + * \return true if the test should be started, false otherwise. */ -static inline ttest_ctx_t ttest_start( +static inline bool ttest_start( ttest_report_ctx_t *report, const char *name, ttest_cleanup_fn cleanup, - void *cleanup_data) + void *cleanup_data, + ttest_ctx_t *test_ctx_out) { ttest_ctx_t tc = { .name = name, @@ -88,9 +141,14 @@ static inline ttest_ctx_t ttest_start( .cleanup_data = cleanup_data, }; + if (!ttest__run_test(report, name)) { + return false; + } + report->tests++; - return tc; + *test_ctx_out = tc; + return true; } /** @@ -203,10 +261,12 @@ static inline void ttest_heading( const ttest_report_ctx_t *tr, const char *heading) { - if (!tr->quiet) { - ttest_divider(); - fprintf(stderr, "TEST: %s\n", heading); - ttest_divider(); + if (tr->test_list == NULL || tr->test_list_len == 0) { + if (!tr->quiet) { + ttest_divider(); + fprintf(stderr, "TEST: %s\n", heading); + ttest_divider(); + } } } diff --git a/test/units/utf8.c b/test/units/utf8.c index b20e455..e31608c 100644 --- a/test/units/utf8.c +++ b/test/units/utf8.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: ISC * - * Copyright (C) 2018 Michael Drake + * Copyright (C) 2018-2021 Michael Drake */ #include @@ -50,7 +50,9 @@ static bool test_utf8_get_codepoint( char name[sizeof(__func__) + 32]; sprintf(name, "%s_%u", __func__, i); - tc = ttest_start(report, name, NULL, NULL); + if (!ttest_start(report, name, NULL, NULL, &tc)) { + continue; + } l = t[i].l; c = cyaml_utf8_get_codepoint((uint8_t *)t[i].s, &l); @@ -97,7 +99,9 @@ static bool test_utf8_strcmp_same( char name[sizeof(__func__) + 32]; sprintf(name, "%s_%u", __func__, i); - tc = ttest_start(report, name, NULL, NULL); + if (!ttest_start(report, name, NULL, NULL, &tc)) { + continue; + } if (cyaml_utf8_casecmp(strings[i], strings[i]) != 0) { pass &= ttest_fail(&tc, "Failed to match: %s", @@ -183,7 +187,9 @@ static bool test_utf8_strcmp_matches( char name[sizeof(__func__) + 32]; sprintf(name, "%s_%u", __func__, i); - tc = ttest_start(report, name, NULL, NULL); + if (!ttest_start(report, name, NULL, NULL, &tc)) { + continue; + } if (cyaml_utf8_casecmp(pairs[i].a, pairs[i].b) != 0) { pass &= ttest_fail(&tc, "Failed to match strings: " @@ -226,7 +232,9 @@ static bool test_utf8_strcmp_mismatches( char name[sizeof(__func__) + 32]; sprintf(name, "%s_%u", __func__, i); - tc = ttest_start(report, name, NULL, NULL); + if (!ttest_start(report, name, NULL, NULL, &tc)) { + continue; + } if (cyaml_utf8_casecmp(pairs[i].a, pairs[i].b) == 0) { pass &= ttest_fail(&tc, "Failed to detect mismatch: " diff --git a/test/units/util.c b/test/units/util.c index 2221add..b000d62 100644 --- a/test/units/util.c +++ b/test/units/util.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: ISC * - * Copyright (C) 2018 Michael Drake + * Copyright (C) 2018-2021 Michael Drake */ #include @@ -28,9 +28,11 @@ static bool test_util_memory_funcs( ttest_report_ctx_t *report, const cyaml_config_t *config) { - ttest_ctx_t tc = ttest_start(report, __func__, NULL, NULL); + ttest_ctx_t tc; unsigned char *mem, *tmp; + if (!ttest_start(report, __func__, NULL, NULL, &tc)) return true; + /* Create test allocation */ mem = cyaml__alloc(config, 0xff, true); if (mem == NULL) { @@ -80,10 +82,12 @@ static bool test_util_strdup( ttest_report_ctx_t *report, const cyaml_config_t *config) { - ttest_ctx_t tc = ttest_start(report, __func__, NULL, NULL); + ttest_ctx_t tc; const char *orig = "Hello!"; char *copy; + if (!ttest_start(report, __func__, NULL, NULL, &tc)) return true; + /* Create test allocation */ copy = cyaml__strdup(config, orig, NULL); if (copy == NULL) { @@ -112,11 +116,13 @@ static bool test_util_strdup_len( ttest_report_ctx_t *report, const cyaml_config_t *config) { - ttest_ctx_t tc = ttest_start(report, __func__, NULL, NULL); + ttest_ctx_t tc; const char *orig = "Hello!"; char *copy; size_t len; + if (!ttest_start(report, __func__, NULL, NULL, &tc)) return true; + /* Create test allocation */ copy = cyaml__strdup(config, orig, &len); if (copy == NULL) { @@ -148,7 +154,9 @@ static bool test_util_strdup_len( static bool test_util_state_invalid( ttest_report_ctx_t *report) { - ttest_ctx_t tc = ttest_start(report, __func__, NULL, NULL); + ttest_ctx_t tc; + + if (!ttest_start(report, __func__, NULL, NULL, &tc)) return true; if (strcmp(cyaml__state_to_str(CYAML_STATE__COUNT), "") != 0) { @@ -172,7 +180,9 @@ static bool test_util_state_invalid( static bool test_util_err_success_zero( ttest_report_ctx_t *report) { - ttest_ctx_t tc = ttest_start(report, __func__, NULL, NULL); + ttest_ctx_t tc; + + if (!ttest_start(report, __func__, NULL, NULL, &tc)) return true; if (CYAML_OK != 0) { return ttest_fail(&tc, "CYAML_OK value not zero"); @@ -190,7 +200,9 @@ static bool test_util_err_success_zero( static bool test_util_err_strings_valid( ttest_report_ctx_t *report) { - ttest_ctx_t tc = ttest_start(report, __func__, NULL, NULL); + ttest_ctx_t tc; + + if (!ttest_start(report, __func__, NULL, NULL, &tc)) return true; if (cyaml_strerror(CYAML_OK) == NULL) { return ttest_fail(&tc, "CYAML_OK string is NULL"); @@ -227,7 +239,9 @@ static bool test_util_err_strings_valid( static bool test_util_err_strings_invalid( ttest_report_ctx_t *report) { - ttest_ctx_t tc = ttest_start(report, __func__, NULL, NULL); + ttest_ctx_t tc; + + if (!ttest_start(report, __func__, NULL, NULL, &tc)) return true; if (strcmp(cyaml_strerror(CYAML_ERR__COUNT), "Invalid error code") != 0) { -- 2.45.2