diff options
author | Sage Weil <sage@newdream.net> | 2012-05-02 15:13:20 -0700 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2012-05-02 15:13:20 -0700 |
commit | 728463794b81ad4645f3894e18fcee3ce6d4292c (patch) | |
tree | 9291d07443a8b095746dca6b8f68df236681cf21 | |
parent | 695d3775c2bf1144325e5d3a3e61e5138f488e56 (diff) | |
download | ceph-728463794b81ad4645f3894e18fcee3ce6d4292c.tar.gz |
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 <sage@newdream.net>
-rw-r--r-- | src/test/encoding/ceph_dencoder.cc | 9 | ||||
-rw-r--r-- | 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 ae9535d0423..68d1ca8ae0a 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 T> class DencoderImpl : public Dencoder { T* m_object; list<T*> 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<t>; +#define TYPEWITHSTRAYDATA(t) dencoders[T_STRINGIFY(t)] = new DencoderImpl<t>(true); #define MESSAGE(t) dencoders[T_STRINGIFY(t)] = new MessageDencoderImpl<t>; #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 5b50147c520..45fe618faf1 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) |