]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/test_features.cc
import quincy beta 17.1.0
[ceph.git] / 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 "common/ceph_releases.h"
8 #include "common/ceph_strings.h"
9 #include "global/global_context.h"
10 #include "gtest/gtest.h"
11 #include "include/ceph_features.h"
12
13 using namespace std;
14
15 TEST(features, release_features)
16 {
17 for (int r = 1; r < CEPH_RELEASE_MAX; ++r) {
18 const char *name = ceph_release_name(r);
19 ASSERT_NE(string("unknown"), name);
20 ASSERT_EQ(ceph_release_t{static_cast<uint8_t>(r)},
21 ceph_release_from_name(name));
22 uint64_t features = ceph_release_features(r);
23 int rr = ceph_release_from_features(features);
24 cout << r << " " << name << " features 0x" << std::hex << features
25 << std::dec << " looks like " << ceph_release_name(rr) << std::endl;
26 EXPECT_LE(rr, r);
27 }
28 }
29
30 TEST(features, release_from_features) {
31 ASSERT_EQ(CEPH_RELEASE_JEWEL, ceph_release_from_features(575862587619852283));
32 ASSERT_EQ(CEPH_RELEASE_LUMINOUS,
33 ceph_release_from_features(1152323339925389307));
34 }
35
36 int main(int argc, char **argv)
37 {
38 auto args = argv_to_vec(argc, argv);
39
40 auto cct = global_init(nullptr, args, CEPH_ENTITY_TYPE_CLIENT,
41 CODE_ENVIRONMENT_UTILITY,
42 CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
43 common_init_finish(g_ceph_context);
44
45 ::testing::InitGoogleTest(&argc, argv);
46 return RUN_ALL_TESTS();
47 }