aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorNorbert Schneider <norbert.schneider@code-intelligence.com>2023-03-10 14:50:55 +0100
committerNorbert Schneider <mail@bertschneider.de>2023-03-16 20:06:06 +0100
commit9313d63d8576bdee82135ce54bdc38cf98fcccb8 (patch)
treec628c357f53b9d9ebd31318f66b86b6303d351c4 /examples
parent4f12657fa80b6f2d8a03d4be103fe17d6ad96f95 (diff)
downloadjazzer-api-9313d63d8576bdee82135ce54bdc38cf98fcccb8.tar.gz
junit: Remove distinction between CLI and fuzz test invocation
No distinction of the invocation type is required anymore. Fuzz tests invoked via the CLI should behave the same as if they were invoked in JUnit tests.
Diffstat (limited to 'examples')
-rw-r--r--examples/junit/src/test/java/com/example/BUILD.bazel21
-rw-r--r--examples/junit/src/test/java/com/example/KeepGoingFuzzTest.java34
2 files changed, 55 insertions, 0 deletions
diff --git a/examples/junit/src/test/java/com/example/BUILD.bazel b/examples/junit/src/test/java/com/example/BUILD.bazel
index b214c765..5f0d68db 100644
--- a/examples/junit/src/test/java/com/example/BUILD.bazel
+++ b/examples/junit/src/test/java/com/example/BUILD.bazel
@@ -84,6 +84,27 @@ java_fuzz_target_test(
],
)
+java_fuzz_target_test(
+ name = "KeepGoingFuzzTest",
+ srcs = ["KeepGoingFuzzTest.java"],
+ allowed_findings = ["java.lang.IllegalArgumentException"],
+ expect_crash = False,
+ fuzzer_args = [
+ "--instrumentation_includes=com.example.**",
+ "--custom_hook_includes=com.example.**",
+ "--keep_going=3",
+ "-runs=10",
+ ],
+ target_class = "com.example.KeepGoingFuzzTest",
+ runtime_deps = [
+ ":junit_runtime",
+ ],
+ deps = [
+ "//src/main/java/com/code_intelligence/jazzer/junit:fuzz_test",
+ "@maven//:org_junit_jupiter_junit_jupiter_api",
+ ],
+)
+
# Verifies that fuzzer command-line arguments are honored for @FuzzTests.
java_fuzz_target_test(
name = "CommandLineFuzzTest",
diff --git a/examples/junit/src/test/java/com/example/KeepGoingFuzzTest.java b/examples/junit/src/test/java/com/example/KeepGoingFuzzTest.java
new file mode 100644
index 00000000..ad5d09d2
--- /dev/null
+++ b/examples/junit/src/test/java/com/example/KeepGoingFuzzTest.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2023 Code Intelligence GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example;
+
+import com.code_intelligence.jazzer.junit.FuzzTest;
+
+public class KeepGoingFuzzTest {
+ private static int counter = 0;
+
+ @FuzzTest
+ public void keepGoingFuzzTest(byte[] ignored) {
+ counter++;
+ if (counter == 1) {
+ throw new IllegalArgumentException("error1");
+ }
+ if (counter == 2) {
+ throw new IllegalArgumentException("error2");
+ }
+ }
+}