Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify building and testing #548

Merged
merged 4 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ build --incompatible_strict_action_env
build --sandbox_tmpfs_path=/tmp
build --enable_platform_specific_config
build -c opt
# Ensure that paths of files printed by our examples are valid.
# Enabling this on Windows leads to an error.
# FIXME: Remove this workaround once
# https://github.com/bazelbuild/bazel/pull/16973 has been merged.
build:linux --nozip_undeclared_test_outputs
build:macos --nozip_undeclared_test_outputs

# C/C++
# GCC is supported on a best-effort basis.
common --repo_env=CC=clang
# We want stock LLVM to be configured on macOS rather than Xcode's Apple Clang
# toolchain.
Expand Down Expand Up @@ -48,7 +55,6 @@ test --test_env=JAZZER_AUTOFUZZ_DEBUG
test --test_env=JAZZER_REFLECTION_DEBUG

# CI tests (not using the toolchain to test OSS-Fuzz & local compatibility)
test:ci --test_env=JAZZER_CI=1
build:ci --bes_results_url=https://app.buildbuddy.io/invocation/
build:ci --bes_backend=grpcs://remote.buildbuddy.io
build:ci --remote_cache=grpcs://remote.buildbuddy.io
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,8 @@ jobs:
name: jazzer
path: _tmp/jazzer.jar
if-no-files-found: error

- name: Delete temporary artifacts
uses: actions/delete-artifact@v2
with:
name: jazzer_tmp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@

@AutoBazelRepository
public class FuzzTargetTestWrapper {
private static final boolean JAZZER_CI = "1".equals(System.getenv("JAZZER_CI"));
private static final String EXCEPTION_PREFIX = "== Java Exception: ";
private static final String FRAME_PREFIX = "\tat ";
private static final Pattern SANITIZER_FINDING = Pattern.compile("^SUMMARY: \\w*Sanitizer");
Expand Down Expand Up @@ -123,26 +122,20 @@ public static void main(String[] args) {
}
command.addAll(arguments);

if (JAZZER_CI) {
// Make JVM error reports available in test outputs.
processBuilder.environment().put(
"JAVA_TOOL_OPTIONS", String.format("-XX:ErrorFile=%s/hs_err_pid%%p.log", outputDir));
processBuilder.redirectOutput(Redirect.INHERIT);
processBuilder.redirectInput(Redirect.INHERIT);
} else {
processBuilder.inheritIO();
}
// Make JVM error reports available in test outputs.
processBuilder.environment().put(
"JAVA_TOOL_OPTIONS", String.format("-XX:ErrorFile=%s/hs_err_pid%%p.log", outputDir));
processBuilder.redirectOutput(Redirect.INHERIT);
processBuilder.redirectInput(Redirect.INHERIT);
processBuilder.command(command);

try {
Process process = processBuilder.start();
if (JAZZER_CI) {
try {
verifyFuzzerOutput(
process.getErrorStream(), allowedFindings, arguments.contains("--nohooks"));
} finally {
process.getErrorStream().close();
}
try {
verifyFuzzerOutput(
process.getErrorStream(), allowedFindings, arguments.contains("--nohooks"));
} finally {
process.getErrorStream().close();
}
int exitCode = process.waitFor();
if (!expectCrash) {
Expand All @@ -166,7 +159,7 @@ public static void main(String[] args) {
System.exit(1);
}
// Verify that libFuzzer dumped a crashing input.
if (JAZZER_CI && shouldVerifyCrashInput
if (shouldVerifyCrashInput
&& outputFiles.stream().noneMatch(
name -> name.getFileName().toString().startsWith("crash-"))
&& !(allowedFindings.contains("timeout")
Expand All @@ -176,7 +169,7 @@ public static void main(String[] args) {
System.exit(1);
}
// Verify that libFuzzer dumped a crash reproducer.
if (JAZZER_CI && shouldVerifyCrashReproducer
if (shouldVerifyCrashReproducer
&& outputFiles.stream().noneMatch(
name -> name.getFileName().toString().startsWith("Crash_"))) {
System.err.printf("No crash reproducer found in %s%n", outputDir);
Expand All @@ -187,7 +180,7 @@ public static void main(String[] args) {
System.exit(1);
}

if (JAZZER_CI && shouldVerifyCrashReproducer) {
if (shouldVerifyCrashReproducer) {
try {
verifyCrashReproducer(outputDir, apiActualPath, targetJarActualPath, allowedFindings);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <dlfcn.h>
#include <stdatomic.h>
#include <stddef.h>
#include <stdint.h>
#ifdef __APPLE__
// Using dyld's interpose feature requires knowing the addresses of libc
// functions.
Expand Down
4 changes: 2 additions & 2 deletions tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ java_fuzz_target_test(
# Regression test for https://github.com/CodeIntelligenceTesting/jazzer/issues/405.
java_fuzz_target_test(
name = "MemoryLeakFuzzer",
timeout = "short",
timeout = "moderate",
srcs = ["src/test/java/com/example/MemoryLeakFuzzer.java"],
allowed_findings = ["com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow"],
env = {
Expand Down Expand Up @@ -185,7 +185,7 @@ java_fuzz_target_test(

java_fuzz_target_test(
name = "BytesMemoryLeakFuzzer",
timeout = "short",
timeout = "moderate",
srcs = ["src/test/java/com/example/BytesMemoryLeakFuzzer.java"],
env = {
"JAVA_OPTS": "-Xmx200m",
Expand Down
1 change: 0 additions & 1 deletion third_party/libFuzzer.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ cc_library(
"-fno-exceptions",
"-funwind-tables",
"-fno-stack-protector",
"-fno-sanitize=safe-stack",
"-fvisibility=hidden",
"-fno-lto",
] + select({
Expand Down