aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_network_transmit_cancel.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/test_network_transmit_cancel.c')
-rw-r--r--src/util/test_network_transmit_cancel.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/util/test_network_transmit_cancel.c b/src/util/test_network_transmit_cancel.c
new file mode 100644
index 000000000..29732d202
--- /dev/null
+++ b/src/util/test_network_transmit_cancel.c
@@ -0,0 +1,97 @@
1/*
2 This file is part of GNUnet.
3 (C) 2009 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 2, 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_network_transmit_cancel.c
22 * @brief tests for network.c
23 */
24#include "platform.h"
25#include "gnunet_common.h"
26#include "gnunet_network_lib.h"
27#include "gnunet_scheduler_lib.h"
28#include "gnunet_time_lib.h"
29
30#define VERBOSE GNUNET_YES
31
32#define PORT 12435
33
34
35static size_t
36not_run (void *cls, size_t size, void *buf)
37{
38 GNUNET_assert (0);
39 return 0;
40}
41
42
43static void
44task_transmit_cancel (void *cls,
45 const struct GNUNET_SCHEDULER_TaskContext *tc)
46{
47 int *ok = cls;
48 struct GNUNET_NETWORK_TransmitHandle *th;
49 struct GNUNET_NETWORK_SocketHandle *csock;
50
51 csock = GNUNET_NETWORK_socket_create_from_connect (tc->sched,
52 "localhost", PORT, 1024);
53 GNUNET_assert (csock != NULL);
54 th = GNUNET_NETWORK_notify_transmit_ready (csock,
55 12,
56 GNUNET_TIME_UNIT_MINUTES,
57 &not_run, cls);
58 GNUNET_NETWORK_notify_transmit_ready_cancel (th);
59 GNUNET_NETWORK_socket_destroy (csock);
60 *ok = 0;
61}
62
63
64
65
66/**
67 * Main method, starts scheduler with task_timeout.
68 */
69static int
70check_transmit_cancel ()
71{
72 int ok;
73
74 ok = 1;
75 GNUNET_SCHEDULER_run (&task_transmit_cancel, &ok);
76 return ok;
77}
78
79
80int
81main (int argc, char *argv[])
82{
83 int ret = 0;
84
85 GNUNET_log_setup ("test_network_transmit_cancel",
86#if VERBOSE
87 "DEBUG",
88#else
89 "WARNING",
90#endif
91 NULL);
92 ret += check_transmit_cancel ();
93
94 return ret;
95}
96
97/* end of test_network_transmit_cancel.c */