summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-01-02 05:34:17 -0300
committerEuAndreh <eu@euandre.org>2024-01-02 05:36:34 -0300
commited7bf08186d83cc82d06ed191fea73e9e18174b2 (patch)
tree4efe745400370207b7de1a9d117bcdac073bee16
parentMakefile: Move manpages and catalog discovery to mkdeps.sh (diff)
downloadpindaiba-ed7bf08186d83cc82d06ed191fea73e9e18174b2.tar.gz
pindaiba-ed7bf08186d83cc82d06ed191fea73e9e18174b2.tar.xz
Makefile: Add support for LLVM fuzzer
-rw-r--r--.gitignore5
-rw-r--r--Makefile19
-rw-r--r--deps.mk10
-rwxr-xr-xmkdeps.sh9
4 files changed, 40 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index a515310..3bd5ddd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,5 +7,8 @@
/src/*.c.txt
/src/*.cat
/doc/*.[0-9]
-/tests/slurp.o
+/tests/fuzz/*.o
+/tests/fuzz/*.xa
+/tests/fuzz/*.bin
/tests/fuzz/corpus/
+/tests/slurp.o
diff --git a/Makefile b/Makefile
index 79eda83..45fe1a2 100644
--- a/Makefile
+++ b/Makefile
@@ -53,6 +53,9 @@ sources.o = $(sources.c:.c=.o)
sources.to = $(sources.c:.c=.to)
sources.xa = $(sources.c:.c=.xa)
sources.bin = $(sources.c:.c=.bin)
+fuzz.o = $(fuzz.c:.c=.o)
+fuzz.xa = $(fuzz.c:.c=.xa)
+fuzz.bin = $(fuzz.c:.c=.bin)
sources = \
$(sources.c) \
@@ -79,6 +82,9 @@ derived-assets = \
src/main.bin \
side-assets = \
+ $(fuzz.o) \
+ $(fuzz.xa) \
+ $(fuzz.bin) \
src/logerr.c.txt \
src/catalog.c.txt \
@@ -91,12 +97,13 @@ all: $(derived-assets)
lib$(NAME).a: $(sources.o)
src/main.xa: $(sources.o) src/main.o
+$(fuzz.bin): lib$(NAME).a
$(manpages) src/config.h: Makefile deps.mk
$(sources.o) $(sources.to): src/config.h Makefile deps.mk
tests/slurp.o: src/config.h Makefile deps.mk
-lib$(NAME).a $(sources.xa) src/main.xa:
+lib$(NAME).a $(sources.xa) src/main.xa $(fuzz.xa):
$(AR) $(ARFLAGS) $@ $?
src/$(NAME).en.cat: src/i18n.bin
@@ -125,6 +132,16 @@ check-unit: $(sources.bin-check)
check: check-unit
+
+fuzz.bin-check = $(fuzz.c:.c=.bin-check)
+$(fuzz.bin-check):
+ $(EXEC)$*.bin tests/fuzz/corpus/ $(FUZZFLAGS)
+
+## Run fuzzing targets indefinitely.
+fuzz: $(fuzz.bin-check)
+
+
+
## Remove *all* derived artifacts produced during the build.
## A dedicated test asserts that this is always true.
clean:
diff --git a/deps.mk b/deps.mk
index aa56673..80296ec 100644
--- a/deps.mk
+++ b/deps.mk
@@ -11,6 +11,16 @@ manpages.in = $(manpages.en.in)
catalogs.en.msg = src/pindaiba.en.msg
catalogs.msg = $(catalogs.en.msg)
+fuzz.c = \
+ tests/fuzz/another.c \
+ tests/fuzz/hello.c \
+
+tests/fuzz/another.xa: tests/fuzz/another.o
+tests/fuzz/hello.xa: tests/fuzz/hello.o
+tests/fuzz/another.bin-check: tests/fuzz/another.bin
+tests/fuzz/hello.bin-check: tests/fuzz/hello.bin
+
+
sources.c = \
src/catalog.c \
src/hash.c \
diff --git a/mkdeps.sh b/mkdeps.sh
index 1ec12fb..4970dc8 100755
--- a/mkdeps.sh
+++ b/mkdeps.sh
@@ -12,10 +12,17 @@ cfiles() {
}
export LANG=POSIX.UTF-8
+
find doc/*.en.*.in 2>/dev/null | sort | varlist 'manpages.en.in' ||:
echo 'manpages.in = $(manpages.en.in)'
printf 'catalogs.en.msg = %s\n' "$(find src/ -name '*.msg')"
echo 'catalogs.msg = $(catalogs.en.msg)'
-echo ''
+printf '\n'
+
+find tests/fuzz/*.c | sort | varlist 'fuzz.c'
+find tests/fuzz/*.c | sort | awk -F. '{ printf "%s.xa: %s.o\n", $1, $1 }'
+find tests/fuzz/*.c | sort | awk -F. '{ printf "%s.bin-check: %s.bin\n", $1, $1 }'
+printf '\n\n'
+
cfiles | varlist 'sources.c'
ldev deps $(cfiles)