MCPcopy Create free account
hub / github.com/ElementsProject/elements / FUZZ_TARGET

Function FUZZ_TARGET

src/test/fuzz/autofile.cpp:17–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include <vector>
16
17FUZZ_TARGET(autofile)
18{
19 FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
20 FuzzedAutoFileProvider fuzzed_auto_file_provider = ConsumeAutoFile(fuzzed_data_provider);
21 CAutoFile auto_file = fuzzed_auto_file_provider.open();
22 LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) {
23 CallOneOf(
24 fuzzed_data_provider,
25 [&] {
26 std::array<std::byte, 4096> arr{};
27 try {
28 auto_file.read({arr.data(), fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 4096)});
29 } catch (const std::ios_base::failure&) {
30 }
31 },
32 [&] {
33 const std::array<std::byte, 4096> arr{};
34 try {
35 auto_file.write({arr.data(), fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 4096)});
36 } catch (const std::ios_base::failure&) {
37 }
38 },
39 [&] {
40 try {
41 auto_file.ignore(fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 4096));
42 } catch (const std::ios_base::failure&) {
43 }
44 },
45 [&] {
46 auto_file.fclose();
47 },
48 [&] {
49 ReadFromStream(fuzzed_data_provider, auto_file);
50 },
51 [&] {
52 WriteToStream(fuzzed_data_provider, auto_file);
53 });
54 }
55 (void)auto_file.Get();
56 (void)auto_file.GetType();
57 (void)auto_file.GetVersion();
58 (void)auto_file.IsNull();
59 if (fuzzed_data_provider.ConsumeBool()) {
60 FILE* f = auto_file.release();
61 if (f != nullptr) {
62 fclose(f);
63 }
64 }
65}

Callers

nothing calls this directly

Calls 15

ConsumeAutoFileFunction · 0.85
CallOneOfFunction · 0.85
ReadFromStreamFunction · 0.85
ConsumeBoolMethod · 0.80
releaseMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
openMethod · 0.45
readMethod · 0.45
writeMethod · 0.45
ignoreMethod · 0.45
fcloseMethod · 0.45

Tested by

no test coverage detected