zircon/system/ulib/fs/journal/test/journal_test.cc
// Tests that operations which won't fit in metadata writeback will fail.
Tests that operations which won't fit in metadata writeback will fail.
Tests that operations which won ' t fit in metadata writeback will fail .
TEST_F(JournalTest, MetadataOperationTooLargeToFitInJournalFails) {
  const uint64_t kBufferLength = kJournalLength + 1;
  storage::VmoBuffer buffer = registry()->InitializeBuffer(kBufferLength);
  const std::vector<storage::UnbufferedOperation> operations = {
      {
          zx::unowned_vmo(buffer.vmo().get()),
          {
              storage::OperationType::kWrite,
              .vmo_offset = 0,
              .dev_offset = 20,
              .length = kBufferLength,
          },
      },
  };
  zx_status_t metadata_status = ZX_OK;
  MockTransactionHandler handler(registry());
  {
    Journal journal(&handler, take_info(), take_journal_buffer(), take_data_buffer(), 0,
                    Journal::Options());
    auto promise = journal.WriteMetadata({operations[0]}).or_else([&](zx_status_t& status) {
      metadata_status = status;
    });
    journal.schedule_task(std::move(promise));
  }
  EXPECT_STATUS(ZX_ERR_NO_SPACE, metadata_status);
}
TEST_F ( JournalTest , MetadataOperationTooLargeToFitInJournalFails ) { const uint64_t kBufferLength = kJournalLength + 1 ; storage :: VmoBuffer buffer = registry ( ) -> InitializeBuffer ( kBufferLength ) ; const std :: vector < storage :: UnbufferedOperation > operations = { { zx :: unowned_vmo ( buffer . vmo ( ) . get ( ) ) , { storage :: OperationType :: kWrite , . vmo_offset = 0 , . dev_offset = 20 , . length = kBufferLength , } , } , } ; zx_status_t metadata_status = ZX_OK ; MockTransactionHandler handler ( registry ( ) ) ; { Journal journal ( & handler , take_info ( ) , take_journal_buffer ( ) , take_data_buffer ( ) , 0 , Journal :: Options ( ) ) ; auto promise = journal . WriteMetadata ( { operations [ 0 ] } ) . or_else ( [ & ] ( zx_status_t & status ) { metadata_status = status ; } ) ; journal . schedule_task ( std :: move ( promise ) ) ; } EXPECT_STATUS ( ZX_ERR_NO_SPACE , metadata_status ) ; }
Tests that operations which won't fit in metadata writeback will fail.
Tests that operations which won ' t fit in metadata writeback will fail .