Replace FUZZTEST_STACK_LIMIT by --stack_limit_kb (#2470)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 702739c..be9a216 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -179,7 +179,7 @@
# FuzzTest bundles GoogleTest so no need to link to gtest librairies.
target_link_libraries(${TEST_NAME} PRIVATE avif_fuzztest_helpers aviftest_helpers_internal avif_enable_warnings)
link_fuzztest(${TEST_NAME})
- add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
+ add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME} --stack_limit_kb=512)
set_property(TEST ${TEST_NAME} PROPERTY ENVIRONMENT "TEST_DATA_DIRS=${CMAKE_CURRENT_SOURCE_DIR}/data/")
endmacro()
@@ -218,6 +218,7 @@
add_avif_fuzztest(avif_fuzztest_dec_incr gtest/avifincrtest_helpers.cc)
add_avif_fuzztest(avif_fuzztest_enc_dec)
add_avif_fuzztest(avif_fuzztest_enc_dec_anim)
+ add_avif_fuzztest(avif_fuzztest_enc_dec_incr gtest/avifincrtest_helpers.cc)
add_avif_fuzztest(avif_fuzztest_read_image)
add_avif_fuzztest(avif_fuzztest_yuvrgb)
@@ -225,8 +226,6 @@
add_avif_fuzztest(avif_fuzztest_enc_dec_experimental)
add_avif_fuzztest(avif_fuzztest_enc_dec_incr_experimental gtest/avifincrtest_helpers.cc)
endif()
-
- add_avif_fuzztest(avif_fuzztest_enc_dec_incr gtest/avifincrtest_helpers.cc)
else()
message(STATUS "FuzzTest targets are disabled because AVIF_ENABLE_FUZZTEST is OFF.")
endif()
diff --git a/tests/gtest/avif_fuzztest_dec.cc b/tests/gtest/avif_fuzztest_dec.cc
index 2aeeef5..7dc5bfc 100644
--- a/tests/gtest/avif_fuzztest_dec.cc
+++ b/tests/gtest/avif_fuzztest_dec.cc
@@ -16,8 +16,6 @@
namespace testutil {
namespace {
-::testing::Environment* const kStackLimitEnv = SetStackLimitTo512x1024Bytes();
-
//------------------------------------------------------------------------------
void Decode(const std::string& arbitrary_bytes, bool is_persistent,
diff --git a/tests/gtest/avif_fuzztest_dec_incr.cc b/tests/gtest/avif_fuzztest_dec_incr.cc
index 5d7814f..8161c8f 100644
--- a/tests/gtest/avif_fuzztest_dec_incr.cc
+++ b/tests/gtest/avif_fuzztest_dec_incr.cc
@@ -19,8 +19,6 @@
namespace testutil {
namespace {
-::testing::Environment* const kStackLimitEnv = SetStackLimitTo512x1024Bytes();
-
//------------------------------------------------------------------------------
struct DecoderInput {
diff --git a/tests/gtest/avif_fuzztest_enc_dec.cc b/tests/gtest/avif_fuzztest_enc_dec.cc
index 0b727f3..f31afc4 100644
--- a/tests/gtest/avif_fuzztest_enc_dec.cc
+++ b/tests/gtest/avif_fuzztest_enc_dec.cc
@@ -13,8 +13,6 @@
namespace testutil {
namespace {
-::testing::Environment* const kStackLimitEnv = SetStackLimitTo512x1024Bytes();
-
void EncodeDecodeValid(ImagePtr image, EncoderPtr encoder, DecoderPtr decoder) {
ImagePtr decoded_image(avifImageCreateEmpty());
ASSERT_NE(image.get(), nullptr);
diff --git a/tests/gtest/avif_fuzztest_enc_dec_anim.cc b/tests/gtest/avif_fuzztest_enc_dec_anim.cc
index 797e6d9..f0cf44a 100644
--- a/tests/gtest/avif_fuzztest_enc_dec_anim.cc
+++ b/tests/gtest/avif_fuzztest_enc_dec_anim.cc
@@ -15,8 +15,6 @@
namespace testutil {
namespace {
-::testing::Environment* const kStackLimitEnv = SetStackLimitTo512x1024Bytes();
-
struct FrameOptions {
uint64_t duration;
avifAddImageFlags flags;
diff --git a/tests/gtest/avif_fuzztest_enc_dec_experimental.cc b/tests/gtest/avif_fuzztest_enc_dec_experimental.cc
index 718f53e..2076424 100644
--- a/tests/gtest/avif_fuzztest_enc_dec_experimental.cc
+++ b/tests/gtest/avif_fuzztest_enc_dec_experimental.cc
@@ -17,8 +17,6 @@
namespace testutil {
namespace {
-::testing::Environment* const kStackLimitEnv = SetStackLimitTo512x1024Bytes();
-
void CheckGainMapMetadataMatches(const avifGainMap& actual,
const avifGainMap& expected) {
EXPECT_EQ(actual.baseHdrHeadroom.n, expected.baseHdrHeadroom.n);
diff --git a/tests/gtest/avif_fuzztest_enc_dec_incr.cc b/tests/gtest/avif_fuzztest_enc_dec_incr.cc
index 14917f3..d4b7a1a 100644
--- a/tests/gtest/avif_fuzztest_enc_dec_incr.cc
+++ b/tests/gtest/avif_fuzztest_enc_dec_incr.cc
@@ -21,8 +21,6 @@
namespace testutil {
namespace {
-::testing::Environment* const kStackLimitEnv = SetStackLimitTo512x1024Bytes();
-
// Encodes an image into an AVIF grid then decodes it.
void EncodeDecodeGridValid(ImagePtr image, EncoderPtr encoder,
DecoderPtr decoder, uint32_t grid_cols,
diff --git a/tests/gtest/avif_fuzztest_enc_dec_incr_experimental.cc b/tests/gtest/avif_fuzztest_enc_dec_incr_experimental.cc
index a7b410c..6f0aa03 100644
--- a/tests/gtest/avif_fuzztest_enc_dec_incr_experimental.cc
+++ b/tests/gtest/avif_fuzztest_enc_dec_incr_experimental.cc
@@ -21,8 +21,6 @@
namespace testutil {
namespace {
-::testing::Environment* const kStackLimitEnv = SetStackLimitTo512x1024Bytes();
-
// Encodes an image into an AVIF grid then decodes it.
void EncodeDecodeGridValid(ImagePtr image, EncoderPtr encoder,
DecoderPtr decoder, uint32_t grid_cols,
diff --git a/tests/gtest/avif_fuzztest_helpers.cc b/tests/gtest/avif_fuzztest_helpers.cc
index c4fb021..4216920 100644
--- a/tests/gtest/avif_fuzztest_helpers.cc
+++ b/tests/gtest/avif_fuzztest_helpers.cc
@@ -270,10 +270,6 @@
};
} // namespace
-::testing::Environment* SetEnv(const char* name, const char* value) {
- return ::testing::AddGlobalTestEnvironment(new Environment(name, value));
-}
-
//------------------------------------------------------------------------------
std::vector<std::string> GetSeedDataDirs() {
diff --git a/tests/gtest/avif_fuzztest_helpers.h b/tests/gtest/avif_fuzztest_helpers.h
index 6564bc9..d107c7e 100644
--- a/tests/gtest/avif_fuzztest_helpers.h
+++ b/tests/gtest/avif_fuzztest_helpers.h
@@ -300,16 +300,6 @@
#endif // AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP
//------------------------------------------------------------------------------
-// Environment setup
-
-// Sets the environment variable 'name' to the 'value' during the setup step.
-::testing::Environment* SetEnv(const char* name, const char* value);
-
-inline ::testing::Environment* SetStackLimitTo512x1024Bytes() {
- return SetEnv("FUZZTEST_STACK_LIMIT", "524288");
-}
-
-//------------------------------------------------------------------------------
// Returns the paths contained in the 'TEST_DATA_DIRS' environment variable.
// Several paths can be set in the variable, separated by ';'.
diff --git a/tests/gtest/avif_fuzztest_read_image.cc b/tests/gtest/avif_fuzztest_read_image.cc
index b0b893d..9f39b61 100644
--- a/tests/gtest/avif_fuzztest_read_image.cc
+++ b/tests/gtest/avif_fuzztest_read_image.cc
@@ -22,8 +22,6 @@
namespace testutil {
namespace {
-::testing::Environment* const kStackLimitEnv = SetStackLimitTo512x1024Bytes();
-
//------------------------------------------------------------------------------
std::string FileFormatToString(avifAppFileFormat file_format) {
diff --git a/tests/oss-fuzz/build.sh b/tests/oss-fuzz/build.sh
index 6327c20..8719e9d 100755
--- a/tests/oss-fuzz/build.sh
+++ b/tests/oss-fuzz/build.sh
@@ -107,7 +107,7 @@
this_dir=\$(dirname \"\$0\")
export TEST_DATA_DIRS=\$this_dir/corpus
chmod +x \$this_dir/$fuzz_basename
-\$this_dir/$fuzz_basename --fuzz=$fuzz_entrypoint -- \$@
+\$this_dir/$fuzz_basename --fuzz=$fuzz_entrypoint --stack_limit_kb=512 -- \$@
chmod -x \$this_dir/$fuzz_basename" > $OUT/$TARGET_FUZZER
chmod +x $OUT/$TARGET_FUZZER
done