Makefile 3.6 KB
Newer Older
N
Niels 已提交
1 2 3 4 5
##########################################################################
# unit tests
##########################################################################

# additional flags
N
Niels 已提交
6
CXXFLAGS += -std=c++11 -Wall -Wextra -pedantic -Weffc++ -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
7
CPPFLAGS += -I ../src -I . -I thirdparty/catch
N
Niels 已提交
8

9 10 11 12
SOURCES = src/unit.cpp \
          src/unit-algorithms.cpp \
          src/unit-allocator.cpp \
          src/unit-capacity.cpp \
N
Niels Lohmann 已提交
13
          src/unit-cbor.cpp \
14 15 16 17 18 19
          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 \
N
Niels 已提交
20 21
          src/unit-constructor1.cpp \
          src/unit-constructor2.cpp \
22 23 24
          src/unit-convenience.cpp \
          src/unit-conversions.cpp \
          src/unit-deserialization.cpp \
N
Niels 已提交
25 26
          src/unit-element_access1.cpp \
          src/unit-element_access2.cpp \
27 28
          src/unit-inspection.cpp \
          src/unit-iterator_wrapper.cpp \
N
Niels 已提交
29 30
          src/unit-iterators1.cpp \
          src/unit-iterators2.cpp \
31 32 33
          src/unit-json_patch.cpp \
          src/unit-json_pointer.cpp \
          src/unit-modifiers.cpp \
N
Niels 已提交
34
          src/unit-msgpack.cpp \
35 36 37 38 39 40 41 42
          src/unit-pointer_access.cpp \
          src/unit-readme.cpp \
          src/unit-reference_access.cpp \
          src/unit-regression.cpp \
          src/unit-serialization.cpp \
          src/unit-unicode.cpp \
          src/unit-testsuites.cpp

N
Niels 已提交
43 44
OBJECTS = $(SOURCES:.cpp=.o)

45 46 47 48 49 50 51 52 53 54 55 56 57 58
TESTCASES = $(patsubst src/unit-%.cpp,test-%,$(wildcard src/unit-*.cpp))

##############################################################################
# main rules
##############################################################################

all: $(TESTCASES)

clean:
	rm -fr json_unit $(OBJECTS) $(SOURCES:.cpp=.gcno) $(SOURCES:.cpp=.gcda) $(TESTCASES)

##############################################################################
# single test file
##############################################################################
N
Niels 已提交
59

60
json_unit: $(OBJECTS) ../src/json.hpp thirdparty/catch/catch.hpp
61 62
	@echo "[CXXLD] $@"
	@$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJECTS) -o $@
N
Niels 已提交
63

64
%.o: %.cpp ../src/json.hpp thirdparty/catch/catch.hpp
65 66
	@echo "[CXX]   $@"
	@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
N
Niels 已提交
67

68 69 70 71 72

##############################################################################
# individual test cases
##############################################################################

73
test-%: src/unit-%.cpp ../src/json.hpp thirdparty/catch/catch.hpp
74 75 76 77 78 79
	@echo "[CXXLD] $@"
	@$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) -DCATCH_CONFIG_MAIN $< -o $@

TEST_PATTERN = "*"
TEST_PREFIX = ""
check: $(TESTCASES)
80
	@cd .. ; for testcase in $(TESTCASES); do echo "Executing $$testcase..."; $(TEST_PREFIX)test/$$testcase $(TEST_PATTERN) || exit 1; done
81 82 83 84 85 86 87 88


##############################################################################
# fuzzer
##############################################################################

parse_afl_fuzzer:
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) src/fuzzer-driver_afl.cpp src/fuzzer-parse_json.cpp -o $@
N
Niels Lohmann 已提交
89 90 91

parse_cbor_fuzzer:
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) src/fuzzer-driver_afl.cpp src/fuzzer-parse_cbor.cpp -o $@
92 93 94

parse_msgpack_fuzzer:
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) src/fuzzer-driver_afl.cpp src/fuzzer-parse_msgpack.cpp -o $@