def test_zeroout_end(loop_device): with util.open(loop_device, "r+") as f: ioutil.blkzeroout(f.fileno(), BLOCKSIZE * 2, BLOCKSIZE) with util.open(loop_device, "r") as f: buf = util.aligned_buffer(BLOCKSIZE * 3) with closing(buf): f.readinto(buf) assert buf[:-BLOCKSIZE] == b"x" * BLOCKSIZE * 2 assert buf[-BLOCKSIZE:] == b"\0" * BLOCKSIZE
def test_zeroout_start(loop_device): with directio.open(loop_device, "r+") as f: ioutil.blkzeroout(f.fileno(), 0, BLOCKSIZE) with directio.open(loop_device, "r") as f: buf = directio.aligned_buffer(BLOCKSIZE * 3) with closing(buf): f.readinto(buf) assert buf[:BLOCKSIZE] == b"\0" * BLOCKSIZE assert buf[BLOCKSIZE:] == b"x" * BLOCKSIZE * 2