diff --git a/util/misc/clock_test.cc b/util/misc/clock_test.cc index c6e2c02a..d7f9cd71 100644 --- a/util/misc/clock_test.cc +++ b/util/misc/clock_test.cc @@ -14,11 +14,11 @@ #include "util/misc/clock.h" -#include #include #include +#include "base/format_macros.h" #include "base/logging.h" #include "base/macros.h" #include "base/strings/stringprintf.h" @@ -85,8 +85,8 @@ TEST(Clock, SleepNanoseconds) { for (size_t index = 0; index < arraysize(kTestData); ++index) { const uint64_t nanoseconds = kTestData[index]; - SCOPED_TRACE( - base::StringPrintf("index %zu, nanoseconds %llu", index, nanoseconds)); + SCOPED_TRACE(base::StringPrintf( + "index %zu, nanoseconds %" PRIu64, index, nanoseconds)); TestSleepNanoseconds(nanoseconds); } diff --git a/util/numeric/checked_address_range_test.cc b/util/numeric/checked_address_range_test.cc index 6b7e4c43..403c000f 100644 --- a/util/numeric/checked_address_range_test.cc +++ b/util/numeric/checked_address_range_test.cc @@ -122,7 +122,7 @@ TEST(CheckedAddressRange, IsValid) { for (size_t index = 0; index < arraysize(kTestData); ++index) { const TestData& testcase = kTestData[index]; SCOPED_TRACE(base::StringPrintf("index %" PRIuS - ", base 0x%llx, size 0x%llx", + ", base 0x%" PRIx64 ", size 0x%" PRIx64, index, testcase.base, testcase.size)); @@ -173,7 +173,7 @@ TEST(CheckedAddressRange, ContainsValue) { for (size_t index = 0; index < arraysize(kTestData); ++index) { const TestData& testcase = kTestData[index]; SCOPED_TRACE(base::StringPrintf( - "index %" PRIuS ", value 0x%llx", index, testcase.value)); + "index %" PRIuS ", value 0x%" PRIx64, index, testcase.value)); EXPECT_EQ(testcase.expectation, parent_range_32.ContainsValue(testcase.value)); @@ -230,7 +230,7 @@ TEST(CheckedAddressRange, ContainsRange) { for (size_t index = 0; index < arraysize(kTestData); ++index) { const TestData& testcase = kTestData[index]; SCOPED_TRACE(base::StringPrintf("index %" PRIuS - ", base 0x%llx, size 0x%llx", + ", base 0x%" PRIx64 ", size 0x%" PRIx64, index, testcase.base, testcase.size)); diff --git a/util/posix/process_info.h b/util/posix/process_info.h index 5aeda25a..1aa23d8c 100644 --- a/util/posix/process_info.h +++ b/util/posix/process_info.h @@ -15,7 +15,6 @@ #ifndef CRASHPAD_UTIL_POSIX_PROCESS_INFO_H_ #define CRASHPAD_UTIL_POSIX_PROCESS_INFO_H_ -#include #include #include #include @@ -30,6 +29,7 @@ #if defined(OS_MACOSX) #include +#include #endif namespace crashpad { diff --git a/util/posix/process_info_test.cc b/util/posix/process_info_test.cc index dd0844be..7e28e5f4 100644 --- a/util/posix/process_info_test.cc +++ b/util/posix/process_info_test.cc @@ -15,12 +15,14 @@ #include "util/posix/process_info.h" #include +#include #include #include #include #include +#include "base/files/scoped_file.h" #include "build/build_config.h" #include "gtest/gtest.h" #include "test/errors.h" @@ -98,6 +100,34 @@ void TestSelfProcess(const ProcessInfo& process_info) { #if defined(OS_MACOSX) int expect_argc = *_NSGetArgc(); char** expect_argv = *_NSGetArgv(); +#elif defined(OS_LINUX) || defined(OS_ANDROID) + std::vector expect_arg_vector; + { + base::ScopedFILE cmdline(fopen("/proc/self/cmdline", "r")); + ASSERT_NE(nullptr, cmdline.get()) << ErrnoMessage("fopen"); + + int expect_arg_char; + std::string expect_arg_string; + while ((expect_arg_char = fgetc(cmdline.get())) != EOF) { + if (expect_arg_char != '\0') { + expect_arg_string.append(1, expect_arg_char); + } else { + expect_arg_vector.push_back(expect_arg_string); + expect_arg_string.clear(); + } + } + ASSERT_EQ(0, ferror(cmdline.get())) << ErrnoMessage("fgetc"); + ASSERT_TRUE(expect_arg_string.empty()); + } + + std::vector expect_argv_storage; + for (const std::string& expect_arg_string : expect_arg_vector) { + expect_argv_storage.push_back(expect_arg_string.c_str()); + } + + int expect_argc = expect_argv_storage.size(); + const char* const* expect_argv = + !expect_argv_storage.empty() ? &expect_argv_storage[0] : nullptr; #else #error Obtain expect_argc and expect_argv correctly on your system. #endif diff --git a/util/posix/symbolic_constants_posix_test.cc b/util/posix/symbolic_constants_posix_test.cc index 6779a30d..ddbe336e 100644 --- a/util/posix/symbolic_constants_posix_test.cc +++ b/util/posix/symbolic_constants_posix_test.cc @@ -14,7 +14,7 @@ #include "util/posix/symbolic_constants_posix.h" -#include +#include #include #include "base/macros.h"