| 107 | } |
| 108 | |
| 109 | void TestStraddling(TableReaderFactory reader_factory) { |
| 110 | // The largest line is 25 bytes, it is surrounded by many valid lines |
| 111 | constexpr std::string_view kData = |
| 112 | "a,b\n1,2\n3,4\n5,6\n7,8\n111111111111,22222222222\n1,2\n3,4\n5,6\n7,8\n"; |
| 113 | constexpr int kHeaderLineLen = 4; |
| 114 | constexpr int kLargestLineLen = 25; |
| 115 | |
| 116 | auto data = std::make_shared<Buffer>(kData); |
| 117 | auto input = std::make_shared<io::BufferReader>(data); |
| 118 | // Sanity check that a large enough block size reads the data successfully |
| 119 | ASSERT_OK_AND_ASSIGN( |
| 120 | auto reader, reader_factory(input, ParseOptions::Defaults(), /*block_size=*/{})); |
| 121 | ASSERT_FINISHES_OK(reader->ReadAsync()); |
| 122 | |
| 123 | for (int block_size = kHeaderLineLen; block_size < kLargestLineLen / 2; ++block_size) { |
| 124 | input = std::make_shared<io::BufferReader>(data); |
| 125 | ASSERT_OK_AND_ASSIGN(auto reader, |
| 126 | reader_factory(input, ParseOptions::Defaults(), block_size)); |
| 127 | ASSERT_FINISHES_AND_RAISES(Invalid, reader->ReadAsync()); |
| 128 | reader.reset(); |
| 129 | } |
| 130 | // This could deadlock in the TableReader destructor if it is not able to recover |
| 131 | // gracefully after an error (GH-48741). Alternatively, the destructor could |
| 132 | // deadlock at process shutdown when the thread pool is reaped. |
| 133 | internal::GetCpuThreadPool()->WaitForIdle(); |
| 134 | } |
| 135 | |
| 136 | void StressTableReader(TableReaderFactory reader_factory) { |
| 137 | #ifdef ARROW_VALGRIND |
no test coverage detected