David Sterba | 9888c34 | 2018-04-03 19:16:55 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Josef Bacik | dc11dd5 | 2013-08-14 15:05:12 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2013 Fusion IO. All rights reserved. |
Josef Bacik | dc11dd5 | 2013-08-14 15:05:12 -0400 | [diff] [blame] | 4 | */ |
| 5 | |
David Sterba | 9888c34 | 2018-04-03 19:16:55 +0200 | [diff] [blame] | 6 | #ifndef BTRFS_TESTS_H |
| 7 | #define BTRFS_TESTS_H |
Josef Bacik | dc11dd5 | 2013-08-14 15:05:12 -0400 | [diff] [blame] | 8 | |
| 9 | #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS |
Jeff Mahoney | 8632daa | 2016-06-20 13:16:40 -0400 | [diff] [blame] | 10 | int btrfs_run_sanity_tests(void); |
Josef Bacik | dc11dd5 | 2013-08-14 15:05:12 -0400 | [diff] [blame] | 11 | |
David Sterba | 315b76b | 2018-05-17 00:00:44 +0200 | [diff] [blame] | 12 | #define test_msg(fmt, ...) pr_info("BTRFS: selftest: " fmt "\n", ##__VA_ARGS__) |
David Sterba | efd31fc | 2019-03-15 17:03:55 +0100 | [diff] [blame] | 13 | #define test_err(fmt, ...) pr_err("BTRFS: selftest: %s:%d " fmt "\n", \ |
| 14 | __FILE__, __LINE__, ##__VA_ARGS__) |
Josef Bacik | dc11dd5 | 2013-08-14 15:05:12 -0400 | [diff] [blame] | 15 | |
David Sterba | 703de42 | 2019-03-15 17:23:30 +0100 | [diff] [blame] | 16 | #define test_std_err(index) test_err("%s", test_error[index]) |
| 17 | |
| 18 | enum { |
| 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 | |
| 28 | extern const char *test_error[]; |
| 29 | |
Josef Bacik | faa2dbf | 2014-05-07 17:06:09 -0400 | [diff] [blame] | 30 | struct btrfs_root; |
Omar Sandoval | 7c55ee0 | 2015-09-29 20:50:36 -0700 | [diff] [blame] | 31 | struct btrfs_trans_handle; |
Josef Bacik | faa2dbf | 2014-05-07 17:06:09 -0400 | [diff] [blame] | 32 | |
Feifei Xu | b9ef22d | 2016-06-01 19:18:25 +0800 | [diff] [blame] | 33 | int btrfs_test_extent_buffer_operations(u32 sectorsize, u32 nodesize); |
Jeff Mahoney | 8632daa | 2016-06-20 13:16:40 -0400 | [diff] [blame] | 34 | int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize); |
Feifei Xu | b9ef22d | 2016-06-01 19:18:25 +0800 | [diff] [blame] | 35 | int btrfs_test_extent_io(u32 sectorsize, u32 nodesize); |
| 36 | int btrfs_test_inodes(u32 sectorsize, u32 nodesize); |
| 37 | int btrfs_test_qgroups(u32 sectorsize, u32 nodesize); |
| 38 | int btrfs_test_free_space_tree(u32 sectorsize, u32 nodesize); |
Liu Bo | 72b2807 | 2018-01-05 12:51:12 -0700 | [diff] [blame] | 39 | int btrfs_test_extent_map(void); |
Josef Bacik | 294e30f | 2013-10-09 12:00:56 -0400 | [diff] [blame] | 40 | struct inode *btrfs_new_test_inode(void); |
Jeff Mahoney | da17066 | 2016-06-15 09:22:56 -0400 | [diff] [blame] | 41 | struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize); |
Jeff Mahoney | 7c0260e | 2016-06-20 14:14:09 -0400 | [diff] [blame] | 42 | void btrfs_free_dummy_fs_info(struct btrfs_fs_info *fs_info); |
Josef Bacik | faa2dbf | 2014-05-07 17:06:09 -0400 | [diff] [blame] | 43 | void btrfs_free_dummy_root(struct btrfs_root *root); |
Omar Sandoval | 7c55ee0 | 2015-09-29 20:50:36 -0700 | [diff] [blame] | 44 | struct btrfs_block_group_cache * |
Jeff Mahoney | da17066 | 2016-06-15 09:22:56 -0400 | [diff] [blame] | 45 | btrfs_alloc_dummy_block_group(struct btrfs_fs_info *fs_info, unsigned long length); |
Omar Sandoval | 7c55ee0 | 2015-09-29 20:50:36 -0700 | [diff] [blame] | 46 | void btrfs_free_dummy_block_group(struct btrfs_block_group_cache *cache); |
Nikolay Borisov | 483bce0 | 2018-05-10 15:44:40 +0300 | [diff] [blame] | 47 | void btrfs_init_dummy_trans(struct btrfs_trans_handle *trans, |
| 48 | struct btrfs_fs_info *fs_info); |
Josef Bacik | dc11dd5 | 2013-08-14 15:05:12 -0400 | [diff] [blame] | 49 | #else |
Jeff Mahoney | 8632daa | 2016-06-20 13:16:40 -0400 | [diff] [blame] | 50 | static inline int btrfs_run_sanity_tests(void) |
Omar Sandoval | 7c55ee0 | 2015-09-29 20:50:36 -0700 | [diff] [blame] | 51 | { |
| 52 | return 0; |
| 53 | } |
Josef Bacik | dc11dd5 | 2013-08-14 15:05:12 -0400 | [diff] [blame] | 54 | #endif |
| 55 | |
| 56 | #endif |