summaryrefslogtreecommitdiff
path: root/simpleperf/libsimpleperf_report_fuzzer.cpp
blob: 4c68610fe3130d3720900cb38019049734868884 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

#include <android-base/file.h>

#include "report_lib_interface.cpp"

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  TemporaryFile tmpfile;
  android::base::WriteStringToFd(std::string(reinterpret_cast<const char*>(data), size),
                                 tmpfile.fd);
  ReportLib* report_lib = CreateReportLib();
  SetRecordFile(report_lib, tmpfile.path);
  while (true) {
    Sample* sample = GetNextSample(report_lib);
    if (sample == nullptr) {
      break;
    }
  }
  DestroyReportLib(report_lib);
  return 0;
}