summaryrefslogtreecommitdiffstats
path: root/fuzz
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2017-05-29 04:08:29 +0200
committerGravatar Nikias Bassen2017-05-29 04:08:29 +0200
commit99f3ab144dcaa97a2be37e562740dbff2de350c6 (patch)
treeb6540c04944d1e493e95693c70b2d39e8b01302b /fuzz
parent1e89644636438269bcedb50f3eabf0780d0074ac (diff)
downloadlibplist-99f3ab144dcaa97a2be37e562740dbff2de350c6.tar.gz
libplist-99f3ab144dcaa97a2be37e562740dbff2de350c6.tar.bz2
Integrate fuzzers into build system
Diffstat (limited to 'fuzz')
-rw-r--r--fuzz/Makefile.am36
-rwxr-xr-xfuzz/fuzzers.test8
-rwxr-xr-xfuzz/init-fuzzers.sh23
-rwxr-xr-xfuzz/test-fuzzers.sh33
4 files changed, 100 insertions, 0 deletions
diff --git a/fuzz/Makefile.am b/fuzz/Makefile.am
new file mode 100644
index 0000000..b9798f9
--- /dev/null
+++ b/fuzz/Makefile.am
@@ -0,0 +1,36 @@
1if BUILD_FUZZERS
2
3libFuzzer.a: Fuzzer/build.sh
4 @echo "Building $@"
5 @./Fuzzer/build.sh
6
7Fuzzer/build.sh: LIBFUZZER_SRC
8
9LIBFUZZER_SRC:
10 @if test -d Fuzzer ; then \
11 if test -d Fuzzer/.git ; then \
12 echo Making sure libFuzzer source tree is up-to-date... ; \
13 cd Fuzzer && git checkout . && git pull && cd .. ; \
14 fi \
15 else \
16 echo Checking out libFuzzer source code... ; \
17 git clone https://chromium.googlesource.com/chromium/llvm-project/llvm/lib/Fuzzer ; \
18 fi
19
20CLEANFILES = libFuzzer.a
21
22noinst_PROGRAMS = xplist_fuzzer bplist_fuzzer
23
24xplist_fuzzer_SOURCES = xplist_fuzzer.cc
25xplist_fuzzer_LDFLAGS = -static
26xplist_fuzzer_LDADD = $(top_builddir)/src/libplist.la libFuzzer.a
27
28bplist_fuzzer_SOURCES = bplist_fuzzer.cc
29bplist_fuzzer_LDFLAGS = -static
30bplist_fuzzer_LDADD = $(top_builddir)/src/libplist.la libFuzzer.a
31
32TESTS = fuzzers.test
33
34EXTRA_DIST = bplist.dict xplist.dict init-fuzzers.sh test-fuzzers.sh fuzzers.test
35
36endif
diff --git a/fuzz/fuzzers.test b/fuzz/fuzzers.test
new file mode 100755
index 0000000..dd3fb08
--- /dev/null
+++ b/fuzz/fuzzers.test
@@ -0,0 +1,8 @@
1## -*- sh -*-
2
3set -e
4
5./init-fuzzers.sh
6
7./test-fuzzers.sh
8
diff --git a/fuzz/init-fuzzers.sh b/fuzz/init-fuzzers.sh
new file mode 100755
index 0000000..e48baa8
--- /dev/null
+++ b/fuzz/init-fuzzers.sh
@@ -0,0 +1,23 @@
1#!/bin/sh
2
3CURDIR=`pwd`
4FUZZDIR=`dirname $0`
5
6cd ${FUZZDIR}
7
8if ! test -x xplist_fuzzer || ! test -x bplist_fuzzer; then
9 echo "ERROR: you need to build the fuzzers first."
10 cd ${CURDIR}
11 exit 1
12fi
13
14mkdir -p xplist-input
15cp ../test/data/*.plist xplist-input/
16./xplist_fuzzer -merge=1 xplist-input crashes leaks -dict=xplist.dict
17
18mkdir -p bplist-input
19cp ../test/data/*.bplist bplist-input/
20./bplist_fuzzer -merge=1 bplist-input crashes leaks -dict=bplist.dict
21
22cd ${CURDIR}
23exit 0
diff --git a/fuzz/test-fuzzers.sh b/fuzz/test-fuzzers.sh
new file mode 100755
index 0000000..5c758c4
--- /dev/null
+++ b/fuzz/test-fuzzers.sh
@@ -0,0 +1,33 @@
1#!/bin/sh
2
3CURDIR=`pwd`
4FUZZDIR=`dirname $0`
5
6cd ${FUZZDIR}
7
8if ! test -x xplist_fuzzer || ! test -x bplist_fuzzer; then
9 echo "ERROR: you need to build the fuzzers first."
10 cd ${CURDIR}
11 exit 1
12fi
13
14if ! test -d xplist-input || ! test -d bplist-input; then
15 echo "ERROR: fuzzer corpora directories are not present. Did you run init-fuzzers.sh ?"
16 cd ${CURDIR}
17 exit 1
18fi
19
20echo "### TESTING xplist_fuzzer ###"
21if ! ./xplist_fuzzer xplist-input -dict=xplist.dict -runs=10000; then
22 cd ${CURDIR}
23 exit 1
24fi
25
26echo "### TESTING bplist_fuzzer ###"
27if ! ./bplist_fuzzer bplist-input -dict=bplist.dict -runs=10000; then
28 cd ${CURDIR}
29 exit 1
30fi
31
32cd ${CURDIR}
33exit 0