]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/filestore/TestFileStore.cc
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / test / filestore / TestFileStore.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
7 *
8 * Author: Loic Dachary <loic@dachary.org>
9 *
10 * This is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License version 2.1, as published by the Free Software
13 * Foundation. See file COPYING.
14 *
15 */
16
17 #include "common/ceph_argparse.h"
18 #include "global/global_init.h"
19 #include "os/filestore/FileStore.h"
20 #include <gtest/gtest.h>
21
22 class TestFileStore {
23 public:
24 static void create_backend(FileStore &fs, long f_type) {
25 fs.create_backend(f_type);
26 }
27 };
28
29 TEST(FileStore, create)
30 {
31 {
32 map<string,string> pm;
33 FileStore fs(g_ceph_context, "a", "b");
34 TestFileStore::create_backend(fs, 0);
35 fs.collect_metadata(&pm);
36 ASSERT_EQ(pm["filestore_backend"], "generic");
37 }
38 #if defined(__linux__)
39 {
40 map<string,string> pm;
41 FileStore fs(g_ceph_context, "a", "b");
42 TestFileStore::create_backend(fs, BTRFS_SUPER_MAGIC);
43 fs.collect_metadata(&pm);
44 ASSERT_EQ(pm["filestore_backend"], "btrfs");
45 }
46 # ifdef HAVE_LIBXFS
47 {
48 map<string,string> pm;
49 FileStore fs(g_ceph_context, "a", "b");
50 TestFileStore::create_backend(fs, XFS_SUPER_MAGIC);
51 fs.collect_metadata(&pm);
52 ASSERT_EQ(pm["filestore_backend"], "xfs");
53 }
54 # endif
55 #endif
56 #ifdef HAVE_LIBZFS
57 {
58 map<string,string> pm;
59 FileStore fs("a", "b");
60 TestFileStore::create_backend(fs, ZFS_SUPER_MAGIC);
61 fs.collect_metadata(&pm);
62 ASSERT_EQ(pm["filestore_backend"], "zfs");
63 }
64 #endif
65 }
66
67 int main(int argc, char **argv) {
68 vector<const char*> args;
69 argv_to_vec(argc, (const char **)argv, args);
70
71 auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
72 CODE_ENVIRONMENT_UTILITY, 0);
73 common_init_finish(g_ceph_context);
74 g_ceph_context->_conf->set_val("osd_journal_size", "100");
75 g_ceph_context->_conf->apply_changes(NULL);
76
77 ::testing::InitGoogleTest(&argc, argv);
78 return RUN_ALL_TESTS();
79 }
80
81 /*
82 * Local Variables:
83 * compile-command: "cd ../.. ; make ceph_test_filestore &&
84 * ./ceph_test_filestore \
85 * --gtest_filter=*.* --log-to-stderr=true --debug-filestore=20
86 * "
87 * End:
88 */