src/devices/nand/drivers/skip-block/test/skip-block-test.cc
// This test attempts to write 2 copies of a single block to a partition that is 10 blocks wide.
// The copies of logical block 1, start out as block 1 and 6. After erase or write failures, the
// blocks are marked bad, and blocks 2 and 7 become the new "physical" copies of logical block 1.
This test attempts to write 2 copies of a single block to a partition that is 10 blocks wide.
The copies of logical block 1, start out as block 1 and 6. After erase or write failures, the
blocks are marked bad, and blocks 2 and 7 become the new "physical" copies of logical block 1.
This test attempts to write 2 copies of a single block to a partition that is 10 blocks wide . The copies of logical block 1 start out as block 1 and 6 . After erase or write failures the blocks are marked bad and blocks 2 and 7 become the new " physical " copies of logical block 1 .
TEST_F(SkipBlockTest, WriteMultipleCopies) {
  const uint32_t count_ = 2;
  ddk().SetMetadata(&count_, sizeof(count_));
  ASSERT_OK(nand::SkipBlockDevice::Create(nullptr, parent()));
  nand().set_result(ZX_OK);
  nand().set_result(ZX_ERR_IO);
  nand().set_result(ZX_OK);
  nand().set_result(ZX_OK);
  nand().set_result(ZX_ERR_IO);
  nand().set_result(ZX_OK);
  nand().set_result(ZX_OK);
  zx::vmo vmo;
  ASSERT_NO_FATAL_FAILURES(CreatePayload(kBlockSize, &vmo));
  nand::ReadWriteOperation op = {};
  op.vmo = std::move(vmo);
  op.block = 1;
  op.block_count = 1;
  bool bad_block_grown;
  ASSERT_NO_FATAL_FAILURES(Write(std::move(op), &bad_block_grown));
  ASSERT_TRUE(bad_block_grown);
  ASSERT_EQ(bad_block().grown_bad_blocks().size(), 2);
  ASSERT_EQ(bad_block().grown_bad_blocks()[0], 1);
  ASSERT_EQ(bad_block().grown_bad_blocks()[1], 6);
  ASSERT_EQ(nand().last_op(), NAND_OP_WRITE);
  ASSERT_NO_FATAL_FAILURES(ValidateUnwritten(kBlockSize * 1, kBlockSize));
  ASSERT_NO_FATAL_FAILURES(ValidateWritten(kBlockSize * 2, kBlockSize));
  ASSERT_NO_FATAL_FAILURES(ValidateUnwritten(kBlockSize * 6, kBlockSize));
  ASSERT_NO_FATAL_FAILURES(ValidateWritten(kBlockSize * 7, kBlockSize));
}
TEST_F ( SkipBlockTest , WriteMultipleCopies ) { const uint32_t count_ = 2 ; ddk ( ) . SetMetadata ( & count_ , sizeof ( count_ ) ) ; ASSERT_OK ( nand :: SkipBlockDevice :: Create ( nullptr , parent ( ) ) ) ; nand ( ) . set_result ( ZX_OK ) ; nand ( ) . set_result ( ZX_ERR_IO ) ; nand ( ) . set_result ( ZX_OK ) ; nand ( ) . set_result ( ZX_OK ) ; nand ( ) . set_result ( ZX_ERR_IO ) ; nand ( ) . set_result ( ZX_OK ) ; nand ( ) . set_result ( ZX_OK ) ; zx :: vmo vmo ; ASSERT_NO_FATAL_FAILURES ( CreatePayload ( kBlockSize , & vmo ) ) ; nand :: ReadWriteOperation op = { } ; op . vmo = std :: move ( vmo ) ; op . block = 1 ; op . block_count = 1 ; bool bad_block_grown ; ASSERT_NO_FATAL_FAILURES ( Write ( std :: move ( op ) , & bad_block_grown ) ) ; ASSERT_TRUE ( bad_block_grown ) ; ASSERT_EQ ( bad_block ( ) . grown_bad_blocks ( ) . size ( ) , 2 ) ; ASSERT_EQ ( bad_block ( ) . grown_bad_blocks ( ) [ 0 ] , 1 ) ; ASSERT_EQ ( bad_block ( ) . grown_bad_blocks ( ) [ 1 ] , 6 ) ; ASSERT_EQ ( nand ( ) . last_op ( ) , NAND_OP_WRITE ) ; ASSERT_NO_FATAL_FAILURES ( ValidateUnwritten ( kBlockSize * 1 , kBlockSize ) ) ; ASSERT_NO_FATAL_FAILURES ( ValidateWritten ( kBlockSize * 2 , kBlockSize ) ) ; ASSERT_NO_FATAL_FAILURES ( ValidateUnwritten ( kBlockSize * 6 , kBlockSize ) ) ; ASSERT_NO_FATAL_FAILURES ( ValidateWritten ( kBlockSize * 7 , kBlockSize ) ) ; }
This test attempts to write 2 copies of a single block to a partition that is 10 blocks wide.
This test attempts to write 2 copies of a single block to a partition that is 10 blocks wide .
// Erase Block 1 // Write Block 1 // Erase Block 2 // Write Block 2 // Erase Block 6 // Erase Block 7 // Write Block 7