cJSON
[Ported from github.com/DaveGamble/cJSON] Fix: heap-use-after-free in merge_patch when patch is subtree of target (#1065)
Brought by drakestapleton
cJSON / tests / unity / test / Makefile
| 1 | CC = gcc |
| 2 | ifeq ($(shell uname -s), Darwin) |
| 3 | CC = clang |
| 4 | endif |
| 5 | ifeq ($(findstring clang, $(CC)), clang) |
| 6 | E = -Weverything |
| 7 | CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes |
| 8 | CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn |
| 9 | endif |
| 10 | CFLAGS += -std=c99 -pedantic -Wall -Wextra -Wconversion -Werror |
| 11 | CFLAGS += -Wno-switch-enum -Wno-double-promotion |
| 12 | CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstrict-overflow \ |
| 13 | -Wstrict-prototypes -Wswitch-default -Wundef |
| 14 | #DEBUG = -O0 -g |
| 15 | CFLAGS += $(DEBUG) |
| 16 | DEFINES = -D UNITY_OUTPUT_CHAR=putcharSpy |
| 17 | DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\) |
| 18 | DEFINES += $(UNITY_SUPPORT_64) $(UNITY_INCLUDE_DOUBLE) |
| 19 | UNITY_SUPPORT_64 = -D UNITY_SUPPORT_64 |
| 20 | UNITY_INCLUDE_DOUBLE = -D UNITY_INCLUDE_DOUBLE |
| 21 | SRC = ../src/unity.c tests/testunity.c build/testunityRunner.c |
| 22 | INC_DIR = -I ../src |
| 23 | COV_FLAGS = -fprofile-arcs -ftest-coverage -I ../../src |
| 24 | BUILD_DIR = build |
| 25 | TARGET = build/testunity-cov.exe |
| 26 | |
| 27 | # To generate coverage, call 'make -s', the default target runs. |
| 28 | # For verbose output of all the tests, run 'make test'. |
| 29 | default: coverage |
| 30 | .PHONY: default coverage test clean |
| 31 | coverage: DEFINES += -D UNITY_NO_WEAK |
| 32 | coverage: $(BUILD_DIR)/testunityRunner.c |
| 33 | cd $(BUILD_DIR) && \ |
| 34 | $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC), ../$i) $(COV_FLAGS) -o ../$(TARGET) |
| 35 | rm -f $(BUILD_DIR)/*.gcda |
| 36 | ./$(TARGET) | grep 'Tests\|]]]' -A1 |
| 37 | cd $(BUILD_DIR) && \ |
| 38 | gcov unity.c | head -3 |
| 39 | grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true |
| 40 | |
| 41 | test: $(BUILD_DIR)/testunityRunner.c |
| 42 | $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC) -o $(TARGET) |
| 43 | ./$(TARGET) |
| 44 | |
| 45 | # Compile only, for testing that preprocessor detection works |
| 46 | UNITY_C_ONLY =-c ../src/unity.c -o $(BUILD_DIR)/unity.o |
| 47 | intDetection: |
| 48 | $(CC) $(CFLAGS) $(INC_DIR) $(UNITY_C_ONLY) -D UNITY_EXCLUDE_STDINT_H |
| 49 | $(CC) $(CFLAGS) $(INC_DIR) $(UNITY_C_ONLY) -D UNITY_EXCLUDE_LIMITS_H |
| 50 | |
| 51 | $(BUILD_DIR)/testunityRunner.c: tests/testunity.c | $(BUILD_DIR) |
| 52 | awk $(AWK_SCRIPT) tests/testunity.c > $@ |
| 53 | |
| 54 | AWK_SCRIPT=\ |
| 55 | '/^void test/{ declarations[d++]=$$0; gsub(/\(?void\)? ?/,""); tests[t++]=$$0; line[u++]=NR } \ |
| 56 | END{ print "\#include \"unity.h\" /* Autogenerated by awk in Makefile */" ; \ |
| 57 | for (i=0; i<d; i++) { print declarations[i] ";" } \ |
| 58 | print "int main(void)\n{\n UnityBegin(\"" FILENAME "\");" ; \ |
| 59 | for (i=0; i<t; i++) { print " RUN_TEST(" tests[i] ", " line[i] ");" } \ |
| 60 | print " return UNITY_END();\n}" }' |
| 61 | |
| 62 | $(BUILD_DIR): |
| 63 | mkdir -p $(BUILD_DIR) |
| 64 | |
| 65 | clean: |
| 66 | rm -f $(TARGET) $(BUILD_DIR)/*.gc* $(BUILD_DIR)/testunityRunner.c |