[functional-tests] a few more bcache tests

This commit is contained in:
Joe Thornber 2017-09-08 09:20:16 +01:00
parent 3f8add4334
commit 3b7320cd84
2 changed files with 34 additions and 1 deletions

View File

@ -34,5 +34,37 @@
(with-bcache (cache md 16)
(with-block (b cache 0 (get-flags))
#f))))
(define-scenario (bcache write-ref)
"get a write-ref on a block"
(with-empty-metadata (md 16)
(with-bcache (cache md 16)
(with-block (b cache 0 (get-flags dirty))
#f))))
(define-scenario (bcache zero-ref)
"get a write-ref on a block"
(with-empty-metadata (md 16)
(with-bcache (cache md 16)
(with-block (b cache 0 (get-flags zero))
#f))))
(define-scenario (bcache multiple-refs-to-same-block)
"the same block can be held multiple times"
(with-empty-metadata (md 16)
(with-bcache (cache md 16)
(with-block (b cache 0 (get-flags))
(with-block (b cache 0 (get-flags))
(with-block (b cache 0 (get-flags))
#f))))))
(define-scenario (bcache multiple-blocks)
"multiple blocks can be held at once"
(with-empty-metadata (md 16)
(with-bcache (cache md 16)
(with-block (b cache 0 (get-flags))
(with-block (b cache 1 (get-flags))
(with-block (b cache 2 (get-flags))
#f))))))
)

View File

@ -707,7 +707,8 @@ struct bcache *bcache_simple(const char *path, unsigned nr_cache_blocks)
}
s = info.st_size;
cache = bcache_create(fd, MD_BLOCK_SIZE >> SECTOR_SHIFT, s / MD_BLOCK_SIZE, nr_cache_blocks);
cache = bcache_create(fd, MD_BLOCK_SIZE >> SECTOR_SHIFT,
s / MD_BLOCK_SIZE, nr_cache_blocks);
if (!cache)
close(fd);