summaryrefslogtreecommitdiff
path: root/src/__support/OSUtil/fuchsia/io.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/__support/OSUtil/fuchsia/io.h')
-rw-r--r--src/__support/OSUtil/fuchsia/io.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/__support/OSUtil/fuchsia/io.h b/src/__support/OSUtil/fuchsia/io.h
index 9a5e00beaa31..f68d734492fa 100644
--- a/src/__support/OSUtil/fuchsia/io.h
+++ b/src/__support/OSUtil/fuchsia/io.h
@@ -9,18 +9,23 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FUCHSIA_IO_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FUCHSIA_IO_H
-#ifndef LIBC_COPT_TEST_USE_FUCHSIA
-#error this file should only be used by tests
-#endif
-
#include "src/__support/CPP/string_view.h"
+#include <iostream>
#include <zircon/sanitizer.h>
namespace LIBC_NAMESPACE {
LIBC_INLINE void write_to_stderr(cpp::string_view msg) {
+#if defined(LIBC_COPT_TEST_USE_ZXTEST)
+ // This is used in standalone context where there is nothing like POSIX I/O.
__sanitizer_log_write(msg.data(), msg.size());
+#elif defined(LIBC_COPT_TEST_USE_GTEST)
+ // The gtest framework already relies on full standard C++ I/O via fdio.
+ std::cerr << std::string_view{msg.data(), msg.size()};
+#else
+#error this file should only be used by tests
+#endif
}
} // namespace LIBC_NAMESPACE