]> git.proxmox.com Git - ceph.git/blame - ceph/src/test/filestore/TestFileStore.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / test / filestore / TestFileStore.cc
CommitLineData
7c673cae
FG
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
22class TestFileStore {
23public:
11fdf7f2 24 static void create_backend(FileStore &fs, unsigned long f_type) {
7c673cae
FG
25 fs.create_backend(f_type);
26 }
27};
28
29TEST(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
67int 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,
11fdf7f2
TL
72 CODE_ENVIRONMENT_UTILITY,
73 CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
7c673cae 74 common_init_finish(g_ceph_context);
11fdf7f2
TL
75 g_ceph_context->_conf.set_val("osd_journal_size", "100");
76 g_ceph_context->_conf.apply_changes(NULL);
7c673cae
FG
77
78 ::testing::InitGoogleTest(&argc, argv);
79 return RUN_ALL_TESTS();
80}
81
82/*
83 * Local Variables:
84 * compile-command: "cd ../.. ; make ceph_test_filestore &&
85 * ./ceph_test_filestore \
86 * --gtest_filter=*.* --log-to-stderr=true --debug-filestore=20
87 * "
88 * End:
89 */