src/devices/nand/drivers/skip-block/test/skip-block-test.cc
// This test attempts to write 4 copies of a single block. The copies live in blocks 0, 1, 2, and 3.
// The first operation, a block erase, fails for each copy of the block. We validate that the
// overall write also fails and all failed blocks are grown bad blocks.
This test attempts to write 4 copies of a single block. The copies live in blocks 0, 1, 2, and 3.
The first operation, a block erase, fails for each copy of the block. We validate that the
overall write also fails and all failed blocks are grown bad blocks.
This test attempts to write 4 copies of a single block . The copies live in blocks 0 1 2 and 3 . The first operation a block erase fails for each copy of the block . We validate that the overall write also fails and all failed blocks are grown bad blocks .
TEST_F(SkipBlockTest, WriteMultipleCopiesNoneSucceeds) {
  const uint32_t count_ = 4;
  ddk().SetMetadata(&count_, sizeof(count_));
  ddk().SetSize(kPageSize * kNumPages * 4);
  nand().set_block_count(4);
  ASSERT_OK(nand::SkipBlockDevice::Create(nullptr, parent()));
  nand().set_result(ZX_ERR_IO);
  nand().set_result(ZX_ERR_IO);
  nand().set_result(ZX_ERR_IO);
  nand().set_result(ZX_ERR_IO);
  zx::vmo vmo;
  ASSERT_NO_FATAL_FAILURES(CreatePayload(kBlockSize, &vmo));
  nand::ReadWriteOperation op = {};
  op.vmo = std::move(vmo);
  op.block = 0;
  op.block_count = 1;
  bool bad_block_grown;
  ASSERT_NO_FATAL_FAILURES(Write(std::move(op), &bad_block_grown, ZX_ERR_IO));
  ASSERT_TRUE(bad_block_grown);
  ASSERT_EQ(bad_block().grown_bad_blocks().size(), 4);
  ASSERT_EQ(bad_block().grown_bad_blocks()[0], 0);
  ASSERT_EQ(bad_block().grown_bad_blocks()[1], 1);
  ASSERT_EQ(bad_block().grown_bad_blocks()[2], 2);
  ASSERT_EQ(bad_block().grown_bad_blocks()[3], 3);
  ASSERT_EQ(nand().last_op(), NAND_OP_ERASE);
  ASSERT_NO_FATAL_FAILURES(ValidateUnwritten(0, kBlockSize * 4));
}
TEST_F ( SkipBlockTest , WriteMultipleCopiesNoneSucceeds ) { const uint32_t count_ = 4 ; ddk ( ) . SetMetadata ( & count_ , sizeof ( count_ ) ) ; ddk ( ) . SetSize ( kPageSize * kNumPages * 4 ) ; nand ( ) . set_block_count ( 4 ) ; ASSERT_OK ( nand :: SkipBlockDevice :: Create ( nullptr , parent ( ) ) ) ; nand ( ) . set_result ( ZX_ERR_IO ) ; nand ( ) . set_result ( ZX_ERR_IO ) ; nand ( ) . set_result ( ZX_ERR_IO ) ; nand ( ) . set_result ( ZX_ERR_IO ) ; zx :: vmo vmo ; ASSERT_NO_FATAL_FAILURES ( CreatePayload ( kBlockSize , & vmo ) ) ; nand :: ReadWriteOperation op = { } ; op . vmo = std :: move ( vmo ) ; op . block = 0 ; op . block_count = 1 ; bool bad_block_grown ; ASSERT_NO_FATAL_FAILURES ( Write ( std :: move ( op ) , & bad_block_grown , ZX_ERR_IO ) ) ; ASSERT_TRUE ( bad_block_grown ) ; ASSERT_EQ ( bad_block ( ) . grown_bad_blocks ( ) . size ( ) , 4 ) ; ASSERT_EQ ( bad_block ( ) . grown_bad_blocks ( ) [ 0 ] , 0 ) ; ASSERT_EQ ( bad_block ( ) . grown_bad_blocks ( ) [ 1 ] , 1 ) ; ASSERT_EQ ( bad_block ( ) . grown_bad_blocks ( ) [ 2 ] , 2 ) ; ASSERT_EQ ( bad_block ( ) . grown_bad_blocks ( ) [ 3 ] , 3 ) ; ASSERT_EQ ( nand ( ) . last_op ( ) , NAND_OP_ERASE ) ; ASSERT_NO_FATAL_FAILURES ( ValidateUnwritten ( 0 , kBlockSize * 4 ) ) ; }
This test attempts to write 4 copies of a single block.
This test attempts to write 4 copies of a single block .
// Erase Block 0 // Erase Block 1 // Erase Block 2 // Erase Block 3