diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/test/test_features.cc | |
parent | Initial commit. (diff) | |
download | ceph-upstream/16.2.11+ds.tar.xz ceph-upstream/16.2.11+ds.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/test_features.cc')
-rw-r--r-- | src/test/test_features.cc | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/test/test_features.cc b/src/test/test_features.cc new file mode 100644 index 000000000..bfd2c537c --- /dev/null +++ b/src/test/test_features.cc @@ -0,0 +1,47 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +#include <stdio.h> + +#include "global/global_init.h" +#include "common/ceph_argparse.h" +#include "common/ceph_releases.h" +#include "common/ceph_strings.h" +#include "global/global_context.h" +#include "gtest/gtest.h" +#include "include/ceph_features.h" + + +TEST(features, release_features) +{ + for (int r = 1; r < CEPH_RELEASE_MAX; ++r) { + const char *name = ceph_release_name(r); + ASSERT_NE(string("unknown"), name); + ASSERT_EQ(ceph_release_t{static_cast<uint8_t>(r)}, + ceph_release_from_name(name)); + uint64_t features = ceph_release_features(r); + int rr = ceph_release_from_features(features); + cout << r << " " << name << " features 0x" << std::hex << features + << std::dec << " looks like " << ceph_release_name(rr) << std::endl; + EXPECT_LE(rr, r); + } +} + +TEST(features, release_from_features) { + ASSERT_EQ(CEPH_RELEASE_JEWEL, ceph_release_from_features(575862587619852283)); + ASSERT_EQ(CEPH_RELEASE_LUMINOUS, + ceph_release_from_features(1152323339925389307)); +} + +int main(int argc, char **argv) +{ + vector<const char*> args; + argv_to_vec(argc, (const char **)argv, args); + + auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_UTILITY, + CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); + common_init_finish(g_ceph_context); + + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} |