From f43928cf478d13e4665e4664e7e3fe1d2f1bdbee Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Tue, 25 May 2021 17:52:11 +0300 Subject: [PATCH] [infra] fix handling Go's SIV in coverage santizer (#5813) --- infra/base-images/base-builder/compile_go_fuzzer | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/infra/base-images/base-builder/compile_go_fuzzer b/infra/base-images/base-builder/compile_go_fuzzer index 2342800fb..a0ae51c5b 100755 --- a/infra/base-images/base-builder/compile_go_fuzzer +++ b/infra/base-images/base-builder/compile_go_fuzzer @@ -42,7 +42,9 @@ if [[ $SANITIZER = *coverage* ]]; then sed -i -e 's/mypackagebeingfuzzed/'$fuzzed_package'/' ./"${function,,}"_test.go sed -i -e 's/TestFuzzCorpus/Test'$function'Corpus/' ./"${function,,}"_test.go - fuzzed_repo=`echo $path | cut -d/ -f-3` + # The repo is the module path/name, which is already created above in case it doesn't exist, + # but not always the same as the module path. This is necessary to handle SIV properly. + fuzzed_repo=$(go list $tags -f {{.Module}} "$path") abspath_repo=`go list -m $tags -f {{.Dir}} $fuzzed_repo || go list $tags -f {{.Dir}} $fuzzed_repo` # give equivalence to absolute paths in another file, as go test -cover uses golangish pkg.Dir echo "s=$fuzzed_repo"="$abspath_repo"= > $OUT/$fuzzer.gocovpath