diff --git a/libcxx/test/libcxx/fuzzing/unique.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/fuzz.unique.sh.cpp rename from libcxx/test/libcxx/fuzzing/unique.pass.cpp rename to libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/fuzz.unique.sh.cpp --- a/libcxx/test/libcxx/fuzzing/unique.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/fuzz.unique.sh.cpp @@ -8,12 +8,16 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { std::vector working(data, data + size); diff --git a/libcxx/test/libcxx/fuzzing/unique_copy.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/fuzz.unique_copy.sh.cpp rename from libcxx/test/libcxx/fuzzing/unique_copy.pass.cpp rename to libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/fuzz.unique_copy.sh.cpp --- a/libcxx/test/libcxx/fuzzing/unique_copy.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.unique/fuzz.unique_copy.sh.cpp @@ -8,13 +8,17 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { std::vector working(data, data + size); diff --git a/libcxx/test/libcxx/fuzzing/search.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/fuzz.sh.cpp rename from libcxx/test/libcxx/fuzzing/search.pass.cpp rename to libcxx/test/std/algorithms/alg.nonmodifying/alg.search/fuzz.sh.cpp --- a/libcxx/test/libcxx/fuzzing/search.pass.cpp +++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/fuzz.sh.cpp @@ -8,13 +8,17 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { if (size < 2) diff --git a/libcxx/test/libcxx/fuzzing/make_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/fuzz.sh.cpp rename from libcxx/test/libcxx/fuzzing/make_heap.pass.cpp rename to libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/fuzz.sh.cpp --- a/libcxx/test/libcxx/fuzzing/make_heap.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/fuzz.sh.cpp @@ -8,12 +8,16 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { std::vector working(data, data + size); diff --git a/libcxx/test/libcxx/fuzzing/pop_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/fuzz.sh.cpp rename from libcxx/test/libcxx/fuzzing/pop_heap.pass.cpp rename to libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/fuzz.sh.cpp --- a/libcxx/test/libcxx/fuzzing/pop_heap.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/fuzz.sh.cpp @@ -8,12 +8,16 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { if (size < 2) diff --git a/libcxx/test/libcxx/fuzzing/push_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/fuzz.sh.cpp rename from libcxx/test/libcxx/fuzzing/push_heap.pass.cpp rename to libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/fuzz.sh.cpp --- a/libcxx/test/libcxx/fuzzing/push_heap.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/fuzz.sh.cpp @@ -8,12 +8,16 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { if (size < 2) diff --git a/libcxx/test/libcxx/fuzzing/nth_element.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.nth.element/fuzz.sh.cpp rename from libcxx/test/libcxx/fuzzing/nth_element.pass.cpp rename to libcxx/test/std/algorithms/alg.sorting/alg.nth.element/fuzz.sh.cpp --- a/libcxx/test/libcxx/fuzzing/nth_element.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.nth.element/fuzz.sh.cpp @@ -8,12 +8,16 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" // Use the first element as a position into the data extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { diff --git a/libcxx/test/libcxx/fuzzing/partition.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.partitions/fuzz.partition.sh.cpp rename from libcxx/test/libcxx/fuzzing/partition.pass.cpp rename to libcxx/test/std/algorithms/alg.sorting/alg.partitions/fuzz.partition.sh.cpp --- a/libcxx/test/libcxx/fuzzing/partition.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.partitions/fuzz.partition.sh.cpp @@ -8,12 +8,16 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { auto is_even = [](auto x) { return x % 2 == 0; }; diff --git a/libcxx/test/libcxx/fuzzing/partition_copy.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.partitions/fuzz.partition_copy.sh.cpp rename from libcxx/test/libcxx/fuzzing/partition_copy.pass.cpp rename to libcxx/test/std/algorithms/alg.sorting/alg.partitions/fuzz.partition_copy.sh.cpp --- a/libcxx/test/libcxx/fuzzing/partition_copy.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.partitions/fuzz.partition_copy.sh.cpp @@ -8,13 +8,17 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { auto is_even = [](auto t) { diff --git a/libcxx/test/libcxx/fuzzing/stable_partition.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.partitions/fuzz.stable_partition.sh.cpp rename from libcxx/test/libcxx/fuzzing/stable_partition.pass.cpp rename to libcxx/test/std/algorithms/alg.sorting/alg.partitions/fuzz.stable_partition.sh.cpp --- a/libcxx/test/libcxx/fuzzing/stable_partition.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.partitions/fuzz.stable_partition.sh.cpp @@ -8,12 +8,16 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { auto is_even = [](auto b) { return b.key % 2 == 0; }; diff --git a/libcxx/test/libcxx/fuzzing/partial_sort_copy.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/fuzz.sh.cpp rename from libcxx/test/libcxx/fuzzing/partial_sort_copy.pass.cpp rename to libcxx/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/fuzz.sh.cpp --- a/libcxx/test/libcxx/fuzzing/partial_sort_copy.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/fuzz.sh.cpp @@ -8,12 +8,16 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" // Use the first element as a count extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { diff --git a/libcxx/test/libcxx/fuzzing/partial_sort.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/partial.sort/fuzz.sh.cpp rename from libcxx/test/libcxx/fuzzing/partial_sort.pass.cpp rename to libcxx/test/std/algorithms/alg.sorting/alg.sort/partial.sort/fuzz.sh.cpp --- a/libcxx/test/libcxx/fuzzing/partial_sort.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/partial.sort/fuzz.sh.cpp @@ -8,12 +8,16 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" // Use the first element as a position into the data extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { diff --git a/libcxx/test/libcxx/fuzzing/sort.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/fuzz.sh.cpp rename from libcxx/test/libcxx/fuzzing/sort.pass.cpp rename to libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/fuzz.sh.cpp --- a/libcxx/test/libcxx/fuzzing/sort.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/fuzz.sh.cpp @@ -8,12 +8,16 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { std::vector working(data, data + size); diff --git a/libcxx/test/libcxx/fuzzing/stable_sort.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/stable.sort/fuzz.sh.cpp rename from libcxx/test/libcxx/fuzzing/stable_sort.pass.cpp rename to libcxx/test/std/algorithms/alg.sorting/alg.sort/stable.sort/fuzz.sh.cpp --- a/libcxx/test/libcxx/fuzzing/stable_sort.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/stable.sort/fuzz.sh.cpp @@ -8,12 +8,16 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) { std::vector input; diff --git a/libcxx/test/libcxx/fuzzing/random.pass.cpp b/libcxx/test/std/numerics/rand/rand.dist/fuzz.sh.cpp rename from libcxx/test/libcxx/fuzzing/random.pass.cpp rename to libcxx/test/std/numerics/rand/rand.dist/fuzz.sh.cpp --- a/libcxx/test/libcxx/fuzzing/random.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dist/fuzz.sh.cpp @@ -8,6 +8,10 @@ // UNSUPPORTED: c++03, c++11 +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include @@ -17,7 +21,7 @@ #include #include -#include "fuzz.h" +#include "fuzz_helper.h" template std::vector GetValues(const std::uint8_t *data, std::size_t size) { diff --git a/libcxx/test/libcxx/fuzzing/regex.pass.cpp b/libcxx/test/std/re/fuzz.sh.cpp rename from libcxx/test/libcxx/fuzzing/regex.pass.cpp rename to libcxx/test/std/re/fuzz.sh.cpp --- a/libcxx/test/libcxx/fuzzing/regex.pass.cpp +++ b/libcxx/test/std/re/fuzz.sh.cpp @@ -10,12 +10,16 @@ // UNSUPPORTED: no-exceptions // UNSUPPORTED: no-localization +// REQUIRES: clang || apple-clang +// RUN: %{build} -fsanitize=fuzzer +// RUN: %{run} -max_total_time=10 + #include #include #include #include -#include "fuzz.h" +#include "fuzz_helper.h" template static int regex_test(const std::uint8_t *data, std::size_t size) { diff --git a/libcxx/test/libcxx/fuzzing/fuzz.h b/libcxx/test/support/fuzz_helper.h rename from libcxx/test/libcxx/fuzzing/fuzz.h rename to libcxx/test/support/fuzz_helper.h --- a/libcxx/test/libcxx/fuzzing/fuzz.h +++ b/libcxx/test/support/fuzz_helper.h @@ -109,37 +109,4 @@ return true; } -// When running inside OSS-Fuzz, we link against a fuzzing library that defines -// main() and calls LLVMFuzzerTestOneInput. -// -// Otherwise, when e.g. running the Lit tests, we define main() to run fuzzing -// tests on a few inputs. -#if !defined(LIBCPP_OSS_FUZZ) -extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t*, std::size_t); - -int main(int, char**) { - const char* test_cases[] = { - "", - "s", - "bac", - "bacasf", - "lkajseravea", - "adsfkajdsfjkas;lnc441324513,34535r34525234", - "b*c", - "ba?sf", - "lka*ea", - "adsf*kas;lnc441[0-9]1r34525234" - }; - - for (const char* tc : test_cases) { - const std::size_t size = std::strlen(tc); - const std::uint8_t* data = reinterpret_cast(tc); - int result = LLVMFuzzerTestOneInput(data, size); - assert(result == 0); - } - - return 0; -} -#endif // !LIBCPP_OSS_FUZZ - #endif // TEST_LIBCXX_FUZZING_FUZZ_H