| Index: chromecast/crash/linux/synchronized_minidump_manager_unittest.cc
|
| diff --git a/chromecast/crash/linux/synchronized_minidump_manager_unittest.cc b/chromecast/crash/linux/synchronized_minidump_manager_unittest.cc
|
| index 5fa5a79b7e00994fd97548ebe26da9c6d45b69e2..c09d2ca36037ddbbfc27d4103af99cf44dc55bbb 100644
|
| --- a/chromecast/crash/linux/synchronized_minidump_manager_unittest.cc
|
| +++ b/chromecast/crash/linux/synchronized_minidump_manager_unittest.cc
|
| @@ -257,7 +257,7 @@ TEST_F(SynchronizedMinidumpManagerTest,
|
| TEST_F(SynchronizedMinidumpManagerTest,
|
| AddEntryToLockFile_SucceedsWithValidEntries) {
|
| // Sample parameters.
|
| - time_t now = time(0);
|
| + base::Time now = base::Time::Now();
|
| MinidumpParams params;
|
| params.process_name = "process";
|
|
|
| @@ -285,30 +285,9 @@ TEST_F(SynchronizedMinidumpManagerTest,
|
| }
|
|
|
| TEST_F(SynchronizedMinidumpManagerTest,
|
| - AcquireLockFile_FailsWhenNonBlockingAndFileLocked) {
|
| - ASSERT_TRUE(CreateFiles(lockfile_.value(), metadata_.value()));
|
| - // Lock the lockfile here. Note that the Chromium base::File tools permit
|
| - // multiple locks on the same process to succeed, so we must use POSIX system
|
| - // calls to accomplish this.
|
| - int fd = open(lockfile_.value().c_str(), O_RDWR | O_CREAT, 0660);
|
| - ASSERT_GE(fd, 0);
|
| - ASSERT_EQ(0, flock(fd, LOCK_EX));
|
| -
|
| - SynchronizedMinidumpManagerSimple manager;
|
| - manager.set_non_blocking(true);
|
| - ASSERT_EQ(-1, manager.DoWorkLocked());
|
| - ASSERT_FALSE(manager.work_done());
|
| -
|
| - // Test that the manager was not able to log the crash dump.
|
| - ScopedVector<DumpInfo> dumps;
|
| - ASSERT_TRUE(FetchDumps(lockfile_.value(), &dumps));
|
| - ASSERT_EQ(0u, dumps.size());
|
| -}
|
| -
|
| -TEST_F(SynchronizedMinidumpManagerTest,
|
| AcquireLockFile_WaitsForOtherThreadWhenBlocking) {
|
| // Create some parameters for a minidump.
|
| - time_t now = time(0);
|
| + base::Time now = base::Time::Now();
|
| MinidumpParams params;
|
| params.process_name = "process";
|
|
|
| @@ -337,7 +316,6 @@ TEST_F(SynchronizedMinidumpManagerTest,
|
| SynchronizedMinidumpManagerSimple manager;
|
| manager.SetDumpInfoToWrite(
|
| base::WrapUnique(new DumpInfo("dump", "log", now, params)));
|
| - manager.set_non_blocking(false);
|
|
|
| EXPECT_EQ(0, manager.DoWorkLocked());
|
| EXPECT_EQ(0, manager.add_entry_return_code());
|
| @@ -357,41 +335,9 @@ TEST_F(SynchronizedMinidumpManagerTest,
|
| // of all tests in this thread. Figure out how to lock the file more cleanly
|
| // from another process.
|
| TEST_F(SynchronizedMinidumpManagerTest,
|
| - DISABLED_AcquireLockFile_FailsWhenNonBlockingAndLockedFromOtherProcess) {
|
| - // Fork the process.
|
| - pid_t pid = base::ForkWithFlags(0u, nullptr, nullptr);
|
| - if (pid != 0) {
|
| - // The child process should instantiate a manager which immediately grabs
|
| - // the lock, and falls aleep for some period of time, then writes a dump,
|
| - // and finally releases the lock.
|
| - SleepySynchronizedMinidumpManagerSimple sleepy_manager(100);
|
| - ASSERT_EQ(0, sleepy_manager.DoWorkLocked());
|
| - ASSERT_TRUE(sleepy_manager.work_done());
|
| - return;
|
| - }
|
| -
|
| - // Meanwhile, this process should wait brielfy to allow the other thread to
|
| - // grab the lock.
|
| - base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(50));
|
| -
|
| - SynchronizedMinidumpManagerSimple manager;
|
| - manager.set_non_blocking(true);
|
| - ASSERT_EQ(-1, manager.DoWorkLocked());
|
| - ASSERT_FALSE(manager.work_done());
|
| -
|
| - // Test that the manager was not able to log the crash dump.
|
| - ScopedVector<DumpInfo> dumps;
|
| - ASSERT_TRUE(FetchDumps(lockfile_.value(), &dumps));
|
| - ASSERT_EQ(0u, dumps.size());
|
| -}
|
| -
|
| -// TODO(slan): These tests are passing but forking them is creating duplicates
|
| -// of all tests in this thread. Figure out how to lock the file more cleanly
|
| -// from another process.
|
| -TEST_F(SynchronizedMinidumpManagerTest,
|
| DISABLED_AcquireLockFile_WaitsForOtherProcessWhenBlocking) {
|
| // Create some parameters for a minidump.
|
| - time_t now = time(0);
|
| + base::Time now = base::Time::Now();
|
| MinidumpParams params;
|
| params.process_name = "process";
|
|
|
| @@ -421,7 +367,6 @@ TEST_F(SynchronizedMinidumpManagerTest,
|
| SynchronizedMinidumpManagerSimple manager;
|
| manager.SetDumpInfoToWrite(
|
| base::WrapUnique(new DumpInfo("dump", "log", now, params)));
|
| - manager.set_non_blocking(false);
|
|
|
| EXPECT_EQ(0, manager.DoWorkLocked());
|
| EXPECT_EQ(0, manager.add_entry_return_code());
|
| @@ -436,7 +381,7 @@ TEST_F(SynchronizedMinidumpManagerTest,
|
| TEST_F(SynchronizedMinidumpManagerTest,
|
| Upload_SucceedsWhenDumpLimitsNotExceeded) {
|
| // Sample parameters.
|
| - time_t now = time(0);
|
| + base::Time now = base::Time::Now();
|
| MinidumpParams params;
|
| params.process_name = "process";
|
|
|
| @@ -452,7 +397,7 @@ TEST_F(SynchronizedMinidumpManagerTest,
|
|
|
| TEST_F(SynchronizedMinidumpManagerTest, Upload_FailsWhenTooManyRecentDumps) {
|
| // Sample parameters.
|
| - time_t now = time(0);
|
| + base::Time now = base::Time::Now();
|
| MinidumpParams params;
|
| params.process_name = "process";
|
|
|
| @@ -472,7 +417,7 @@ TEST_F(SynchronizedMinidumpManagerTest, Upload_FailsWhenTooManyRecentDumps) {
|
|
|
| TEST_F(SynchronizedMinidumpManagerTest, UploadSucceedsAfterRateLimitPeriodEnd) {
|
| // Sample parameters.
|
| - time_t now = time(0);
|
| + base::Time now = base::Time::Now();
|
| MinidumpParams params;
|
| params.process_name = "process";
|
|
|
| @@ -493,15 +438,16 @@ TEST_F(SynchronizedMinidumpManagerTest, UploadSucceedsAfterRateLimitPeriodEnd) {
|
| ASSERT_FALSE(uploader.can_upload_return_val());
|
|
|
| int64_t period = SynchronizedMinidumpManager::kRatelimitPeriodSeconds;
|
| + time_t now_time_t = now.ToTimeT();
|
|
|
| // Half period shouldn't trigger reset
|
| produce_dumps(producer, 1);
|
| - SetRatelimitPeriodStart(metadata_.value(), now - period / 2);
|
| + SetRatelimitPeriodStart(metadata_.value(), now_time_t - period / 2);
|
| ASSERT_EQ(0, uploader.DoWorkLocked());
|
| ASSERT_FALSE(uploader.can_upload_return_val());
|
|
|
| // Set period starting time to trigger a reset
|
| - SetRatelimitPeriodStart(metadata_.value(), now - period);
|
| + SetRatelimitPeriodStart(metadata_.value(), now_time_t - period);
|
| }
|
|
|
| produce_dumps(producer, 1);
|
| @@ -515,7 +461,7 @@ TEST_F(SynchronizedMinidumpManagerTest, HasDumpsWithoutDumps) {
|
|
|
| TEST_F(SynchronizedMinidumpManagerTest, HasDumpsWithDumps) {
|
| // Sample parameters.
|
| - time_t now = time(0);
|
| + base::Time now = base::Time::Now();
|
| MinidumpParams params;
|
| params.process_name = "process";
|
|
|
|
|