Loading system/gd/common/testing/android/log_capture.cc +2 −5 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ LogCapture* LogCapture::Rewind() { return this; } bool LogCapture::Find(std::string to_find) { bool LogCapture::Find(const std::string& to_find) { // For |atest| assume all log captures succeed return true; } Loading @@ -63,10 +63,7 @@ size_t LogCapture::Size() const { return size; } void LogCapture::WaitUntilLogContains(std::promise<void>* promise, std::string text) { std::async([promise, text]() { promise->set_value(); }); promise->get_future().wait(); } void LogCapture::WaitUntilLogContains(const std::string& text) {} std::pair<int, int> LogCapture::create_backing_store() const { int dup_fd = -1; Loading system/gd/common/testing/host/log_capture.cc +6 −10 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ LogCapture* LogCapture::Rewind() { return this; } bool LogCapture::Find(std::string to_find) { bool LogCapture::Find(const std::string& to_find) { std::string str = this->Read(); return str.find(to_find) != std::string::npos; } Loading Loading @@ -135,15 +135,11 @@ size_t LogCapture::Size() const { return size; } void LogCapture::WaitUntilLogContains(std::promise<void>* promise, std::string text) { std::async([this, promise, text]() { void LogCapture::WaitUntilLogContains(const std::string& text) { bool found = false; do { found = this->Rewind()->Find(text); } while (!found); promise->set_value(); }); promise->get_future().wait(); } std::pair<int, int> LogCapture::create_backing_store() const { Loading system/gd/common/testing/host/log_capture_test.cc +1 −2 Original line number Diff line number Diff line Loading @@ -146,8 +146,7 @@ TEST_F(LogCaptureTest, DISABLED_wait_until_log_contains) { std::unique_ptr<LogCapture> log_capture = std::make_unique<LogCapture>(); LOG_DEBUG("%s", kLogDebug); std::promise<void> promise; log_capture->WaitUntilLogContains(&promise, kLogDebug); log_capture->WaitUntilLogContains(kLogDebug); bluetooth::common::InitFlags::Load(nullptr); } Loading system/gd/common/testing/log_capture.h +2 −2 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ class LogCapture { LogCapture* Rewind(); // Searches from filepointer to end of file for |to_find| string // Returns true if found, false otherwise bool Find(std::string to_find); bool Find(const std::string& to_find); // Reads and returns the entirety of the backing store into a string std::string Read(); // Flushes contents of log capture back to |stderr| Loading @@ -43,7 +43,7 @@ class LogCapture { // Truncates and resets the file pointer discarding all logs up to this point void Reset(); // Wait until the provided string shows up in the logs void WaitUntilLogContains(std::promise<void>* promise, std::string text); void WaitUntilLogContains(const std::string& text); private: std::pair<int, int> create_backing_store() const; Loading system/stack/test/a2dp/a2dp_aac_unittest.cc +4 −11 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ #include <cstdint> #include <fstream> #include <future> #include <iomanip> #include <map> #include <string> Loading Loading @@ -171,9 +170,7 @@ TEST_F(A2dpAacTest, a2dp_source_read_underflow) { usleep(kA2dpTickUs); timestamp_us = bluetooth::common::time_gettimeofday_us(); encoder_iface_->send_frames(timestamp_us); std::promise<void> promise; log_capture_->WaitUntilLogContains(&promise, "a2dp_aac_encode_frames: underflow"); log_capture_->WaitUntilLogContains("a2dp_aac_encode_frames: underflow"); } TEST_F(A2dpAacTest, a2dp_enqueue_cb_is_invoked) { Loading @@ -193,8 +190,7 @@ TEST_F(A2dpAacTest, a2dp_enqueue_cb_is_invoked) { usleep(kA2dpTickUs); timestamp_us = bluetooth::common::time_gettimeofday_us(); encoder_iface_->send_frames(timestamp_us); std::promise<void> promise; log_capture_->WaitUntilLogContains(&promise, kEnqueueCallbackIsInvoked); log_capture_->WaitUntilLogContains(kEnqueueCallbackIsInvoked); } TEST_F(A2dpAacTest, decoded_data_cb_not_invoked_when_empty_packet) { Loading Loading @@ -232,8 +228,7 @@ TEST_F(A2dpAacTest, decoded_data_cb_invoked) { timestamp_us = bluetooth::common::time_gettimeofday_us(); encoder_iface_->send_frames(timestamp_us); std::promise<void> promise; log_capture_->WaitUntilLogContains(&promise, kEnqueueCallbackIsInvoked); log_capture_->WaitUntilLogContains(kEnqueueCallbackIsInvoked); decoder_iface_->decode_packet(packet); osi_free(packet); ASSERT_TRUE(log_capture_->Find(kDecodedDataCallbackIsInvoked)); Loading Loading @@ -282,9 +277,7 @@ TEST_F(A2dpAacTest, effective_mtu_when_peer_does_not_support_3mbps) { TEST_F(A2dpAacTest, debug_codec_dump) { log_capture_ = std::make_unique<LogCapture>(); a2dp_codecs_->debug_codec_dump(2); std::promise<void> promise; log_capture_->WaitUntilLogContains(&promise, "Current Codec: AAC"); log_capture_->WaitUntilLogContains("Current Codec: AAC"); } TEST_F(A2dpAacTest, codec_info_string) { Loading Loading
system/gd/common/testing/android/log_capture.cc +2 −5 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ LogCapture* LogCapture::Rewind() { return this; } bool LogCapture::Find(std::string to_find) { bool LogCapture::Find(const std::string& to_find) { // For |atest| assume all log captures succeed return true; } Loading @@ -63,10 +63,7 @@ size_t LogCapture::Size() const { return size; } void LogCapture::WaitUntilLogContains(std::promise<void>* promise, std::string text) { std::async([promise, text]() { promise->set_value(); }); promise->get_future().wait(); } void LogCapture::WaitUntilLogContains(const std::string& text) {} std::pair<int, int> LogCapture::create_backing_store() const { int dup_fd = -1; Loading
system/gd/common/testing/host/log_capture.cc +6 −10 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ LogCapture* LogCapture::Rewind() { return this; } bool LogCapture::Find(std::string to_find) { bool LogCapture::Find(const std::string& to_find) { std::string str = this->Read(); return str.find(to_find) != std::string::npos; } Loading Loading @@ -135,15 +135,11 @@ size_t LogCapture::Size() const { return size; } void LogCapture::WaitUntilLogContains(std::promise<void>* promise, std::string text) { std::async([this, promise, text]() { void LogCapture::WaitUntilLogContains(const std::string& text) { bool found = false; do { found = this->Rewind()->Find(text); } while (!found); promise->set_value(); }); promise->get_future().wait(); } std::pair<int, int> LogCapture::create_backing_store() const { Loading
system/gd/common/testing/host/log_capture_test.cc +1 −2 Original line number Diff line number Diff line Loading @@ -146,8 +146,7 @@ TEST_F(LogCaptureTest, DISABLED_wait_until_log_contains) { std::unique_ptr<LogCapture> log_capture = std::make_unique<LogCapture>(); LOG_DEBUG("%s", kLogDebug); std::promise<void> promise; log_capture->WaitUntilLogContains(&promise, kLogDebug); log_capture->WaitUntilLogContains(kLogDebug); bluetooth::common::InitFlags::Load(nullptr); } Loading
system/gd/common/testing/log_capture.h +2 −2 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ class LogCapture { LogCapture* Rewind(); // Searches from filepointer to end of file for |to_find| string // Returns true if found, false otherwise bool Find(std::string to_find); bool Find(const std::string& to_find); // Reads and returns the entirety of the backing store into a string std::string Read(); // Flushes contents of log capture back to |stderr| Loading @@ -43,7 +43,7 @@ class LogCapture { // Truncates and resets the file pointer discarding all logs up to this point void Reset(); // Wait until the provided string shows up in the logs void WaitUntilLogContains(std::promise<void>* promise, std::string text); void WaitUntilLogContains(const std::string& text); private: std::pair<int, int> create_backing_store() const; Loading
system/stack/test/a2dp/a2dp_aac_unittest.cc +4 −11 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ #include <cstdint> #include <fstream> #include <future> #include <iomanip> #include <map> #include <string> Loading Loading @@ -171,9 +170,7 @@ TEST_F(A2dpAacTest, a2dp_source_read_underflow) { usleep(kA2dpTickUs); timestamp_us = bluetooth::common::time_gettimeofday_us(); encoder_iface_->send_frames(timestamp_us); std::promise<void> promise; log_capture_->WaitUntilLogContains(&promise, "a2dp_aac_encode_frames: underflow"); log_capture_->WaitUntilLogContains("a2dp_aac_encode_frames: underflow"); } TEST_F(A2dpAacTest, a2dp_enqueue_cb_is_invoked) { Loading @@ -193,8 +190,7 @@ TEST_F(A2dpAacTest, a2dp_enqueue_cb_is_invoked) { usleep(kA2dpTickUs); timestamp_us = bluetooth::common::time_gettimeofday_us(); encoder_iface_->send_frames(timestamp_us); std::promise<void> promise; log_capture_->WaitUntilLogContains(&promise, kEnqueueCallbackIsInvoked); log_capture_->WaitUntilLogContains(kEnqueueCallbackIsInvoked); } TEST_F(A2dpAacTest, decoded_data_cb_not_invoked_when_empty_packet) { Loading Loading @@ -232,8 +228,7 @@ TEST_F(A2dpAacTest, decoded_data_cb_invoked) { timestamp_us = bluetooth::common::time_gettimeofday_us(); encoder_iface_->send_frames(timestamp_us); std::promise<void> promise; log_capture_->WaitUntilLogContains(&promise, kEnqueueCallbackIsInvoked); log_capture_->WaitUntilLogContains(kEnqueueCallbackIsInvoked); decoder_iface_->decode_packet(packet); osi_free(packet); ASSERT_TRUE(log_capture_->Find(kDecodedDataCallbackIsInvoked)); Loading Loading @@ -282,9 +277,7 @@ TEST_F(A2dpAacTest, effective_mtu_when_peer_does_not_support_3mbps) { TEST_F(A2dpAacTest, debug_codec_dump) { log_capture_ = std::make_unique<LogCapture>(); a2dp_codecs_->debug_codec_dump(2); std::promise<void> promise; log_capture_->WaitUntilLogContains(&promise, "Current Codec: AAC"); log_capture_->WaitUntilLogContains("Current Codec: AAC"); } TEST_F(A2dpAacTest, codec_info_string) { Loading