2016-08-04 05:24:46 +00:00
|
|
|
##########################################################################
|
|
|
|
# unit tests
|
|
|
|
##########################################################################
|
|
|
|
|
|
|
|
# additional flags
|
2017-10-05 17:43:19 +00:00
|
|
|
CXXFLAGS += -std=c++11 -Wall -Wextra -pedantic -Wcast-align -Wcast-qual -Wno-ctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wno-float-equal
|
2019-01-13 16:41:21 +00:00
|
|
|
CPPFLAGS += -I ../single_include -I . -I thirdparty/doctest -I thirdparty/fifo_map -DDOCTEST_CONFIG_SUPER_FAST_ASSERTS
|
2016-08-04 05:24:46 +00:00
|
|
|
|
2016-08-04 19:55:47 +00:00
|
|
|
SOURCES = src/unit.cpp \
|
|
|
|
src/unit-algorithms.cpp \
|
|
|
|
src/unit-allocator.cpp \
|
2018-03-12 18:15:11 +00:00
|
|
|
src/unit-alt-string.cpp \
|
2018-10-24 13:43:37 +00:00
|
|
|
src/unit-bson.cpp \
|
2016-08-04 19:55:47 +00:00
|
|
|
src/unit-capacity.cpp \
|
2016-11-26 23:09:24 +00:00
|
|
|
src/unit-cbor.cpp \
|
2016-08-04 19:55:47 +00:00
|
|
|
src/unit-class_const_iterator.cpp \
|
|
|
|
src/unit-class_iterator.cpp \
|
|
|
|
src/unit-class_lexer.cpp \
|
|
|
|
src/unit-class_parser.cpp \
|
|
|
|
src/unit-comparison.cpp \
|
|
|
|
src/unit-concepts.cpp \
|
2016-08-04 20:51:08 +00:00
|
|
|
src/unit-constructor1.cpp \
|
|
|
|
src/unit-constructor2.cpp \
|
2016-08-04 19:55:47 +00:00
|
|
|
src/unit-convenience.cpp \
|
|
|
|
src/unit-conversions.cpp \
|
|
|
|
src/unit-deserialization.cpp \
|
2016-08-04 20:51:08 +00:00
|
|
|
src/unit-element_access1.cpp \
|
|
|
|
src/unit-element_access2.cpp \
|
2016-08-04 19:55:47 +00:00
|
|
|
src/unit-inspection.cpp \
|
2018-01-23 15:33:08 +00:00
|
|
|
src/unit-items.cpp \
|
2016-08-04 20:51:08 +00:00
|
|
|
src/unit-iterators1.cpp \
|
|
|
|
src/unit-iterators2.cpp \
|
2017-12-13 22:36:22 +00:00
|
|
|
src/unit-merge_patch.cpp \
|
2016-08-04 19:55:47 +00:00
|
|
|
src/unit-json_patch.cpp \
|
|
|
|
src/unit-json_pointer.cpp \
|
2017-01-12 20:35:27 +00:00
|
|
|
src/unit-meta.cpp \
|
2016-08-04 19:55:47 +00:00
|
|
|
src/unit-modifiers.cpp \
|
2016-11-11 16:11:13 +00:00
|
|
|
src/unit-msgpack.cpp \
|
2016-08-04 19:55:47 +00:00
|
|
|
src/unit-pointer_access.cpp \
|
|
|
|
src/unit-readme.cpp \
|
|
|
|
src/unit-reference_access.cpp \
|
|
|
|
src/unit-regression.cpp \
|
|
|
|
src/unit-serialization.cpp \
|
2016-12-30 13:02:51 +00:00
|
|
|
src/unit-testsuites.cpp \
|
2018-01-07 21:09:12 +00:00
|
|
|
src/unit-ubjson.cpp \
|
2018-04-01 17:12:36 +00:00
|
|
|
src/unit-unicode.cpp \
|
|
|
|
src/unit-wstring.cpp
|
2016-08-04 19:55:47 +00:00
|
|
|
|
2016-08-04 05:24:46 +00:00
|
|
|
OBJECTS = $(SOURCES:.cpp=.o)
|
|
|
|
|
2016-11-27 15:19:26 +00:00
|
|
|
TESTCASES = $(patsubst src/unit-%.cpp,test-%,$(wildcard src/unit-*.cpp))
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# main rules
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
all: $(TESTCASES)
|
|
|
|
|
|
|
|
clean:
|
2018-01-27 17:38:11 +00:00
|
|
|
rm -fr json_unit $(OBJECTS) $(SOURCES:.cpp=.gcno) $(SOURCES:.cpp=.gcda) $(TESTCASES) $(FUZZERS)
|
2016-11-27 15:19:26 +00:00
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# single test file
|
|
|
|
##############################################################################
|
2016-08-04 05:24:46 +00:00
|
|
|
|
2019-01-13 16:41:21 +00:00
|
|
|
json_unit: $(OBJECTS) ../single_include/nlohmann/json.hpp thirdparty/doctest/doctest.h
|
2016-08-04 19:55:47 +00:00
|
|
|
@echo "[CXXLD] $@"
|
|
|
|
@$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJECTS) -o $@
|
2016-08-04 05:24:46 +00:00
|
|
|
|
2019-01-13 16:41:21 +00:00
|
|
|
%.o: %.cpp ../single_include/nlohmann/json.hpp thirdparty/doctest/doctest.h
|
2016-08-04 19:55:47 +00:00
|
|
|
@echo "[CXX] $@"
|
|
|
|
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
|
2016-08-04 05:24:46 +00:00
|
|
|
|
2016-11-27 15:19:26 +00:00
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# individual test cases
|
|
|
|
##############################################################################
|
|
|
|
|
2019-01-13 16:41:21 +00:00
|
|
|
test-%: src/unit-%.o src/unit.o ../single_include/nlohmann/json.hpp thirdparty/doctest/doctest.h
|
2016-11-27 15:19:26 +00:00
|
|
|
@echo "[CXXLD] $@"
|
2017-02-04 07:25:55 +00:00
|
|
|
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $< src/unit.o -o $@
|
2016-11-27 15:19:26 +00:00
|
|
|
|
2017-01-16 21:11:07 +00:00
|
|
|
TEST_PATTERN ?= "*"
|
2016-11-27 15:19:26 +00:00
|
|
|
TEST_PREFIX = ""
|
2017-08-14 18:45:33 +00:00
|
|
|
check: $(OBJECTS) $(TESTCASES)
|
2016-11-28 22:20:03 +00:00
|
|
|
@cd .. ; for testcase in $(TESTCASES); do echo "Executing $$testcase..."; $(TEST_PREFIX)test/$$testcase $(TEST_PATTERN) || exit 1; done
|
2016-12-22 10:09:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# fuzzer
|
|
|
|
##############################################################################
|
|
|
|
|
2017-01-03 21:35:31 +00:00
|
|
|
FUZZER_ENGINE = src/fuzzer-driver_afl.cpp
|
2018-10-24 13:43:37 +00:00
|
|
|
FUZZERS = parse_afl_fuzzer parse_bson_fuzzer parse_cbor_fuzzer parse_msgpack_fuzzer parse_ubjson_fuzzer
|
2018-01-27 17:38:11 +00:00
|
|
|
fuzzers: $(FUZZERS)
|
2017-01-01 20:51:36 +00:00
|
|
|
|
2016-12-22 10:09:26 +00:00
|
|
|
parse_afl_fuzzer:
|
2017-01-03 21:35:31 +00:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(FUZZER_ENGINE) src/fuzzer-parse_json.cpp -o $@
|
2016-12-22 11:08:36 +00:00
|
|
|
|
2018-10-24 13:43:37 +00:00
|
|
|
parse_bson_fuzzer:
|
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(FUZZER_ENGINE) src/fuzzer-parse_bson.cpp -o $@
|
|
|
|
|
2016-12-22 11:08:36 +00:00
|
|
|
parse_cbor_fuzzer:
|
2017-01-03 21:35:31 +00:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(FUZZER_ENGINE) src/fuzzer-parse_cbor.cpp -o $@
|
2016-12-25 15:18:56 +00:00
|
|
|
|
|
|
|
parse_msgpack_fuzzer:
|
2017-01-03 21:35:31 +00:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(FUZZER_ENGINE) src/fuzzer-parse_msgpack.cpp -o $@
|
2018-01-27 17:38:11 +00:00
|
|
|
|
|
|
|
parse_ubjson_fuzzer:
|
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(FUZZER_ENGINE) src/fuzzer-parse_ubjson.cpp -o $@
|