summaryrefslogtreecommitdiffstats
path: root/audio/core
diff options
context:
space:
mode:
authorKevin Rocard <krocard@google.com>2018-08-29 16:22:52 -0700
committerKevin Rocard <krocard@google.com>2018-09-19 18:27:15 +0000
commitd87a288e82120208af566677ef4c30fe1382df39 (patch)
treeb4ad906e03c786f56acf97464ae0c18616c4d36b /audio/core
parent2070f8b0b8982f0521efb1798fce2cc56631e26e (diff)
downloadandroid_hardware_interfaces-d87a288e82120208af566677ef4c30fe1382df39.tar.gz
android_hardware_interfaces-d87a288e82120208af566677ef4c30fe1382df39.tar.bz2
android_hardware_interfaces-d87a288e82120208af566677ef4c30fe1382df39.zip
Audio VTS: Workaround async HIDL destructor by sleeping
The test creates an instance of the Audio HAL then destroys it and create it again. The test assumed that the destruction was synchronous when in fact it is async with no way of knowing when the object has been destroyed. As a result, until a better solution is found, sleep for 100ms to hopefully let enouth time for the HAL destructor to return. Bug: 112566489 Test: adb shell /data/nativetest64/VtsHalAudioV4_0TargetTest/VtsHalAudioV4_0TargetTest --gtest_filter=*OpenPrimaryDeviceUsingGetDevice atest VtsHalAudioV4_0TargetTest Change-Id: I0ec75c12007d39060232632708722df5bf0f99d7 Signed-off-by: Kevin Rocard <krocard@google.com>
Diffstat (limited to 'audio/core')
-rw-r--r--audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
index 59ced271e..359b4b328 100644
--- a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -29,6 +29,8 @@
#include <fcntl.h>
#include <unistd.h>
+#include <hwbinder/IPCThreadState.h>
+
#include <VtsHalHidlTargetTestBase.h>
#include <android-base/logging.h>
@@ -55,13 +57,14 @@ using std::vector;
using std::list;
using ::android::sp;
-using ::android::hardware::Return;
using ::android::hardware::hidl_bitfield;
using ::android::hardware::hidl_enum_iterator;
using ::android::hardware::hidl_handle;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
+using ::android::hardware::IPCThreadState;
using ::android::hardware::MQDescriptorSync;
+using ::android::hardware::Return;
using ::android::hardware::audio::V4_0::AudioDrain;
using ::android::hardware::audio::V4_0::DeviceAddress;
using ::android::hardware::audio::V4_0::IDevice;
@@ -164,15 +167,25 @@ TEST_F(AudioHidlTest, OpenDeviceInvalidParameter) {
TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) {
doc::test("Calling openDevice(\"primary\") should return the primary device.");
- Result result;
- sp<IDevice> baseDevice;
- ASSERT_OK(devicesFactory->openDevice("primary", returnIn(result, baseDevice)));
- ASSERT_OK(result);
- ASSERT_TRUE(baseDevice != nullptr);
-
- Return<sp<IPrimaryDevice>> primaryDevice = IPrimaryDevice::castFrom(baseDevice);
- ASSERT_TRUE(primaryDevice.isOk());
- ASSERT_TRUE(sp<IPrimaryDevice>(primaryDevice) != nullptr);
+ {
+ Result result;
+ sp<IDevice> baseDevice;
+ ASSERT_OK(devicesFactory->openDevice("primary", returnIn(result, baseDevice)));
+ ASSERT_OK(result);
+ ASSERT_TRUE(baseDevice != nullptr);
+
+ Return<sp<IPrimaryDevice>> primaryDevice = IPrimaryDevice::castFrom(baseDevice);
+ ASSERT_TRUE(primaryDevice.isOk());
+ ASSERT_TRUE(sp<IPrimaryDevice>(primaryDevice) != nullptr);
+ } // Destroy local IDevice proxy
+ // FIXME: there is no way to know when the remote IDevice 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);
}
//////////////////////////////////////////////////////////////////////////////