Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit de4497ef authored by Alex Deymo's avatar Alex Deymo
Browse files

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
parent c7f43c6a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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_));