Build unittests in Brillo.
Many unittests do not pass for simple reasons that will be addressed
later. This CL includes all the changes to make the unittests build.
In particular, the generated DBus mocks, required to build several
unittests are now included here.
The dbus-constants.h files were moved to the system_api repo, so they
can be removed from here.
The unittest build is only enabled for Brillo targets, since non-Brillo
targets don't even build DBus.
Bug: 26955860
TEST=`mmma` on edison-eng (and aosp_arm-eng).
Change-Id: Ib38241f0a6eb99b1d60d72db6bcfd125d38e3fad
diff --git a/common/http_common.cc b/common/http_common.cc
index 7d98889..d07ced3 100644
--- a/common/http_common.cc
+++ b/common/http_common.cc
@@ -18,6 +18,8 @@
#include "update_engine/common/http_common.h"
+#include <cstdlib>
+
#include <base/macros.h>
namespace chromeos_update_engine {
diff --git a/common/http_common.h b/common/http_common.h
index 041cad5..6d444ed 100644
--- a/common/http_common.h
+++ b/common/http_common.h
@@ -20,8 +20,6 @@
#ifndef UPDATE_ENGINE_COMMON_HTTP_COMMON_H_
#define UPDATE_ENGINE_COMMON_HTTP_COMMON_H_
-#include <cstdlib>
-
namespace chromeos_update_engine {
// Enumeration type for HTTP response codes.
diff --git a/common/http_fetcher_unittest.cc b/common/http_fetcher_unittest.cc
index 17e360e..91f85db 100644
--- a/common/http_fetcher_unittest.cc
+++ b/common/http_fetcher_unittest.cc
@@ -650,7 +650,7 @@
this->loop_.Run();
// verify the data we get back
- ASSERT_EQ(kBigLength, delegate.data.size());
+ ASSERT_EQ(kBigLength, static_cast<int>(delegate.data.size()));
for (int i = 0; i < kBigLength; i += 10) {
// Assert so that we don't flood the screen w/ EXPECT errors on failure.
ASSERT_EQ(delegate.data.substr(i, 10), "abcdefghij");
@@ -831,7 +831,7 @@
MessageLoop::current()->Run();
if (expected_successful) {
// verify the data we get back
- ASSERT_EQ(kMediumLength, delegate.data.size());
+ ASSERT_EQ(static_cast<size_t>(kMediumLength), delegate.data.size());
for (int i = 0; i < kMediumLength; i += 10) {
// Assert so that we don't flood the screen w/ EXPECT errors on failure.
ASSERT_EQ(delegate.data.substr(i, 10), "abcdefghij");
@@ -929,7 +929,7 @@
delegate.fetcher_.reset(fetcher_in);
MultiRangeHttpFetcher* multi_fetcher =
- dynamic_cast<MultiRangeHttpFetcher*>(fetcher_in);
+ static_cast<MultiRangeHttpFetcher*>(fetcher_in);
ASSERT_TRUE(multi_fetcher);
multi_fetcher->ClearRanges();
for (vector<pair<off_t, off_t>>::const_iterator it = ranges.begin(),
diff --git a/common/hwid_override_unittest.cc b/common/hwid_override_unittest.cc
index fff64bc..26ef30a 100644
--- a/common/hwid_override_unittest.cc
+++ b/common/hwid_override_unittest.cc
@@ -48,7 +48,7 @@
keyval += ("=" + expected_hwid);
ASSERT_EQ(base::WriteFile(tempdir_.path().Append("etc/lsb-release"),
keyval.c_str(), keyval.length()),
- keyval.length());
+ static_cast<int>(keyval.length()));
EXPECT_EQ(expected_hwid, HwidOverride::Read(tempdir_.path()));
}
@@ -56,7 +56,7 @@
std::string keyval("SOMETHING_ELSE=UNINTERESTING");
ASSERT_EQ(base::WriteFile(tempdir_.path().Append("etc/lsb-release"),
keyval.c_str(), keyval.length()),
- keyval.length());
+ static_cast<int>(keyval.length()));
EXPECT_EQ(std::string(), HwidOverride::Read(tempdir_.path()));
}
diff --git a/common/prefs_unittest.cc b/common/prefs_unittest.cc
index 967c411..d94623a 100644
--- a/common/prefs_unittest.cc
+++ b/common/prefs_unittest.cc
@@ -144,18 +144,18 @@
TEST_F(PrefsTest, GetInt64Max) {
ASSERT_TRUE(SetValue(kKey, base::StringPrintf(
- "%" PRIi64, std::numeric_limits<uint64_t>::max())));
+ "%" PRIi64, std::numeric_limits<int64_t>::max())));
int64_t value;
EXPECT_TRUE(prefs_.GetInt64(kKey, &value));
- EXPECT_EQ(std::numeric_limits<uint64_t>::max(), value);
+ EXPECT_EQ(std::numeric_limits<int64_t>::max(), value);
}
TEST_F(PrefsTest, GetInt64Min) {
ASSERT_TRUE(SetValue(kKey, base::StringPrintf(
- "%" PRIi64, std::numeric_limits<uint64_t>::min())));
+ "%" PRIi64, std::numeric_limits<int64_t>::min())));
int64_t value;
EXPECT_TRUE(prefs_.GetInt64(kKey, &value));
- EXPECT_EQ(std::numeric_limits<uint64_t>::min(), value);
+ EXPECT_EQ(std::numeric_limits<int64_t>::min(), value);
}
TEST_F(PrefsTest, GetInt64Negative) {
diff --git a/common/subprocess_unittest.cc b/common/subprocess_unittest.cc
index b37dc91..467fca8 100644
--- a/common/subprocess_unittest.cc
+++ b/common/subprocess_unittest.cc
@@ -179,7 +179,7 @@
cmd.push_back("./test_http_server");
cmd.push_back(temp_file_name);
uint32_t tag = Subprocess::Get().Exec(cmd, base::Bind(&CallbackBad));
- EXPECT_NE(0, tag);
+ EXPECT_NE(0U, tag);
*spawned = true;
printf("test http server spawned\n");
// Wait for server to be up and running
diff --git a/common/utils_unittest.cc b/common/utils_unittest.cc
index fde89e8..6c4e5af 100644
--- a/common/utils_unittest.cc
+++ b/common/utils_unittest.cc
@@ -181,11 +181,11 @@
}
TEST(UtilsTest, FuzzIntTest) {
- static const unsigned int kRanges[] = { 0, 1, 2, 20 };
- for (unsigned int range : kRanges) {
+ static const uint32_t kRanges[] = { 0, 1, 2, 20 };
+ for (uint32_t range : kRanges) {
const int kValue = 50;
for (int tries = 0; tries < 100; ++tries) {
- int value = utils::FuzzInt(kValue, range);
+ uint32_t value = utils::FuzzInt(kValue, range);
EXPECT_GE(value, kValue - range / 2);
EXPECT_LE(value, kValue + range - range / 2);
}
@@ -493,7 +493,7 @@
EXPECT_TRUE(store.LoadFromString("PAYLOAD_MINOR_VERSION=123\n"));
EXPECT_TRUE(utils::GetMinorVersion(store, &minor_version));
- EXPECT_EQ(minor_version, 123);
+ EXPECT_EQ(123U, minor_version);
}
static bool BoolMacroTestHelper() {