| 481 | } |
| 482 | |
| 483 | void TestWrites(const int64_t total_bytes, const int64_t chunksize, |
| 484 | const int64_t buffer_size = 0) { |
| 485 | std::shared_ptr<ResizableBuffer> buffer; |
| 486 | ASSERT_OK(MakeRandomByteBuffer(total_bytes, default_memory_pool(), &buffer)); |
| 487 | |
| 488 | if (buffer_size > 0) { |
| 489 | ASSERT_OK(writer_->SetBufferSize(buffer_size)); |
| 490 | } |
| 491 | |
| 492 | ASSERT_OK_AND_EQ(0, writer_->Tell()); |
| 493 | |
| 494 | const uint8_t* host_data = buffer->data(); |
| 495 | ASSERT_OK(writer_->Write(host_data, chunksize)); |
| 496 | ASSERT_OK_AND_EQ(chunksize, writer_->Tell()); |
| 497 | |
| 498 | ASSERT_OK(writer_->Seek(0)); |
| 499 | ASSERT_OK_AND_EQ(0, writer_->Tell()); |
| 500 | |
| 501 | int64_t position = 0; |
| 502 | while (position < total_bytes) { |
| 503 | int64_t bytes_to_write = std::min(chunksize, total_bytes - position); |
| 504 | ASSERT_OK(writer_->Write(host_data + position, bytes_to_write)); |
| 505 | position += bytes_to_write; |
| 506 | } |
| 507 | |
| 508 | ASSERT_OK(writer_->Flush()); |
| 509 | |
| 510 | AssertCudaBufferEquals(*device_buffer_, *buffer); |
| 511 | } |
| 512 | |
| 513 | protected: |
| 514 | std::shared_ptr<CudaBuffer> device_buffer_; |
nothing calls this directly
no test coverage detected