summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/test/encoding/ceph_dencoder.cc9
-rw-r--r--src/test/encoding/types.h4
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)