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 it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
16 * @file transport/test_transport_api.c
17 * @brief base test case for transport implementations
18 * @author Christian Grothoff
20 * This test case serves as a base for tcp, udp, and udp-nat
21 * transport test cases. Based on the executable being run
22 * the correct test case will be performed. Conservation of
26 #include "gnunet_transport_service.h"
27 #include "transport-testing.h"
30 * How long until we give up on transmitting the message?
32 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
34 static struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc;
38 notify_receive (void *cls,
39 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
40 const struct GNUNET_PeerIdentity *sender,
41 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
44 char *ps = GNUNET_strdup (GNUNET_i2s (&receiver->id));
46 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
47 "Peer %u (`%s') received message of type %d and size %u size from peer %s!\n",
50 ntohs (message->header.type),
51 ntohs (message->header.size),
56 if ((GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE == ntohs (message->header.type)) &&
57 (GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE == ntohs (message->header.size)))
59 ccc->global_ret = GNUNET_OK;
60 GNUNET_SCHEDULER_shutdown ();
65 ccc->global_ret = GNUNET_SYSERR;
66 GNUNET_SCHEDULER_shutdown ();
74 * @param argv the argv argument from main()
75 * @param bi_directional should we try to establish connections
76 * in both directions simultaneously?
82 struct GNUNET_TRANSPORT_TESTING_SendClosure sc = {
85 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = {
86 .connect_continuation = &GNUNET_TRANSPORT_TESTING_large_send,
87 .connect_continuation_cls = &sc,
88 .config_file = "test_transport_api_data.conf",
89 .rec = ¬ify_receive,
90 .nc = &GNUNET_TRANSPORT_TESTING_log_connect,
91 .nd = &GNUNET_TRANSPORT_TESTING_log_disconnect,
93 .bi_directional = bi_directional
99 GNUNET_TRANSPORT_TESTING_main (2,
100 &GNUNET_TRANSPORT_TESTING_connect_check,
111 if ( (0 != test (argv,
119 /* end of test_transport_api.c */