Skip to content

Commit 7345481

Browse files
gchateletMizux
authored andcommitted
Remove fuzztest support from OR-Tools (#4938)
* Remove fuzztest support from OR-Tools
1 parent e09ed7a commit 7345481

File tree

14 files changed

+18
-444
lines changed

14 files changed

+18
-444
lines changed

CMakeLists.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -202,32 +202,15 @@ if(BUILD_TESTING)
202202
CMAKE_DEPENDENT_OPTION(BUILD_benchmark "Build benchmark" OFF
203203
"NOT BUILD_DEPS" ON)
204204
set(BUILD_protobuf_matchers ON)
205-
# Fuzztest do not support MSVC or toolchain
206-
if(APPLE OR MSVC OR CMAKE_CROSSCOMPILING)
207-
set(USE_fuzztest OFF)
208-
else()
209-
# since no distro provide a fuzztest package disable support by default.
210-
CMAKE_DEPENDENT_OPTION(USE_fuzztest "Enable fuzztest" ${BUILD_DEPS} "BUILD_CXX" OFF)
211-
endif()
212-
if(NOT USE_fuzztest)
213-
set(BUILD_fuzztest OFF)
214-
else()
215-
CMAKE_DEPENDENT_OPTION(BUILD_fuzztest "Build fuzztest" OFF
216-
"NOT BUILD_DEPS" ON)
217-
endif()
218205
else()
219206
set(OR_TOOLS_BUILD_TESTING OFF)
220207
set(BUILD_googletest OFF)
221208
set(BUILD_protobuf_matchers OFF)
222209
set(BUILD_benchmark OFF)
223-
set(USE_fuzztest OFF)
224-
set(BUILD_fuzztest OFF)
225210
endif()
226211
message(STATUS "Build googletest: ${BUILD_googletest}")
227212
message(STATUS "Build protobuf_matchers: ${BUILD_protobuf_matchers}")
228213
message(STATUS "Build benchmark: ${BUILD_benchmark}")
229-
message(STATUS "Enable fuzztest: ${USE_fuzztest}")
230-
message(STATUS "Build fuzztest: ${BUILD_fuzztest}")
231214

232215
# Optional third party solvers (enabled by default)
233216
## BOP

MODULE.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ bazel_dep(name = "rules_shell", version = "0.6.1")
4141
bazel_dep(name = "abseil-cpp", version = "20250814.1")
4242
bazel_dep(name = "bzip2", version = "1.0.8.bcr.2")
4343
bazel_dep(name = "eigen", version = "3.4.0.bcr.3")
44-
bazel_dep(name = "fuzztest", version = "20250805.0")
4544
bazel_dep(name = "glpk", version = "5.0.bcr.4")
4645
bazel_dep(name = "google_benchmark", version = "1.9.2")
4746
bazel_dep(name = "googletest", version = "1.17.0")

cmake/check_deps.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ if(BUILD_TESTING)
121121
if(NOT TARGET benchmark::benchmark)
122122
message(FATAL_ERROR "Target benchmark::benchmark not available.")
123123
endif()
124-
if(USE_fuzztest AND NOT TARGET fuzztest::fuzztest)
125-
message(FATAL_ERROR "Target fuzztest::fuzztest not available.")
126-
endif()
127124
endif()
128125

129126
# Check language Dependencies

cmake/dependencies/CMakeLists.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -573,20 +573,3 @@ if(BUILD_benchmark)
573573
list(POP_BACK CMAKE_MESSAGE_INDENT)
574574
message(CHECK_PASS "fetched")
575575
endif()
576-
577-
if(BUILD_fuzztest)
578-
message(CHECK_START "Fetching fuzztest")
579-
list(APPEND CMAKE_MESSAGE_INDENT " ")
580-
FetchContent_Declare(
581-
fuzztest
582-
GIT_REPOSITORY https://github.com/google/fuzztest.git
583-
GIT_TAG 2025-08-05
584-
GIT_SHALLOW TRUE
585-
UPDATE_COMMAND git reset --hard
586-
PATCH_COMMAND git apply --ignore-whitespace
587-
"${CMAKE_CURRENT_LIST_DIR}/../../patches/fuzztest-2025-08-05.patch"
588-
)
589-
FetchContent_MakeAvailable(fuzztest)
590-
list(POP_BACK CMAKE_MESSAGE_INDENT)
591-
message(CHECK_PASS "fetched")
592-
endif()

cmake/system_deps.cmake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,6 @@ if(BUILD_TESTING)
112112
if(NOT BUILD_benchmark AND NOT TARGET benchmark::benchmark)
113113
find_package(benchmark REQUIRED)
114114
endif()
115-
116-
if(USE_fuzztest)
117-
if(NOT BUILD_fuzztest AND NOT TARGET fuzztest::fuzztest)
118-
find_package(fuzztest REQUIRED)
119-
endif()
120-
endif()
121115
endif()
122116

123117
# Check language Dependencies

ortools/algorithms/BUILD.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,3 +435,20 @@ cc_library(
435435
"@abseil-cpp//absl/time",
436436
],
437437
)
438+
439+
cc_test(
440+
name = "n_choose_k_test",
441+
srcs = ["n_choose_k_test.cc"],
442+
deps = [
443+
":n_choose_k",
444+
"//ortools/base:dump_vars",
445+
"//ortools/base:gmock_main",
446+
"//ortools/util:flat_matrix",
447+
"@abseil-cpp//absl/numeric:int128",
448+
"@abseil-cpp//absl/random",
449+
"@abseil-cpp//absl/random:distributions",
450+
"@abseil-cpp//absl/status",
451+
"@abseil-cpp//absl/status:statusor",
452+
"@google_benchmark//:benchmark",
453+
],
454+
)

ortools/algorithms/CMakeLists.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,6 @@ if(BUILD_TESTING)
5252
GTest::gmock
5353
)
5454
endforeach()
55-
if(USE_fuzztest)
56-
ortools_cxx_test(
57-
NAME
58-
algorithms_n_choose_k_test
59-
SOURCES
60-
"./n_choose_k_test.cc"
61-
LINK_LIBRARIES
62-
benchmark::benchmark
63-
fuzztest::fuzztest
64-
fuzztest::fuzztest_gtest_main
65-
GTest::gmock
66-
)
67-
endif()
68-
6955
# These tests are too long so we disable them.
7056
set_tests_properties(
7157
cxx_algorithms_radix_sort_test

ortools/algorithms/n_choose_k_test.cc

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,19 @@
1616
#include <cmath>
1717
#include <cstdint>
1818
#include <limits>
19-
#include <random>
20-
#include <utility>
21-
#include <vector>
2219

2320
#include "absl/numeric/int128.h"
2421
#include "absl/random/distributions.h"
2522
#include "absl/random/random.h"
2623
#include "absl/status/status.h"
2724
#include "absl/status/statusor.h"
28-
#include "benchmark/benchmark.h"
2925
#include "gtest/gtest.h"
3026
#include "ortools/base/dump_vars.h"
31-
//#include "ortools/base/fuzztest.h"
3227
#include "ortools/base/gmock.h"
33-
#include "ortools/base/mathutil.h"
3428
#include "ortools/util/flat_matrix.h"
3529

3630
namespace operations_research {
3731
namespace {
38-
//using ::fuzztest::NonNegative;
3932
using ::testing::HasSubstr;
4033
using ::testing::status::IsOkAndHolds;
4134
using ::testing::status::StatusIs;
@@ -248,74 +241,5 @@ TEST(NChooseKTest, ComparisonAgainstPascalTriangleForK5OrAbove) {
248241
}
249242
}
250243

251-
void MatchesLogCombinations(int n, int k) {
252-
if (n < k) {
253-
std::swap(k, n);
254-
}
255-
const auto exact = NChooseK(n, k);
256-
const double log_approx = MathUtil::LogCombinations(n, k);
257-
if (exact.ok()) {
258-
// We accepted to compute the exact value, make sure that it matches the
259-
// approximation.
260-
ASSERT_NEAR(log(exact.value()), log_approx, 0.0001);
261-
} else {
262-
// We declined to compute the exact value, make sure that we had a good
263-
// reason to, i.e. that the result did indeed overflow.
264-
ASSERT_THAT(exact, StatusIs(absl::StatusCode::kInvalidArgument,
265-
HasSubstr("overflows int64")));
266-
const double approx = exp(log_approx);
267-
ASSERT_GE(std::nextafter(approx, std::numeric_limits<double>::infinity()),
268-
std::numeric_limits<int64_t>::max())
269-
<< "we declined to compute the exact value of NChooseK(" << n << ", "
270-
<< k << "), but the log value is " << log_approx
271-
<< " (value: " << approx << "), which fits in int64_t";
272-
}
273-
}
274-
/*
275-
FUZZ_TEST(NChooseKTest, MatchesLogCombinations)
276-
// Ideally we'd test with `uint64_t`, but `LogCombinations` only accepts
277-
// `int`.
278-
.WithDomains(NonNegative<int>(), NonNegative<int>());
279-
*/
280-
template <int kMaxN, auto algo>
281-
void BM_NChooseK(benchmark::State& state) {
282-
static constexpr int kNumInputs = 1000;
283-
// Use deterministic random numbers to avoid noise.
284-
std::mt19937 gen(42);
285-
std::uniform_int_distribution<int64_t> random(0, kMaxN);
286-
std::vector<std::pair<int64_t, int64_t>> inputs;
287-
inputs.reserve(kNumInputs);
288-
for (int i = 0; i < kNumInputs; ++i) {
289-
int64_t n = random(gen);
290-
int64_t k = random(gen);
291-
if (n < k) {
292-
std::swap(n, k);
293-
}
294-
inputs.emplace_back(n, k);
295-
}
296-
// Force the one-time, costly static initializations of NChooseK() to happen
297-
// before the benchmark starts.
298-
auto result = NChooseK(62, 31);
299-
benchmark::DoNotOptimize(result);
300-
301-
// Start the benchmark.
302-
for (auto _ : state) {
303-
for (const auto [n, k] : inputs) {
304-
auto result = algo(n, k);
305-
benchmark::DoNotOptimize(result);
306-
}
307-
}
308-
state.SetItemsProcessed(state.iterations() * kNumInputs);
309-
}
310-
// int32_t domain.
311-
BENCHMARK(BM_NChooseK<30, operations_research::NChooseK>);
312-
313-
// int{32,64} domain.
314-
BENCHMARK(BM_NChooseK<60, operations_research::NChooseK>);
315-
316-
// int{32,64,128} domain.
317-
BENCHMARK(BM_NChooseK<100, operations_research::NChooseK>);
318-
BENCHMARK(BM_NChooseK<100, MathUtil::LogCombinations>);
319-
320244
} // namespace
321245
} // namespace operations_research

ortools/base/fuzztest.h

Lines changed: 0 additions & 51 deletions
This file was deleted.

ortools/math_opt/elemental/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ if(BUILD_TESTING)
5050
file(GLOB _TEST_SRCS "*_test.cc")
5151
list(FILTER _TEST_SRCS
5252
EXCLUDE REGEX "elemental_export_model_update_test.cc$")
53-
list(FILTER _TEST_SRCS
54-
EXCLUDE REGEX "elemental_from_proto_fuzz_test.cc$") # need fuzztest
5553
foreach(_FULL_FILE_NAME IN LISTS _TEST_SRCS)
5654
get_filename_component(_NAME ${_FULL_FILE_NAME} NAME_WE)
5755
get_filename_component(_FILE_NAME ${_FULL_FILE_NAME} NAME)

0 commit comments

Comments
 (0)