Googletest export

Fix iOS logging issues in tests

PiperOrigin-RevId: 370484087
This commit is contained in:
Abseil Team
2021-04-26 13:09:24 -04:00
committed by Derek Mauro
parent 11da093e04
commit 252ce9c52d
2 changed files with 21 additions and 1 deletions

View File

@@ -80,6 +80,10 @@
# include <zircon/syscalls.h>
#endif // GTEST_OS_FUCHSIA
#if GTEST_OS_IOS
#import <Foundation/Foundation.h>
#endif // GTEST_OS_IOS
#include "gtest/gtest-spi.h"
#include "gtest/gtest-message.h"
#include "gtest/internal/gtest-internal.h"
@@ -1111,9 +1115,15 @@ class CapturedStream {
// '/sdcard' and other variants cannot be relied on, as they are not
// guaranteed to be mounted, or may have a delay in mounting.
char name_template[] = "/data/local/tmp/gtest_captured_stream.XXXXXX";
# elif GTEST_OS_IOS
NSString* temp_path = [NSTemporaryDirectory()
stringByAppendingPathComponent:@"gtest_captured_stream.XXXXXX"];
char name_template[PATH_MAX + 1];
strncpy(name_template, [temp_path UTF8String], PATH_MAX);
# else
char name_template[] = "/tmp/captured_stream.XXXXXX";
# endif // GTEST_OS_LINUX_ANDROID
# endif
const int captured_fd = mkstemp(name_template);
if (captured_fd == -1) {
GTEST_LOG_(WARNING)