xref: /aosp_15_r20/external/libxml2/fuzz/Makefile.am (revision 7c5688314b92172186c154356a6374bf7684c3ca)
1AUTOMAKE_OPTIONS = -Wno-syntax
2EXTRA_PROGRAMS = genSeed \
3		 api html lint reader regexp schema uri valid xinclude \
4		 xml xpath
5check_PROGRAMS = testFuzzer
6EXTRA_DIST = html.dict regexp.dict schema.dict xml.dict xpath.dict \
7	     static_seed/uri static_seed/regexp fuzz.h
8CLEANFILES = $(EXTRA_PROGRAMS)
9AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include
10DEPENDENCIES = $(top_builddir)/libxml2.la
11LDADD = $(top_builddir)/libxml2.la
12
13XML_MAX_LEN = 80000
14# Single quotes to avoid wildcard expansion by the shell
15XML_SEED_CORPUS_SRC = \
16    '$(top_srcdir)/test/*' \
17    '$(top_srcdir)/test/errors/*.xml' \
18    '$(top_srcdir)/test/errors10/*.xml' \
19    '$(top_srcdir)/test/namespaces/*' \
20    '$(top_srcdir)/test/recurse/*.xml' \
21    '$(top_srcdir)/test/SVG/*.xml' \
22    '$(top_srcdir)/test/valid/*.xml' \
23    '$(top_srcdir)/test/VC/*' \
24    '$(top_srcdir)/test/VCM/*' \
25    '$(top_srcdir)/test/XInclude/docs/*' \
26    '$(top_srcdir)/test/XInclude/without-reader/*' \
27    '$(top_srcdir)/test/xmlid/*'
28
29testFuzzer_SOURCES = testFuzzer.c fuzz.c
30
31.PHONY: corpus clean-corpus
32
33corpus: seed/html.stamp seed/lint.stamp seed/reader.stamp seed/regexp.stamp \
34    seed/schema.stamp seed/uri.stamp seed/valid.stamp seed/xinclude.stamp \
35    seed/xml.stamp seed/xpath.stamp
36
37check-local: corpus
38	./testFuzzer$(EXEEXT)
39
40clean-corpus:
41	rm -rf seed
42
43clean-local: clean-corpus
44
45# Seed corpus
46
47genSeed_SOURCES = genSeed.c fuzz.c
48
49# XML fuzzer
50
51seed/xml.stamp: genSeed$(EXEEXT)
52	@mkdir -p seed/xml
53	./genSeed$(EXEEXT) xml $(XML_SEED_CORPUS_SRC)
54	@touch seed/xml.stamp
55
56xml_SOURCES = xml.c fuzz.c
57xml_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
58
59fuzz-xml: xml$(EXEEXT) seed/xml.stamp
60	@mkdir -p corpus/xml
61	./xml$(EXEEXT) \
62	    -dict=xml.dict \
63	    -max_len=$(XML_MAX_LEN) \
64	    $$XML_FUZZ_OPTIONS \
65	    corpus/xml seed/xml
66
67# DTD validation fuzzer
68
69seed/valid.stamp: genSeed$(EXEEXT)
70	@mkdir -p seed/valid
71	./genSeed$(EXEEXT) valid $(XML_SEED_CORPUS_SRC)
72	@touch seed/valid.stamp
73
74valid_SOURCES = valid.c fuzz.c
75valid_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
76
77fuzz-valid: valid$(EXEEXT) seed/valid.stamp
78	@mkdir -p corpus/valid
79	./valid$(EXEEXT) \
80	    -dict=xml.dict \
81	    -max_len=$(XML_MAX_LEN) \
82	    $$XML_FUZZ_OPTIONS \
83	    corpus/valid seed/valid
84
85# XInclude fuzzer
86
87seed/xinclude.stamp: genSeed$(EXEEXT)
88	@mkdir -p seed/xinclude
89	./genSeed$(EXEEXT) xinclude $(XML_SEED_CORPUS_SRC)
90	@touch seed/xinclude.stamp
91
92xinclude_SOURCES = xinclude.c fuzz.c
93xinclude_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
94
95fuzz-xinclude: xinclude$(EXEEXT) seed/xinclude.stamp
96	@mkdir -p corpus/xinclude
97	./xinclude$(EXEEXT) \
98	    -dict=xml.dict \
99	    -max_len=$(XML_MAX_LEN) \
100	    $$XML_FUZZ_OPTIONS \
101	    corpus/xinclude seed/xinclude
102
103# HTML fuzzer
104
105seed/html.stamp: genSeed$(EXEEXT)
106	@mkdir -p seed/html
107	./genSeed$(EXEEXT) html '$(top_srcdir)/test/HTML/*'
108	@touch seed/html.stamp
109
110html_SOURCES = html.c fuzz.c
111html_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
112
113fuzz-html: html$(EXEEXT) seed/html.stamp
114	@mkdir -p corpus/html
115	./html$(EXEEXT) \
116	    -dict=html.dict \
117	    -max_len=1000000 \
118	    $$XML_FUZZ_OPTIONS \
119	    corpus/html seed/html
120
121# Reader fuzzer
122
123seed/reader.stamp: genSeed$(EXEEXT)
124	@mkdir -p seed/reader
125	./genSeed$(EXEEXT) reader $(XML_SEED_CORPUS_SRC)
126	@touch seed/reader.stamp
127
128reader_SOURCES = reader.c fuzz.c
129reader_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
130
131fuzz-reader: reader$(EXEEXT) seed/reader.stamp
132	@mkdir -p corpus/reader
133	./reader$(EXEEXT) \
134	    -dict=xml.dict \
135	    -max_len=$(XML_MAX_LEN) \
136	    $$XML_FUZZ_OPTIONS \
137	    corpus/reader seed/reader
138
139# xmllint fuzzer
140
141seed/lint.stamp: genSeed$(EXEEXT)
142	@mkdir -p seed/lint
143	./genSeed$(EXEEXT) lint $(XML_SEED_CORPUS_SRC)
144	@touch seed/lint.stamp
145
146lint_SOURCES = lint.c fuzz.c
147lint_LDFLAGS = -fsanitize=fuzzer
148
149fuzz-lint: lint$(EXEEXT) seed/lint.stamp
150	@mkdir -p corpus/lint
151	./lint$(EXEEXT) \
152	    -dict=xml.dict \
153	    -max_len=$(XML_MAX_LEN) \
154	    $$XML_FUZZ_OPTIONS \
155	    corpus/lint seed/lint
156
157# API fuzzer
158
159api_SOURCES = api.c fuzz.c
160api_LDFLAGS = -fsanitize=fuzzer
161
162fuzz-api: api$(EXEEXT)
163	@mkdir -p corpus/api
164	./api$(EXEEXT) \
165	    -max_len=100 \
166	    $$XML_FUZZ_OPTIONS \
167	    corpus/api
168
169# Regexp fuzzer
170
171seed/regexp.stamp:
172	@mkdir -p seed/regexp
173	cp -r $(srcdir)/static_seed/regexp seed
174	@touch seed/regexp.stamp
175
176regexp_SOURCES = regexp.c fuzz.c
177regexp_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
178
179fuzz-regexp: regexp$(EXEEXT) seed/regexp.stamp
180	@mkdir -p corpus/regexp
181	./regexp$(EXEEXT) \
182	    -dict=regexp.dict \
183	    -max_len=200 \
184	    $$XML_FUZZ_OPTIONS \
185	    corpus/regexp seed/regexp
186
187# URI fuzzer
188
189seed/uri.stamp:
190	@mkdir -p seed/uri
191	cp -r $(srcdir)/static_seed/uri seed
192	@touch seed/uri.stamp
193
194uri_SOURCES = uri.c fuzz.c
195uri_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
196
197fuzz-uri: uri$(EXEEXT) seed/uri.stamp
198	@mkdir -p corpus/uri
199	./uri$(EXEEXT) \
200	    -max_len=10000 \
201	    $$XML_FUZZ_OPTIONS \
202	    corpus/uri seed/uri
203
204# XML Schema fuzzer
205
206seed/schema.stamp: genSeed$(EXEEXT)
207	@mkdir -p seed/schema
208	./genSeed$(EXEEXT) schema '$(top_srcdir)/test/schemas/*.xsd'
209	@touch seed/schema.stamp
210
211schema_SOURCES = schema.c fuzz.c
212schema_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
213
214fuzz-schema: schema$(EXEEXT) seed/schema.stamp
215	@mkdir -p corpus/schema
216	./schema$(EXEEXT) \
217	    -dict=schema.dict \
218	    -max_len=$(XML_MAX_LEN) \
219	    $$XML_FUZZ_OPTIONS \
220	    corpus/schema seed/schema
221
222# XPath fuzzer
223
224seed/xpath.stamp: genSeed$(EXEEXT)
225	@mkdir -p seed/xpath
226	./genSeed$(EXEEXT) xpath '$(top_srcdir)/test/XPath'
227	@touch seed/xpath.stamp
228
229xpath_SOURCES = xpath.c fuzz.c
230xpath_LDFLAGS = $(AM_LDFLAGS) -fsanitize=fuzzer
231
232fuzz-xpath: xpath$(EXEEXT) seed/xpath.stamp
233	@mkdir -p corpus/xpath
234	./xpath$(EXEEXT) \
235	    -dict=xpath.dict \
236	    -max_len=10000 \
237	    $$XML_FUZZ_OPTIONS \
238	    corpus/xpath seed/xpath
239
240