Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: client/crash_report_database_test.cc

Issue 1392653002: Add functionality to prune old crash reports from the database. (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 EXPECT_EQ(0, _wunlink(report.file_path.value().c_str())); 506 EXPECT_EQ(0, _wunlink(report.file_path.value().c_str()));
507 #else 507 #else
508 EXPECT_EQ(0, unlink(report.file_path.value().c_str())) 508 EXPECT_EQ(0, unlink(report.file_path.value().c_str()))
509 << ErrnoMessage("unlink"); 509 << ErrnoMessage("unlink");
510 #endif 510 #endif
511 511
512 EXPECT_EQ(CrashReportDatabase::kReportNotFound, 512 EXPECT_EQ(CrashReportDatabase::kReportNotFound,
513 db()->LookUpCrashReport(uuid, &report)); 513 db()->LookUpCrashReport(uuid, &report));
514 } 514 }
515 515
516 TEST_F(CrashReportDatabaseTest, DeleteReport) {
517 CrashReportDatabase::Report keep_pending;
518 CrashReportDatabase::Report delete_pending;
519 CrashReportDatabase::Report keep_completed;
520 CrashReportDatabase::Report delete_completed;
521
522 CreateCrashReport(&keep_pending);
523 CreateCrashReport(&delete_pending);
524 CreateCrashReport(&keep_completed);
525 CreateCrashReport(&delete_completed);
526
527 EXPECT_TRUE(FileExists(keep_pending.file_path));
528 EXPECT_TRUE(FileExists(delete_pending.file_path));
529 EXPECT_TRUE(FileExists(keep_completed.file_path));
530 EXPECT_TRUE(FileExists(delete_completed.file_path));
531
532 UploadReport(keep_completed.uuid, true, "1");
533 UploadReport(delete_completed.uuid, true, "2");
534
535 EXPECT_EQ(CrashReportDatabase::kNoError,
536 db()->LookUpCrashReport(keep_completed.uuid, &keep_completed));
537 EXPECT_EQ(CrashReportDatabase::kNoError,
538 db()->LookUpCrashReport(delete_completed.uuid, &delete_completed));
539
540 EXPECT_TRUE(FileExists(keep_completed.file_path));
541 EXPECT_TRUE(FileExists(delete_completed.file_path));
542
543 EXPECT_EQ(CrashReportDatabase::kNoError,
544 db()->DeleteReport(delete_pending.uuid));
545 EXPECT_FALSE(FileExists(delete_pending.file_path));
546 EXPECT_EQ(CrashReportDatabase::kReportNotFound,
547 db()->LookUpCrashReport(delete_pending.uuid, &delete_pending));
548 EXPECT_EQ(CrashReportDatabase::kReportNotFound,
549 db()->DeleteReport(delete_pending.uuid));
550
551 EXPECT_EQ(CrashReportDatabase::kNoError,
552 db()->DeleteReport(delete_completed.uuid));
553 EXPECT_FALSE(FileExists(delete_completed.file_path));
554 EXPECT_EQ(CrashReportDatabase::kReportNotFound,
555 db()->LookUpCrashReport(delete_completed.uuid, &delete_completed));
556 EXPECT_EQ(CrashReportDatabase::kReportNotFound,
557 db()->DeleteReport(delete_completed.uuid));
558
559 EXPECT_EQ(CrashReportDatabase::kNoError,
560 db()->LookUpCrashReport(keep_pending.uuid, &keep_pending));
561 EXPECT_EQ(CrashReportDatabase::kNoError,
562 db()->LookUpCrashReport(keep_completed.uuid, &keep_completed));
563 }
564
516 } // namespace 565 } // namespace
517 } // namespace test 566 } // namespace test
518 } // namespace crashpad 567 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698