Support "size" and "timeout" on *_fuzz_test (#204)
diff --git a/examples/BUILD b/examples/BUILD
index 65219ca..e4a4eef 100644
--- a/examples/BUILD
+++ b/examples/BUILD
@@ -21,6 +21,7 @@
cc_fuzz_test(
name = "empty_fuzz_test",
+ size = "small",
srcs = ["empty_fuzz_test.cc"],
)
@@ -32,6 +33,7 @@
# This target shows how to create a fuzz test target with corpus files.
cc_fuzz_test(
name = "empty_fuzz_test_with_corpus",
+ timeout = "short",
srcs = ["empty_fuzz_test.cc"],
corpus = [
"corpus_0.txt",
diff --git a/examples/java/BUILD b/examples/java/BUILD
index c35edd2..b6a8b42 100644
--- a/examples/java/BUILD
+++ b/examples/java/BUILD
@@ -29,6 +29,7 @@
java_fuzz_test(
name = "EmptyFuzzTest",
+ size = "small",
srcs = ["com/example/EmptyFuzzTest.java"],
corpus = [
"corpus_0.txt",
@@ -37,6 +38,7 @@
java_fuzz_test(
name = "FuzzTest",
+ timeout = "short",
srcs = ["com/example/FuzzTest.java"],
tags = [
"no-oss-fuzz",
diff --git a/fuzzing/private/fuzz_test.bzl b/fuzzing/private/fuzz_test.bzl
index 96f9c74..3a21942 100644
--- a/fuzzing/private/fuzz_test.bzl
+++ b/fuzzing/private/fuzz_test.bzl
@@ -32,7 +32,9 @@
dicts = None,
instrument_binary = True,
define_regression_test = True,
- test_tags = None):
+ test_size = None,
+ test_tags = None,
+ test_timeout = None):
"""Generates the standard targets associated to a fuzz test.
This macro can be used to define custom fuzz test rules in case the default
@@ -62,7 +64,9 @@
default instrumentation mode does not work for your use case, please
file a Github issue to discuss.
define_regression_test: If true, generate a regression test rule.
+ test_size: The size of the fuzzing regression test.
test_tags: Tags set on the fuzzing regression test.
+ test_timeout: The timeout for the fuzzing regression test.
"""
# We tag all non-test targets as "manual" in order to optimize the build
@@ -122,7 +126,9 @@
fuzzing_regression_test(
name = name,
binary = instrum_binary_name,
+ size = test_size,
tags = test_tags,
+ timeout = test_timeout,
)
oss_fuzz_package(
@@ -138,7 +144,9 @@
corpus = None,
dicts = None,
engine = "@rules_fuzzing//fuzzing:cc_engine",
+ size = None,
tags = None,
+ timeout = None,
**binary_kwargs):
"""Defines a C++ fuzz test and a few associated tools and metadata.
@@ -164,7 +172,11 @@
corpus: A list containing corpus files.
dicts: A list containing dictionaries.
engine: A label pointing to the fuzzing engine to use.
- tags: Tags set on the fuzzing regression test.
+ size: The size of the regression test. This does *not* affect fuzzing
+ itself. Takes the [common size values](https://bazel.build/reference/be/common-definitions#test.size).
+ tags: Tags set on the regression test.
+ timeout: The timeout for the regression test. This does *not* affect
+ fuzzing itself. Takes the [common timeout values](https://docs.bazel.build/versions/main/be/common-definitions.html#test.timeout).
**binary_kwargs: Keyword arguments directly forwarded to the fuzz test
binary rule.
"""
@@ -194,9 +206,11 @@
engine = engine,
corpus = corpus,
dicts = dicts,
+ test_size = size,
test_tags = (tags or []) + [
"fuzz-test",
],
+ test_timeout = timeout,
)
def java_fuzz_test(
@@ -206,7 +220,9 @@
corpus = None,
dicts = None,
engine = "@rules_fuzzing//fuzzing:java_engine",
+ size = None,
tags = None,
+ timeout = None,
**binary_kwargs):
"""Defines a Java fuzz test and a few associated tools and metadata.
@@ -235,7 +251,11 @@
corpus: A list containing corpus files.
dicts: A list containing dictionaries.
engine: A label pointing to the fuzzing engine to use.
- tags: Tags set on the fuzzing regression test.
+ size: The size of the regression test. This does *not* affect fuzzing
+ itself. Takes the [common size values](https://bazel.build/reference/be/common-definitions#test.size).
+ tags: Tags set on the regression test.
+ timeout: The timeout for the regression test. This does *not* affect
+ fuzzing itself. Takes the [common timeout values](https://docs.bazel.build/versions/main/be/common-definitions.html#test.timeout).
**binary_kwargs: Keyword arguments directly forwarded to the fuzz test
binary rule.
"""
@@ -316,7 +336,9 @@
engine = engine,
corpus = corpus,
dicts = dicts,
+ test_size = size,
test_tags = (tags or []) + [
"fuzz-test",
],
+ test_timeout = timeout,
)