From 728463794b81ad4645f3894e18fcee3ce6d4292c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 2 May 2012 15:13:20 -0700 Subject: [PATCH] ceph-dencoder: ignore trailing goop after OSDMap and OSDMap::Incremental All users pass around bufferlists and avoid encoding these structures inline, but the dencoder tests are picky. Disable that for these types so that we can add new fields without noise. Signed-off-by: Sage Weil --- src/test/encoding/ceph_dencoder.cc | 9 +++++++-- src/test/encoding/types.h | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/test/encoding/ceph_dencoder.cc b/src/test/encoding/ceph_dencoder.cc index ae9535d04239a..68d1ca8ae0a30 100644 --- a/src/test/encoding/ceph_dencoder.cc +++ b/src/test/encoding/ceph_dencoder.cc @@ -9,9 +9,11 @@ #include "msg/Message.h" #define TYPE(t) +#define TYPEWITHSTRAYDATA(t) #define MESSAGE(t) #include "types.h" #undef TYPE +#undef TYPEWITHSTRAYDATA #undef MESSAGE void usage(ostream &out) @@ -51,9 +53,10 @@ template class DencoderImpl : public Dencoder { T* m_object; list m_list; + bool stray_okay; public: - DencoderImpl() : m_object(new T) {} + DencoderImpl(bool stray_okay=false) : m_object(new T), stray_okay(stray_okay) {} string decode(bufferlist bl) { bufferlist::iterator p = bl.begin(); @@ -63,7 +66,7 @@ public: catch (buffer::error& e) { return e.what(); } - if (!p.end()) + if (!stray_okay && !p.end()) return "stray data at end of buffer"; return string(); } @@ -178,9 +181,11 @@ int main(int argc, const char **argv) #define T_STR(x) #x #define T_STRINGIFY(x) T_STR(x) #define TYPE(t) dencoders[T_STRINGIFY(t)] = new DencoderImpl; +#define TYPEWITHSTRAYDATA(t) dencoders[T_STRINGIFY(t)] = new DencoderImpl(true); #define MESSAGE(t) dencoders[T_STRINGIFY(t)] = new MessageDencoderImpl; #include "types.h" #undef TYPE +#undef TYPEWITHSTRAYDATA #undef T_STR #undef T_STRRINGIFY diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index 5b50147c52070..45fe618faf184 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -19,8 +19,8 @@ TYPE(entity_addr_t) #include "osd/OSDMap.h" TYPE(osd_info_t) -TYPE(OSDMap) -TYPE(OSDMap::Incremental) +TYPEWITHSTRAYDATA(OSDMap) +TYPEWITHSTRAYDATA(OSDMap::Incremental) #include "crush/CrushWrapper.h" TYPE(CrushWrapper) -- 2.39.5