Skip to content

Commit 039af8b

Browse files
authored
Add new tags, improve error handling, add func as unique key (#41871)
### What does this PR do? This improve the `fuzz_infra.py` script to handle ctx.run throws that we encountered in this job: https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/1175663441 That made the list of fuzzer to be started truncated to the first crashing build. This also adds the `nvml` tag to build some new targets. (TODO: how can we automate the list of tags to include "everything" ? Now that we can fail a build safely, should we "add them all" ?) And finally, there's a small improvements on the naming scheme for Go fuzzer: the function name is now part of the package. This creates duplicate binaries, but if a package has multiple fuzzers, we can now run them properly (i.e: with their own inputs/crash/coverage) ### Motivation Improve the fuzzing infrastructure error handling and improve coverage ### Describe how you validated your changes Gitlab run with the build failure not blocking the remaining fuzzers: https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/1175824522 ### Additional Notes N/A
1 parent e334ea8 commit 039af8b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tasks/fuzz_infra.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def get_slack_channel_for_directory(directory_path: str) -> str:
4747
first_owner = owners[0].lower()
4848

4949
# Map the owner to a slack channel
50-
return GITHUB_SLACK_MAP.get(first_owner, DEFAULT_FUZZING_SLACK_CHANNEL)
50+
return GITHUB_SLACK_MAP.get(first_owner, DEFAULT_FUZZING_SLACK_CHANNEL).replace("#", "")
5151

5252
except Exception as e:
5353
print(
@@ -77,14 +77,22 @@ def build_and_upload_fuzz(ctx, team="chaos-platform", core_count=2, duration=360
7777
with ctx.cd(directory):
7878
# eg: convert "/path/to/fuzz/target" to "datadog-agent-path-to-fuzz-target".
7979
# It's a unique identifier for the fuzz target.
80+
# We also append the function name to the package name to make sure that every function inside the same package
81+
# has a unique target name. This allows us to have different inputs for different functions in the same package.
8082
rel = directory.removeprefix("/go/src/github.com/DataDog/datadog-agent/")
8183
pkgname = "datadog-agent-"
8284
pkgname += "-".join(rel.split('/'))[:max_pkg_name_length]
85+
pkgname += f"-{func}"
8386
build_file = "fuzz.test"
8487

8588
print(f'Building {pkgname}/{func} for {git_sha}...')
86-
fuzz_build_cmd = f'go test . -c -fuzz={func}$ -o {build_file} -cover -tags=test,linux_bpf'
87-
ctx.run(fuzz_build_cmd)
89+
fuzz_build_cmd = f'go test . -c -fuzz={func}$ -o {build_file} -cover -tags=test,linux_bpf,nvml,amd64'
90+
try:
91+
ctx.run(fuzz_build_cmd)
92+
except Exception as e:
93+
print(f'❌ Failed to build {pkgname}: {e}... Skipping this fuzz target')
94+
continue
95+
8896
build_full_path = directory + "/" + build_file
8997
if not os.path.exists(build_full_path):
9098
print(

0 commit comments

Comments
 (0)