Mercurial > hg
view contrib/fuzz/fuzzutil.h @ 40853:d7e44da4dc70
shelve: drop unnecessary backup of dirstate for phase-based case
Regular shelve has a hack using an uncommitted transaction that's then
aborted at the end of the operation. It preserves the dirstate across
the abort, however, by saving a backup copy of it. Phase-based shelve
instead commits the transaction, so the hack shouldn't be necessary
there.
Differential Revision: https://phab.mercurial-scm.org/D5389
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 05 Dec 2018 14:08:01 -0800 |
parents | 36d55f90e2a3 |
children | 6f5c352f41b6 |
line wrap: on
line source
#ifndef CONTRIB_FUZZ_FUZZUTIL_H #define CONTRIB_FUZZ_FUZZUTIL_H #include <iostream> #include <memory> #include <stdint.h> /* Try and use std::optional, but failing that assume we'll have a * workable https://abseil.io/ install on the include path to get * their backport of std::optional. */ #ifdef __has_include #if __has_include(<optional>) && __cplusplus >= 201703L #include <optional> #define CONTRIB_FUZZ_HAVE_STD_OPTIONAL #endif #endif #ifdef CONTRIB_FUZZ_HAVE_STD_OPTIONAL namespace contrib { using std::nullopt; using std::optional; } /* namespace contrib */ #else #include "third_party/absl/types/optional.h" namespace contrib { using absl::nullopt; using absl::optional; } /* namespace contrib */ #endif /* set DEBUG to 1 for a few debugging prints, or 2 for a lot */ #define DEBUG 0 #define LOG(level) \ if (level <= DEBUG) \ std::cout struct two_inputs { std::unique_ptr<char[]> right; size_t right_size; std::unique_ptr<char[]> left; size_t left_size; }; /* Split a non-zero-length input into two inputs. */ contrib::optional<two_inputs> SplitInputs(const uint8_t *Data, size_t Size); #endif /* CONTRIB_FUZZ_FUZZUTIL_H */