zircon/system/ulib/fs/journal/test/journal_test.cc
// Tests that TrimData() is observable from the "block device".
Tests that TrimData() is observable from the "block device".
Tests that TrimData () is observable from the " block device " .
TEST_F(JournalTest, TrimDataObserveTransaction) {
  const storage::BufferedOperation operation = {
      0,
      {
          storage::OperationType::kTrim,
          .vmo_offset = 0,
          .dev_offset = 20,
          .length = 5,
      },
  };
  MockTransactionHandler::TransactionCallback callbacks[] = {
      [&](const std::vector<storage::BufferedOperation>& requests) {
        if (requests.size() != 1) {
          ADD_FAILURE("Unexpected count");
          return ZX_ERR_OUT_OF_RANGE;
        }
        EXPECT_EQ(storage::OperationType::kTrim, requests[0].op.type);
        EXPECT_EQ(20, requests[0].op.dev_offset);
        EXPECT_EQ(5, requests[0].op.length);
        return ZX_OK;
      },
  };
  MockTransactionHandler handler(registry(), callbacks, std::size(callbacks));
  {
    Journal journal(&handler, take_info(), take_journal_buffer(), take_data_buffer(), 0,
                    Journal::Options());
    auto promise = journal.TrimData({operation}).and_then([&]() {
      CheckInfoBlock(registry()->info(),  0,  0);
    });
    journal.schedule_task(std::move(promise));
  }
}
TEST_F ( JournalTest , TrimDataObserveTransaction ) { const storage :: BufferedOperation operation = { 0 , { storage :: OperationType :: kTrim , . vmo_offset = 0 , . dev_offset = 20 , . length = 5 , } , } ; MockTransactionHandler :: TransactionCallback callbacks [ ] = { [ & ] ( const std :: vector < storage :: BufferedOperation > & requests ) { if ( requests . size ( ) != 1 ) { ADD_FAILURE ( " " ) ; return ZX_ERR_OUT_OF_RANGE ; } EXPECT_EQ ( storage :: OperationType :: kTrim , requests [ 0 ] . op . type ) ; EXPECT_EQ ( 20 , requests [ 0 ] . op . dev_offset ) ; EXPECT_EQ ( 5 , requests [ 0 ] . op . length ) ; return ZX_OK ; } , } ; MockTransactionHandler handler ( registry ( ) , callbacks , std :: size ( callbacks ) ) ; { Journal journal ( & handler , take_info ( ) , take_journal_buffer ( ) , take_data_buffer ( ) , 0 , Journal :: Options ( ) ) ; auto promise = journal . TrimData ( { operation } ) . and_then ( [ & ] ( ) { CheckInfoBlock ( registry ( ) -> info ( ) , 0 , 0 ) ; } ) ; journal . schedule_task ( std :: move ( promise ) ) ; } }
Tests that TrimData() is observable from the "block device".
Tests that TrimData () is observable from the " block device " .
/* start= */ /* sequence_number= */