test(audio): reduce wait time (#4247)

This commit is contained in:
ReenigneArcher 2025-09-08 17:59:19 -04:00 committed by GitHub
commit 54a8dd792f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -18,7 +18,7 @@ struct AudioTest: PlatformTestSuite, testing::WithParamInterface<std::tuple<std:
safe::mail_t m_mail;
};
constexpr std::bitset<config_t::MAX_FLAGS> config_flags(int flag = -1) {
constexpr std::bitset<config_t::MAX_FLAGS> config_flags(const int flag = -1) {
std::bitset<3> result = std::bitset<config_t::MAX_FLAGS>();
if (flag >= 0) {
result.set(flag);
@ -42,22 +42,21 @@ INSTANTIATE_TEST_SUITE_P(
TEST_P(AudioTest, TestEncode) {
std::thread timer([&] {
// Terminate the audio capture after 5 seconds.
std::this_thread::sleep_for(5s);
auto shutdown_event = m_mail->event<bool>(mail::shutdown);
auto audio_packets = m_mail->queue<packet_t>(mail::audio_packets);
// Terminate the audio capture after 100 ms
std::this_thread::sleep_for(100ms);
const auto shutdown_event = m_mail->event<bool>(mail::shutdown);
const auto audio_packets = m_mail->queue<packet_t>(mail::audio_packets);
shutdown_event->raise(true);
audio_packets->stop();
});
std::thread capture([&] {
auto packets = m_mail->queue<packet_t>(mail::audio_packets);
auto shutdown_event = m_mail->event<bool>(mail::shutdown);
while (auto packet = packets->pop()) {
const auto packets = m_mail->queue<packet_t>(mail::audio_packets);
const auto shutdown_event = m_mail->event<bool>(mail::shutdown);
while (const auto packet = packets->pop()) {
if (shutdown_event->peek()) {
break;
}
auto packet_data = packet->second;
if (packet_data.size() == 0) {
if (auto packet_data = packet->second; packet_data.size() == 0) {
FAIL() << "Empty packet data";
}
}