zircon/system/ulib/fs/transaction/test/writeback_test.cc
// This acts as a regression test against a previous implementation of
// "FlushRequests", which could pop the stack with a large enough number
// of requests. The new implementation utilizes heap allocation when necessary,
// and should be able to withstand very large request counts.
This acts as a regression test against a previous implementation of
"FlushRequests", which could pop the stack with a large enough number
of requests. The new implementation utilizes heap allocation when necessary,
and should be able to withstand very large request counts.
This acts as a regression test against a previous implementation of " FlushRequests " which could pop the stack with a large enough number of requests . The new implementation utilizes heap allocation when necessary and should be able to withstand very large request counts .
TEST(FlushRequestsTest, FlushAVeryLargeNumberOfRequests) {
  static constexpr vmoid_t kVmoid = 7;
  static constexpr size_t kOperationCount = 10000;
  class TestTransactionHandler : public MockTransactionHandler {
    zx_status_t Transaction(block_fifo_request_t* requests, size_t count) final {
      if (count != kOperationCount) {
        ADD_FAILURE("Unexpected count");
        return ZX_ERR_OUT_OF_RANGE;
      }
      for (size_t i = 0; i < count; i++) {
        EXPECT_EQ(i * 2 * kDiskBlockRatio, requests[i].vmo_offset);
        EXPECT_EQ(i * 2 * kDiskBlockRatio, requests[i].dev_offset);
        EXPECT_EQ(1 * kDiskBlockRatio, requests[i].length);
        EXPECT_EQ(kVmoid, requests[i].vmoid);
      }
      return ZX_OK;
    }
  } handler;
  fbl::Vector<storage::BufferedOperation> operations;
  for (size_t i = 0; i < kOperationCount; i++) {
    operations.push_back(storage::BufferedOperation{
        kVmoid, storage::Operation{storage::OperationType::kWrite, i * 2, i * 2, 1}});
  }
  EXPECT_OK(FlushRequests(&handler, operations));
}
TEST ( FlushRequestsTest , FlushAVeryLargeNumberOfRequests ) { static constexpr vmoid_t kVmoid = 7 ; static constexpr size_t kOperationCount = 10000 ; class TestTransactionHandler : public MockTransactionHandler { zx_status_t Transaction ( block_fifo_request_t * requests , size_t count ) final { if ( count != kOperationCount ) { ADD_FAILURE ( " " ) ; return ZX_ERR_OUT_OF_RANGE ; } for ( size_t i = 0 ; i < count ; i ++ ) { EXPECT_EQ ( i * 2 * kDiskBlockRatio , requests [ i ] . vmo_offset ) ; EXPECT_EQ ( i * 2 * kDiskBlockRatio , requests [ i ] . dev_offset ) ; EXPECT_EQ ( 1 * kDiskBlockRatio , requests [ i ] . length ) ; EXPECT_EQ ( kVmoid , requests [ i ] . vmoid ) ; } return ZX_OK ; } } handler ; fbl :: Vector < storage :: BufferedOperation > operations ; for ( size_t i = 0 ; i < kOperationCount ; i ++ ) { operations . push_back ( storage :: BufferedOperation { kVmoid , storage :: Operation { storage :: OperationType :: kWrite , i * 2 , i * 2 , 1 } } ) ; } EXPECT_OK ( FlushRequests ( & handler , operations ) ) ; }
This acts as a regression test against a previous implementation of
"FlushRequests", which could pop the stack with a large enough number
of requests.
This acts as a regression test against a previous implementation of " FlushRequests " which could pop the stack with a large enough number of requests .