btrfs-tests.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2013 Fusion IO. All rights reserved.
  4. */
  5. #ifndef BTRFS_TESTS_H
  6. #define BTRFS_TESTS_H
  7. #include <linux/types.h>
  8. #include <linux/cleanup.h>
  9. #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
  10. int btrfs_run_sanity_tests(void);
  11. #define test_msg(fmt, ...) pr_info("BTRFS: selftest: " fmt "\n", ##__VA_ARGS__)
  12. #define test_err(fmt, ...) pr_err("BTRFS: selftest: %s:%d " fmt "\n", \
  13. __FILE__, __LINE__, ##__VA_ARGS__)
  14. #define test_std_err(index) test_err("%s", test_error[index])
  15. enum {
  16. TEST_ALLOC_FS_INFO,
  17. TEST_ALLOC_ROOT,
  18. TEST_ALLOC_EXTENT_BUFFER,
  19. TEST_ALLOC_PATH,
  20. TEST_ALLOC_INODE,
  21. TEST_ALLOC_BLOCK_GROUP,
  22. TEST_ALLOC_EXTENT_MAP,
  23. TEST_ALLOC_CHUNK_MAP,
  24. TEST_ALLOC_IO_CONTEXT,
  25. TEST_ALLOC_TRANSACTION,
  26. };
  27. extern const char *test_error[];
  28. struct btrfs_root;
  29. struct btrfs_trans_handle;
  30. struct btrfs_transaction;
  31. int btrfs_test_extent_buffer_operations(u32 sectorsize, u32 nodesize);
  32. int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize);
  33. int btrfs_test_extent_io(u32 sectorsize, u32 nodesize);
  34. int btrfs_test_inodes(u32 sectorsize, u32 nodesize);
  35. int btrfs_test_qgroups(u32 sectorsize, u32 nodesize);
  36. int btrfs_test_free_space_tree(u32 sectorsize, u32 nodesize);
  37. int btrfs_test_raid_stripe_tree(u32 sectorsize, u32 nodesize);
  38. int btrfs_test_extent_map(void);
  39. int btrfs_test_delayed_refs(u32 sectorsize, u32 nodesize);
  40. int btrfs_test_chunk_allocation(u32 sectorsize, u32 nodesize);
  41. struct inode *btrfs_new_test_inode(void);
  42. struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize);
  43. void btrfs_free_dummy_fs_info(struct btrfs_fs_info *fs_info);
  44. DEFINE_FREE(btrfs_free_dummy_fs_info, struct btrfs_fs_info *,
  45. btrfs_free_dummy_fs_info(_T))
  46. void btrfs_free_dummy_root(struct btrfs_root *root);
  47. struct btrfs_block_group *
  48. btrfs_alloc_dummy_block_group(struct btrfs_fs_info *fs_info, unsigned long length);
  49. void btrfs_free_dummy_block_group(struct btrfs_block_group *cache);
  50. DEFINE_FREE(btrfs_free_dummy_block_group, struct btrfs_block_group *,
  51. btrfs_free_dummy_block_group(_T));
  52. void btrfs_init_dummy_trans(struct btrfs_trans_handle *trans,
  53. struct btrfs_fs_info *fs_info);
  54. void btrfs_init_dummy_transaction(struct btrfs_transaction *trans, struct btrfs_fs_info *fs_info);
  55. struct btrfs_device *btrfs_alloc_dummy_device(struct btrfs_fs_info *fs_info);
  56. #else
  57. static inline int btrfs_run_sanity_tests(void)
  58. {
  59. return 0;
  60. }
  61. #endif
  62. #endif