diff options
Diffstat (limited to 'tests/Makefile')
| -rw-r--r-- | tests/Makefile | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/tests/Makefile b/tests/Makefile index b14fd6b..4e5ee00 100644 --- a/tests/Makefile +++ b/tests/Makefile | |||
| @@ -1,6 +1,11 @@ | |||
| 1 | CFLAGS=-I../include/ -D_FORTIFY_SOURCE=3 -static -O2 | 1 | CFLAGS=-I../include/ -D_FORTIFY_SOURCE=3 -static -O2 |
| 2 | 2 | ||
| 3 | TARGETS= \ | 3 | COMPTIME_TARGETS= \ |
| 4 | test_memcpy_overwrite_under \ | ||
| 5 | test_memcpy_static_write \ | ||
| 6 | |||
| 7 | |||
| 8 | RUNTIME_TARGETS= \ | ||
| 4 | test_FD_CLR_SETSIZE \ | 9 | test_FD_CLR_SETSIZE \ |
| 5 | test_FD_CLR_negative \ | 10 | test_FD_CLR_negative \ |
| 6 | test_FD_SET_SETSIZE \ | 11 | test_FD_SET_SETSIZE \ |
| @@ -42,9 +47,7 @@ TARGETS= \ | |||
| 42 | test_memcpy_dynamic_read \ | 47 | test_memcpy_dynamic_read \ |
| 43 | test_memcpy_dynamic_write \ | 48 | test_memcpy_dynamic_write \ |
| 44 | test_memcpy_overwrite_over \ | 49 | test_memcpy_overwrite_over \ |
| 45 | test_memcpy_overwrite_under \ | ||
| 46 | test_memcpy_static_read \ | 50 | test_memcpy_static_read \ |
| 47 | test_memcpy_static_write \ | ||
| 48 | test_memmove_dynamic_read \ | 51 | test_memmove_dynamic_read \ |
| 49 | test_memmove_dynamic_write \ | 52 | test_memmove_dynamic_write \ |
| 50 | test_memmove_static_read \ | 53 | test_memmove_static_read \ |
| @@ -124,37 +127,42 @@ TARGETS= \ | |||
| 124 | .SILENT: | 127 | .SILENT: |
| 125 | 128 | ||
| 126 | gcc: CC=../x86_64-linux-musl-native/bin/gcc | 129 | gcc: CC=../x86_64-linux-musl-native/bin/gcc |
| 127 | gcc: $(TARGETS) | 130 | gcc: $(RUNTIME_TARGETS) |
| 128 | 131 | ||
| 129 | clang: CC=clang | 132 | clang: CC=clang |
| 130 | clang: GCOV=gcov | ||
| 131 | clang: CFLAGS+=-I/usr/include/x86_64-linux-musl | 133 | clang: CFLAGS+=-I/usr/include/x86_64-linux-musl |
| 132 | clang: CFLAGS+=-I../x86_64-linux-musl-native/include/ | 134 | clang: CFLAGS+=-I../x86_64-linux-musl-native/include/ |
| 133 | clang: CFLAGS+=-Ix86_64-linux-musl-native/include/ | 135 | clang: CFLAGS+=-Ix86_64-linux-musl-native/include/ |
| 134 | clang: CFLAGS+=-nostdinc | 136 | clang: CFLAGS+=-nostdinc |
| 135 | clang: $(TARGETS) | 137 | clang: comptime $(RUNTIME_TARGETS) |
| 136 | |||
| 137 | all: gcc | ||
| 138 | 138 | ||
| 139 | coverage: CFLAGS += -fprofile-arcs -ftest-coverage | 139 | coverage: CFLAGS += -fprofile-arcs -ftest-coverage |
| 140 | coverage: CC=../x86_64-linux-musl-native/bin/gcc | 140 | coverage: CC=../x86_64-linux-musl-native/bin/gcc |
| 141 | coverage: GCOV=../x86_64-linux-musl-native/bin/gcov | 141 | coverage: GCOV=../x86_64-linux-musl-native/bin/gcov |
| 142 | coverage: $(TARGETS) run | 142 | coverage: $(RUNTIME_TARGETS) run |
| 143 | $(GCOV) *.c | 143 | $(GCOV) *.c |
| 144 | lcov --capture --directory . --output-file coverage.info | 144 | lcov --capture --directory . --output-file coverage.info |
| 145 | lcov --remove ./coverage.info "*/tests/*" --output-file cleaned-coverage.info | 145 | lcov --remove ./coverage.info "*/tests/*" --output-file cleaned-coverage.info |
| 146 | genhtml cleaned-coverage.info --output-directory coverage | 146 | genhtml cleaned-coverage.info --output-directory coverage |
| 147 | 147 | ||
| 148 | $(TARGETS): %: %.c | 148 | all: gcc |
| 149 | |||
| 150 | |||
| 151 | $(RUNTIME_TARGETS): %: %.c | ||
| 149 | $(CC) $(CFLAGS) -o $@ $< | 152 | $(CC) $(CFLAGS) -o $@ $< |
| 150 | 153 | ||
| 151 | run: $(TARGETS) | 154 | run: $(RUNTIME_TARGETS) |
| 152 | $(foreach EXE, $(TARGETS), \ | 155 | $(foreach EXE, $(RUNTIME_TARGETS), \ |
| 153 | timeout 1s ./$(EXE) 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \ | 156 | timeout 1s ./$(EXE) 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \ |
| 154 | ) | 157 | ) |
| 155 | 158 | ||
| 159 | comptime: # only works on clang, as gcc doesn't have the diagnose_if attribute | ||
| 160 | $(foreach EXE, $(COMPTIME_TARGETS), \ | ||
| 161 | ($(CC) $(CFLAGS) -o ./$(EXE) ./$(EXE).c 1>/dev/null 2>/dev/null && echo "$(EXE) FAIL" || echo "$(EXE) OK") || true ;\ | ||
| 162 | ) | ||
| 163 | |||
| 156 | clean: | 164 | clean: |
| 157 | $(foreach EXE, $(TARGETS), \ | 165 | $(foreach EXE, $(RUNTIME_TARGETS) $(COMPTIME_TARGETS), \ |
| 158 | rm -f ./$(EXE) \ | 166 | rm -f ./$(EXE) \ |
| 159 | ) | 167 | ) |
| 160 | rm -rf ./*.gcno ./*.gcda ./*.gcov ./coverage.info ./coverage | 168 | rm -rf ./*.gcno ./*.gcda ./*.gcov ./coverage.info ./coverage |
