infra: build: functions: cut corpus directory by last period (#9302)

When a corpus zip file is unzipped the destination folder is set to be
the directory corresponding to the filepath of the zip file but without
".zip" in the name. This is achieved by `for f in /corpus/*.zip; do
unzip -q $f -d ${f%%.*}` where `f%%.*` substitutes the path of `f` based
on the first occurrence of ".". This causes some issues with fuzztest
fuzzers where a fuzzer name always has a "." in it, e.g.

`escaping_test@EscapingTest.EscapingAStringNeverTriggersUndefinedBehavior`

Substituting the name in this way causes issues for some coverage builds
e.g.
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53479

This changes it to substiute based on the last occurrence of ".", i.e.
just cutting off the ".zip".

Alternatively, we could substitute over
e.g. ".zip", however, this may cause some issues as a fuzztest fuzzer
may have ".zip" in the name.

Signed-off-by: David Korczynski <david@adalogics.com>

Signed-off-by: David Korczynski <david@adalogics.com>
This commit is contained in:
DavidKorczynski 2023-01-03 22:52:09 +00:00 committed by GitHub
parent 49c2379eab
commit beef253ac7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -138,8 +138,8 @@ def get_build_steps( # pylint: disable=too-many-locals, too-many-arguments
coverage_env,
'args': [
'bash', '-c',
('for f in /corpus/*.zip; do unzip -q $f -d ${f%%.*} || ('
'echo "Failed to unpack the corpus for $(basename ${f%%.*}). '
('for f in /corpus/*.zip; do unzip -q $f -d ${f%.*} || ('
'echo "Failed to unpack the corpus for $(basename ${f%.*}). '
'This usually means that corpus backup for a particular fuzz '
'target does not exist. If a fuzz target was added in the last '
'24 hours, please wait one more day. Otherwise, something is '

View File

@ -87,7 +87,7 @@
"args": [
"bash",
"-c",
"for f in /corpus/*.zip; do unzip -q $f -d ${f%%.*} || (echo \"Failed to unpack the corpus for $(basename ${f%%.*}). This usually means that corpus backup for a particular fuzz target does not exist. If a fuzz target was added in the last 24 hours, please wait one more day. Otherwise, something is wrong with the fuzz target or the infrastructure, and corpus pruning task does not finish successfully.\" && exit 1); done && coverage || (echo \"********************************************************************************\nCode coverage report generation failed.\nTo reproduce, run:\npython infra/helper.py build_image test-project\npython infra/helper.py build_fuzzers --sanitizer coverage test-project\npython infra/helper.py coverage test-project\n********************************************************************************\" && false)"
"for f in /corpus/*.zip; do unzip -q $f -d ${f%.*} || (echo \"Failed to unpack the corpus for $(basename ${f%.*}). This usually means that corpus backup for a particular fuzz target does not exist. If a fuzz target was added in the last 24 hours, please wait one more day. Otherwise, something is wrong with the fuzz target or the infrastructure, and corpus pruning task does not finish successfully.\" && exit 1); done && coverage || (echo \"********************************************************************************\nCode coverage report generation failed.\nTo reproduce, run:\npython infra/helper.py build_image test-project\npython infra/helper.py build_fuzzers --sanitizer coverage test-project\npython infra/helper.py coverage test-project\n********************************************************************************\" && false)"
],
"volumes": [
{