diff options
author | Yabin Cui <yabinc@google.com> | 2022-11-30 22:09:31 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-11-30 22:09:31 +0000 |
commit | 8ab3ec69a78ee902eae4d370a5583809086e3e43 (patch) | |
tree | 701e57c7ab2c50d42f37d223120c304803315914 | |
parent | 72236c1eabd8d3cab8f8d224e493cb8a9dddb79b (diff) | |
parent | 211a4ad020bf35b9c813f3e8d1131c19765e8bb1 (diff) | |
download | extras-8ab3ec69a78ee902eae4d370a5583809086e3e43.tar.gz |
Merge "simpleperf: run dump cmd in fuzz." am: 211a4ad020
Original change: https://android-review.googlesource.com/c/platform/system/extras/+/2322756
Change-Id: Ib4706d5beb706f1a2c17100f66dcfa87b5b77911
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | simpleperf/libsimpleperf_report_fuzzer.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/simpleperf/libsimpleperf_report_fuzzer.cpp b/simpleperf/libsimpleperf_report_fuzzer.cpp index 4c68610f..8c6d8788 100644 --- a/simpleperf/libsimpleperf_report_fuzzer.cpp +++ b/simpleperf/libsimpleperf_report_fuzzer.cpp @@ -1,14 +1,17 @@ #include <android-base/file.h> +#include "command.h" #include "report_lib_interface.cpp" +#include "test_util.h" -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); +using namespace simpleperf; + +namespace { + +void TestReportLib(const char* record_file) { ReportLib* report_lib = CreateReportLib(); - SetRecordFile(report_lib, tmpfile.path); + SetRecordFile(report_lib, record_file); while (true) { Sample* sample = GetNextSample(report_lib); if (sample == nullptr) { @@ -16,5 +19,21 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { } } DestroyReportLib(report_lib); +} + +void TestDumpCmd(const char* record_file) { + std::unique_ptr<Command> dump_cmd = CreateCommandInstance("dump"); + CaptureStdout capture; + capture.Start(); + dump_cmd->Run({"-i", record_file, "--dump-etm", "raw,packet,element"}); +} + +} // namespace + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + TemporaryFile tmpfile; + android::base::WriteFully(tmpfile.fd, data, size); + TestReportLib(tmpfile.path); + TestDumpCmd(tmpfile.path); return 0; } |