summaryrefslogtreecommitdiff
path: root/fuzz/Makefile.am
blob: 3aa5b2a83fa8cf88ca864833f30a2418a8c24d5b (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
AM_CFLAGS = $(WERROR_CFLAGS) $(WARN_CFLAGS) -Wno-unused-parameter -Wno-pedantic
AM_CPPFLAGS = -I$(top_srcdir)/lib/includes -I$(top_builddir)/lib/includes -I$(srcdir) \
 -DSRCDIR=\"$(abs_srcdir)\" -DTEST_RUN
AM_LDFLAGS = -static
LDADD = ../gl/libgnu.la ../lib/libgnutls.la \
 $(LIBOBJS) $(GETADDRINFO_LIB) $(HOSTENT_LIB) $(INET_NTOP_LIB)\
 $(LIBSOCKET) $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP) $(LIB_POLL) $(LIB_PTHREAD)\
 $(LIB_SELECT) $(LIBTHREAD) $(SERVENT_LIB) \
 $(LIBS)

FUZZERS = \
 gnutls_base64_decoder_fuzzer$(EXEEXT) \
 gnutls_base64_encoder_fuzzer$(EXEEXT) \
 gnutls_client_fuzzer$(EXEEXT) \
 gnutls_dn_parser_fuzzer$(EXEEXT) \
 gnutls_idna_parser_fuzzer$(EXEEXT) \
 gnutls_ocsp_req_parser_fuzzer$(EXEEXT) \
 gnutls_ocsp_resp_parser_fuzzer$(EXEEXT) \
 gnutls_pkcs12_key_parser_fuzzer$(EXEEXT) \
 gnutls_pkcs7_parser_fuzzer$(EXEEXT) \
 gnutls_pkcs8_key_parser_fuzzer$(EXEEXT) \
 gnutls_private_key_parser_fuzzer$(EXEEXT) \
 gnutls_psk_client_fuzzer$(EXEEXT) \
 gnutls_psk_server_fuzzer$(EXEEXT) \
 gnutls_reverse_idna_parser_fuzzer$(EXEEXT) \
 gnutls_server_fuzzer$(EXEEXT) \
 gnutls_srp_client_fuzzer$(EXEEXT) \
 gnutls_srp_server_fuzzer$(EXEEXT) \
 gnutls_set_trust_file_fuzzer$(EXEEXT) \
 gnutls_x509_parser_fuzzer$(EXEEXT)

check_PROGRAMS = $(FUZZERS)

gnutls_base64_decoder_fuzzer_SOURCES = gnutls_base64_decoder_fuzzer.c main.c fuzzer.h
gnutls_base64_encoder_fuzzer_SOURCES = gnutls_base64_encoder_fuzzer.c main.c fuzzer.h
gnutls_client_fuzzer_SOURCES = gnutls_client_fuzzer.c main.c fuzzer.h
gnutls_dn_parser_fuzzer_SOURCES = gnutls_dn_parser_fuzzer.c main.c fuzzer.h
gnutls_idna_parser_fuzzer_SOURCES = gnutls_idna_parser_fuzzer.c main.c fuzzer.h
gnutls_ocsp_req_parser_fuzzer_SOURCES = gnutls_ocsp_req_parser_fuzzer.c main.c fuzzer.h
gnutls_ocsp_resp_parser_fuzzer_SOURCES = gnutls_ocsp_resp_parser_fuzzer.c main.c fuzzer.h
gnutls_pkcs12_key_parser_fuzzer_SOURCES = gnutls_pkcs12_key_parser_fuzzer.c main.c fuzzer.h
gnutls_pkcs7_parser_fuzzer_SOURCES = gnutls_pkcs7_parser_fuzzer.c main.c fuzzer.h
gnutls_pkcs8_key_parser_fuzzer_SOURCES = gnutls_pkcs8_key_parser_fuzzer.c main.c fuzzer.h
gnutls_private_key_parser_fuzzer_SOURCES = gnutls_private_key_parser_fuzzer.c main.c fuzzer.h
gnutls_psk_client_fuzzer_SOURCES = gnutls_psk_client_fuzzer.c main.c fuzzer.h
gnutls_psk_server_fuzzer_SOURCES = gnutls_psk_server_fuzzer.c main.c fuzzer.h
gnutls_reverse_idna_parser_fuzzer_SOURCES = gnutls_reverse_idna_parser_fuzzer.c main.c fuzzer.h
gnutls_server_fuzzer_SOURCES = gnutls_server_fuzzer.c main.c fuzzer.h
gnutls_srp_client_fuzzer_SOURCES = gnutls_srp_client_fuzzer.c main.c fuzzer.h
gnutls_srp_server_fuzzer_SOURCES = gnutls_srp_server_fuzzer.c main.c fuzzer.h
gnutls_set_trust_file_fuzzer_SOURCES = gnutls_set_trust_file_fuzzer.c main.c fuzzer.h
gnutls_x509_parser_fuzzer_SOURCES = gnutls_x509_parser_fuzzer.c main.c fuzzer.h

gnutls_set_trust_file_fuzzer_LDADD = $(LDADD) -ldl


#EXTRA_DIST = $(wildcard *.options) $(wildcard *.dict) \
# $(wildcard *.in) $(wildcard *.repro)

dist-hook:
	find . -name '*.options' -exec cp -v '{}' $(distdir) ';'
	find . -name '*.dict' -exec cp -v '{}' $(distdir) ';'
	find . -name '*.in' -exec cp -vr '{}' $(distdir) ';'
	find . -name '*.repro' -exec cp -vr '{}' $(distdir) ';'

TESTS = $(FUZZERS)

clean-local:
	rm -rf *.gc?? *.log lcov

oss-fuzz:
	if test "$$OUT" != ""; then \
	for ccfile in *_fuzzer.c; do \
	fuzzer=$$(basename $$ccfile .c); \
	XLIBS="-lnettle -lhogweed -ltasn1 -lgmp -lidn2 -lunistring"; \
	$$CXX $$CXXFLAGS -I$(top_srcdir)/lib/includes/ -I$(top_srcdir) \
	"$${fuzzer}.c" -o "$${fuzzer}" \
	../lib/.libs/libgnutls.a $${LIB_FUZZING_ENGINE} \
	-Wl,-Bstatic \
	$${XLIBS} \
	-Wl,-Bdynamic; \
	done; \
	fi

.PHONY: oss-fuzz

LCOV_INFO=coverage.info
clean-lcov:
	rm -rf $(LCOV_INFO) ../*/*.gc?? ../*/.libs/*.gc?? lcov/
	lcov --zerocounters --directory ../lib/

coverage: clean clean-lcov
	$(MAKE) -C .. clean
	$(MAKE) -C ../gl
	$(MAKE) -C ../lib CFLAGS="$(CFLAGS) --coverage" LDFLAGS="$(LDFLAGS) --coverage"
	$(MAKE) check CFLAGS="$(CFLAGS) --coverage" LDFLAGS="$(LDFLAGS) --coverage"
	lcov --capture --initial --directory ../lib/.libs --output-file $(LCOV_INFO)
	lcov --capture --directory ../lib/.libs --output-file $(LCOV_INFO)
	genhtml --prefix . --ignore-errors source $(LCOV_INFO) --legend --title "gnutls-fuzz" --output-directory=lcov
	@echo
	@echo "You can now view the coverage report with 'xdg-open lcov/index.html'"