aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorCatena cyber <35799796+catenacyber@users.noreply.github.com>2020-11-20 19:55:33 +0100
committerGitHub <noreply@github.com>2020-11-20 10:55:33 -0800
commitc031d50ec9486c04f9e6fded888f6b7a67e023b2 (patch)
tree2db727733b23fb0d89b8ffd937cb4d8a8b08f367 /docs
parentee7031c4a528b4a24c98ce4e61c04fb3cd90ae1c (diff)
downloadoss-fuzz-c031d50ec9486c04f9e6fded888f6b7a67e023b2.tar.gz
[infra] Golang coverage summary for each fuzz target (#2817, #2714). (#4671)
* Golang coverage summary for each fuzz target * Document usage of compile_go_fuzzer * update the documentation change Co-authored-by: Max Moroz <mmoroz@chromium.org>
Diffstat (limited to 'docs')
-rw-r--r--docs/getting-started/new-project-guide/go_lang.md25
1 files changed, 11 insertions, 14 deletions
diff --git a/docs/getting-started/new-project-guide/go_lang.md b/docs/getting-started/new-project-guide/go_lang.md
index be7482c33..94ab41707 100644
--- a/docs/getting-started/new-project-guide/go_lang.md
+++ b/docs/getting-started/new-project-guide/go_lang.md
@@ -74,21 +74,18 @@ RUN go get github.com/ianlancetaylor/demangle
In order to build a Go fuzz target, you need to call `go-fuzz`
command first, and then link the resulting `.a` file against
`$LIB_FUZZING_ENGINE` using the `$CXX $CXXFLAGS ...` command.
-[Example](https://github.com/google/oss-fuzz/blob/356f2b947670b7eb33a1f535c71bc5c87a60b0d1/projects/syzkaller/build.sh#L19):
-```sh
-function compile_fuzzer {
- path=$1
- function=$2
- fuzzer=$3
-
- # Compile and instrument all Go files relevant to this fuzz target.
- go-fuzz -func $function -o $fuzzer.a $path
+The best way to do this is by using a `compile_go_fuzzer` script,
+as it also supports coverage builds.
- # Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary.
- $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer
-}
+A usage example from go-dns project is
-compile_fuzzer ./pkg/compiler Fuzz compiler_fuzzer
-compile_fuzzer ./prog/test FuzzDeserialize prog_deserialize_fuzzer
+```sh
+compile_go_fuzzer github.com/miekg/dns FuzzNewRR fuzz_newrr fuzz
```
+
+Arguments are :
+* path of the package with the fuzz target
+* name of the fuzz function
+* name of the fuzzer to be built
+* optional tag to be used by `go build` and such