diff options
author | Diego Vela <diegovela@google.com> | 2023-03-08 00:08:50 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-03-08 00:08:50 +0000 |
commit | 18cdb377d19a2797a7db011a6402283e5bbc26fa (patch) | |
tree | cd1d5fb4e738cc8700bb37e4af4aa9ff2c8e528b | |
parent | 6a9c22a63e0704fe60e8d9317f46322525ea9718 (diff) | |
parent | 91ba37be107e1fdefc2bb2ab9a34b36910e0bfd2 (diff) | |
download | googletest-android14-d2-s2-release.tar.gz |
Revert "Revert "Revert "Fix device death tests.""" am: 42795cf170 am: 276e32ec33 am: 817e9f6edc am: 91ba37be10android-14.0.0_r45android-14.0.0_r44android-14.0.0_r43android-14.0.0_r42android-14.0.0_r41android-14.0.0_r40android-14.0.0_r39android-14.0.0_r38android-14.0.0_r27android-14.0.0_r26android-14.0.0_r25android-14.0.0_r24android-14.0.0_r23android-14.0.0_r22android-14.0.0_r21android-14.0.0_r20android-14.0.0_r19android-14.0.0_r18android-14.0.0_r17android-14.0.0_r16android14-qpr1-s2-releaseandroid14-qpr1-releaseandroid14-d2-s5-releaseandroid14-d2-s4-releaseandroid14-d2-s3-releaseandroid14-d2-s2-releaseandroid14-d2-s1-releaseandroid14-d2-release
Original change: https://android-review.googlesource.com/c/platform/external/googletest/+/2475384
Change-Id: Ib60f98f8cc088bc5f1152fd6ba2ded343d14327b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-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_ |