2016-08-04 08:24:46 +03:00
|
|
|
##########################################################################
|
|
|
|
# unit tests
|
|
|
|
##########################################################################
|
|
|
|
|
|
|
|
# additional flags
|
2017-10-05 20:43:19 +03: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
|
2017-06-20 21:13:56 +03:00
|
|
|
CPPFLAGS += -I ../src -I . -I thirdparty/catch -DCATCH_CONFIG_FAST_COMPILE
|
2016-08-04 08:24:46 +03:00
|
|
|
|
2016-08-04 22:55:47 +03:00
|
|
|
SOURCES = src/unit.cpp \
|
|
|
|
src/unit-algorithms.cpp \
|
|
|
|
src/unit-allocator.cpp \
|
|
|
|
src/unit-capacity.cpp \
|
2016-11-27 02:09:24 +03:00
|
|
|
src/unit-cbor.cpp \
|
2016-08-04 22:55:47 +03: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 23:51:08 +03:00
|
|
|
src/unit-constructor1.cpp \
|
|
|
|
src/unit-constructor2.cpp \
|
2016-08-04 22:55:47 +03:00
|
|
|
src/unit-convenience.cpp \
|
|
|
|
src/unit-conversions.cpp \
|
|
|
|
src/unit-deserialization.cpp \
|
2016-08-04 23:51:08 +03:00
|
|
|
src/unit-element_access1.cpp \
|
|
|
|
src/unit-element_access2.cpp \
|
2016-08-04 22:55:47 +03:00
|
|
|
src/unit-inspection.cpp \
|
|
|
|
src/unit-iterator_wrapper.cpp \
|
2016-08-04 23:51:08 +03:00
|
|
|
src/unit-iterators1.cpp \
|
|
|
|
src/unit-iterators2.cpp \
|
2016-08-04 22:55:47 +03:00
|
|
|
src/unit-json_patch.cpp \
|
|
|
|
src/unit-json_pointer.cpp \
|
2017-01-12 23:35:27 +03:00
|
|
|
src/unit-meta.cpp \
|
2016-08-04 22:55:47 +03:00
|
|
|
src/unit-modifiers.cpp \
|
2016-11-11 19:11:13 +03:00
|
|
|
src/unit-msgpack.cpp \
|
2016-08-04 22:55:47 +03: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 16:02:51 +03:00
|
|
|
src/unit-testsuites.cpp \
|
2017-01-12 23:35:27 +03:00
|
|
|
src/unit-unicode.cpp
|
2016-08-04 22:55:47 +03:00
|
|
|
|
2016-08-04 08:24:46 +03:00
|
|
|
OBJECTS = $(SOURCES:.cpp=.o)
|
|
|
|
|
2016-11-27 18:19:26 +03:00
|
|
|
TESTCASES = $(patsubst src/unit-%.cpp,test-%,$(wildcard src/unit-*.cpp))
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# main rules
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
all: $(TESTCASES)
|
|
|
|
|
|
|
|
clean:
|
2017-01-04 00:35:31 +03:00
|
|
|
rm -fr json_unit $(OBJECTS) $(SOURCES:.cpp=.gcno) $(SOURCES:.cpp=.gcda) $(TESTCASES) parse_afl_fuzzer parse_cbor_fuzzer parse_msgpack_fuzzer
|
2016-11-27 18:19:26 +03:00
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# single test file
|
|
|
|
##############################################################################
|
2016-08-04 08:24:46 +03:00
|
|
|
|
2016-12-22 11:35:53 +03:00
|
|
|
json_unit: $(OBJECTS) ../src/json.hpp thirdparty/catch/catch.hpp
|
2016-08-04 22:55:47 +03:00
|
|
|
@echo "[CXXLD] $@"
|
|
|
|
@$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJECTS) -o $@
|
2016-08-04 08:24:46 +03:00
|
|
|
|
2016-12-22 11:35:53 +03:00
|
|
|
%.o: %.cpp ../src/json.hpp thirdparty/catch/catch.hpp
|
2016-08-04 22:55:47 +03:00
|
|
|
@echo "[CXX] $@"
|
|
|
|
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
|
2016-08-04 08:24:46 +03:00
|
|
|
|
2016-11-27 18:19:26 +03:00
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# individual test cases
|
|
|
|
##############################################################################
|
|
|
|
|
2017-02-04 10:25:55 +03:00
|
|
|
test-%: src/unit-%.o src/unit.o ../src/json.hpp thirdparty/catch/catch.hpp
|
2016-11-27 18:19:26 +03:00
|
|
|
@echo "[CXXLD] $@"
|
2017-02-04 10:25:55 +03:00
|
|
|
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $< src/unit.o -o $@
|
2016-11-27 18:19:26 +03:00
|
|
|
|
2017-01-17 00:11:07 +03:00
|
|
|
TEST_PATTERN ?= "*"
|
2016-11-27 18:19:26 +03:00
|
|
|
TEST_PREFIX = ""
|
2017-08-14 21:45:33 +03:00
|
|
|
check: $(OBJECTS) $(TESTCASES)
|
2016-11-29 01:20:03 +03:00
|
|
|
@cd .. ; for testcase in $(TESTCASES); do echo "Executing $$testcase..."; $(TEST_PREFIX)test/$$testcase $(TEST_PATTERN) || exit 1; done
|
2016-12-22 13:09:26 +03:00
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# fuzzer
|
|
|
|
##############################################################################
|
|
|
|
|
2017-01-04 00:35:31 +03:00
|
|
|
FUZZER_ENGINE = src/fuzzer-driver_afl.cpp
|
2017-01-01 23:51:36 +03:00
|
|
|
fuzzers: parse_afl_fuzzer parse_cbor_fuzzer parse_msgpack_fuzzer
|
|
|
|
|
2016-12-22 13:09:26 +03:00
|
|
|
parse_afl_fuzzer:
|
2017-01-04 00:35:31 +03:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(FUZZER_ENGINE) src/fuzzer-parse_json.cpp -o $@
|
2016-12-22 14:08:36 +03:00
|
|
|
|
|
|
|
parse_cbor_fuzzer:
|
2017-01-04 00:35:31 +03:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(FUZZER_ENGINE) src/fuzzer-parse_cbor.cpp -o $@
|
2016-12-25 18:18:56 +03:00
|
|
|
|
|
|
|
parse_msgpack_fuzzer:
|
2017-01-04 00:35:31 +03:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(FUZZER_ENGINE) src/fuzzer-parse_msgpack.cpp -o $@
|