From 886963274a145ee9f8a36e95bbc9e0fc353e6914 Mon Sep 17 00:00:00 2001 From: Jack He Date: Mon, 5 Nov 2018 19:51:28 -0800 Subject: [PATCH] BT: Make Bluetooth HCI VTS tests more stable * Add a 200ms sleep after BluetoothHci->close() to give HAL an ample time to shutdown * Add override modifier to certain serviceDied() callback * Change from return to break in handle_no_ops * Add more logging to TearDown() Test: make, VtsHalBluetoothV1_0TargetTest Bug: 119071943 Change-Id: I5c919a99fb651f8f52d1d34847e1f9b4325efcd5 --- .../functional/VtsHalBluetoothV1_0TargetTest.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp index 88d42340e0..90fbb3f279 100644 --- a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp +++ b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp @@ -26,7 +26,10 @@ #include #include #include + +#include #include +#include using ::android::sp; using ::android::hardware::hidl_death_recipient; @@ -46,6 +49,7 @@ using ::android::hardware::bluetooth::V1_0::Status; #define WAIT_FOR_HCI_EVENT_TIMEOUT std::chrono::milliseconds(2000) #define WAIT_FOR_SCO_DATA_TIMEOUT std::chrono::milliseconds(1000) #define WAIT_FOR_ACL_DATA_TIMEOUT std::chrono::milliseconds(1000) +#define INTERFACE_CLOSE_DELAY_MS std::chrono::milliseconds(200) #define COMMAND_HCI_SHOULD_BE_UNKNOWN \ { 0xff, 0x3B, 0x08, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 } @@ -197,8 +201,10 @@ class BluetoothHidlTest : public ::testing::VtsHalHidlTargetTestBase { } virtual void TearDown() override { + ALOGI("TearDown"); // Should not be checked in production code ASSERT_TRUE(bluetooth->close().isOk()); + std::this_thread::sleep_for(INTERFACE_CLOSE_DELAY_MS); handle_no_ops(); EXPECT_EQ(static_cast(0), event_queue.size()); EXPECT_EQ(static_cast(0), sco_queue.size()); @@ -222,9 +228,10 @@ class BluetoothHidlTest : public ::testing::VtsHalHidlTargetTestBase { class BluetoothHciDeathRecipient : public hidl_death_recipient { public: - virtual void serviceDied( + void serviceDied( uint64_t /*cookie*/, - const android::wp<::android::hidl::base::V1_0::IBase>& /*who*/) { + const android::wp<::android::hidl::base::V1_0::IBase>& /*who*/) + override { FAIL(); } }; @@ -308,7 +315,7 @@ void BluetoothHidlTest::handle_no_ops() { if (event_is_no_op) { event_queue.pop(); } else { - return; + break; } } }