aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Meumertzheim <fabian@meumertzhe.im>2022-08-11 09:59:31 +0200
committerFabian Meumertzheim <fabian@meumertzhe.im>2022-08-15 22:27:22 +0200
commit766b77226a38388b772983aafe40c9c230a882a1 (patch)
treea803f73bd3e8cd6c8f1c5e6bf7c617cefb2b6eea
parent0c8cb3317c2db790e1efebb5122afc1e6797a17c (diff)
downloadjazzer-api-766b77226a38388b772983aafe40c9c230a882a1.tar.gz
tests: Verify that the driver indirectly sets Jazzer.SEED
-rw-r--r--tests/BUILD.bazel12
-rw-r--r--tests/src/test/java/com/example/SeedFuzzer.java30
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel
index ee927aef..ba2a8f6d 100644
--- a/tests/BUILD.bazel
+++ b/tests/BUILD.bazel
@@ -211,3 +211,15 @@ java_fuzz_target_test(
],
target_class = "com.example.NoCoverageFuzzer",
)
+
+java_fuzz_target_test(
+ name = "SeedFuzzer",
+ timeout = "short",
+ srcs = ["src/test/java/com/example/SeedFuzzer.java"],
+ expect_crash = False,
+ fuzzer_args = [
+ "-runs=0",
+ "-seed=1234567",
+ ],
+ target_class = "com.example.SeedFuzzer",
+)
diff --git a/tests/src/test/java/com/example/SeedFuzzer.java b/tests/src/test/java/com/example/SeedFuzzer.java
new file mode 100644
index 00000000..4d1e4e8b
--- /dev/null
+++ b/tests/src/test/java/com/example/SeedFuzzer.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2022 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.api.FuzzerSecurityIssueLow;
+import com.code_intelligence.jazzer.api.Jazzer;
+
+public class SeedFuzzer {
+ public static void fuzzerInitialize() {
+ if (Jazzer.SEED != 1234567) {
+ throw new FuzzerSecurityIssueLow("Expected Jazzer.SEED to be 1234567, got " + Jazzer.SEED);
+ }
+ }
+
+ public static void fuzzerTestOneInput(byte[] data) {}
+}