Merge "Update hash and VTS for the 2nd FD of dumpstate" into oc-dr1-dev am: 79fb65bb7b
am: 514e9c074e
Change-Id: I3c3246697ec248d08b57beb82b0c9dc97a2b77b1
This commit is contained in:
commit
180a8ed591
3 changed files with 33 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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<void> 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();
|
||||
|
|
Loading…
Reference in a new issue