summaryrefslogtreecommitdiff
path: root/tests/Makefile
blob: 2c4e067ffed0580fcd34f45c0de0c70caeeb5ab1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
CC=../x86_64-linux-musl-native/bin/gcc
GCOV=../x86_64-linux-musl-native/bin/gcov
CFLAGS=-I../include/ -D_FORTIFY_SOURCE=3 -static -O2

TARGETS=test_memcpy_static_write  \
	test_memcpy_dynamic_write  \
	test_memcpy_static_read    \
	test_memcpy_dynamic_read   \
	test_memmove_static_write  \
	test_memmove_dynamic_write \
	test_memmove_static_read   \
	test_memmove_dynamic_read  \
	test_memset_static_write   \
	test_memset_dynamic_write  \
	test_strcpy_static_write   \
	test_strcat_static_write   \
	test_strcpy_overwrite_over \
	test_strcpy_overwrite_under\
	test_getcwd                \

.SILENT:

all: $(TARGETS) run

coverage: CFLAGS += -fprofile-arcs -ftest-coverage
coverage: all
	$(GCOV) *.c
	lcov --capture --directory . --output-file coverage.info
	genhtml coverage.info --output-directory coverage

$(TARGETS): %: %.c
	$(CC) $(CFLAGS) -o $@ $<

run: $(TARGETS)
	$(foreach EXE, $(TARGETS), \
		./$(EXE) 1 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL" ; \
	)

clean:
	$(foreach EXE, $(TARGETS), \
		rm -f ./$(EXE) \
	)
	rm -rf ./*.gcno ./*.gcda ./*.gcov ./coverage.info ./coverage