From: Casey Bodley Date: Tue, 8 May 2018 17:52:59 +0000 (-0400) Subject: encoding: add test for ceph::coarse_real_time X-Git-Tag: v13.2.3~122^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=491a8945333279cd2a6001dafa241e4551617f7c;p=ceph.git encoding: add test for ceph::coarse_real_time Signed-off-by: Casey Bodley (cherry picked from commit e4030eab2a30459ee56ba4510f8233fe4937f77a) Conflicts: src/test/encoding/test_ceph_time.h src/test/encoding/types.h --- diff --git a/src/test/encoding/test_ceph_time.h b/src/test/encoding/test_ceph_time.h index 18f89314b7a..bfd250f98ff 100644 --- a/src/test/encoding/test_ceph_time.h +++ b/src/test/encoding/test_ceph_time.h @@ -8,11 +8,13 @@ #include "common/Formatter.h" // wrapper for ceph::real_time that implements the dencoder interface -class real_time_wrapper { - ceph::real_time t; +template +class time_point_wrapper { + using time_point = typename Clock::time_point; + time_point t; public: - real_time_wrapper() = default; - real_time_wrapper(const ceph::real_time& t) : t(t) {} + time_point_wrapper() = default; + time_point_wrapper(const time_point& t) : t(t) {} void encode(bufferlist& bl) const { using ceph::encode; @@ -23,14 +25,19 @@ class real_time_wrapper { decode(t, p); } void dump(Formatter* f) { - auto epoch_time = ceph::real_clock::to_time_t(t); + auto epoch_time = Clock::to_time_t(t); f->dump_string("time", std::ctime(&epoch_time)); } - static void generate_test_instances(std::list& ls) { + static void generate_test_instances(std::list& ls) { constexpr time_t t{455500800}; // Ghostbusters release date - ls.push_back(new real_time_wrapper(ceph::real_clock::from_time_t(t))); + ls.push_back(new time_point_wrapper(Clock::from_time_t(t))); } }; + +using real_time_wrapper = time_point_wrapper; WRITE_CLASS_ENCODER(real_time_wrapper) +using coarse_real_time_wrapper = time_point_wrapper; +WRITE_CLASS_ENCODER(coarse_real_time_wrapper) + #endif diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index 8e9e8f8e61a..d89ab36a392 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -16,6 +16,7 @@ TYPE(compressible_bloom_filter) #include "test_ceph_time.h" TYPE(real_time_wrapper) +TYPE(coarse_real_time_wrapper) #include "test_sstring.h" TYPE(sstring_wrapper)