Commit dbe50ca0 authored by Yi Fan's avatar Yi Fan Committed by Commit Bot

log attachment file size

To check whether dump file size is too big to be uploaded.

Bug: b/130366217
Test: build and run; file feedback and check logcat
Change-Id: I12ddd67a48255319b31725b36f9c28285465f233
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1625899Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Commit-Queue: Yi Fan <yfa@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686233}
parent 109c27a3
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <sys/stat.h> #include <sys/stat.h>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h" #include "base/logging.h"
// TODO(slan): Find a replacement for LibcurlWrapper in Chromium to remove the // TODO(slan): Find a replacement for LibcurlWrapper in Chromium to remove the
// breakpad dependency. // breakpad dependency.
...@@ -51,6 +53,12 @@ CastCrashdumpUploader::~CastCrashdumpUploader() { ...@@ -51,6 +53,12 @@ CastCrashdumpUploader::~CastCrashdumpUploader() {
bool CastCrashdumpUploader::AddAttachment(const std::string& label, bool CastCrashdumpUploader::AddAttachment(const std::string& label,
const std::string& filename) { const std::string& filename) {
int64_t file_size = 0;
if (!base::GetFileSize(base::FilePath(filename), &file_size)) {
LOG(WARNING) << "file size of " << filename << " not readable";
return false;
}
LOG(INFO) << "file size of " << filename << ": " << file_size;
attachments_[label] = filename; attachments_[label] = filename;
return true; return true;
} }
......
...@@ -138,9 +138,6 @@ TEST(CastCrashdumpUploaderTest, UploadFailsWithInvalidAttachment) { ...@@ -138,9 +138,6 @@ TEST(CastCrashdumpUploaderTest, UploadFailsWithInvalidAttachment) {
// Create a temporary file. // Create a temporary file.
ScopedTempFile minidump; ScopedTempFile minidump;
EXPECT_CALL(*m, Init()).Times(1).WillOnce(Return(true));
EXPECT_CALL(*m, AddFile(minidump.path().value(), _)).WillOnce(Return(true));
CastCrashdumpData data; CastCrashdumpData data;
data.product = "foobar"; data.product = "foobar";
data.version = "1.0"; data.version = "1.0";
...@@ -152,8 +149,7 @@ TEST(CastCrashdumpUploaderTest, UploadFailsWithInvalidAttachment) { ...@@ -152,8 +149,7 @@ TEST(CastCrashdumpUploaderTest, UploadFailsWithInvalidAttachment) {
CastCrashdumpUploader uploader(data, std::move(m)); CastCrashdumpUploader uploader(data, std::move(m));
// Add a file that does not exist as an attachment. // Add a file that does not exist as an attachment.
uploader.AddAttachment("label", "/path/does/not/exist"); ASSERT_FALSE(uploader.AddAttachment("label", "/path/does/not/exist"));
ASSERT_FALSE(uploader.Upload(nullptr));
} }
TEST(CastCrashdumpUploaderTest, UploadSucceedsWithValidAttachment) { TEST(CastCrashdumpUploaderTest, UploadSucceedsWithValidAttachment) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment