1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include <library/cpp/containers/flat_hash/lib/map.h>
#include <library/cpp/containers/flat_hash/lib/containers.h>
#include <library/cpp/containers/flat_hash/lib/probings.h>
#include <library/cpp/containers/flat_hash/lib/size_fitters.h>
#include <library/cpp/containers/flat_hash/lib/expanders.h>
#include <library/cpp/containers/flat_hash/fuzz/fuzz_common/fuzz_common.h>
#include <util/generic/hash.h>
#include <util/generic/xrange.h>
#include <util/generic/bt_exception.h>
using namespace NFlatHash;
namespace {
template <class Key, class T>
using TFlatLinearModMap = NFlatHash::TMap<Key,
T,
THash<Key>,
std::equal_to<Key>,
TFlatContainer<std::pair<const Key, T>>,
TLinearProbing,
TAndSizeFitter,
TSimpleExpander>;
NFuzz::EActionType EvalType(ui8 data) {
return static_cast<NFuzz::EActionType>((data >> 5) & 0b111);
}
ui8 EvalKey(ui8 data) {
return data & 0b11111;
}
ui8 EvalValue() {
return RandomNumber<ui8>();
}
} // namespace
extern "C" int LLVMFuzzerTestOneInput(const ui8* const wireData, const size_t wireSize) {
THashMap<ui8, ui8> etalon;
TFlatLinearModMap<ui8, ui8> testee;
for (auto i : xrange(wireSize)) {
auto data = wireData[i];
NFuzz::MakeAction(etalon, testee, EvalKey(data), EvalValue(), EvalType(data));
NFuzz::CheckInvariants(etalon, testee);
}
return 0;
}
|