crash_report: Fix several signed-unsigned comparison warnings in tests.

The two types of fixes are:
* Assign expected non-negative values to unsigned int variables.
* Annotate constant expected integer values as unsigned.

Bug: 27378717
Change-Id: Ifc13beedd61a28ed685e1a06a7cefe99072e3345
This commit is contained in:
James Hawkins 2016-02-26 11:24:38 -08:00
parent a692f431d6
commit a28317d137
4 changed files with 21 additions and 14 deletions

View file

@ -74,10 +74,11 @@ TEST_F(CrashCollectorTest, Initialize) {
TEST_F(CrashCollectorTest, WriteNewFile) {
FilePath test_file = test_dir_.path().Append("test_new");
const char kBuffer[] = "buffer";
EXPECT_EQ(strlen(kBuffer),
collector_.WriteNewFile(test_file,
kBuffer,
strlen(kBuffer)));
unsigned int numBytesWritten = collector_.WriteNewFile(
test_file,
kBuffer,
strlen(kBuffer));
EXPECT_EQ(strlen(kBuffer), numBytesWritten);
EXPECT_LT(collector_.WriteNewFile(test_file,
kBuffer,
strlen(kBuffer)), 0);

View file

@ -49,7 +49,9 @@ class KernelCollectorTest : public ::testing::Test {
protected:
void WriteStringToFile(const FilePath &file_path,
const char *data) {
ASSERT_EQ(strlen(data), base::WriteFile(file_path, data, strlen(data)));
unsigned int numBytesWritten =
base::WriteFile(file_path, data, strlen(data));
ASSERT_EQ(strlen(data), numBytesWritten);
}
void SetUpSuccessfulCollect();
@ -284,7 +286,7 @@ TEST_F(KernelCollectorTest, CollectOK) {
size_t end_pos = filename.find_first_of("\n");
ASSERT_NE(std::string::npos, end_pos);
filename = filename.substr(0, end_pos);
ASSERT_EQ(0, filename.find(test_crash_directory().value()));
ASSERT_EQ(0U, filename.find(test_crash_directory().value()));
ASSERT_TRUE(base::PathExists(FilePath(filename)));
std::string contents;
ASSERT_TRUE(base::ReadFileToString(FilePath(filename), &contents));

View file

@ -73,7 +73,9 @@ class UncleanShutdownCollectorTest : public ::testing::Test {
protected:
void WriteStringToFile(const FilePath &file_path,
const char *data) {
ASSERT_EQ(strlen(data), base::WriteFile(file_path, data, strlen(data)));
unsigned int numBytesWritten =
base::WriteFile(file_path, data, strlen(data));
ASSERT_EQ(strlen(data), numBytesWritten);
}
UncleanShutdownCollectorMock collector_;

View file

@ -101,15 +101,15 @@ TEST_F(UserCollectorTest, ParseCrashAttributes) {
&pid, &signal, &uid, &gid, &exec_name));
EXPECT_EQ(123456, pid);
EXPECT_EQ(11, signal);
EXPECT_EQ(1000, uid);
EXPECT_EQ(2000, gid);
EXPECT_EQ(1000U, uid);
EXPECT_EQ(2000U, gid);
EXPECT_EQ("foobar", exec_name);
EXPECT_TRUE(collector_.ParseCrashAttributes("4321:6:barfoo",
&pid, &signal, &uid, &gid, &exec_name));
EXPECT_EQ(4321, pid);
EXPECT_EQ(6, signal);
EXPECT_EQ(-1, uid);
EXPECT_EQ(-1, gid);
EXPECT_EQ(-1U, uid);
EXPECT_EQ(-1U, gid);
EXPECT_EQ("barfoo", exec_name);
EXPECT_FALSE(collector_.ParseCrashAttributes("123456:11",
@ -333,8 +333,8 @@ TEST_F(UserCollectorTest, GetUserInfoFromName) {
gid_t gid = 100;
uid_t uid = 100;
EXPECT_TRUE(collector_.GetUserInfoFromName("root", &uid, &gid));
EXPECT_EQ(0, uid);
EXPECT_EQ(0, gid);
EXPECT_EQ(0U, uid);
EXPECT_EQ(0U, gid);
}
TEST_F(UserCollectorTest, CopyOffProcFilesBadPath) {
@ -387,7 +387,9 @@ TEST_F(UserCollectorTest, ValidateProcFiles) {
// maps file is not empty
const char data[] = "test data";
ASSERT_EQ(sizeof(data), base::WriteFile(maps_file, data, sizeof(data)));
unsigned int numBytesWritten =
base::WriteFile(maps_file, data, sizeof(data));
ASSERT_EQ(sizeof(data), numBytesWritten);
ASSERT_TRUE(base::PathExists(maps_file));
EXPECT_TRUE(collector_.ValidateProcFiles(container_dir));
}