- test for external iterator
[oweals/gnunet.git] / src / util / test_server_mst_interrupt.c
1 /*
2      This file is part of GNUnet.
3      (C) 2009, 2010 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20 /**
21  * @file util/test_server_mst_interrupt.c
22  * @brief test for interrupt message processing in server_mst.c
23  */
24 #include "platform.h"
25 #include "gnunet_common.h"
26 #include "gnunet_protocols.h"
27 #include "gnunet_client_lib.h"
28 #include "gnunet_scheduler_lib.h"
29 #include "gnunet_server_lib.h"
30 #include "gnunet_time_lib.h"
31
32 static struct GNUNET_SERVER_MessageStreamTokenizer * mst;
33
34
35 /* Callback destroying mst with data in buffer */
36 static int
37 mst_cb (void *cls, void *client,
38         const struct GNUNET_MessageHeader * message)
39 {
40   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MST gave me message, destroying\n");
41   GNUNET_SERVER_mst_destroy (mst);
42   return GNUNET_SYSERR;
43 }
44
45
46 int
47 main (int argc, char *argv[])
48 {
49   struct GNUNET_PeerIdentity id;
50   struct GNUNET_MessageHeader msg[2];
51
52   GNUNET_log_setup ("test_server_mst_interrupt", "WARNING", NULL);
53   memset (&id, 0, sizeof (id));
54   msg[0].size = htons (sizeof (msg));
55   msg[0].type = htons (sizeof (GNUNET_MESSAGE_TYPE_DUMMY));
56   mst = GNUNET_SERVER_mst_create(mst_cb, NULL);
57   GNUNET_SERVER_mst_receive (mst, &id,  
58                              (const char *) &msg, 2 * sizeof (msg), 
59                              GNUNET_NO, GNUNET_NO);
60   /* If we reach this line, it did not crash */
61   return 0;
62 }
63
64 /* end of test_server_mst_interrupt.c */