]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/filestore/TestFileStore.cc
import quincy beta 17.1.0
[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 using namespace std;
23
24 class TestFileStore {
25 public:
26 static void create_backend(FileStore &fs, unsigned long f_type) {
27 fs.create_backend(f_type);
28 }
29 };
30
31 TEST(FileStore, create)
32 {
33 {
34 map<string,string> pm;
35 FileStore fs(g_ceph_context, "a", "b");
36 TestFileStore::create_backend(fs, 0);
37 fs.collect_metadata(&pm);
38 ASSERT_EQ(pm["filestore_backend"], "generic");
39 }
40 #if defined(__linux__)
41 {
42 map<string,string> pm;
43 FileStore fs(g_ceph_context, "a", "b");
44 TestFileStore::create_backend(fs, BTRFS_SUPER_MAGIC);
45 fs.collect_metadata(&pm);
46 ASSERT_EQ(pm["filestore_backend"], "btrfs");
47 }
48 # ifdef HAVE_LIBXFS
49 {
50 map<string,string> pm;
51 FileStore fs(g_ceph_context, "a", "b");
52 TestFileStore::create_backend(fs, XFS_SUPER_MAGIC);
53 fs.collect_metadata(&pm);
54 ASSERT_EQ(pm["filestore_backend"], "xfs");
55 }
56 # endif
57 #endif
58 #ifdef HAVE_LIBZFS
59 {
60 map<string,string> pm;
61 FileStore fs("a", "b");
62 TestFileStore::create_backend(fs, ZFS_SUPER_MAGIC);
63 fs.collect_metadata(&pm);
64 ASSERT_EQ(pm["filestore_backend"], "zfs");
65 }
66 #endif
67 }
68
69 int main(int argc, char **argv) {
70 auto args = argv_to_vec(argc, argv);
71
72 auto cct = global_init(nullptr, args, CEPH_ENTITY_TYPE_CLIENT,
73 CODE_ENVIRONMENT_UTILITY,
74 CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
75 common_init_finish(g_ceph_context);
76 g_ceph_context->_conf.set_val("osd_journal_size", "100");
77 g_ceph_context->_conf.apply_changes(NULL);
78
79 ::testing::InitGoogleTest(&argc, argv);
80 return RUN_ALL_TESTS();
81 }
82
83 /*
84 * Local Variables:
85 * compile-command: "cd ../.. ; make ceph_test_filestore &&
86 * ./ceph_test_filestore \
87 * --gtest_filter=*.* --log-to-stderr=true --debug-filestore=20
88 * "
89 * End:
90 */