Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / test / test_features.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 #include <stdio.h>
4
5 #include "global/global_init.h"
6 #include "common/ceph_argparse.h"
7 #include "global/global_context.h"
8 #include "gtest/gtest.h"
9 #include "include/ceph_features.h"
10 #include "include/rados.h"
11
12
13 TEST(features, release_features)
14 {
15   for (int r = 1; r < CEPH_RELEASE_MAX; ++r) {
16     const char *name = ceph_release_name(r);
17     ASSERT_NE(string("unknown"), name);
18     ASSERT_EQ(r, ceph_release_from_name(name));
19     uint64_t features = ceph_release_features(r);
20     int rr = ceph_release_from_features(features);
21     cout << r << " " << name << " features 0x" << std::hex << features
22          << std::dec << " looks like " << ceph_release_name(rr) << std::endl;
23     EXPECT_LE(rr, r);
24   }
25 }
26
27 TEST(features, release_from_features) {
28   ASSERT_EQ(CEPH_RELEASE_JEWEL, ceph_release_from_features(575862587619852283));
29   ASSERT_EQ(CEPH_RELEASE_LUMINOUS,
30             ceph_release_from_features(1152323339925389307));
31 }
32
33 int main(int argc, char **argv)
34 {
35   vector<const char*> args;
36   argv_to_vec(argc, (const char **)argv, args);
37
38   auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
39                          CODE_ENVIRONMENT_UTILITY, 0);
40   common_init_finish(g_ceph_context);
41
42   ::testing::InitGoogleTest(&argc, argv);
43   return RUN_ALL_TESTS();
44 }