summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2021-09-21 18:23:08 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-09-21 18:23:08 +0000
commitee11da8a11d6d162b1ee72b1e547bde2a06fa4a7 (patch)
tree65254728d8649b2e7c38d20c1b769dd68ea44f66
parentffd106e790f8babb4fb0cf245c50672430eca76b (diff)
parentebfc198a1f53d058b672216f09b76a59de8e2d73 (diff)
downloadgtest_extras-ee11da8a11d6d162b1ee72b1e547bde2a06fa4a7.tar.gz
Add extra warnings. am: db00a3a819 am: acdc64be3c am: 859e215fe4 am: ebfc198a1f
Original change: https://android-review.googlesource.com/c/platform/system/testing/gtest_extras/+/1831294 Change-Id: I9e85f19d70625a57ff6bfbf65fe5036f1a3edb1e
-rw-r--r--Android.bp6
-rw-r--r--Isolate.cpp10
-rw-r--r--IsolateMain.cpp2
-rw-r--r--Options.cpp4
-rw-r--r--tests/OptionsTest.cpp2
-rw-r--r--tests/SystemTests.cpp2
6 files changed, 13 insertions, 13 deletions
diff --git a/Android.bp b/Android.bp
index c728f22..ef855f2 100644
--- a/Android.bp
+++ b/Android.bp
@@ -19,7 +19,7 @@ package {
cc_library_static {
name: "libgtest_isolated",
host_supported: true,
- cflags: ["-Wall", "-Werror"],
+ cflags: ["-Wall", "-Werror", "-Wextra", "-Wconversion"],
export_include_dirs: ["include"],
srcs: [
@@ -45,7 +45,7 @@ cc_library_static {
cc_library_static {
name: "libgtest_isolated_main",
host_supported: true,
- cflags: ["-Wall", "-Werror"],
+ cflags: ["-Wall", "-Werror", "-Wextra"],
srcs: [
"Main.cpp",
],
@@ -68,7 +68,7 @@ cc_test {
"tests/OptionsTest.cpp",
"tests/SystemTests.cpp",
],
- cflags: ["-Wall", "-Werror"],
+ cflags: ["-Wall", "-Werror", "-Wextra"],
shared_libs: [
"libbase",
diff --git a/Isolate.cpp b/Isolate.cpp
index f7ea4e3..689c3ce 100644
--- a/Isolate.cpp
+++ b/Isolate.cpp
@@ -105,9 +105,9 @@ void Isolate::EnumerateTests() {
FATAL_PLOG("Unexpected failure from popen");
}
- size_t total_shards = options_.total_shards();
+ uint64_t total_shards = options_.total_shards();
bool sharded = total_shards > 1;
- size_t test_count = 0;
+ uint64_t test_count = 0;
if (sharded) {
test_count = options_.shard_index() + 1;
}
@@ -187,7 +187,7 @@ int Isolate::ChildProcessFn(const std::tuple<std::string, std::string>& test) {
std::string filter("--gtest_filter=" + GetTestName(test));
args.push_back(filter.data());
- int argc = args.size();
+ int argc = static_cast<int>(args.size());
// Add the null terminator.
args.push_back(nullptr);
::testing::InitGoogleTest(&argc, args.data());
@@ -262,7 +262,7 @@ void Isolate::LaunchTests() {
}
void Isolate::ReadTestsOutput() {
- int ready = poll(running_pollfds_.data(), running_pollfds_.size(), 0);
+ int ready = poll(running_pollfds_.data(), static_cast<nfds_t>(running_pollfds_.size()), 0);
if (ready <= 0) {
return;
}
@@ -285,7 +285,7 @@ size_t Isolate::CheckTestsFinished() {
size_t finished_tests = 0;
int status;
pid_t pid;
- while ((pid = TEMP_FAILURE_RETRY(waitpid(-1, &status, WNOHANG))) > 0) {
+ while ((pid = static_cast<pid_t>(TEMP_FAILURE_RETRY(waitpid(-1, &status, WNOHANG)))) > 0) {
if (pid == -1) {
FATAL_PLOG("Unexpected failure from waitpid");
}
diff --git a/IsolateMain.cpp b/IsolateMain.cpp
index 980fb70..77db51b 100644
--- a/IsolateMain.cpp
+++ b/IsolateMain.cpp
@@ -77,7 +77,7 @@ static void PrintHelpInfo() {
}
static int GtestRun(std::vector<const char*>* args) {
- int argc = args->size();
+ int argc = static_cast<int>(args->size());
args->push_back(nullptr);
::testing::InitGoogleTest(&argc, const_cast<char**>(args->data()));
return RUN_ALL_TESTS();
diff --git a/Options.cpp b/Options.cpp
index 7e54259..36f618d 100644
--- a/Options.cpp
+++ b/Options.cpp
@@ -213,14 +213,14 @@ bool Options::HandleArg(const std::string& arg, const std::string& value, const
}
static bool ReadFileToString(const std::string& file, std::string* contents) {
- int fd = TEMP_FAILURE_RETRY(open(file.c_str(), O_RDONLY | O_CLOEXEC));
+ int fd = static_cast<int>(TEMP_FAILURE_RETRY(open(file.c_str(), O_RDONLY | O_CLOEXEC)));
if (fd == -1) {
return false;
}
char buf[4096];
ssize_t bytes_read;
while ((bytes_read = TEMP_FAILURE_RETRY(read(fd, &buf, sizeof(buf)))) > 0) {
- contents->append(buf, bytes_read);
+ contents->append(buf, static_cast<size_t>(bytes_read));
}
close(fd);
return true;
diff --git a/tests/OptionsTest.cpp b/tests/OptionsTest.cpp
index 434c4df..36f5bef 100644
--- a/tests/OptionsTest.cpp
+++ b/tests/OptionsTest.cpp
@@ -561,7 +561,7 @@ TEST_F(OptionsTest, gtest_flagfile) {
ASSERT_TRUE(options.Process(cur_args, &child_args_));
EXPECT_EQ("no", options.color());
EXPECT_FALSE(options.print_time());
- EXPECT_EQ(10U, options.num_iterations());
+ EXPECT_EQ(10, options.num_iterations());
EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore"), StrEq("--gtest_color=no")));
}
diff --git a/tests/SystemTests.cpp b/tests/SystemTests.cpp
index 2b434a9..ef280df 100644
--- a/tests/SystemTests.cpp
+++ b/tests/SystemTests.cpp
@@ -1200,7 +1200,7 @@ TEST_F(SystemTests, verify_memory) {
memory_iteration++;
}
}
- ASSERT_EQ(400, memory_iteration)
+ ASSERT_EQ(400U, memory_iteration)
<< "Did not find the expected 400 lines of memory data." << std::endl
<< "Raw output:" << std::endl
<< raw_output_;