aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com
AgeCommit message (Collapse)Author
2023-03-13mutation: Add a mutator for Protobuf enum fieldsFabian Meumertzheim
Co-authored-by: Norbert Schneider <norbert.schneider@code-intelligence.com> Co-authored-by: Peter Samarin <peter.samarin@code-intelligence.com>
2023-03-07Added offline instrumentation supportCory Barker
2023-03-06initital proto2 support (#644)434b
initial proto2 support
2023-02-22mutation: Add enum mutatorFabian Meumertzheim
2023-02-17mutation: Validate annotation usage on fuzz target parametersFabian Meumertzheim
Annotations such as `@NotNull` and `@InRange` only apply to particular types and were silently ignored when applied on other types. This could lead to subtle issues such as the user (or the author of this commit) declaring a `@NotNull byte[]` parameter and being surprised to find that the byte array is sometimes `null` - the annotation applies to the primitive array component type rather than the array itself. This commit adds an `@AppliesTo` meta-annotation that can be used to describe the valid usage sites of an annotation. Valid uses are enforced both in `ArgumentsMutator` and the `StressTest`.
2023-02-17mutation: Add support for string fields in protosFabian Meumertzheim
2023-02-17mutation: Add support for bytes fields in protosFabian Meumertzheim
2023-02-17mutation: Add a mutator for StringFabian Meumertzheim
2023-02-17mutation: Actually implement the byte[] mutatorFabian Meumertzheim
2023-02-17mutation: Fix and test InputStreamSupport#readAllBytesFabian Meumertzheim
The function wasn't tested and - unsurprisingly - broken.
2023-02-16mutation: Add support for integral proto fieldsFabian Meumertzheim
2023-02-16mutation: Add proto3 tests to StressTestFabian Meumertzheim
When messages become too complex to exercise fully in unit tests, we should be adding them to `StressTest` instead.
2023-02-16mutation: Add a mutator for integral typesFabian Meumertzheim
The mutator applies to byte, short, int, and long as well as their wrapper types and is based on fuzztest's `InRange` and `Arbitrary` implementations for integral types. Also enhances the statistical tests performed in `StressTest` to more accurately assert the domain coverage achieved by the mutator.
2023-02-16mutation: Refactor and expand `PseudoRandom`Fabian Meumertzheim
Adds more helper functions to `PseudoRandom` for operations commonly encountered in mutators and not covered well by the standard `SplittableRandom` API. Also renames methods to be more descriptive.
2023-02-16mutation: Add explicit support for oneof message fieldsFabian Meumertzheim
While `oneof`s were handled by the existing code, the mutator wasn't aware of the `oneof`'s state and would thus change it frequently, which ends up invalidating mutations applied to its other fields. With this commit, `oneof` fields have their current state tracked and mutated in 1 out of 100 cases, which allows individual fields to reach more complicated states.
2023-02-16mutation: Add support for recursive message typesFabian Meumertzheim
In order to support Protobuf messages types that transitively refer to themselves, the factory for Builder mutators is modified to generate a single shared mutator instance for a given builder type, which ensures that recursive structures are represented as finite directed graphs (no longer just trees) of mutators.
2023-02-16mutation: Add support for repeated message fieldsFabian Meumertzheim
This requires introducing a new mutable list view as the reflection API for repeated message fields is subtly different from the one for other types of fields.
2023-02-16mutation: Add basic support for message fieldsFabian Meumertzheim
Support for repeated and recursive message fields will come in follow-up commits.
2023-02-16mutation: Make `toString()` work with cyclic mutator structuresFabian Meumertzheim
A new `getDebugString` function is introduced that provides a predicate as an argument with which implementors can check whether they are part of a cyclic structure (e.g. a self-referential Protobuf message). This requires making `SerializingMutator` an abstract class so that an implementation of `toString` can be provided.
2023-02-16mutation: Do not keep MutatorFactory in static final fieldsFabian Meumertzheim
Instead, since MutatorFactories are generally lightweight, they can be recreated on demand via static `newFactory` calls. This allows them to maintain instance state without the need for synchronization.
2023-02-16mutation: Make BuilderMutatorFactory a regular MutatorFactoryFabian Meumertzheim
This has multiple advantages: * No longer need to reflectively get a Parser for a message. * Users can request Builders as arguments. * Allows Builders to be created as needed to support embedded message fields. * Reduces MessageMutatorFactory to a single mutateThenMapToImmutable call.
2023-02-16mutation: Add a few utility methodsFabian Meumertzheim
This adds: * asSubclassOrEmpty as a variant of Class#asSubclass; * an overload of combine that assembles a SerializingInPlaceMutator; * an overload of MutatorFactory#createInPlaceOrThrow for AnnotatedType.
2023-02-16Add a structured mutation frameworkFabian Meumertzheim
2023-02-07agent: Fix Kotlin compiler warnings about `@OptIn` (#618)Fabian Meumertzheim
Some `@OptIn`s aren't needed anymore, the other can be replaced with dedicated annotations that do not require special compiler flags.
2023-01-26all: Extract fuzz target finding out of FuzzTargetRunnerFabian Meumertzheim
FuzzTargetRunner now interfaces with the rest of code only via the global FuzzTarget field on FuzzTargetHolder, which contains the resolved fuzz target method and instance as reflect objects. As a result, the JUnit extension can directly pass in the objects it has access to without going through the class name and letting FuzzTargetFinder find the fuzz test method.
2023-01-26driver: Install agent in Driver rather than FuzzTargetRunnerFabian Meumertzheim
The JUnit extension already installed the agent manually, so the call to `AgentInstaller#install` in `FuzzTargetRunner` only took effect when called from `Driver`.
2023-01-26tests: Make FuzzTargetRunnerTest fail quickly rather than timeoutFabian Meumertzheim
If an assertion in `fuzzerTearDown` failed, the test timed out rather than failing quickly. This is fixed by catching assertion failures and halting with a non-zero exit code.
2023-01-18junit: Simplify and improve inputs directory discoveryFabian Meumertzheim
Inputs directory handling was confusing as e.g. Maven doesn't copy over empty resource directories by default. Instead of relying on that, always fall back to locating the inputs directory in the source tree and even try to create it if at least the test resources root is found.
2023-01-12all: Use logger class everywhereFabian Meumertzheim
This commit replaces all direct usages of `System.err` and `System.out` with equivalent `Log` method calls. This change is meant to be mostly invisible to users. In some cases the formatting is changed as we no longer manually wrap lines, which we never did in a consistent manner. If we want to bring back line breaks, we should implement this in `Log` instead in a follow-up PR. In some cases unstructured logging to stdout is moved to stderr. Fixes FUZZ-480
2023-01-05autofuzz: Fix handling of generic array typesFabian Meumertzheim
Before this commit, `consume` would construct an `Object[]` when a `Class<?>[]` was requested, leading to `IllegalArgumentExeption`s.
2023-01-02junit: Disable hooks in non-fuzz tests during regression testingFabian Meumertzheim
This makes it possible to run fuzz tests alongside unit tests without having the instrumentation applied by the agent interfere with unit tests, e.g. by throwing unexpected exceptions.
2023-01-02agent: Allow hooks to be enabled conditionallyFabian Meumertzheim
This is used in a follow-up commit to seletively enable hooks in `@FuzzTest`s but not unit tests during JUnit regression test runs. Since the additional bytecode for conditional hooks is guarded behind a property, no performance overhead is expected during fuzzing.
2023-01-02ci: Address linter errorsFabian Meumertzheim
2022-12-26tests: Reenable `FuzzTestExecutorTest`Fabian Meumertzheim
This test was disabled accidentally in 727ecb9bdfc25500533e8d4a43d30524b4677fc8.
2022-12-22format: update scripts and docs, and rerun the scriptsKhaled Yakdan
2022-12-20junit: Implement fuzzing within JUnit JupiterFabian Meumertzheim
Instead of implementing fuzzing runs as a custom JUnit test engine, this commit implements it within the JUnit Jupiter platform instead. The main benefit of this approach is the full and effortless interoperability with lifecycle hooks such as `@BeforeAll` and `@AfterAll`. The new implementation is also significantly shorter and automatically avoids inconsistencies such as https://github.com/CodeIntelligenceTesting/jazzer/issues/539 and https://github.com/CodeIntelligenceTesting/jazzer/issues/543. The new implementation models fuzzing as a single invocation of the `@ParameterizedTest` used for the regression test with fake arguments named `Fuzzing...`. The registered `InvocationInterceptor` is then used to replace the invocation with the actual fuzzing run. In this way, `@FuzzTest` methods invoke `@BeforeEach` hooks once before fuzzing starts. Having the invocation represented as a single invocation parametrized test should make this behavior less surprising. Fixes #543
2022-12-19all: Merge `//driver/...` and `//agent/...`Fabian Meumertzheim
The "driver" and the "agent" used to be separate components of Jazzer that were written in different languages (C++ and Java), but this is no longer the case: They are now mostly implemented in Java and deployed as a single jar. The natural separation into Java packages rather than top-level directories fits this architecture better. This commit has been produced by moving the directory contents, replacing `//(agent|driver)/` with `//`, running `buildifier -r .` and manually editing non-BUILD occurences (e.g. .bazelrc, format.sh as well as runfiles paths).