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
diff --git a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
index 88d4234..90fbb3f 100644
--- a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
+++ b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
@@ -26,7 +26,10 @@
#include <VtsHalHidlTargetCallbackBase.h>
#include <VtsHalHidlTargetTestBase.h>
#include <VtsHalHidlTargetTestEnvBase.h>
+
+#include <chrono>
#include <queue>
+#include <thread>
using ::android::sp;
using ::android::hardware::hidl_death_recipient;
@@ -46,6 +49,7 @@
#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 @@
}
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<size_t>(0), event_queue.size());
EXPECT_EQ(static_cast<size_t>(0), sco_queue.size());
@@ -222,9 +228,10 @@
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 @@
if (event_is_no_op) {
event_queue.pop();
} else {
- return;
+ break;
}
}
}