3962896f682a222bc76170558808a860d749ff85
[strongswan.git] / fuzz / Makefile.am
1 AM_CPPFLAGS = @CPPFLAGS@ \
2         -I$(top_srcdir)/src/libstrongswan \
3         -DPLUGINDIR=\""$(abs_top_builddir)/src/libstrongswan/plugins\"" \
4         -DPLUGINS="\"${fuzz_plugins}\""
5
6 fuzz_ldflags = ${libfuzzer} \
7         $(top_builddir)/src/libstrongswan/.libs/libstrongswan.a \
8         -Wl,-Bstatic -lgmp -Wl,-Bdynamic \
9         @FUZZING_LDFLAGS@
10
11 FUZZ_TARGETS=fuzz_certs fuzz_crls
12
13 all-local: $(FUZZ_TARGETS)
14
15 CLEANFILES=$(FUZZ_TARGETS)
16
17 fuzz_certs: fuzz_certs.c ${libfuzzer}
18         $(CC) $(AM_CPPFLAGS) $(CFLAGS) -o $@ $< $(fuzz_ldflags)
19
20 fuzz_crls: fuzz_crls.c ${libfuzzer}
21         $(CC) $(AM_CPPFLAGS) $(CFLAGS) -o $@ $< $(fuzz_ldflags)
22
23 noinst_LIBRARIES = libFuzzerLocal.a
24 libFuzzerLocal_a_SOURCES = libFuzzerLocal.c
25 libFuzzerLocal_a_LIBADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
26
27 check: all
28         for f in $(FUZZ_TARGETS); do \
29                 corpus=$${f#fuzz_}; \
30                 corpus=$${corpus%%_*}; \
31                 ./$$f $(FUZZING_CORPORA)/$${corpus}/*; \
32                 crashes=$(FUZZING_CORPORA)/$${corpus}-crash; \
33                 test ! -d $${crashes} || ./$$f $${crashes}/*; \
34         done