1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
8 * Author: Loic Dachary <loic@dachary.org>
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.
17 #include "common/ceph_argparse.h"
18 #include "global/global_init.h"
19 #include "os/filestore/FileStore.h"
20 #include <gtest/gtest.h>
24 static void create_backend(FileStore &fs, long f_type) {
25 fs.create_backend(f_type);
29 TEST(FileStore, create)
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");
38 #if defined(__linux__)
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");
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");
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");
67 int main(int argc, char **argv) {
68 vector<const char*> args;
69 argv_to_vec(argc, (const char **)argv, args);
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);
77 ::testing::InitGoogleTest(&argc, argv);
78 return RUN_ALL_TESTS();
83 * compile-command: "cd ../.. ; make ceph_test_filestore &&
84 * ./ceph_test_filestore \
85 * --gtest_filter=*.* --log-to-stderr=true --debug-filestore=20