From 28452dd865aa7702a44335af6f046821858fe533 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Fri, 24 Apr 2026 03:31:12 -0700 Subject: [PATCH] [unittest] Use TempDir() in gtest death-test stream capture on Linux gtest's CapturedStream on Linux hardcoded /tmp/ for its temp file without consulting the environment, causing failures in sandboxed environments where /tmp is read-only. Use TempDir() instead, which checks TEST_TMPDIR then TMPDIR and falls back to /tmp/, matching the behavior already present on Android and macOS/iOS. Assisted-by: Claude Code --- googletest/src/gtest-port.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc index d34a693e4..3f4617532 100644 --- a/googletest/src/gtest-port.cc +++ b/googletest/src/gtest-port.cc @@ -1146,7 +1146,7 @@ class CapturedStream { if (!EndsWithPathSeparator(name_template)) name_template.push_back(GTEST_PATH_SEP_[0]); #else - name_template = "/tmp/"; + name_template = TempDir(); #endif name_template.append("gtest_captured_stream.XXXXXX");