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

Commit ee771e9c authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Fix potentiel deadlock in audio VTS



The IDevice::debugDump method dumps debug info in a file descriptor.
Such file descriptor was previously the writing end of a pipe.

As the test is not multithreaded, if the dump was bigger than the pipe
buffer, a deadlock would occur.

With this patch, the test uses a file instead of a pipe. Thus write
will never block infinitely.

Test: run the corresponding vts test
Test: vts-tradefed r vts-hal-hidl -m VtsHalAudioV2_0Target

Bug: 34170075
Change-Id: I928cae712a1cb4411f907b3a9583014ba6486abc
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent a20c5172
Loading
Loading
Loading
Loading
+5 −15
Original line number Diff line number Diff line
@@ -465,25 +465,15 @@ TEST_F(AudioPrimaryHidlTest, debugDump) {
    hidl_handle handle;
    handle.setTo(nativeHandle, true /*take ownership*/);

    auto ret = device->debugDump(handle);
    ASSERT_TRUE(ret.isOk());

    // FIXME: debugDump does not return a Result.
    // TODO: debugDump does not return a Result.
    // This mean that the hal can not report that it not implementing the function.
    // As the default hal does not implement debugDump, the function can not be tested.
    /*
    res = ret;
    if (res == Result::NOT_SUPPORTED) {
         doc::partialTest("debugDump is not implemented");
         return;
    }
    ASSERT_OK(res);
    rewind(file);
    ASSERT_OK(device->debugDump(handle));

    rewind(file); // can not fail

    // Check that at least one bit was written by the hal
    char buff;
    ASSERT_EQ(1, fread(&buff, sizeof(buff), 1, file));
    */
    ASSERT_EQ(size_t{1}, fread(&buff, sizeof(buff), 1, file));
    EXPECT_EQ(0, fclose(file)) << errno;
}