Merge "Audio VTS: Wait after stream close" am: 1f004177c6 am: 98d63d2b1d am: 91b0183ac1

am: f6d64fbeef

Change-Id: I42154ce2c57075c9e817a35a6596865b26f3c996
This commit is contained in:
Mikhail Naganov 2019-10-22 17:26:14 -07:00 committed by android-build-merger
commit 6469b85899
2 changed files with 25 additions and 5 deletions

View file

@ -24,7 +24,7 @@ static void waitForDeviceDestruction() {
// 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);
}
TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) {

View file

@ -699,13 +699,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());
}
AudioConfigPrimaryTest::TearDown();
}
@ -1003,8 +1017,14 @@ 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()))
// clang-format off
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())
// clang-format on
static void testCreateTooBigMmapBuffer(IStream* stream) {
MmapBufferInfo info;