pending testcase for fragementation
authorJi Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96>
Thu, 4 Mar 2010 22:34:46 +0000 (22:34 +0000)
committerJi Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96>
Thu, 4 Mar 2010 22:34:46 +0000 (22:34 +0000)
src/fragmentation/test_frag_ji.c [new file with mode: 0644]

diff --git a/src/fragmentation/test_frag_ji.c b/src/fragmentation/test_frag_ji.c
new file mode 100644 (file)
index 0000000..8cba654
--- /dev/null
@@ -0,0 +1,38 @@
+#include "platform.h"\r
+#include "gnunet_fragmentation_lib.h"\r
+\r
+void message_proc1(void *cls, const struct GNUNET_MessageHeader * msg){\r
+\r
+       struct GNUNET_MessageHeader * originalMsg = (struct GNUNET_MessageHeader *)cls;\r
+       if(originalMsg->size != msg->size){\r
+                       fprintf(stderr, "the received message has the different size with the sent one!");\r
+               }\r
+       if(originalMsg->type != msg->type){\r
+                       fprintf(stderr, "the received message has the different type with the sent one!");\r
+               }\r
+       if(memcmp(&originalMsg[1], &msg[1], originalMsg->size - sizeof(struct GNUNET_MessageHeader))){\r
+                       fprintf(stderr, "the received message is not the sent one!");\r
+       }\r
+\r
+}\r
+\r
+void message_proc2(void *cls, const struct GNUNET_MessageHeader * msg){\r
+       struct GNUNET_FRAGMENT_Context * ctx = (struct GNUNET_FRAGMENT_Context * )cls;\r
+       struct Fragment *frag;\r
+       struct GNUNET_PeerIdentity sender;\r
+       GNUNET_FRAGMENT_process(ctx, &sender, msg);\r
+}\r
+\r
+int\r
+main(int argc, char * argv[]){\r
+\r
+       struct GNUNET_FRAGMENT_Context * ctx;\r
+       struct GNUNET_MessageHeader *msg;\r
+       ctx = GNUNET_FRAGMENT_context_create(stats, message_proc1, msg);\r
+       msg->size = sizeof(struct GNUNET_MessageHeader)+2*mtu;\r
+       msg->type = GNUNET_MESSAGE_TYPE_HELLO;\r
+       memcpy(&msg[1], 5, 2*mtu);\r
+       GNUNET_FRAGMENT_fragment(msg, mtu, message_proc2, ctx);\r
+\r
+       return 0;\r
+}\r