[libcxx-commits] [libcxx] daacf57 - [libc++] Add fuzzing tests for parts of <random>.

Eric Fiselier via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 11 12:47:27 PST 2019


Author: Eric Fiselier
Date: 2019-12-11T15:47:06-05:00
New Revision: daacf57032450079b44b8a7f9b976700d3bc38f8

URL: https://github.com/llvm/llvm-project/commit/daacf57032450079b44b8a7f9b976700d3bc38f8
DIFF: https://github.com/llvm/llvm-project/commit/daacf57032450079b44b8a7f9b976700d3bc38f8.diff

LOG: [libc++] Add fuzzing tests for parts of <random>.

This patch also re-names the existing fuzzing unit tests so they
actually run.

Added: 
    libcxx/fuzzing/fuzz_test_template.cpp
    libcxx/test/libcxx/fuzzing/fuzzer_test.h
    libcxx/test/libcxx/fuzzing/geometric_distribution.pass.cpp
    libcxx/test/libcxx/fuzzing/nth_element.pass.cpp
    libcxx/test/libcxx/fuzzing/partial_sort.pass.cpp
    libcxx/test/libcxx/fuzzing/partial_sort_copy.pass.cpp
    libcxx/test/libcxx/fuzzing/partition.pass.cpp
    libcxx/test/libcxx/fuzzing/partition_copy.pass.cpp
    libcxx/test/libcxx/fuzzing/regex_ECMAScript.pass.cpp
    libcxx/test/libcxx/fuzzing/regex_POSIX.pass.cpp
    libcxx/test/libcxx/fuzzing/regex_awk.pass.cpp
    libcxx/test/libcxx/fuzzing/regex_egrep.pass.cpp
    libcxx/test/libcxx/fuzzing/regex_extended.pass.cpp
    libcxx/test/libcxx/fuzzing/regex_grep.pass.cpp
    libcxx/test/libcxx/fuzzing/sort.pass.cpp
    libcxx/test/libcxx/fuzzing/stable_partition.pass.cpp
    libcxx/test/libcxx/fuzzing/stable_sort.pass.cpp
    libcxx/test/libcxx/fuzzing/unique.pass.cpp
    libcxx/test/libcxx/fuzzing/unique_copy.pass.cpp

Modified: 
    libcxx/fuzzing/RoutineNames.txt
    libcxx/fuzzing/fuzzing.cpp
    libcxx/fuzzing/fuzzing.h

Removed: 
    libcxx/test/libcxx/fuzzing/nth_element.cpp
    libcxx/test/libcxx/fuzzing/partial_sort.cpp
    libcxx/test/libcxx/fuzzing/partial_sort_copy.cpp
    libcxx/test/libcxx/fuzzing/partition.cpp
    libcxx/test/libcxx/fuzzing/partition_copy.cpp
    libcxx/test/libcxx/fuzzing/regex_ECMAScript.cpp
    libcxx/test/libcxx/fuzzing/regex_POSIX.cpp
    libcxx/test/libcxx/fuzzing/regex_awk.cpp
    libcxx/test/libcxx/fuzzing/regex_egrep.cpp
    libcxx/test/libcxx/fuzzing/regex_extended.cpp
    libcxx/test/libcxx/fuzzing/regex_grep.cpp
    libcxx/test/libcxx/fuzzing/sort.cpp
    libcxx/test/libcxx/fuzzing/stable_partition.cpp
    libcxx/test/libcxx/fuzzing/stable_sort.cpp
    libcxx/test/libcxx/fuzzing/unique.cpp
    libcxx/test/libcxx/fuzzing/unique_copy.cpp


################################################################################
diff  --git a/libcxx/fuzzing/RoutineNames.txt b/libcxx/fuzzing/RoutineNames.txt
index 06ef70ed6491..a853c87e1f73 100644
--- a/libcxx/fuzzing/RoutineNames.txt
+++ b/libcxx/fuzzing/RoutineNames.txt
@@ -18,3 +18,23 @@ regex_awk
 regex_grep
 regex_egrep
 search
+uniform_int_distribution
+uniform_real_distribution
+bernoulli_distribution
+poisson_distribution
+geometric_distribution
+binomial_distribution
+negative_binomial_distribution
+exponential_distribution
+gamma_distribution
+weibull_distribution
+extreme_value_distribution
+normal_distribution
+lognormal_distribution
+chi_squared_distribution
+cauchy_distribution
+fisher_f_distribution
+student_t_distribution
+discrete_distribution
+piecewise_constant_distribution
+piecewise_linear_distribution

diff  --git a/libcxx/fuzzing/fuzz_test_template.cpp b/libcxx/fuzzing/fuzz_test_template.cpp
new file mode 100644
index 000000000000..ba44eef7891d
--- /dev/null
+++ b/libcxx/fuzzing/fuzz_test_template.cpp
@@ -0,0 +1,22 @@
+//===------------------------- fuzz_test.cpp ------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzing/fuzzing.h"
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <cassert>
+
+#ifndef TEST_FUNCTION
+#error TEST_FUNCTION must be defined
+#endif
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+  int result = fuzzing::TEST_FUNCTION(data, size);
+  assert(result == 0); return 0;
+}

diff  --git a/libcxx/fuzzing/fuzzing.cpp b/libcxx/fuzzing/fuzzing.cpp
index 5c32f28a3add..284993918aaa 100644
--- a/libcxx/fuzzing/fuzzing.cpp
+++ b/libcxx/fuzzing/fuzzing.cpp
@@ -27,10 +27,16 @@
 #include <algorithm>
 #include <functional>
 #include <regex>
+#include <random>
 #include <cassert>
+#include <cmath>
 
 #include <iostream>
 
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+#include <cassert>
 //  If we had C++14, we could use the four iterator version of is_permutation and equal
 
 namespace fuzzing {
@@ -212,7 +218,7 @@ int partition_copy(const uint8_t *data, size_t size)
     auto iter = std::partition_copy(data, data + size,
         std::back_inserter<Vec>(v1), std::back_inserter<Vec>(v2),
         is_even<uint8_t>());
-
+  ((void)iter);
 //  The two vectors should add up to the original size
     if (v1.size() + v2.size() != size) return 1;
 
@@ -614,4 +620,201 @@ static void set_helper (const uint8_t *data, size_t size, Vec &v1, Vec &v2)
     std::sort(v2.begin(), v2.end());
 }
 
+enum class ParamKind {
+  OneValue,
+  TwoValues,
+  PointerRange
+};
+
+template <class IntT>
+std::vector<IntT> GetValues(const uint8_t *data, size_t size) {
+  std::vector<IntT> result;
+  while (size >= sizeof(IntT)) {
+    IntT tmp;
+    memcpy(&tmp, data, sizeof(IntT));
+    size -= sizeof(IntT);
+    data += sizeof(IntT);
+    result.push_back(tmp);
+  }
+  return result;
+}
+
+enum InitKind {
+  Default,
+  DoubleOnly,
+  VectorDouble,
+  VectorResultType
+};
+
+template <class Dist>
+struct ParamTypeHelper {
+  using ParamT = typename Dist::param_type;
+  using ResultT = typename Dist::result_type;
+  static_assert(std::is_same<ResultT, typename ParamT::distribution_type::result_type>::value, "");
+  static  ParamT Create(const uint8_t* data, size_t size, bool &OK) {
+
+    if constexpr (std::is_constructible<ParamT, ResultT*, ResultT*, ResultT*>::value)
+      return CreateVectorResult(data, size, OK);
+    else if constexpr (std::is_constructible<ParamT, double*, double*>::value)
+      return CreateVectorDouble(data, size, OK);
+    else
+      return CreateDefault(data, size, OK);
+  }
+
+
+static    ParamT
+CreateVectorResult(const uint8_t *data, size_t size, bool &OK) {
+  auto Input = GetValues<ResultT>(data, size);
+  OK = false;
+  if (Input.size() < 10)
+    return ParamT{};
+  OK = true;
+  auto Beg = Input.begin();
+  auto End = Input.end();
+  auto Mid = Beg + ((End - Beg) / 2);
+
+  assert(Mid - Beg <= (End  -  Mid));
+  ParamT p(Beg, Mid, Mid);
+  return p;
+}
+
+  static ParamT
+  CreateVectorDouble(const uint8_t *data, size_t size, bool &OK) {
+    auto Input = GetValues<double>(data, size);
+
+    OK = true;
+    auto Beg = Input.begin();
+    auto End = Input.end();
+
+    ParamT p(Beg, End);
+    return p;
+  }
+
+
+  static ParamT
+  CreateDefault(const uint8_t *data, size_t size, bool &OK) {
+    OK = false;
+    if (size < sizeof(ParamT))
+      return ParamT{};
+    OK = true;
+    ParamT input;
+    memcpy(&input, data, sizeof(ParamT));
+    return input;
+  }
+
+};
+
+
+
+
+template <class IntT>
+struct ParamTypeHelper<std::poisson_distribution<IntT>> {
+    using Dist = std::poisson_distribution<IntT>;
+      using ParamT = typename Dist::param_type;
+    using ResultT = typename Dist::result_type;
+
+     static ParamT Create(const uint8_t *data, size_t size, bool& OK) {
+        OK = false;
+        auto vals = GetValues<double>(data, size);
+        if (vals.empty() || std::isnan(vals[0]) || std::isnan(std::abs(vals[0])) || vals[0] < 0 )
+          return ParamT{};
+        OK = true;
+        //std::cerr << "Value: " << vals[0] << std::endl;
+        return ParamT{vals[0]};
+     }
+};
+
+
+template <class IntT>
+struct ParamTypeHelper<std::geometric_distribution<IntT>> {
+    using Dist = std::geometric_distribution<IntT>;
+      using ParamT = typename Dist::param_type;
+    using ResultT = typename Dist::result_type;
+
+     static ParamT Create(const uint8_t *data, size_t size, bool& OK) {
+        OK = false;
+        auto vals = GetValues<double>(data, size);
+        if (vals.empty() || std::isnan(vals[0]) || vals[0] < 0 )
+          return ParamT{};
+        OK = true;
+       // std::cerr << "Value: " << vals[0] << std::endl;
+        return ParamT{vals[0]};
+     }
+};
+
+
+template <class IntT>
+struct ParamTypeHelper<std::lognormal_distribution<IntT>> {
+    using Dist = std::lognormal_distribution<IntT>;
+      using ParamT = typename Dist::param_type;
+    using ResultT = typename Dist::result_type;
+
+     static ParamT Create(const uint8_t *data, size_t size, bool& OK) {
+        OK = false;
+        auto vals = GetValues<ResultT>(data, size);
+        if (vals.size() < 2 )
+          return ParamT{};
+        OK = true;
+        return ParamT{vals[0], vals[1]};
+     }
+};
+
+
+template <>
+struct ParamTypeHelper<std::bernoulli_distribution> {
+    using Dist = std::bernoulli_distribution;
+      using ParamT = typename Dist::param_type;
+    using ResultT = typename Dist::result_type;
+
+     static ParamT Create(const uint8_t *data, size_t size, bool& OK) {
+        OK = false;
+        auto vals = GetValues<double>(data, size);
+        if (vals.empty())
+          return ParamT{};
+        OK = true;
+        return ParamT{vals[0]};
+     }
+};
+
+template <class Distribution>
+int random_distribution_helper(const uint8_t *data, size_t size) {
+
+  std::mt19937 engine;
+  using ParamT = typename Distribution::param_type;
+  bool OK;
+  ParamT p = ParamTypeHelper<Distribution>::Create(data, size, OK);
+  if (!OK)
+    return 0;
+  Distribution d(p);
+  volatile auto res = d(engine);
+  if (std::isnan(res))
+    return 1;
+  return 0;
+}
+
+#define DEFINE_RANDOM_TEST(name, ...) \
+int name(const uint8_t *data, size_t size) { \
+  return random_distribution_helper< std::name __VA_ARGS__ >(data, size); \
+}
+DEFINE_RANDOM_TEST(uniform_int_distribution,<std::int16_t>)
+DEFINE_RANDOM_TEST(uniform_real_distribution,<float>)
+DEFINE_RANDOM_TEST(bernoulli_distribution)
+DEFINE_RANDOM_TEST(poisson_distribution,<std::int16_t>)
+DEFINE_RANDOM_TEST(geometric_distribution,<std::int16_t>)
+DEFINE_RANDOM_TEST(binomial_distribution, <std::int16_t>)
+DEFINE_RANDOM_TEST(negative_binomial_distribution, <std::int16_t>)
+DEFINE_RANDOM_TEST(exponential_distribution, <float>)
+DEFINE_RANDOM_TEST(gamma_distribution, <float>)
+DEFINE_RANDOM_TEST(weibull_distribution, <float>)
+DEFINE_RANDOM_TEST(extreme_value_distribution, <float>)
+DEFINE_RANDOM_TEST(normal_distribution, <float>)
+DEFINE_RANDOM_TEST(lognormal_distribution, <float>)
+DEFINE_RANDOM_TEST(chi_squared_distribution, <float>)
+DEFINE_RANDOM_TEST(cauchy_distribution, <float>)
+DEFINE_RANDOM_TEST(fisher_f_distribution, <float>)
+DEFINE_RANDOM_TEST(student_t_distribution, <float>)
+DEFINE_RANDOM_TEST(discrete_distribution, <std::int16_t>)
+DEFINE_RANDOM_TEST(piecewise_constant_distribution, <float>)
+DEFINE_RANDOM_TEST(piecewise_linear_distribution, <float>)
+
 } // namespace fuzzing

diff  --git a/libcxx/fuzzing/fuzzing.h b/libcxx/fuzzing/fuzzing.h
index 64103e59007d..99a3aa14a777 100644
--- a/libcxx/fuzzing/fuzzing.h
+++ b/libcxx/fuzzing/fuzzing.h
@@ -56,6 +56,28 @@ namespace fuzzing {
 // 	int set_symmetric_
diff erence (const uint8_t *data, size_t size);
 // 	int merge                    (const uint8_t *data, size_t size);
 
+// Random numbers
+  int uniform_int_distribution(const uint8_t*, size_t);
+  int uniform_real_distribution(const uint8_t*, size_t);
+  int bernoulli_distribution(const uint8_t*, size_t);
+  int poisson_distribution(const uint8_t*, size_t);
+  int geometric_distribution(const uint8_t*, size_t);
+  int binomial_distribution(const uint8_t*, size_t);
+  int negative_binomial_distribution(const uint8_t*, size_t);
+  int exponential_distribution(const uint8_t*, size_t);
+  int gamma_distribution(const uint8_t*, size_t);
+  int weibull_distribution(const uint8_t*, size_t);
+  int extreme_value_distribution(const uint8_t*, size_t);
+  int normal_distribution(const uint8_t*, size_t);
+  int lognormal_distribution(const uint8_t*, size_t);
+  int chi_squared_distribution(const uint8_t*, size_t);
+  int cauchy_distribution(const uint8_t*, size_t);
+  int fisher_f_distribution(const uint8_t*, size_t);
+  int student_t_distribution(const uint8_t*, size_t);
+  int discrete_distribution(const uint8_t*, size_t);
+  int piecewise_constant_distribution(const uint8_t*, size_t);
+  int piecewise_linear_distribution(const uint8_t*, size_t);
+
 } // namespace fuzzing
 
 #endif // _LIBCPP_FUZZING

diff  --git a/libcxx/test/libcxx/fuzzing/fuzzer_test.h b/libcxx/test/libcxx/fuzzing/fuzzer_test.h
new file mode 100644
index 000000000000..9b9a23feb693
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/fuzzer_test.h
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_LIBCXX_FUZZER_TEST_H
+#define TEST_LIBCXX_FUZZER_TEST_H
+
+#include <cstddef>
+#include <cassert>
+
+#include "../../../fuzzing/fuzzing.h"
+#include "../../../fuzzing/fuzzing.cpp"
+
+const char* TestCaseSetOne[] = {"", "s", "bac",
+                            "bacasf"
+                            "lkajseravea",
+                            "adsfkajdsfjkas;lnc441324513,34535r34525234",
+                            "b*c",
+                            "ba?sf"
+                            "lka*ea",
+                            "adsf*kas;lnc441[0-9]1r34525234"};
+
+using FuzzerFuncType = int(const uint8_t*, size_t);
+
+template <size_t NumCases>
+inline void RunFuzzingTest(FuzzerFuncType *to_test, const char* (&test_cases)[NumCases]) {
+  for (const char* TC : test_cases) {
+    const size_t size = std::strlen(TC);
+    const uint8_t* data = (const uint8_t*)TC;
+    int result = to_test(data, size);
+    assert(result == 0);
+  }
+}
+
+#define FUZZER_TEST(FuncName) \
+int main() { \
+  RunFuzzingTest(FuncName, TestCaseSetOne); \
+} \
+extern int require_semi
+
+#endif // TEST_LIBCXX_FUZZER_TEST_H

diff  --git a/libcxx/test/libcxx/fuzzing/geometric_distribution.pass.cpp b/libcxx/test/libcxx/fuzzing/geometric_distribution.pass.cpp
new file mode 100644
index 000000000000..acb07ef875a0
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/geometric_distribution.pass.cpp
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===------------------------ unique_copy.cpp -----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <random>
+#include <cstdint>
+
+#include "fuzzer_test.h"
+
+template <class Distribution>
+int random_distribution_helper(const uint8_t *data, size_t size) {
+  std::mt19937 engine;
+  using ParamT = typename Distribution::param_type;
+  if (size < sizeof(double))
+    return 0;
+  double Arg;
+  memcpy(&Arg, data, sizeof(double));
+  ParamT p(Arg);
+  Distribution d(p);
+  for (int I=0; I < 1000; ++I) {
+    volatile auto res = d(engine);
+    ((void)res);
+  }
+  return 0;
+}
+
+int FuzzRandom(const uint8_t *Data, size_t Size) {
+  return random_distribution_helper<std::geometric_distribution<std::int16_t>>(Data, Size);
+}
+FUZZER_TEST(FuzzRandom);
+
+

diff  --git a/libcxx/test/libcxx/fuzzing/nth_element.cpp b/libcxx/test/libcxx/fuzzing/nth_element.cpp
deleted file mode 100644
index 482aeb65ffe8..000000000000
--- a/libcxx/test/libcxx/fuzzing/nth_element.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// -*- C++ -*-
-//===----------------------- nth_element.cpp ------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"bac",
-	"bacasf"
-	"lkajseravea",
-	"adsfkajdsfjkas;lnc441324513,34535r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::nth_element(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/nth_element.pass.cpp b/libcxx/test/libcxx/fuzzing/nth_element.pass.cpp
new file mode 100644
index 000000000000..580c5593e908
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/nth_element.pass.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===----------------------- nth_element.cpp ------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::nth_element);

diff  --git a/libcxx/test/libcxx/fuzzing/partial_sort.cpp b/libcxx/test/libcxx/fuzzing/partial_sort.cpp
deleted file mode 100644
index 4f3576663302..000000000000
--- a/libcxx/test/libcxx/fuzzing/partial_sort.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// -*- C++ -*-
-//===-------------------------- partial_sort.cpp --------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"bac",
-	"bacasf"
-	"lkajseravea",
-	"adsfkajdsfjkas;lnc441324513,34535r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::partial_sort(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/partial_sort.pass.cpp b/libcxx/test/libcxx/fuzzing/partial_sort.pass.cpp
new file mode 100644
index 000000000000..08fa1a38de17
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/partial_sort.pass.cpp
@@ -0,0 +1,30 @@
+// -*- C++ -*-
+//===-------------------------- partial_sort.cpp --------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <cassert>
+#include <cstring> // for strlen
+
+#include "../fuzzing/fuzzing.h"
+#include "../fuzzing/fuzzing.cpp"
+
+const char* test_cases[] = {"", "s", "bac",
+                            "bacasf"
+                            "lkajseravea",
+                            "adsfkajdsfjkas;lnc441324513,34535r34525234"};
+
+const size_t k_num_tests = sizeof(test_cases) / sizeof(test_cases[0]);
+
+int main(int, char**) {
+  for (size_t i = 0; i < k_num_tests; ++i) {
+    const size_t size = std::strlen(test_cases[i]);
+    const uint8_t* data = (const uint8_t*)test_cases[i];
+    assert(0 == fuzzing::partial_sort(data, size));
+  }
+  return 0;
+}

diff  --git a/libcxx/test/libcxx/fuzzing/partial_sort_copy.cpp b/libcxx/test/libcxx/fuzzing/partial_sort_copy.cpp
deleted file mode 100644
index b569f55ebd84..000000000000
--- a/libcxx/test/libcxx/fuzzing/partial_sort_copy.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// -*- C++ -*-
-//===----------------------- partial_sort_copy.cpp ------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"bac",
-	"bacasf"
-	"lkajseravea",
-	"adsfkajdsfjkas;lnc441324513,34535r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::partial_sort_copy(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/partial_sort_copy.pass.cpp b/libcxx/test/libcxx/fuzzing/partial_sort_copy.pass.cpp
new file mode 100644
index 000000000000..42bc4addfd1f
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/partial_sort_copy.pass.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===----------------------- partial_sort_copy.cpp ------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::partial_sort_copy);

diff  --git a/libcxx/test/libcxx/fuzzing/partition.cpp b/libcxx/test/libcxx/fuzzing/partition.cpp
deleted file mode 100644
index 0833e38e2111..000000000000
--- a/libcxx/test/libcxx/fuzzing/partition.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// -*- C++ -*-
-//===--------------------------- partition.cpp ----------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"bac",
-	"bacasf"
-	"lkajseravea",
-	"adsfkajdsfjkas;lnc441324513,34535r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::partition(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/partition.pass.cpp b/libcxx/test/libcxx/fuzzing/partition.pass.cpp
new file mode 100644
index 000000000000..15bdcf43ce28
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/partition.pass.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===--------------------------- partition.cpp ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::partition);

diff  --git a/libcxx/test/libcxx/fuzzing/partition_copy.cpp b/libcxx/test/libcxx/fuzzing/partition_copy.cpp
deleted file mode 100644
index f336a14cab6d..000000000000
--- a/libcxx/test/libcxx/fuzzing/partition_copy.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// -*- C++ -*-
-//===------------------------ partition_copy.cpp --------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"bac",
-	"bacasf"
-	"lkajseravea",
-	"adsfkajdsfjkas;lnc441324513,34535r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::partition_copy(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/partition_copy.pass.cpp b/libcxx/test/libcxx/fuzzing/partition_copy.pass.cpp
new file mode 100644
index 000000000000..b026e7c1920f
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/partition_copy.pass.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===------------------------ partition_copy.cpp --------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::partition_copy);

diff  --git a/libcxx/test/libcxx/fuzzing/regex_ECMAScript.cpp b/libcxx/test/libcxx/fuzzing/regex_ECMAScript.cpp
deleted file mode 100644
index ca9a7dae5210..000000000000
--- a/libcxx/test/libcxx/fuzzing/regex_ECMAScript.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// -*- C++ -*-
-//===--------------------- regex_ECMAScript.cpp ---------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"b*c",
-	"ba?sf"
-	"lka*ea",
-	"adsf*kas;lnc441[0-9]1r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::regex_ECMAScript(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/regex_ECMAScript.pass.cpp b/libcxx/test/libcxx/fuzzing/regex_ECMAScript.pass.cpp
new file mode 100644
index 000000000000..d0e1cf87b1e0
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/regex_ECMAScript.pass.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===--------------------- regex_ECMAScript.cpp ---------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::regex_ECMAScript);

diff  --git a/libcxx/test/libcxx/fuzzing/regex_POSIX.cpp b/libcxx/test/libcxx/fuzzing/regex_POSIX.cpp
deleted file mode 100644
index 69f40de6d190..000000000000
--- a/libcxx/test/libcxx/fuzzing/regex_POSIX.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// -*- C++ -*-
-//===----------------------- regex_POSIX.cpp ------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"b*c",
-	"ba?sf"
-	"lka*ea",
-	"adsf*kas;lnc441[0-9]1r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::regex_POSIX(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/regex_POSIX.pass.cpp b/libcxx/test/libcxx/fuzzing/regex_POSIX.pass.cpp
new file mode 100644
index 000000000000..db1d760a718b
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/regex_POSIX.pass.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===----------------------- regex_POSIX.cpp ------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::regex_POSIX);

diff  --git a/libcxx/test/libcxx/fuzzing/regex_awk.cpp b/libcxx/test/libcxx/fuzzing/regex_awk.cpp
deleted file mode 100644
index ca9a7dae5210..000000000000
--- a/libcxx/test/libcxx/fuzzing/regex_awk.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// -*- C++ -*-
-//===--------------------- regex_ECMAScript.cpp ---------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"b*c",
-	"ba?sf"
-	"lka*ea",
-	"adsf*kas;lnc441[0-9]1r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::regex_ECMAScript(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/regex_awk.pass.cpp b/libcxx/test/libcxx/fuzzing/regex_awk.pass.cpp
new file mode 100644
index 000000000000..d3630594e29e
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/regex_awk.pass.cpp
@@ -0,0 +1,12 @@
+// -*- C++ -*-
+//===------------------------- regex_awk.cpp ------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::regex_awk);

diff  --git a/libcxx/test/libcxx/fuzzing/regex_egrep.cpp b/libcxx/test/libcxx/fuzzing/regex_egrep.cpp
deleted file mode 100644
index f350f63e334c..000000000000
--- a/libcxx/test/libcxx/fuzzing/regex_egrep.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// -*- C++ -*-
-//===------------------------ regex_egrep.cpp -----------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"b*c",
-	"ba?sf"
-	"lka*ea",
-	"adsf*kas;lnc441[0-9]1r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::regex_egrep(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/regex_egrep.pass.cpp b/libcxx/test/libcxx/fuzzing/regex_egrep.pass.cpp
new file mode 100644
index 000000000000..840fd71f2ca8
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/regex_egrep.pass.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===------------------------ regex_egrep.cpp -----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::regex_egrep);

diff  --git a/libcxx/test/libcxx/fuzzing/regex_extended.cpp b/libcxx/test/libcxx/fuzzing/regex_extended.cpp
deleted file mode 100644
index ae55f5bb8372..000000000000
--- a/libcxx/test/libcxx/fuzzing/regex_extended.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// -*- C++ -*-
-//===---------------------- regex_extended.cpp ----------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"b*c",
-	"ba?sf"
-	"lka*ea",
-	"adsf*kas;lnc441[0-9]1r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::regex_extended(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/regex_extended.pass.cpp b/libcxx/test/libcxx/fuzzing/regex_extended.pass.cpp
new file mode 100644
index 000000000000..fe81d263a3c3
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/regex_extended.pass.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===---------------------- regex_extended.cpp ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::regex_extended);

diff  --git a/libcxx/test/libcxx/fuzzing/regex_grep.cpp b/libcxx/test/libcxx/fuzzing/regex_grep.cpp
deleted file mode 100644
index ac497b3a9fcf..000000000000
--- a/libcxx/test/libcxx/fuzzing/regex_grep.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// -*- C++ -*-
-//===------------------------ regex_grep.cpp ------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"b*c",
-	"ba?sf"
-	"lka*ea",
-	"adsf*kas;lnc441[0-9]1r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::regex_grep(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/regex_grep.pass.cpp b/libcxx/test/libcxx/fuzzing/regex_grep.pass.cpp
new file mode 100644
index 000000000000..321c7297e3a8
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/regex_grep.pass.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===------------------------ regex_grep.cpp ------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::regex_grep);

diff  --git a/libcxx/test/libcxx/fuzzing/sort.cpp b/libcxx/test/libcxx/fuzzing/sort.cpp
deleted file mode 100644
index 43b9064de033..000000000000
--- a/libcxx/test/libcxx/fuzzing/sort.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// -*- C++ -*-
-//===--------------------------- sort.cpp ---------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"bac",
-	"bacasf"
-	"lkajseravea",
-	"adsfkajdsfjkas;lnc441324513,34535r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::sort(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/sort.pass.cpp b/libcxx/test/libcxx/fuzzing/sort.pass.cpp
new file mode 100644
index 000000000000..3de5fe463297
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/sort.pass.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===--------------------------- sort.cpp ---------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::sort);

diff  --git a/libcxx/test/libcxx/fuzzing/stable_partition.cpp b/libcxx/test/libcxx/fuzzing/stable_partition.cpp
deleted file mode 100644
index b236190cbf27..000000000000
--- a/libcxx/test/libcxx/fuzzing/stable_partition.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// -*- C++ -*-
-//===--------------------- stable_partition.cpp ---------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"bac",
-	"bacasf"
-	"lkajseravea",
-	"adsfkajdsfjkas;lnc441324513,34535r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::stable_partition(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/stable_partition.pass.cpp b/libcxx/test/libcxx/fuzzing/stable_partition.pass.cpp
new file mode 100644
index 000000000000..ed22a36fcd9e
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/stable_partition.pass.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===--------------------- stable_partition.cpp ---------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::stable_partition);

diff  --git a/libcxx/test/libcxx/fuzzing/stable_sort.cpp b/libcxx/test/libcxx/fuzzing/stable_sort.cpp
deleted file mode 100644
index 1c8ac4904256..000000000000
--- a/libcxx/test/libcxx/fuzzing/stable_sort.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// -*- C++ -*-
-//===------------------------ stable_sort.cpp ----------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"bac",
-	"bacasf"
-	"lkajseravea",
-	"adsfkajdsfjkas;lnc441324513,34535r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::stable_sort(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/stable_sort.pass.cpp b/libcxx/test/libcxx/fuzzing/stable_sort.pass.cpp
new file mode 100644
index 000000000000..130e1cab0839
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/stable_sort.pass.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===------------------------ stable_sort.cpp ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::stable_sort);

diff  --git a/libcxx/test/libcxx/fuzzing/unique.cpp b/libcxx/test/libcxx/fuzzing/unique.cpp
deleted file mode 100644
index cab512eb89e8..000000000000
--- a/libcxx/test/libcxx/fuzzing/unique.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// -*- C++ -*-
-//===--------------------------- unique.cpp -------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"bac",
-	"bacasf"
-	"lkajseravea",
-	"adsfkajdsfjkas;lnc441324513,34535r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::unique(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/unique.pass.cpp b/libcxx/test/libcxx/fuzzing/unique.pass.cpp
new file mode 100644
index 000000000000..d30c9666785b
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/unique.pass.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===--------------------------- unique.cpp -------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::unique);

diff  --git a/libcxx/test/libcxx/fuzzing/unique_copy.cpp b/libcxx/test/libcxx/fuzzing/unique_copy.cpp
deleted file mode 100644
index 311eb4cf64e3..000000000000
--- a/libcxx/test/libcxx/fuzzing/unique_copy.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// -*- C++ -*-
-//===------------------------ unique_copy.cpp -----------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL
-
-#include "fuzzing.h"
-#include <cassert>
-#include <cstring> // for strlen
-
-const char * test_cases[] = {
-	"",
-	"s",
-	"bac",
-	"bacasf"
-	"lkajseravea",
-	"adsfkajdsfjkas;lnc441324513,34535r34525234"
-	};
-
-const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
-
-
-int main(int, char**)
-{
-	for (size_t i = 0; i < k_num_tests; ++i)
-		{
-		const size_t   size = std::strlen(test_cases[i]);
-		const uint8_t *data = (const uint8_t *) test_cases[i];
-		assert(0 == fuzzing::unique_copy(data, size));
-		}
-	return 0;
-}

diff  --git a/libcxx/test/libcxx/fuzzing/unique_copy.pass.cpp b/libcxx/test/libcxx/fuzzing/unique_copy.pass.cpp
new file mode 100644
index 000000000000..78fed9799506
--- /dev/null
+++ b/libcxx/test/libcxx/fuzzing/unique_copy.pass.cpp
@@ -0,0 +1,11 @@
+// -*- C++ -*-
+//===------------------------ unique_copy.cpp -----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_test.h"
+FUZZER_TEST(fuzzing::unique_copy);


        


More information about the libcxx-commits mailing list