diff options
author | EuAndreh <eu@euandre.org> | 2024-10-02 08:21:10 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-10-02 08:33:47 -0300 |
commit | c8f256f633d6e94839e95cafc0c18c22886bae01 (patch) | |
tree | d249e20eb5b05c1484899aa28773ce33ad2d8e12 /Makefile | |
parent | tests/golite.go: Add explicit "deps" variable (diff) | |
download | golite-c8f256f633d6e94839e95cafc0c18c22886bae01.tar.gz golite-c8f256f633d6e94839e95cafc0c18c22886bae01.tar.xz |
Makefile: Add fuzz target setup
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 25 |
1 files changed, 22 insertions, 3 deletions
@@ -37,6 +37,8 @@ include deps.mk functional-tests.a = $(functional-tests.go:.go=.a) functional-tests.bin = $(functional-tests.go:.go=.bin) +fuzz-targets.a = $(fuzz-targets.go:.go=.a) +fuzz-targets.bin = $(fuzz-targets.go:.go=.bin) cgo.go = \ src/_cgo_import.go \ @@ -67,6 +69,8 @@ derived-assets = \ $(functional-tests.a) \ $(functional-tests.bin) \ tests/functional/streq.so \ + $(fuzz-targets.a) \ + $(fuzz-targets.bin) \ side-assets = \ src/_cgo_export.h \ @@ -83,6 +87,8 @@ $(derived-assets): Makefile deps.mk $(cgo.go) $(cgo.c) $(cgo.o): src/_cgo_.o +$(functional-tests.a) $(fuzz-targets.a): src/$(NAME).a + src/_cgo_.o: src/$(NAME).go go tool cgo --objdir $(@D) src/$(NAME).go @@ -107,10 +113,13 @@ tests/main.bin: tests/main.a src/version.go: Makefile echo 'package $(NAME); const Version = "$(VERSION)"' > $@ -$(functional-tests.a): src/$(NAME).a - go tool compile $(GOCFLAGS) -o $@ -p main -I src $*.go +$(functional-tests.a): + go tool compile $(GOCFLAGS) -o $@ -p main -I src $*.go + +$(fuzz-targets.a): + go tool compile -d=libfuzzer $(GOCFLAGS) -o $@ -p main -I src $*.go -$(functional-tests.bin): +$(functional-tests.bin) $(fuzz-targets.bin): go tool link $(GOLDFLAGS) -o $@ -L src --extldflags '$(LDLIBS)' $*.a tests/functional/streq.so: tests/functional/streq.c @@ -152,6 +161,16 @@ check: check-unit check-integration +FUZZSEC=1 +fuzz-targets.bin-check = $(fuzz-targets.go:.go=.bin-check) +$(fuzz-targets.bin-check): + $(EXEC)$*.bin --test.fuzztime=$(FUZZSEC)s \ + --test.fuzz=Fuzz --test.fuzzcachedir=tests/fuzz/corpus + +fuzz: $(fuzz-targets.bin-check) + + + bench: tests/main.bin $(EXEC)tests/main.bin -test.bench '.*' |