[libc-commits] [libc] [libc] Keep a stream buffered when setvbuf is passed no buffer (PR #236517)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Thu Nov 5 14:05:16 PST 2026
================
@@ -95,6 +102,39 @@ TEST_F(LlvmLibcSetvbufTest, SetLBFBuffer) {
ASSERT_EQ(0, LIBC_NAMESPACE::fclose(fr));
}
+TEST_F(LlvmLibcSetvbufTest, NullBufferAsksForOne) {
+ // A null buffer asks the library to provide one, so the stream stays
+ // buffered in the mode asked for whatever the size. Data written to a fully
+ // buffered stream is not readable through another handle until it is
+ // flushed.
+ constexpr char FILENAME[] = "testdata/setvbuf_null_buffer.test";
+ constexpr char CONTENT[] = "abcdef";
+ constexpr size_t CONTENT_SIZE = sizeof(CONTENT) - 1;
+ const size_t sizes[] = {0, 16};
+
+ for (size_t size : sizes) {
----------------
michaelrj-google wrote:
this sort of loop makes debugging a test much more difficult. When an assertion fails the error message provides the line number. If there's a loop, then it's unclear which iteration of the loop it was on. Similarly, if you run the test under a debugger like gdb or lldb then set a breakpoint on the failing line it may not be the correct iteration.
Given that there are two iterations of this loop, they should just be written out in full. Having long test files isn't a problem if it makes the files easier to understand and debug.
https://github.com/llvm/llvm-project/pull/236517
More information about the libc-commits
mailing list