blob: ee277bbd939b201f75580b4fad70942d47dde864 [file] [log] [blame]
David Sterba9888c342018-04-03 19:16:55 +02001/* SPDX-License-Identifier: GPL-2.0 */
Josef Bacikdc11dd52013-08-14 15:05:12 -04002/*
3 * Copyright (C) 2013 Fusion IO. All rights reserved.
Josef Bacikdc11dd52013-08-14 15:05:12 -04004 */
5
David Sterba9888c342018-04-03 19:16:55 +02006#ifndef BTRFS_TESTS_H
7#define BTRFS_TESTS_H
Josef Bacikdc11dd52013-08-14 15:05:12 -04008
9#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
Jeff Mahoney8632daa2016-06-20 13:16:40 -040010int btrfs_run_sanity_tests(void);
Josef Bacikdc11dd52013-08-14 15:05:12 -040011
David Sterba315b76b2018-05-17 00:00:44 +020012#define test_msg(fmt, ...) pr_info("BTRFS: selftest: " fmt "\n", ##__VA_ARGS__)
David Sterbaefd31fc2019-03-15 17:03:55 +010013#define test_err(fmt, ...) pr_err("BTRFS: selftest: %s:%d " fmt "\n", \
14 __FILE__, __LINE__, ##__VA_ARGS__)
Josef Bacikdc11dd52013-08-14 15:05:12 -040015
David Sterba703de422019-03-15 17:23:30 +010016#define test_std_err(index) test_err("%s", test_error[index])
17
18enum {
19 TEST_ALLOC_FS_INFO,
20 TEST_ALLOC_ROOT,
21 TEST_ALLOC_EXTENT_BUFFER,
22 TEST_ALLOC_PATH,
23 TEST_ALLOC_INODE,
24 TEST_ALLOC_BLOCK_GROUP,
25 TEST_ALLOC_EXTENT_MAP,
26};
27
28extern const char *test_error[];
29
Josef Bacikfaa2dbf2014-05-07 17:06:09 -040030struct btrfs_root;
Omar Sandoval7c55ee02015-09-29 20:50:36 -070031struct btrfs_trans_handle;
Josef Bacikfaa2dbf2014-05-07 17:06:09 -040032
Feifei Xub9ef22d2016-06-01 19:18:25 +080033int btrfs_test_extent_buffer_operations(u32 sectorsize, u32 nodesize);
Jeff Mahoney8632daa2016-06-20 13:16:40 -040034int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize);
Feifei Xub9ef22d2016-06-01 19:18:25 +080035int btrfs_test_extent_io(u32 sectorsize, u32 nodesize);
36int btrfs_test_inodes(u32 sectorsize, u32 nodesize);
37int btrfs_test_qgroups(u32 sectorsize, u32 nodesize);
38int btrfs_test_free_space_tree(u32 sectorsize, u32 nodesize);
Liu Bo72b28072018-01-05 12:51:12 -070039int btrfs_test_extent_map(void);
Josef Bacik294e30f2013-10-09 12:00:56 -040040struct inode *btrfs_new_test_inode(void);
Jeff Mahoneyda170662016-06-15 09:22:56 -040041struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize);
Jeff Mahoney7c0260e2016-06-20 14:14:09 -040042void btrfs_free_dummy_fs_info(struct btrfs_fs_info *fs_info);
Josef Bacikfaa2dbf2014-05-07 17:06:09 -040043void btrfs_free_dummy_root(struct btrfs_root *root);
Omar Sandoval7c55ee02015-09-29 20:50:36 -070044struct btrfs_block_group_cache *
Jeff Mahoneyda170662016-06-15 09:22:56 -040045btrfs_alloc_dummy_block_group(struct btrfs_fs_info *fs_info, unsigned long length);
Omar Sandoval7c55ee02015-09-29 20:50:36 -070046void btrfs_free_dummy_block_group(struct btrfs_block_group_cache *cache);
Nikolay Borisov483bce02018-05-10 15:44:40 +030047void btrfs_init_dummy_trans(struct btrfs_trans_handle *trans,
48 struct btrfs_fs_info *fs_info);
Josef Bacikdc11dd52013-08-14 15:05:12 -040049#else
Jeff Mahoney8632daa2016-06-20 13:16:40 -040050static inline int btrfs_run_sanity_tests(void)
Omar Sandoval7c55ee02015-09-29 20:50:36 -070051{
52 return 0;
53}
Josef Bacikdc11dd52013-08-14 15:05:12 -040054#endif
55
56#endif