X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Ftest%2Ffilestore%2FTestFileStore.cc;fp=src%2Fceph%2Fsrc%2Ftest%2Ffilestore%2FTestFileStore.cc;h=8cc6665394eb55f5664f6ca3ffd8177d1af9cd7f;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/test/filestore/TestFileStore.cc b/src/ceph/src/test/filestore/TestFileStore.cc new file mode 100644 index 0000000..8cc6665 --- /dev/null +++ b/src/ceph/src/test/filestore/TestFileStore.cc @@ -0,0 +1,88 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2014 Cloudwatt + * + * Author: Loic Dachary + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#include "common/ceph_argparse.h" +#include "global/global_init.h" +#include "os/filestore/FileStore.h" +#include + +class TestFileStore { +public: + static void create_backend(FileStore &fs, long f_type) { + fs.create_backend(f_type); + } +}; + +TEST(FileStore, create) +{ + { + map pm; + FileStore fs(g_ceph_context, "a", "b"); + TestFileStore::create_backend(fs, 0); + fs.collect_metadata(&pm); + ASSERT_EQ(pm["filestore_backend"], "generic"); + } +#if defined(__linux__) + { + map pm; + FileStore fs(g_ceph_context, "a", "b"); + TestFileStore::create_backend(fs, BTRFS_SUPER_MAGIC); + fs.collect_metadata(&pm); + ASSERT_EQ(pm["filestore_backend"], "btrfs"); + } +# ifdef HAVE_LIBXFS + { + map pm; + FileStore fs(g_ceph_context, "a", "b"); + TestFileStore::create_backend(fs, XFS_SUPER_MAGIC); + fs.collect_metadata(&pm); + ASSERT_EQ(pm["filestore_backend"], "xfs"); + } +# endif +#endif +#ifdef HAVE_LIBZFS + { + map pm; + FileStore fs("a", "b"); + TestFileStore::create_backend(fs, ZFS_SUPER_MAGIC); + fs.collect_metadata(&pm); + ASSERT_EQ(pm["filestore_backend"], "zfs"); + } +#endif +} + +int main(int argc, char **argv) { + vector args; + argv_to_vec(argc, (const char **)argv, args); + + auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_UTILITY, 0); + common_init_finish(g_ceph_context); + g_ceph_context->_conf->set_val("osd_journal_size", "100"); + g_ceph_context->_conf->apply_changes(NULL); + + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + +/* + * Local Variables: + * compile-command: "cd ../.. ; make ceph_test_filestore && + * ./ceph_test_filestore \ + * --gtest_filter=*.* --log-to-stderr=true --debug-filestore=20 + * " + * End: + */