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

This patch also re-names the existing fuzzing unit tests so they
actually run.
This commit is contained in:
Eric Fiselier 2019-12-11 15:45:48 -05:00
parent fe593fe15f
commit daacf57032
38 changed files with 547 additions and 587 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -56,6 +56,28 @@ namespace fuzzing {
// int set_symmetric_difference (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

View File

@ -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

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);