diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2019-10-23 22:57:06 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-10-23 22:57:06 +0000 |
commit | b0a0799f56c176bf6782f0a370cc3d9054adb55d (patch) | |
tree | 6cc55421fa23328400e33e2015854723ea9d4a25 | |
parent | 999c5e83c4f03d6b4195833f73b82b3102ad0fdb (diff) | |
parent | 17030494e3671fe216befcbaf8b08a7627cbb17c (diff) | |
download | platform_hardware_interfaces-b0a0799f56c176bf6782f0a370cc3d9054adb55d.tar.gz platform_hardware_interfaces-b0a0799f56c176bf6782f0a370cc3d9054adb55d.tar.bz2 platform_hardware_interfaces-b0a0799f56c176bf6782f0a370cc3d9054adb55d.zip |
Merge "DO NOT MERGE: Audio VTS: Wait after stream close" into pie-vts-dev
-rw-r--r-- | audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp index 46c228a19f..71d91db360 100644 --- a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp +++ b/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp @@ -191,7 +191,7 @@ TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) { // flushCommand makes sure all local command are sent, thus should reduce // the latency between local and remote destruction. IPCThreadState::self()->flushCommands(); - usleep(100); + usleep(100*1000); } ////////////////////////////////////////////////////////////////////////////// @@ -698,13 +698,27 @@ class OpenStreamTest : public AudioConfigPrimaryTest, Return<Result> closeStream() { open = false; - return stream->close(); + auto res = stream->close(); + stream.clear(); + waitForStreamDestruction(); + return res; + } + + void waitForStreamDestruction() { + // FIXME: there is no way to know when the remote IStream is being destroyed + // Binder does not support testing if an object is alive, thus + // wait for 100ms to let the binder destruction propagates and + // the remote device has the time to be destroyed. + // flushCommand makes sure all local command are sent, thus should reduce + // the latency between local and remote destruction. + IPCThreadState::self()->flushCommands(); + usleep(100*1000); } private: void TearDown() override { if (open) { - ASSERT_OK(stream->close()); + ASSERT_OK(closeStream()); } } @@ -1051,8 +1065,12 @@ TEST_IO_STREAM(getMmapPositionNoMmap, "Get a stream Mmap position before mapping ASSERT_RESULT(invalidStateOrNotSupported, stream->stop())) TEST_IO_STREAM(close, "Make sure a stream can be closed", ASSERT_OK(closeStream())) -TEST_IO_STREAM(closeTwice, "Make sure a stream can not be closed twice", ASSERT_OK(closeStream()); - ASSERT_RESULT(Result::INVALID_STATE, closeStream())) +TEST_IO_STREAM(closeTwice, "Make sure a stream can not be closed twice", + auto streamCopy = stream; + ASSERT_OK(closeStream()); + ASSERT_RESULT(Result::INVALID_STATE, streamCopy->close()); + streamCopy.clear(); + waitForStreamDestruction()) static void testCreateTooBigMmapBuffer(IStream* stream) { MmapBufferInfo info; |