libbinder_random_parcel: more failures logs
If we can't open an FD, add a log.
Bug: 240589211
Test: android.hardware.vibrator-service.example_fuzzer
Change-Id: Iac30601b4d2ca65ae8a66a8b35f3c2292c38f923
diff --git a/libs/binder/tests/parcel_fuzzer/random_fd.cpp b/libs/binder/tests/parcel_fuzzer/random_fd.cpp
index 3fcf104..e4dbb2d 100644
--- a/libs/binder/tests/parcel_fuzzer/random_fd.cpp
+++ b/libs/binder/tests/parcel_fuzzer/random_fd.cpp
@@ -26,9 +26,12 @@
using base::unique_fd;
std::vector<unique_fd> getRandomFds(FuzzedDataProvider* provider) {
+ const char* fdType;
+
std::vector<unique_fd> fds = provider->PickValueInArray<
std::function<std::vector<unique_fd>()>>({
[&]() {
+ fdType = "ashmem";
std::vector<unique_fd> ret;
ret.push_back(unique_fd(
ashmem_create_region("binder test region",
@@ -36,18 +39,21 @@
return ret;
},
[&]() {
+ fdType = "/dev/null";
std::vector<unique_fd> ret;
ret.push_back(unique_fd(open("/dev/null", O_RDWR)));
return ret;
},
[&]() {
+ fdType = "pipefd";
+
int pipefds[2];
int flags = O_CLOEXEC;
if (provider->ConsumeBool()) flags |= O_DIRECT;
if (provider->ConsumeBool()) flags |= O_NONBLOCK;
- CHECK_EQ(0, pipe2(pipefds, flags));
+ CHECK_EQ(0, pipe2(pipefds, flags)) << flags;
if (provider->ConsumeBool()) std::swap(pipefds[0], pipefds[1]);
@@ -58,7 +64,7 @@
},
})();
- for (const auto& fd : fds) CHECK(fd.ok()) << fd.get();
+ for (const auto& fd : fds) CHECK(fd.ok()) << fd.get() << " " << fdType;
return fds;
}