forked from youtube/cobalt_sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update GoogleTest from Chromium 114.0.5735.343
Issue: 280671902 Reviewed-on: youtube/cobalt#2157
- Loading branch information
Showing
14 changed files
with
593 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# This file is a dummy used so that non-Chromium clients can specify | ||
# recursive DEPS. Otherwise the clients would need to nest DEPS inside | ||
# each other. Nested DEPS are not supported by gclient. | ||
# | ||
# Clients *must* specify googletest_revision when using this DEPS file. | ||
|
||
use_relative_paths = True | ||
|
||
vars = { | ||
'chromium_git': 'https://chromium.googlesource.com', | ||
|
||
# We must specify a dummy variable here for recursedeps to work. | ||
'googletest_revision': 'master', | ||
} | ||
|
||
deps = { | ||
'src': '{chromium_git}/external/github.com/google/googletest.git@{googletest_revision}' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
monorail: { | ||
component: "Test>gTest" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,7 @@ | ||
name: "googletest" | ||
description: | ||
"Google Test is Google's C++ test framework. src/ is taken from git hash listed here. BUILD.gn is copied from Chromium branch-heads/5735" | ||
|
||
third_party { | ||
url { | ||
type: GIT | ||
value: "https://chromium.googlesource.com/external/github.com/google/googletest.git" | ||
} | ||
version: "af29db7ec28d6df1c7f0f745186884091e602e07" | ||
# from https://chromium.googlesource.com/chromium/src/+/114.0.5735.330/DEPS#331 | ||
last_upgrade_date { | ||
year: 2023 | ||
month: 5 | ||
day: 19 | ||
value: "https://chromium.googlesource.com/chromium/src.git" | ||
} | ||
version: "114.0.5735.343" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[email protected] | ||
[email protected] | ||
[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
Name: Google Test: Google's C++ Testing Framework | ||
Short Name: googletest | ||
URL: https://github.com/google/googletest.git | ||
Version: unknown | ||
License: BSD | ||
License File: NOT_SHIPPED | ||
Security critical: no | ||
|
||
Google Test is imported as-is, to facilitate version bumping. However, the | ||
file/directory layout of Google Test is not yet considered stable. Therefore, | ||
until Google Test's layout stabilizes, Chromium code MUST NOT depend on it | ||
directly. Instead, Chromium code MUST: | ||
|
||
* #include the headers in testing/gtest and testing/gmock | ||
* use //testing/gtest(:gtest_main) and //testing/gmock(:gmock_main) in BUILD.gn | ||
deps | ||
|
||
This will allow us to adapt to Google Test changes with minimal disruption. | ||
|
||
|
||
## Resources for Rolling Googletest in Chrome | ||
|
||
### What is Googletest | ||
|
||
Googletest is an open source C++ testing framework developed by Google and used | ||
by Chromium. See the [User Guide](https://google.github.io/googletest/). | ||
|
||
### Where is Googletest | ||
|
||
Googletest is developed in google3 and uses | ||
[copybara](https://github.com/google/copybara) to sync with the public GitHub | ||
repository. | ||
|
||
* Development (Googler only): [google3/third\_party/googletest](http://google3/third_party/googletest/) | ||
* GitHub: https://github.com/google/googletest | ||
* Chromium mirror: https://chromium.googlesource.com/external/github.com/google/googletest/ | ||
* Locally, [third\_party/googletest/src/](https://source.chromium.org/chromium/chromium/src/+/master:third_party/googletest/src/) | ||
is a copy of Googletest which is updated via `gclient sync` according to the | ||
`googletest revision` commit hash in the | ||
[DEPS file](https://source.chromium.org/chromium/chromium/src/+/master:DEPS;l=244?q=DEPS%20googletest) | ||
|
||
### Unblocking Googletest Rolls | ||
|
||
1. Roll Googletest to include the breaking change | ||
* Find the hash (on GitHub) of the offending commit | ||
* If the change came from google3, the CL number can be found in the | ||
`PiperOrigin-RevId` footer of Copybara commits | ||
* On a fresh checkout, pull in the relevant change. Either: | ||
* Sync using the DEPS file | ||
``` | ||
roll-dep --roll-to=commitish src/third_party/googletest/src/ | ||
gclient sync | ||
``` | ||
* Check out the commit directly | ||
``` | ||
cd third_party/googletest/src | ||
git remote add up https://github.com/google/googletest.git | ||
git checkout commitish | ||
``` | ||
|
||
2. Observe errors | ||
* Ideally, this can be done by building locally. | ||
If the build is successful, this means the change does not affect your OS or | ||
your compiler flags differ from the trybots | ||
* Upload a CL with the added trybots from | ||
[Testing Changes to Chromium in Chromium](#testing-changes-to-chromium-in-chromium) | ||
|
||
3. Make changes | ||
* To Chromium: create a CL including both the roll and other changes | ||
* To Googletest: | ||
* Make changes to [third\_party/googletest/src/](https://source.chromium.org/chromium/chromium/src/+/master:third_party/googletest/src/) | ||
and try building locally. If the fix is successful and you’re confident | ||
this change will work across all the trybots, create a PR on GitHub or a | ||
CL to google3 (Googler only) of the changes you made locally to | ||
[third\_party/googletest/src/](https://source.chromium.org/chromium/chromium/src/+/master:third_party/googletest/src/). | ||
See [Testing Changes to Googletest in Googletest](#testing-changes-to-googletest-in-googletest) | ||
* What if I need to make a change to Googletest, but I’m not confident it | ||
will work with Chromium? Maybe it has to do with a tricky compiler error | ||
that only affects a specific OS. See | ||
[Testing Changes to Googletest in Chromium](#testing-changes-to-googletest-in-chromium) | ||
* Once your Googletest change lands, create a roll which includes both the | ||
offending commit and your change | ||
|
||
### Testing Changes to Chromium in Chromium | ||
|
||
Most changes should only require testing via the trybots, | ||
with the following added: | ||
|
||
`Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:linux_chromium_cfi_rel_ng;luci.chrome.try:win-chrome` | ||
|
||
### Testing Changes to Googletest in Googletest | ||
|
||
External: Upload a PR with your proposed changes to GitHub. | ||
This will trigger automated testing. | ||
|
||
Googlers: See the [Googletest Developer’s Guide](http://go/gunitdev). | ||
|
||
### Testing Changes to Googletest in Chromium | ||
|
||
In most cases, testing locally with changes to | ||
[third\_party/googletest/src/](https://source.chromium.org/chromium/chromium/src/+/master:third_party/googletest/src/) | ||
should be enough. But how can you make sure the changes to Googletest actually | ||
work in Chromium? Sometimes it’s not possible to test these changes locally | ||
(different compiler flags, error that only affects a specific OS, etc). | ||
Insert the pwnall repo: | ||
|
||
* Development: https://github.com/pwnall/googletest | ||
* Chromium mirror: https://chromium.googlesource.com/external/github.com/pwnall/googletest/ | ||
|
||
The pwnall repo allows you to make speculative changes to Googletest and run | ||
them against the Chromium trybots. The flow is as follows: | ||
|
||
* Create a local remote to the pwnall repo (alternatively, clone it elsewhere): | ||
``` | ||
cd third_party/googletest/src | ||
git remote | ||
git remote add up https://github.com/google/googletest.git | ||
git remote add pwnall [email protected]:pwnall/googletest.git | ||
``` | ||
* Sync the pwnall repo: | ||
``` | ||
git checkout master | ||
git pull up master | ||
git push pwnall master | ||
``` | ||
* Make changes on a new branch | ||
* `git push pwnall branch-name` | ||
* Update the `googletest revision` in the | ||
[DEPS file](https://source.chromium.org/chromium/chromium/src/+/master:DEPS) | ||
with the commit hash and `/external/github.com/google/googletest.git` to | ||
`/external/github.com/pwnall/googletest.git` | ||
* Upload the CL to run the change against the Chromium trybots | ||
|
||
### Common Problems | ||
|
||
* Differences in C++ version and clang compiler flags between Chromium and Googletest | ||
* Chromium is on C++14, though its dependencies, | ||
which may use Googletest, may be further behind | ||
* Look for NACL in build errors. You may need to update your GN args with | ||
`enable_nacl=true` to reproduce these errors locally | ||
* [A Googletest interface is changed](https://github.com/google/googletest/pull/2718/) | ||
* Rolling past the commit will fail, since Chromium still uses the old interface | ||
* Roll past the affecting commit and update uses in Chromium [in one CL](https://crrev.com/c/2709263) | ||
* [A Googletest header is removed](https://github.com/google/googletest/commit/df6b75949b1efab7606ba60c0f0a0125ac95c5af) | ||
* Rolling past the commit will fail, since Chromium still expects the header to exist | ||
* Roll past the affecting commit and updates uses in Chromium [in one CL](https://crrev.com/c/2713029) | ||
* [A new Googletest feature](https://github.com/google/googletest/commit/ec94d9f24c92a5090fda5567156d6dde99cdbf31) | ||
requires [updating tests in Chromium](https://crbug.com/1163396#c8) | ||
|
||
### Other Resources | ||
|
||
* [AutoRoller](https://autoroll.skia.org/r/googletest-chromium-autoroll) and | ||
accompanying [configuration file](https://skia.googlesource.com/skia-autoroll-internal-config.git/+/main/skia-public/googletest-chromium.cfg) | ||
* [Bug tracking substantial roll](https://crbug.com/1163396) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This directory contains Google Test glue that depends on //base. | ||
include_rules = [ | ||
'+base', | ||
'+build', | ||
] |
104 changes: 104 additions & 0 deletions
104
third_party/googletest/custom/gtest/internal/custom/chrome_custom_temp_dir.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// Copyright 2020 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "third_party/googletest/custom/gtest/internal/custom/chrome_custom_temp_dir.h" | ||
#include "third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h" | ||
#if GTEST_OS_WINDOWS | ||
#include <windows.h> | ||
#endif // GTEST_OS_WINDOWS | ||
|
||
namespace testing { | ||
|
||
namespace { | ||
|
||
// The temporary directory read from the OS canonical environment variable. | ||
// | ||
// Returns an empty string if the environment variable is not set. The returned | ||
// string may or may not end with the OS-specific path separator. The path is | ||
// not guaranteed to point to an existing directory. The directory it points to | ||
// is not guaranteed to be writable by the application. | ||
std::string ChromeGetEnvTempDir() { | ||
#if GTEST_OS_WINDOWS_MOBILE | ||
const char* env_result = internal::posix::GetEnv("TEMP"); | ||
#elif GTEST_OS_WINDOWS | ||
char temp_dir_path[_MAX_PATH + 1] = {'\0'}; // NOLINT | ||
if (::GetTempPathA(sizeof(temp_dir_path), temp_dir_path) != 0) | ||
return temp_dir_path; | ||
const char* env_result = internal::posix::GetEnv("TEMP"); | ||
#else | ||
const char* env_result = internal::posix::GetEnv("TMPDIR"); | ||
#endif // GETST_OS_WINDOWS | ||
|
||
if (env_result == nullptr) | ||
return std::string(); | ||
return env_result; | ||
} | ||
|
||
} // namespace | ||
|
||
// returns temp directory for tests. | ||
std::string ChromeCustomTempDir() { | ||
std::string temp_dir = ChromeGetEnvTempDir(); | ||
if (!temp_dir.empty()) { | ||
if (temp_dir.back() != GTEST_PATH_SEP_[0]) | ||
temp_dir.push_back(GTEST_PATH_SEP_[0]); | ||
return temp_dir; | ||
} | ||
|
||
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS | ||
return "\\temp\\"; | ||
#elif GTEST_OS_LINUX_ANDROID | ||
// Android applications are expected to call the framework's | ||
// Context.getExternalStorageDirectory() method through JNI to get the | ||
// location of the world-writable SD Card directory. However, this requires a | ||
// Context handle, which cannot be retrieved globally from native code. Doing | ||
// so also precludes running the code as part of a regular standalone | ||
// executable, which doesn't run in a Dalvik process (e.g. when running it | ||
// through 'adb shell'). | ||
// | ||
// Starting from Android O, the recommended generic temporary directory is | ||
// '/data/local/tmp'. The recommended fallback is the current directory, | ||
// which is usually accessible in app context. | ||
if (::access("/data/local/tmp", R_OK | W_OK | X_OK) == 0) | ||
return "/data/local/tmp/"; | ||
const char* current_dir = ::getcwd(nullptr, 0); | ||
if (current_dir != nullptr && | ||
::access(current_dir, R_OK | W_OK | X_OK) == 0) { | ||
temp_dir = current_dir; | ||
temp_dir.push_back(GTEST_PATH_SEP_[0]); | ||
return temp_dir; | ||
} | ||
// Before Android O, /sdcard is usually available. | ||
if (::access("/sdcard", R_OK | W_OK | X_OK) == 0) | ||
return "/sdcard/"; | ||
// Generic POSIX fallback. | ||
return "/tmp/"; | ||
#elif GTEST_OS_IOS | ||
char name_template[PATH_MAX + 1]; | ||
|
||
// Documented alternative to NSTemporaryDirectory() (for obtaining creating | ||
// a temporary directory) at | ||
// https://developer.apple.com/library/archive/documentation/Security/Conceptual/SecureCodingGuide/Articles/RaceConditions.html#//apple_ref/doc/uid/TP40002585-SW10 | ||
// | ||
// _CS_DARWIN_USER_TEMP_DIR (as well as _CS_DARWIN_USER_CACHE_DIR) is not | ||
// documented in the confstr() man page at | ||
// https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/confstr.3.html#//apple_ref/doc/man/3/confstr | ||
// but are still available, according to the WebKit patches at | ||
// https://trac.webkit.org/changeset/262004/webkit | ||
// https://trac.webkit.org/changeset/263705/webkit | ||
// | ||
// The confstr() implementation falls back to getenv("TMPDIR"). See | ||
// https://opensource.apple.com/source/Libc/Libc-1439.100.3/gen/confstr.c.auto.html | ||
::confstr(_CS_DARWIN_USER_TEMP_DIR, name_template, sizeof(name_template)); | ||
|
||
temp_dir = name_template; | ||
if (temp_dir.back() != GTEST_PATH_SEP_[0]) | ||
temp_dir.push_back(GTEST_PATH_SEP_[0]); | ||
return temp_dir; | ||
#else | ||
return "/tmp/"; | ||
#endif // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS | ||
} | ||
|
||
} // namespace testing |
15 changes: 15 additions & 0 deletions
15
third_party/googletest/custom/gtest/internal/custom/chrome_custom_temp_dir.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2020 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef THIRD_PARTY_GOOGLETEST_CUSTOM_GTEST_INTERNAL_CUSTOM_CHROME_CUSTOM_TEMP_DIR_H_ | ||
#define THIRD_PARTY_GOOGLETEST_CUSTOM_GTEST_INTERNAL_CUSTOM_CHROME_CUSTOM_TEMP_DIR_H_ | ||
|
||
#include <string> | ||
|
||
namespace testing { | ||
// Returns alternate temp directory for gtest. | ||
std::string ChromeCustomTempDir(); | ||
} // namespace testing | ||
|
||
#endif // THIRD_PARTY_GOOGLETEST_CUSTOM_GTEST_INTERNAL_CUSTOM_CHROME_CUSTOM_TEMP_DIR_H_ |
23 changes: 23 additions & 0 deletions
23
third_party/googletest/custom/gtest/internal/custom/gtest.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2018 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef THIRD_PARTY_GOOGLETEST_CUSTOM_GTEST_INTERNAL_CUSTOM_GTEST_H_ | ||
#define THIRD_PARTY_GOOGLETEST_CUSTOM_GTEST_INTERNAL_CUSTOM_GTEST_H_ | ||
|
||
#include "build/build_config.h" | ||
#include "third_party/googletest/custom/gtest/internal/custom/chrome_custom_temp_dir.h" | ||
|
||
#if !defined(GTEST_DISABLE_PRINT_STACK_TRACE) | ||
#include "third_party/googletest/custom/gtest/internal/custom/stack_trace_getter.h" | ||
|
||
// Tell Google Test to use a stack trace getter based on Chromium's | ||
// base::debug::StackTrace. | ||
#define GTEST_OS_STACK_TRACE_GETTER_ StackTraceGetter | ||
#endif // defined(GTEST_DISABLE_PRINT_STACK_TRACE) | ||
|
||
// TODO(crbug.com/1009553): Remove once googletest android temporary path is | ||
// fixed. | ||
#define GTEST_CUSTOM_TEMPDIR_FUNCTION_ ChromeCustomTempDir | ||
|
||
#endif // THIRD_PARTY_GOOGLETEST_CUSTOM_GTEST_INTERNAL_CUSTOM_GTEST_H_ |
Oops, something went wrong.