Fix unittest build in x86_64.
Some size_t values (generally resulting from X.size() calls) were
compared to off_t values (such as utils::FileSize()) which resulted
in a compile error on x86_64 targets. This patch fixes those issues
with explicit casts in the unittests since the range of the expected
values is small enough.
Bug: 26955860
TEST=`mma` on edison-eng and brilloemulator_x86_64-eng.
Change-Id: I2d09d356e1b97ab6527b17596fe20d425da6d519
diff --git a/payload_consumer/delta_performer_integration_test.cc b/payload_consumer/delta_performer_integration_test.cc
index f0aea95..34ce0de 100644
--- a/payload_consumer/delta_performer_integration_test.cc
+++ b/payload_consumer/delta_performer_integration_test.cc
@@ -543,10 +543,12 @@
// Extend the "partitions" holding the file system a bit.
EXPECT_EQ(0, HANDLE_EINTR(truncate(state->a_img.c_str(),
state->image_size + 1024 * 1024)));
- EXPECT_EQ(state->image_size + 1024 * 1024, utils::FileSize(state->a_img));
+ EXPECT_EQ(static_cast<off_t>(state->image_size + 1024 * 1024),
+ utils::FileSize(state->a_img));
EXPECT_EQ(0, HANDLE_EINTR(truncate(state->b_img.c_str(),
state->image_size + 1024 * 1024)));
- EXPECT_EQ(state->image_size + 1024 * 1024, utils::FileSize(state->b_img));
+ EXPECT_EQ(static_cast<off_t>(state->image_size + 1024 * 1024),
+ utils::FileSize(state->b_img));
if (signature_test == kSignatureGeneratedPlaceholder ||
signature_test == kSignatureGeneratedPlaceholderMismatch) {
@@ -745,7 +747,7 @@
(*performer)->set_public_key_path(kUnittestPublicKeyPath);
DeltaPerformerIntegrationTest::SetSupportedVersion(*performer, minor_version);
- EXPECT_EQ(state->image_size,
+ EXPECT_EQ(static_cast<off_t>(state->image_size),
HashCalculator::RawHashOfFile(
state->a_img,
state->image_size,
@@ -892,7 +894,7 @@
EXPECT_EQ(state->image_size, partitions[0].target_size);
brillo::Blob expected_new_rootfs_hash;
- EXPECT_EQ(state->image_size,
+ EXPECT_EQ(static_cast<off_t>(state->image_size),
HashCalculator::RawHashOfFile(state->b_img,
state->image_size,
&expected_new_rootfs_hash));
diff --git a/payload_consumer/download_action_unittest.cc b/payload_consumer/download_action_unittest.cc
index 51d3c3a..d12b4ae 100644
--- a/payload_consumer/download_action_unittest.cc
+++ b/payload_consumer/download_action_unittest.cc
@@ -307,7 +307,8 @@
const off_t resulting_file_size(utils::FileSize(temp_file.GetPath()));
EXPECT_GE(resulting_file_size, 0);
if (resulting_file_size != 0)
- EXPECT_EQ(kMockHttpFetcherChunkSize, resulting_file_size);
+ EXPECT_EQ(kMockHttpFetcherChunkSize,
+ static_cast<size_t>(resulting_file_size));
}
} // namespace
diff --git a/payload_consumer/extent_writer_unittest.cc b/payload_consumer/extent_writer_unittest.cc
index efeab09..6884c0b 100644
--- a/payload_consumer/extent_writer_unittest.cc
+++ b/payload_consumer/extent_writer_unittest.cc
@@ -86,7 +86,8 @@
EXPECT_TRUE(direct_writer.Write(bytes.data(), bytes.size()));
EXPECT_TRUE(direct_writer.End());
- EXPECT_EQ(kBlockSize + bytes.size(), utils::FileSize(path_));
+ EXPECT_EQ(static_cast<off_t>(kBlockSize + bytes.size()),
+ utils::FileSize(path_));
brillo::Blob result_file;
EXPECT_TRUE(utils::ReadFile(path_, &result_file));
@@ -153,7 +154,7 @@
}
EXPECT_TRUE(direct_writer.End());
- EXPECT_EQ(data.size(), utils::FileSize(path_));
+ EXPECT_EQ(static_cast<off_t>(data.size()), utils::FileSize(path_));
brillo::Blob result_file;
EXPECT_TRUE(utils::ReadFile(path_, &result_file));
@@ -202,7 +203,7 @@
ASSERT_TRUE(zero_pad_writer.Write(data.data(), bytes_to_write));
EXPECT_TRUE(zero_pad_writer.End());
- EXPECT_EQ(data.size(), utils::FileSize(path_));
+ EXPECT_EQ(static_cast<off_t>(data.size()), utils::FileSize(path_));
brillo::Blob result_file;
EXPECT_TRUE(utils::ReadFile(path_, &result_file));
@@ -251,7 +252,7 @@
EXPECT_TRUE(direct_writer.End());
// check file size, then data inside
- ASSERT_EQ(2 * kBlockSize, utils::FileSize(path_));
+ ASSERT_EQ(static_cast<off_t>(2 * kBlockSize), utils::FileSize(path_));
brillo::Blob resultant_data;
EXPECT_TRUE(utils::ReadFile(path_, &resultant_data));