chromium/third_party/fuzztest/src/fuzztest/internal/runtime.cc

// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "./fuzztest/internal/runtime.h"

#if !defined(_WIN32) && !defined(__Fuchsia__)
#define FUZZTEST_HAS_RUSAGE
#include <sys/resource.h>
#endif

#include <algorithm>
#include <cerrno>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <memory>
#include <optional>
#include <random>
#include <string>
#include <thread>  // NOLINT
#include <utility>
#include <vector>

#include "absl/functional/function_ref.h"
#include "absl/log/check.h"
#include "absl/random/bit_gen_ref.h"
#include "absl/random/discrete_distribution.h"
#include "absl/random/random.h"
#include "absl/status/status.h"
#include "absl/strings/match.h"
#include "absl/strings/numbers.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/string_view.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "absl/types/span.h"
#include "./fuzztest/internal/configuration.h"
#include "./fuzztest/internal/corpus_database.h"
#include "./fuzztest/internal/coverage.h"
#include "./fuzztest/internal/domains/domain_base.h"
#include "./fuzztest/internal/fixture_driver.h"
#include "./fuzztest/internal/flag_name.h"
#include "./fuzztest/internal/io.h"
#include "./fuzztest/internal/logging.h"
#include "./fuzztest/internal/printer.h"
#include "./fuzztest/internal/serialization.h"

#ifdef ADDRESS_SANITIZER
#include <sanitizer/asan_interface.h>
#endif

#ifndef TRAP_PERF
inline constexpr int TRAP_PERF =;
#endif

namespace fuzztest::internal {

PrintMode;
RawSink;

void (*crash_handler_hook)();

void Runtime::DumpReproducer(absl::string_view outdir) const {}

void Runtime::PrintFinalStats(RawSink out) const {}

namespace {

// Returns a reproduction command for replaying
// `configuration.crashing_input_to_reproduce` from a command line, using the
// `configuration.reproduction_command_template`.
std::optional<std::string> GetReproductionCommand(
    const Configuration& configuration) {}

constexpr size_t kValueMaxPrintLength =;
constexpr absl::string_view kTrimIndicator =;

}  // namespace

void Runtime::PrintReport(RawSink out) const {}

void Runtime::StartWatchdog() {}

void Runtime::Watchdog() {}

static size_t GetPeakRSSBytes() {}

void Runtime::CheckWatchdogLimits() {}

void Runtime::OnTestIterationEnd() {}

#if defined(__linux__)

struct OldSignalHandler {};

static FILE* signal_out;
struct FILESink {};
static FILESink signal_out_sink;

static OldSignalHandler crash_handlers[] =;

static OldSignalHandler termination_handlers[] =;

static bool HasCustomHandler(const struct sigaction& sigaction) {}

static void HandleCrash(int signum, siginfo_t* info, void* ucontext) {}

static void HandleTermination(int, siginfo_t*, void*) {}

static void SetNewSigAction(int signum, void (*handler)(int, siginfo_t*, void*),
                            struct sigaction* old_sigact) {}

void InstallSignalHandlers(FILE* out) {}

void Runtime::PrintFinalStatsOnDefaultSink() const {}

void Runtime::PrintReportOnDefaultSink() const {}

#else   // __linux__
// TODO(sbenzaquen): We should still install signal handlers in other systems.
void InstallSignalHandlers(FILE* out) {}

void Runtime::PrintFinalStatsOnDefaultSink() const {}

void Runtime::PrintReportOnDefaultSink() const {}
#endif  // __linux__

corpus_type;

FuzzTestFuzzerImpl::FuzzTestFuzzerImpl(
    const FuzzTest& test, std::unique_ptr<UntypedFixtureDriver> fixture_driver)
    :{}

FuzzTestFuzzerImpl::~FuzzTestFuzzerImpl() {}

std::optional<corpus_type> FuzzTestFuzzerImpl::TryParse(
    absl::string_view data) {}

std::optional<GenericDomainCorpusType>
FuzzTestFuzzerImpl::GetCorpusValueFromFile(const std::string& path) {}

void FuzzTestFuzzerImpl::ReplayInput(const std::string& path) {}

bool FuzzTestFuzzerImpl::ReplayInputsIfAvailable(
    const Configuration& configuration) {}

std::optional<std::vector<std::string>> FuzzTestFuzzerImpl::GetFilesToReplay() {}

std::optional<corpus_type> FuzzTestFuzzerImpl::ReadReproducerToMinimize() {}

void FuzzTestFuzzerImpl::MutateValue(Input& input, absl::BitGenRef prng) {}

void FuzzTestFuzzerImpl::UpdateCorpusDistribution() {}

FuzzTestFuzzerImpl::RunResult FuzzTestFuzzerImpl::TrySample(
    const Input& sample, bool write_to_file) {}

void FuzzTestFuzzerImpl::TrySampleAndUpdateInMemoryCorpus(Input sample,
                                                          bool write_to_file) {}

void FuzzTestFuzzerImpl::ForEachInputFile(
    absl::Span<const std::string> files,
    absl::FunctionRef<void(Input&&)> consume) {}

bool FuzzTestFuzzerImpl::MinimizeCorpusIfInMinimizationMode(
    absl::BitGenRef prng) {}

std::vector<FuzzTestFuzzerImpl::Input>
FuzzTestFuzzerImpl::TryReadCorpusFromFiles() {}

void FuzzTestFuzzerImpl::TryWriteCorpusFile(const Input& input) {}

void FuzzTestFuzzerImpl::InitializeCorpus(absl::BitGenRef prng) {}

bool FuzzTestFuzzerImpl::ShouldStop() {}

void FuzzTestFuzzerImpl::PopulateFromSeeds(
    const std::vector<std::string>& corpus_files) {}

size_t GetStackLimitFromEnvOrConfiguration(const Configuration& configuration) {}

void PopulateLimits(const Configuration& configuration,
                    ExecutionCoverage* execution_coverage) {}

void FuzzTestFuzzerImpl::RunInUnitTestMode(const Configuration& configuration) {}

FuzzTestFuzzerImpl::RunResult FuzzTestFuzzerImpl::RunOneInput(
    const Input& input) {}

void FuzzTestFuzzerImpl::MinimizeNonFatalFailureLocally(absl::BitGenRef prng) {}

int FuzzTestFuzzerImpl::RunInFuzzingMode(int* /*argc*/, char*** /*argv*/,
                                         const Configuration& configuration) {}

}  // namespace fuzztest::internal