MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / fuzz

Method fuzz

fuzzing/bb_fuzzer.cpp:194–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192 }
193
194 void fuzz()
195 {
196 size_t num_operations = fuzz_data_.ConsumeIntegralInRange<size_t>(50, 200);
197
198 for(size_t i = 0; i < num_operations && !blackboards_.empty(); ++i)
199 {
200 try
201 {
202 // Randomly select a blackboard to operate on
203 size_t bb_idx =
204 fuzz_data_.ConsumeIntegralInRange<size_t>(0, blackboards_.size() - 1);
205 auto bb = blackboards_[bb_idx];
206
207 switch(fuzz_data_.ConsumeIntegralInRange<size_t>(0, 3))
208 {
209 case 0:
210 // Fuzz single blackboard operations
211 fuzzSingleBB(bb);
212 break;
213
214 case 1:
215 // Create new blackboards in hierarchy
216 if(fuzz_data_.ConsumeBool())
217 {
218 createBlackboardHierarchy();
219 }
220 break;
221
222 case 2:
223 // JSON operations
224 fuzzJsonOperations(bb);
225 break;
226
227 case 3:
228 // Cleanup operations
229 if(fuzz_data_.ConsumeBool() && blackboards_.size() > 1)
230 {
231 size_t remove_idx =
232 fuzz_data_.ConsumeIntegralInRange<size_t>(0, blackboards_.size() - 1);
233 blackboards_.erase(blackboards_.begin() + remove_idx);
234 }
235 break;
236 }
237 }
238 catch(const std::exception& e)
239 {
240 if(!ExceptionFilter::isExpectedException(e))
241 {
242 std::cerr << "Unexpected exception: " << e.what() << std::endl;
243 throw;
244 }
245 }
246 }
247 }
248};
249
250extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)

Callers 1

LLVMFuzzerTestOneInputFunction · 0.80

Calls 4

emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected