aboutsummaryrefslogtreecommitdiff
path: root/infra/base-images
diff options
context:
space:
mode:
authorCatena cyber <35799796+catenacyber@users.noreply.github.com>2021-02-19 19:03:22 +0100
committerGitHub <noreply@github.com>2021-02-19 10:03:22 -0800
commit18500c17d79d75f3ffd70cc1c024dd282d99c20e (patch)
treea251953021e79f2e7e7f1373de890d9b836229b0 /infra/base-images
parent12d7371cf6ff37946c375134840bdb518a59579a (diff)
downloadoss-fuzz-18500c17d79d75f3ffd70cc1c024dd282d99c20e.tar.gz
golang: compatibility with go 1.16 modules (#5221)
Diffstat (limited to 'infra/base-images')
-rwxr-xr-xinfra/base-images/base-builder/compile_go_fuzzer9
1 files changed, 7 insertions, 2 deletions
diff --git a/infra/base-images/base-builder/compile_go_fuzzer b/infra/base-images/base-builder/compile_go_fuzzer
index 8f8cde759..fc2f4c2b3 100755
--- a/infra/base-images/base-builder/compile_go_fuzzer
+++ b/infra/base-images/base-builder/compile_go_fuzzer
@@ -23,9 +23,14 @@ if [[ $# -eq 4 ]]; then
tags="-tags $4"
fi
+cd $GOPATH/src/$path || true
+# project was downloaded with go get if go list fails
+go list $path || cd $GOPATH/pkg/mod/ && cd `echo $path | cut -d/ -f1-3 | awk '{print $1"*"}'`
+# project does not have go.mod if go list fails again
+go list $path || go mod init $path
+
if [[ $SANITIZER = *coverage* ]]; then
- cd $GOPATH/src/$path
- fuzzed_package=`go list $tags -f '{{.Name}}'`
+ fuzzed_package=`go list $tags -f '{{.Name}}' $path`
cp $GOPATH/ossfuzz_coverage_runner.go ./"${function,,}"_test.go
sed -i -e 's/FuzzFunction/'$function'/' ./"${function,,}"_test.go
sed -i -e 's/mypackagebeingfuzzed/'$fuzzed_package'/' ./"${function,,}"_test.go