File size: 1,195 Bytes
dc9f5c2 | 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 | #include <cstddef>
#include <cstdint>
#include <executorch/extension/data_loader/buffer_data_loader.h>
#include <executorch/runtime/executor/program.h>
#include <executorch/runtime/platform/runtime.h>
using executorch::extension::BufferDataLoader;
using executorch::runtime::Program;
static bool g_initialized = false;
extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) {
if (!g_initialized) { executorch::runtime::runtime_init(); g_initialized = true; }
if (data == nullptr || size == 0 || size > 32U*1024U*1024U) return 0;
BufferDataLoader loader(data, size);
auto program = Program::load(&loader, Program::Verification::InternalConsistency);
if (program.ok()) {
auto& p = program.get();
auto n = p.num_methods();
for (size_t i = 0; i < n; ++i) {
auto name = p.get_method_name(i);
if (name.ok()) {
auto meta = p.method_meta(name.get());
if (meta.ok()) {
auto& m = meta.get();
size_t nb = m.num_backends();
for (size_t bi = 0; bi < nb; ++bi) {
(void)m.get_backend_name(bi); // ONLY this call - no uses_backend()
}
}
}
}
}
return 0;
}
|