diff options
author | Gilad Arnold <garnold@chromium.org> | 2014-05-21 09:37:18 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-05-31 01:47:05 +0000 |
commit | 897b5e592cf64e3c04ed1151d19ce5cd51a90592 (patch) | |
tree | 0afb03927a90ac153f2a6d2e60cfcb341bff5426 /update_manager/update_manager_unittest.cc | |
parent | 3d21b12092a0108f77c3332b85eaf81524fe7c32 (diff) |
PM: Blocking policy requests cannot be called synchronously.
Policy requests that may return EvalStatus::kAskMeAgainLater are
considered blocking and should only be called asynchronously. It is
therefore an error to call a policy returning this value via
UpdateManager::PolicyRequest(), and so we kill the program with an
assertion (DCHECK) if this happens; for release builds, a warning log is
emitted.
Note: the associated death test builds and runs iff DCHECK is enabled.
BUG=None
TEST=Unit tests.
Change-Id: I75e2f5e4498f85857aff41778df0300d7c8898e7
Reviewed-on: https://chromium-review.googlesource.com/200760
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Diffstat (limited to 'update_manager/update_manager_unittest.cc')
-rw-r--r-- | update_manager/update_manager_unittest.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/update_manager/update_manager_unittest.cc b/update_manager/update_manager_unittest.cc index 39427b39..95fd3e00 100644 --- a/update_manager/update_manager_unittest.cc +++ b/update_manager/update_manager_unittest.cc @@ -128,14 +128,16 @@ TEST_F(UmUpdateManagerTest, PolicyRequestCallsDefaultOnError) { EXPECT_TRUE(result.updates_enabled); } -TEST_F(UmUpdateManagerTest, PolicyRequestDoesntBlock) { +// This test only applies to debug builds where DCHECK is enabled. +#if DCHECK_IS_ON +TEST_F(UmUpdateManagerTest, PolicyRequestDoesntBlockDeathTest) { + // The update manager should die (DCHECK) if a policy called synchronously + // returns a kAskMeAgainLater value. UpdateCheckParams result; umut_->set_policy(new LazyPolicy()); - - EvalStatus status = umut_->PolicyRequest( - &Policy::UpdateCheckAllowed, &result); - EXPECT_EQ(EvalStatus::kAskMeAgainLater, status); + EXPECT_DEATH(umut_->PolicyRequest(&Policy::UpdateCheckAllowed, &result), ""); } +#endif // DCHECK_IS_ON TEST_F(UmUpdateManagerTest, AsyncPolicyRequestDelaysEvaluation) { // To avoid differences in code execution order between an AsyncPolicyRequest |