• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 #include <android-base/file.h>
3 
4 #include "command.h"
5 #include "report_lib_interface.cpp"
6 #include "test_util.h"
7 
8 using namespace simpleperf;
9 
10 namespace {
11 
TestReportLib(const char * record_file)12 void TestReportLib(const char* record_file) {
13   ReportLib* report_lib = CreateReportLib();
14   SetRecordFile(report_lib, record_file);
15   while (true) {
16     Sample* sample = GetNextSample(report_lib);
17     if (sample == nullptr) {
18       break;
19     }
20   }
21   DestroyReportLib(report_lib);
22 }
23 
TestDumpCmd(const char * record_file)24 void TestDumpCmd(const char* record_file) {
25   std::unique_ptr<Command> dump_cmd = CreateCommandInstance("dump");
26   CaptureStdout capture;
27   capture.Start();
28   dump_cmd->Run({"-i", record_file, "--dump-etm", "raw,packet,element"});
29 }
30 
31 }  // namespace
32 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)33 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
34   TemporaryFile tmpfile;
35   android::base::WriteFully(tmpfile.fd, data, size);
36   TestReportLib(tmpfile.path);
37   TestDumpCmd(tmpfile.path);
38   return 0;
39 }
40