zircon/system/ulib/blobfs/test/host/host-test.cc
// This test verifies that formatting actually writes zero-filled
// blocks within the journal.
This test verifies that formatting actually writes zero-filled
blocks within the journal.
This test verifies that formatting actually writes zero - filled blocks within the journal .
TEST(BlobfsHostFormatTest, JournalFormattedAsEmpty) {
  File file(tmpfile());
  constexpr uint64_t kBlockCount = 10000;
  EXPECT_EQ(0, Mkfs(file.fd(), kBlockCount));
  char block[kBlobfsBlockSize] = {};
  ASSERT_OK(ReadBlock(file.fd(), 0, block));
  static_assert(sizeof(Superblock) <= sizeof(block), "Superblock too big");
  const Superblock* superblock = reinterpret_cast<Superblock*>(block);
  ASSERT_OK(CheckSuperblock(superblock, kBlockCount));
  uint64_t journal_blocks = JournalBlocks(*superblock);
  char zero_block[kBlobfsBlockSize] = {};
  for (uint64_t n = 1; n < journal_blocks; n++) {
    char block[kBlobfsBlockSize] = {};
    ASSERT_OK(ReadBlock(file.fd(), JournalStartBlock(*superblock) + n, block));
    EXPECT_BYTES_EQ(zero_block, block, kBlobfsBlockSize, "Journal should be formatted with zeros");
  }
}
TEST ( BlobfsHostFormatTest , JournalFormattedAsEmpty ) { File file ( tmpfile ( ) ) ; constexpr uint64_t kBlockCount = 10000 ; EXPECT_EQ ( 0 , Mkfs ( file . fd ( ) , kBlockCount ) ) ; char block [ kBlobfsBlockSize ] = { } ; ASSERT_OK ( ReadBlock ( file . fd ( ) , 0 , block ) ) ; static_assert ( sizeof ( Superblock ) <= sizeof ( block ) , " " ) ; const Superblock * superblock = reinterpret_cast < Superblock * > ( block ) ; ASSERT_OK ( CheckSuperblock ( superblock , kBlockCount ) ) ; uint64_t journal_blocks = JournalBlocks ( * superblock ) ; char zero_block [ kBlobfsBlockSize ] = { } ; for ( uint64_t n = 1 ; n < journal_blocks ; n ++ ) { char block [ kBlobfsBlockSize ] = { } ; ASSERT_OK ( ReadBlock ( file . fd ( ) , JournalStartBlock ( * superblock ) + n , block ) ) ; EXPECT_BYTES_EQ ( zero_block , block , kBlobfsBlockSize , " " ) ; } }
This test verifies that formatting actually writes zero-filled
blocks within the journal.
This test verifies that formatting actually writes zero - filled blocks within the journal .
// '1' -> Skip the journal info block.