|
20 | 20 | #include "test/UnitTest/ErrnoSetterMatcher.h" |
21 | 21 | #include "test/UnitTest/Test.h" |
22 | 22 |
|
23 | | -#if defined(LIBC_TARGET_OS_IS_LINUX) && \ |
24 | | - !defined(LIBC_COPT_STDIO_USE_SYSTEM_FILE) |
25 | | -#include "src/stdio/fopencookie.h" |
26 | | -#endif |
27 | | - |
28 | 23 | namespace printf_test { |
29 | 24 | #ifndef LIBC_COPT_STDIO_USE_SYSTEM_FILE |
30 | 25 | using LIBC_NAMESPACE::fclose; |
@@ -93,33 +88,6 @@ TEST(LlvmLibcFPrintfTest, WriteToFile) { |
93 | 88 | ASSERT_EQ(printf_test::fclose(file), 0); |
94 | 89 | } |
95 | 90 |
|
96 | | -#if !defined(LIBC_COPT_STDIO_USE_SYSTEM_FILE) && \ |
97 | | - defined(LIBC_TARGET_OS_IS_LINUX) |
98 | | -TEST(LlvmLibcFPrintfTest, CharsWrittenOverflow) { |
99 | | - struct NoopStream {}; |
100 | | - auto noop_write = [](void *, const char *, size_t size) -> ssize_t { |
101 | | - return size; |
102 | | - }; |
103 | | - |
104 | | - NoopStream stream; |
105 | | - cookie_io_functions_t funcs = {nullptr, +noop_write, nullptr, nullptr}; |
106 | | - ::FILE *file = LIBC_NAMESPACE::fopencookie(&stream, "w", funcs); |
107 | | - ASSERT_NE(file, nullptr); |
108 | | - |
109 | | - // Trigger an overflow in the return value of fprintf by writing more than |
110 | | - // INT_MAX bytes. We do this by printing a string with precision INT_MAX, and |
111 | | - // then one more character. |
112 | | - int max_int = LIBC_NAMESPACE::cpp::numeric_limits<int>::max(); |
113 | | - int result = LIBC_NAMESPACE::fprintf(file, "%*sA", max_int, ""); |
114 | | - |
115 | | - EXPECT_LT(result, 0); |
116 | | - ASSERT_ERRNO_EQ(EOVERFLOW); |
117 | | - |
118 | | - EXPECT_EQ(printf_test::fclose(file), 0); |
119 | | -} |
120 | | -#endif // #if !defined(LIBC_COPT_STDIO_USE_SYSTEM_FILE) && |
121 | | - // defined(LIBC_TARGET_OS_IS_LINUX) |
122 | | - |
123 | 91 | #ifndef LIBC_COPT_PRINTF_NO_NULLPTR_CHECKS |
124 | 92 | TEST(LlvmLibcFPrintfTest, NullPtrCheck) { |
125 | 93 | const char *FILENAME = APPEND_LIBC_TEST("fprintf_nullptr.test"); |
|
0 commit comments