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>
26 static void create_backend(FileStore
&fs
, unsigned long f_type
) {
27 fs
.create_backend(f_type
);
31 TEST(FileStore
, create
)
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");
40 #if defined(__linux__)
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");
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");
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");
69 int main(int argc
, char **argv
) {
70 auto args
= argv_to_vec(argc
, argv
);
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
);
79 ::testing::InitGoogleTest(&argc
, argv
);
80 return RUN_ALL_TESTS();
85 * compile-command: "cd ../.. ; make ceph_test_filestore &&
86 * ./ceph_test_filestore \
87 * --gtest_filter=*.* --log-to-stderr=true --debug-filestore=20