diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-03-09 02:08:37 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-03-09 02:08:37 +0000 |
commit | 2cc73a5bb5463fbd3afc0ed8272f7317000fb8a6 (patch) | |
tree | cd1d5fb4e738cc8700bb37e4af4aa9ff2c8e528b | |
parent | f0fa0ebeede31132a0604cdfa46531a3f76baa5b (diff) | |
parent | 91ba37be107e1fdefc2bb2ab9a34b36910e0bfd2 (diff) | |
download | googletest-android14-s1-release.tar.gz |
Snap for 9712464 from 91ba37be107e1fdefc2bb2ab9a34b36910e0bfd2 to udc-releaseandroid-vts-14.0_r4android-vts-14.0_r3android-vts-14.0_r2android-vts-14.0_r1android-security-14.0.0_r9android-security-14.0.0_r8android-security-14.0.0_r7android-security-14.0.0_r6android-security-14.0.0_r5android-security-14.0.0_r4android-security-14.0.0_r3android-security-14.0.0_r2android-security-14.0.0_r1android-platform-14.0.0_r7android-platform-14.0.0_r6android-platform-14.0.0_r5android-platform-14.0.0_r4android-platform-14.0.0_r3android-platform-14.0.0_r2android-platform-14.0.0_r1android-cts-14.0_r4android-cts-14.0_r3android-cts-14.0_r2android-cts-14.0_r1android-14.0.0_r28android-14.0.0_r2android-14.0.0_r15android-14.0.0_r14android-14.0.0_r13android-14.0.0_r1android14-tests-releaseandroid14-security-releaseandroid14-s2-releaseandroid14-s1-releaseandroid14-releaseandroid14-platform-release
Change-Id: Id41116d92672bc427e880b5858551c6919a34633
-rw-r--r-- | googletest/include/gtest/internal/custom/gtest.h | 50 |
1 files changed, 4 insertions, 46 deletions
diff --git a/googletest/include/gtest/internal/custom/gtest.h b/googletest/include/gtest/internal/custom/gtest.h index 3d855613..67ce67f1 100644 --- a/googletest/include/gtest/internal/custom/gtest.h +++ b/googletest/include/gtest/internal/custom/gtest.h @@ -35,21 +35,13 @@ #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ #if GTEST_OS_LINUX_ANDROID -#include <dlfcn.h> -#include <unistd.h> - -#define GTEST_CUSTOM_TEMPDIR_FUNCTION_ GetAndroidTempDir -#define GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv) \ - internal::InitGoogleTestImpl(argc, argv); \ - SetAndroidTestLogger() - +# define GTEST_CUSTOM_TEMPDIR_FUNCTION_ GetAndroidTempDir +# include <unistd.h> static inline std::string GetAndroidTempDir() { // Android doesn't have /tmp, and /sdcard is no longer accessible from // an app context starting from Android O. On Android, /data/local/tmp // is usually used as the temporary directory, so try that first... - if (access("/data/local/tmp", R_OK | W_OK | X_OK) == 0) { - return "/data/local/tmp/"; - } + if (access("/data/local/tmp", R_OK | W_OK | X_OK) == 0) return "/data/local/tmp/"; // Processes running in an app context can't write to /data/local/tmp, // so fall back to the current directory... @@ -62,40 +54,6 @@ static inline std::string GetAndroidTempDir() { } return result; } - -static inline void SetAndroidTestLogger() { - // By default, Android log messages are only written to the log buffer, where - // GTest cannot see them. This breaks death tests, which need to check the - // crash message to ensure that the process died for the expected reason. - // To fix this, send log messages to both logd and stderr if we are in a death - // test child process. - struct LogMessage; - using LoggerFunction = void (*)(const LogMessage*); - using SetLoggerFunction = void (*)(LoggerFunction logger); - - static void* liblog = dlopen("liblog.so", RTLD_NOW); - if (liblog == nullptr) { - return; - } - - static SetLoggerFunction set_logger = reinterpret_cast<SetLoggerFunction>( - dlsym(liblog, "__android_log_set_logger")); - static LoggerFunction logd_logger = reinterpret_cast<LoggerFunction>( - dlsym(liblog, "__android_log_logd_logger")); - static LoggerFunction stderr_logger = reinterpret_cast<LoggerFunction>( - dlsym(liblog, "__android_log_stderr_logger")); - if (set_logger == nullptr || logd_logger == nullptr || - stderr_logger == nullptr) { - return; - } - - set_logger([](const LogMessage* message) { - logd_logger(message); - if (::testing::internal::InDeathTestChild()) { - stderr_logger(message); - } - }); -} -#endif // GTEST_OS_LINUX_ANDROID +#endif //GTEST_OS_LINUX_ANDROID #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ |