From 5d190b774e220f69edd942ccda9186f7a4518682 Mon Sep 17 00:00:00 2001 From: Wyatt Riley Date: Mon, 19 Jun 2017 14:42:34 -0700 Subject: [PATCH] Clear notification count to handle different flows Notifiation count now cleared in Setup (and discarded messages warned about in Teardown.) Fixes: 62645164 Test: passes on device Change-Id: I7e88da7251464f281d7c98140d7a9b5a73d79542 (cherry picked from commit 6ec696b7fed0c597707762a6d5f5ecd709408aae) --- gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp b/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp index fde3171c..53181f15 100644 --- a/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp +++ b/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp @@ -49,6 +49,7 @@ class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase { capabilities_called_count_ = 0; location_called_count_ = 0; info_called_count_ = 0; + notify_count_ = 0; gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService(); ASSERT_NE(gnss_hal_, nullptr); @@ -93,12 +94,15 @@ class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase { if (gnss_hal_ != nullptr) { gnss_hal_->cleanup(); } + if (notify_count_ > 0) { + ALOGW("%d unprocessed callbacks discarded", notify_count_); + } } /* Used as a mechanism to inform the test that a callback has occurred */ inline void notify() { std::unique_lock lock(mtx_); - count++; + notify_count_++; cv_.notify_one(); } @@ -108,11 +112,11 @@ class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase { std::cv_status status = std::cv_status::no_timeout; auto now = std::chrono::system_clock::now(); - while (count == 0) { - status = cv_.wait_until(lock, now + std::chrono::seconds(timeoutSeconds)); - if (status == std::cv_status::timeout) return status; + while (notify_count_ == 0) { + status = cv_.wait_until(lock, now + std::chrono::seconds(timeoutSeconds)); + if (status == std::cv_status::timeout) return status; } - count--; + notify_count_--; return status; } @@ -188,7 +192,7 @@ class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase { private: std::mutex mtx_; std::condition_variable cv_; - int count; + int notify_count_; }; /* -- 2.11.0