2 This file is part of GNUnet.
3 Copyright (C) 2009, 2010, 2016 GNUnet e.V.
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.
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.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 * @file transport/test_transport_api.c
22 * @brief base test case for transport implementations
23 * @author Christian Grothoff
25 * This test case serves as a base for tcp, udp, and udp-nat
26 * transport test cases. Based on the executable being run
27 * the correct test case will be performed. Conservation of
31 #include "gnunet_transport_service.h"
32 #include "transport-testing.h"
35 * How long until we give up on transmitting the message?
37 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
39 static struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc;
43 notify_receive (void *cls,
44 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
45 const struct GNUNET_PeerIdentity *sender,
46 const struct GNUNET_MessageHeader *message)
49 char *ps = GNUNET_strdup (GNUNET_i2s (&receiver->id));
51 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
52 "Peer %u (`%s') received message of type %d and size %u size from peer %s!\n",
55 ntohs (message->type),
56 ntohs (message->size),
61 if ((GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE == ntohs (message->type)) &&
62 (GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE == ntohs (message->size)))
64 ccc->global_ret = GNUNET_OK;
65 GNUNET_SCHEDULER_shutdown ();
70 ccc->global_ret = GNUNET_SYSERR;
71 GNUNET_SCHEDULER_shutdown ();
79 * @param argv the argv argument from main()
80 * @param bi_directional should we try to establish connections
81 * in both directions simultaneously?
87 struct GNUNET_TRANSPORT_TESTING_SendClosure sc = {
90 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = {
91 .connect_continuation = &GNUNET_TRANSPORT_TESTING_large_send,
92 .connect_continuation_cls = &sc,
93 .config_file = "test_transport_api_data.conf",
94 .rec = ¬ify_receive,
95 .nc = &GNUNET_TRANSPORT_TESTING_log_connect,
96 .nd = &GNUNET_TRANSPORT_TESTING_log_disconnect,
98 .bi_directional = bi_directional
104 GNUNET_TRANSPORT_TESTING_main (2,
105 &GNUNET_TRANSPORT_TESTING_connect_check,
116 if ( (0 != test (argv,
124 /* end of test_transport_api.c */