summaryrefslogtreecommitdiff
path: root/fs/btrfs/tests
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2019-03-15 18:41:06 +0100
committerDavid Sterba <dsterba@suse.com>2019-04-29 19:02:27 +0200
commite71f2e17e8c9f9d4cf51a1ade535d65670d93c72 (patch)
tree1f97ce054790ff18f74361342483a0d3671ebd95 /fs/btrfs/tests
parentd7de4b0864dd8ba844faf40771104e71bbbd129e (diff)
downloadlwn-e71f2e17e8c9f9d4cf51a1ade535d65670d93c72.tar.gz
lwn-e71f2e17e8c9f9d4cf51a1ade535d65670d93c72.zip
btrfs: tests: return errors from extent map test case 2
Replace asserts with error messages and return errors. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/tests')
-rw-r--r--fs/btrfs/tests/extent-map-tests.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/fs/btrfs/tests/extent-map-tests.c b/fs/btrfs/tests/extent-map-tests.c
index 320c2842347c..d56d03d6b781 100644
--- a/fs/btrfs/tests/extent-map-tests.c
+++ b/fs/btrfs/tests/extent-map-tests.c
@@ -143,7 +143,10 @@ static int test_case_2(struct btrfs_fs_info *fs_info,
em->block_start = EXTENT_MAP_INLINE;
em->block_len = (u64)-1;
ret = add_extent_mapping(em_tree, em, 0);
- ASSERT(ret == 0);
+ if (ret < 0) {
+ test_err("cannot add extent range [0, 1K)");
+ goto out;
+ }
free_extent_map(em);
/* Add [4K, 4K) following [0, 1K) */
@@ -158,7 +161,10 @@ static int test_case_2(struct btrfs_fs_info *fs_info,
em->block_start = SZ_4K;
em->block_len = SZ_4K;
ret = add_extent_mapping(em_tree, em, 0);
- ASSERT(ret == 0);
+ if (ret < 0) {
+ test_err("cannot add extent range [4K, 8K)");
+ goto out;
+ }
free_extent_map(em);
em = alloc_extent_map();
@@ -173,19 +179,21 @@ static int test_case_2(struct btrfs_fs_info *fs_info,
em->block_start = EXTENT_MAP_INLINE;
em->block_len = (u64)-1;
ret = btrfs_add_extent_mapping(fs_info, em_tree, &em, em->start, em->len);
- if (ret)
+ if (ret) {
test_err("case2 [0 1K]: ret %d", ret);
+ goto out;
+ }
if (em &&
(em->start != 0 || extent_map_end(em) != SZ_1K ||
- em->block_start != EXTENT_MAP_INLINE || em->block_len != (u64)-1))
+ em->block_start != EXTENT_MAP_INLINE || em->block_len != (u64)-1)) {
test_err(
"case2 [0 1K]: ret %d return a wrong em (start %llu len %llu block_start %llu block_len %llu",
ret, em->start, em->len, em->block_start,
em->block_len);
+ ret = -EINVAL;
+ }
free_extent_map(em);
- ret = 0;
out:
- /* free memory */
free_extent_map_tree(em_tree);
return ret;