diff --git a/current.txt b/current.txt index 8d0785ffd6..b671bac348 100644 --- a/current.txt +++ b/current.txt @@ -189,4 +189,5 @@ fe3c3c2f572b72f15f8594c538b0577bd5c28722c31879cfe6231330cddb6747 android.hardwar # ABI preserving changes to HALs released in Android O +760485232f6cce07f8bb05e3475509956996b702f77415ee5bff05e2ec5a5bcc android.hardware.dumpstate@1.0::IDumpstateDevice 28e929b453df3d9f5060af2764e6cdb123ddb893e3e86923c877f6ff7e5f02c9 android.hardware.wifi@1.0::types diff --git a/dumpstate/1.0/IDumpstateDevice.hal b/dumpstate/1.0/IDumpstateDevice.hal index 206c139b36..12a0db40b6 100644 --- a/dumpstate/1.0/IDumpstateDevice.hal +++ b/dumpstate/1.0/IDumpstateDevice.hal @@ -18,7 +18,14 @@ package android.hardware.dumpstate@1.0; interface IDumpstateDevice { /** - * Dumps device-specific state into the given file descriptor. + * Dump device-specific state into the given file descriptors. + * + * One file descriptor must be passed to this method but two may be passed: + * the first descriptor must be used to dump device-specific state in text + * format, the second descriptor is optional and may be used to dump + * device-specific state in binary format. + * + * @param h A native handle with one or two valid file descriptors. */ dumpstateBoard(handle h); }; diff --git a/dumpstate/1.0/vts/functional/VtsHalDumpstateV1_0TargetTest.cpp b/dumpstate/1.0/vts/functional/VtsHalDumpstateV1_0TargetTest.cpp index 7ab4812ba6..046bf56e4b 100644 --- a/dumpstate/1.0/vts/functional/VtsHalDumpstateV1_0TargetTest.cpp +++ b/dumpstate/1.0/vts/functional/VtsHalDumpstateV1_0TargetTest.cpp @@ -59,6 +59,7 @@ TEST_F(DumpstateHidlTest, TestHandleWithNoFd) { // Positive test: make sure dumpstateBoard() writes something to the FD. TEST_F(DumpstateHidlTest, TestOk) { FILE* file = tmpfile(); + ASSERT_NE(nullptr, file) << "Could not create temp file: " << strerror(errno); native_handle_t* handle = native_handle_create(1, 0); @@ -80,6 +81,29 @@ TEST_F(DumpstateHidlTest, TestOk) { native_handle_delete(handle); } +// Positive test: make sure dumpstateBoard() doesn't crash with two FDs. +TEST_F(DumpstateHidlTest, TestHandleWithTwoFds) { + FILE* file1 = tmpfile(); + FILE* file2 = tmpfile(); + + ASSERT_NE(nullptr, file1) << "Could not create temp file #1: " << strerror(errno); + ASSERT_NE(nullptr, file2) << "Could not create temp file #2: " << strerror(errno); + + native_handle_t* handle = native_handle_create(2, 0); + ASSERT_NE(handle, nullptr) << "Could not create native_handle"; + handle->data[0] = fileno(file1); + handle->data[1] = fileno(file2); + + Return status = dumpstate->dumpstateBoard(handle); + ASSERT_TRUE(status.isOk()) << "Status should be ok: " << status.description(); + + EXPECT_EQ(0, fclose(file1)) << errno; + EXPECT_EQ(0, fclose(file2)) << errno; + + native_handle_close(handle); + native_handle_delete(handle); +} + int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); int status = RUN_ALL_TESTS();