Fix UploadService unittests.
The unittest was creating a brillo::Daemon in a smart pointer and then resetting it to a newly created different brillo::Daemon instance. This creates two brillo::Daemon instances for a short period of time, which both setup global context (the default message loop). This patch fixes this situation by deleting the service before creating a new one. Bug: 27121855 TEST=`/data/nativetest/metricsd_tests/metricsd_tests` on edison-eng Change-Id: I3b60cbfcdba77febbfa6104aa0ecad60a29afec5
This commit is contained in:
parent
c7f43c6ae1
commit
de4497ef3d
1 changed files with 4 additions and 0 deletions
|
@ -304,6 +304,8 @@ TEST_F(UploadServiceTest, CurrentLogSavedAndResumed) {
|
|||
upload_service_->PersistToDisk();
|
||||
EXPECT_EQ(
|
||||
1, upload_service_->current_log_->uma_proto()->histogram_event().size());
|
||||
// Destroy the old service before creating a new one.
|
||||
upload_service_.reset();
|
||||
upload_service_.reset(new UploadService(
|
||||
"", base::TimeDelta(), base::TimeDelta(), private_dir_, shared_dir_));
|
||||
upload_service_->InitForTest(nullptr);
|
||||
|
@ -325,6 +327,8 @@ TEST_F(UploadServiceTest, CorruptedSavedLog) {
|
|||
// Write a bogus saved log.
|
||||
EXPECT_EQ(5, base::WriteFile(upload_service_->saved_log_path_, "hello", 5));
|
||||
|
||||
// Destroy the old service before creating a new one.
|
||||
upload_service_.reset();
|
||||
upload_service_.reset(new UploadService(
|
||||
"", base::TimeDelta(), base::TimeDelta(), private_dir_, shared_dir_));
|
||||
|
||||
|
|
Loading…
Reference in a new issue