[Lldb-commits] [lldb] [lldb] Fixed PipeWindows bugs; added Pipe::WriteWithTimeout() (PR #101383)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 5 06:27:50 PDT 2024


================
@@ -47,5 +50,92 @@ TEST_F(PipeTest, OpenAsReader) {
   ASSERT_THAT_ERROR(
       pipe.OpenAsReader(name_ref, /*child_process_inherit=*/false).ToError(),
       llvm::Succeeded());
+
+  ASSERT_TRUE(pipe.CanRead());
 }
 #endif
+
+TEST_F(PipeTest, WriteWithTimeout) {
+  Pipe pipe;
+  ASSERT_THAT_ERROR(pipe.CreateNew(false).ToError(), llvm::Succeeded());
+  // Note write_chunk_size must be less than the pipe buffer.
+  // The pipe buffer is 1024 for PipeWindows and at least 512 on Darwin.
+  const size_t buf_size = 8192;
+  const size_t write_chunk_size = 234;
+
+  std::vector<int32_t> write_buf(buf_size / sizeof(int32_t));
+  std::iota(write_buf.begin(), write_buf.end(), 0);
+  std::vector<int32_t> read_buf(write_buf.size() + 100, -1);
+
+  char *write_ptr = (char *)&write_buf.front();
+  char *read_ptr = (char *)&read_buf.front();
----------------
labath wrote:

```suggestion
  char *write_ptr = reinterpret_cast<char *>(write_buf.data());
  char *read_ptr = reinterpret_cast<char *>read_buf.data());
```

https://github.com/llvm/llvm-project/pull/101383


More information about the lldb-commits mailing list