Fix vts sco test fail for usb interface

[Description]
If bt controller device is usb interface,
sco loopback single pkt and bandwidth test can not pass
because pkt size is limited accroding to core spec

[Root Cause]
USB sco packet size is limited in spec

[Solution]
If is bt usb chip, continuous receive sco packets
  from controller until size is enough

[Test Report]
Test Pass

Bug: 286355871
Change-Id: Idb150d8a72149f7e1dfaccfd7bc82a91710da59c
This commit is contained in:
xiaoshun.xu
2023-07-11 17:30:04 +08:00
committed by Can Chen
parent 031aeee88c
commit 4e85c09959

View File

@@ -222,6 +222,8 @@ class BluetoothAidlTest : public ::testing::TestWithParam<std::string> {
int wait_for_completed_packets_event(uint16_t handle);
void send_and_wait_for_cmd_complete(std::unique_ptr<CommandBuilder> cmd,
std::vector<uint8_t>& cmd_complete);
void reassemble_sco_loopback_pkt(std::vector<uint8_t>& scoPackets,
size_t size);
// A simple test implementation of BluetoothHciCallbacks.
class BluetoothHciCallbacks
@@ -569,6 +571,11 @@ void BluetoothAidlTest::sendAndCheckSco(int num_packets, size_t size,
ASSERT_TRUE(
sco_queue.tryPopWithTimeout(sco_loopback, kWaitForScoDataTimeout));
if (sco_loopback.size() < size) {
// The packets may have been split for USB. Reassemble before checking.
reassemble_sco_loopback_pkt(sco_loopback, size);
}
ASSERT_EQ(sco_packet, sco_loopback);
}
logger.setTotalBytes(num_packets * size * 2);
@@ -703,6 +710,22 @@ void BluetoothAidlTest::send_and_wait_for_cmd_complete(
wait_for_command_complete_event(view.GetOpCode(), cmd_complete));
}
// Handle the loopback packet.
void BluetoothAidlTest::reassemble_sco_loopback_pkt(std::vector<uint8_t>& scoPackets,
size_t size) {
std::vector<uint8_t> sco_packet_whole;
sco_packet_whole.assign(scoPackets.begin(), scoPackets.end());
while (size + 3 > sco_packet_whole.size()) {
std::vector<uint8_t> sco_packets;
ASSERT_TRUE(
sco_queue.tryPopWithTimeout(sco_packets, kWaitForScoDataTimeout));
sco_packet_whole.insert(sco_packet_whole.end(), sco_packets.begin() + 3,
sco_packets.end());
}
scoPackets.assign(sco_packet_whole.begin(), sco_packet_whole.end());
scoPackets[2] = size;
}
// Empty test: Initialize()/Close() are called in SetUp()/TearDown().
TEST_P(BluetoothAidlTest, InitializeAndClose) {}