From 3b7320cd84f55911194cd272935835aae8a2c77f Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Fri, 8 Sep 2017 09:20:16 +0100 Subject: [PATCH] [functional-tests] a few more bcache tests --- functional-tests/bcache/bcache-tests.scm | 32 ++++++++++++++++++++++++ functional-tests/bcache/bcache.c | 3 ++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/functional-tests/bcache/bcache-tests.scm b/functional-tests/bcache/bcache-tests.scm index 997f4dd..b2be812 100644 --- a/functional-tests/bcache/bcache-tests.scm +++ b/functional-tests/bcache/bcache-tests.scm @@ -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)))))) ) diff --git a/functional-tests/bcache/bcache.c b/functional-tests/bcache/bcache.c index d8f172b..ca1921d 100644 --- a/functional-tests/bcache/bcache.c +++ b/functional-tests/bcache/bcache.c @@ -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);