Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79fb65bb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update hash and VTS for the 2nd FD of dumpstate" into oc-dr1-dev

parents da4568eb cc4ddffe
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+8 −1
Original line number Diff line number Diff line
@@ -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);
};
+24 −0
Original line number Diff line number Diff line
@@ -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();