src/storage/blobfs/test/unit/format-test.cc
// Validates that a formatted filesystem, mounted as writable, is converted
// to read-only on a device that is not writable.
Validates that a formatted filesystem, mounted as writable, is converted
to read-only on a device that is not writable.
Validates that a formatted filesystem mounted as writable is converted to read - only on a device that is not writable .
TEST(FormatFilesystemTest, FormatDeviceNoJournalAutoConvertReadonly) {
  const uint64_t kBlockCount = 1 << 20;
  const uint32_t kBlockSize = kBlobfsBlockSize;
  auto device = std::make_unique<FakeBlockDevice>(kBlockCount, kBlockSize);
  ASSERT_EQ(FormatFilesystem(device.get()), ZX_OK);
  device->SetInfoFlags(fuchsia_hardware_block_FLAG_READONLY);
  MountOptions mount_options = {};
  mount_options.writability = Writability::Writable;
  mount_options.metrics = false;
  mount_options.journal = false;
  std::unique_ptr<Blobfs> fs = nullptr;
  ASSERT_EQ(Blobfs::Create(nullptr, std::move(device), &mount_options, zx::resource(), &fs), ZX_OK);
  ASSERT_EQ(Writability::ReadOnlyDisk, fs->writability());
}
TEST ( FormatFilesystemTest , FormatDeviceNoJournalAutoConvertReadonly ) { const uint64_t kBlockCount = 1 << 20 ; const uint32_t kBlockSize = kBlobfsBlockSize ; auto device = std :: make_unique < FakeBlockDevice > ( kBlockCount , kBlockSize ) ; ASSERT_EQ ( FormatFilesystem ( device . get ( ) ) , ZX_OK ) ; device -> SetInfoFlags ( fuchsia_hardware_block_FLAG_READONLY ) ; MountOptions mount_options = { } ; mount_options . writability = Writability :: Writable ; mount_options . metrics = false ; mount_options . journal = false ; std :: unique_ptr < Blobfs > fs = nullptr ; ASSERT_EQ ( Blobfs :: Create ( nullptr , std :: move ( device ) , & mount_options , zx :: resource ( ) , & fs ) , ZX_OK ) ; ASSERT_EQ ( Writability :: ReadOnlyDisk , fs -> writability ( ) ) ; }
Validates that a formatted filesystem, mounted as writable, is converted
to read-only on a device that is not writable.
Validates that a formatted filesystem mounted as writable is converted to read - only on a device that is not writable .