]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-dencoder: ignore trailing goop after OSDMap and OSDMap::Incremental
authorSage Weil <sage@newdream.net>
Wed, 2 May 2012 22:13:20 +0000 (15:13 -0700)
committerSage Weil <sage@newdream.net>
Wed, 2 May 2012 22:13:20 +0000 (15:13 -0700)
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>
src/test/encoding/ceph_dencoder.cc
src/test/encoding/types.h

index ae9535d04239a17f50e04258a6c5742279ae0a76..68d1ca8ae0a303fac4c2deab5d3f4d3d4a75293f 100644 (file)
@@ -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
 
index 5b50147c5207022dff0d7ed0c06699418a6fdf33..45fe618faf18421cdd9073580f703c96edeeac61 100644 (file)
@@ -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)