summaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_api.c')
-rw-r--r--src/transport/test_transport_api.c78
1 files changed, 39 insertions, 39 deletions
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index 0b458a317..e7d2e5a7e 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20/** 20/**
21 * @file transport/test_transport_api.c 21 * @file transport/test_transport_api.c
22 * @brief base test case for transport implementations 22 * @brief base test case for transport implementations
@@ -34,42 +34,42 @@
34/** 34/**
35 * How long until we give up on transmitting the message? 35 * How long until we give up on transmitting the message?
36 */ 36 */
37#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) 37#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)
38 38
39static struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc; 39static struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc;
40 40
41 41
42static void 42static void
43notify_receive (void *cls, 43notify_receive(void *cls,
44 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, 44 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
45 const struct GNUNET_PeerIdentity *sender, 45 const struct GNUNET_PeerIdentity *sender,
46 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) 46 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
47{ 47{
48 { 48 {
49 char *ps = GNUNET_strdup (GNUNET_i2s (&receiver->id)); 49 char *ps = GNUNET_strdup(GNUNET_i2s(&receiver->id));
50
51 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
52 "Peer %u (`%s') received message of type %d and size %u size from peer %s!\n",
53 receiver->no,
54 ps,
55 ntohs (message->header.type),
56 ntohs (message->header.size),
57 GNUNET_i2s (sender));
58 GNUNET_free (ps);
59 }
60 50
61 if ((GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE == ntohs (message->header.type)) && 51 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
62 (GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE == ntohs (message->header.size))) 52 "Peer %u (`%s') received message of type %d and size %u size from peer %s!\n",
63 { 53 receiver->no,
64 ccc->global_ret = GNUNET_OK; 54 ps,
65 GNUNET_SCHEDULER_shutdown (); 55 ntohs(message->header.type),
56 ntohs(message->header.size),
57 GNUNET_i2s(sender));
58 GNUNET_free(ps);
66 } 59 }
60
61 if ((GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE == ntohs(message->header.type)) &&
62 (GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE == ntohs(message->header.size)))
63 {
64 ccc->global_ret = GNUNET_OK;
65 GNUNET_SCHEDULER_shutdown();
66 }
67 else 67 else
68 { 68 {
69 GNUNET_break (0); 69 GNUNET_break(0);
70 ccc->global_ret = GNUNET_SYSERR; 70 ccc->global_ret = GNUNET_SYSERR;
71 GNUNET_SCHEDULER_shutdown (); 71 GNUNET_SCHEDULER_shutdown();
72 } 72 }
73} 73}
74 74
75 75
@@ -81,8 +81,8 @@ notify_receive (void *cls,
81 * in both directions simultaneously? 81 * in both directions simultaneously?
82 */ 82 */
83static int 83static int
84test (char *argv[], 84test(char *argv[],
85 int bi_directional) 85 int bi_directional)
86{ 86{
87 struct GNUNET_TRANSPORT_TESTING_SendClosure sc = { 87 struct GNUNET_TRANSPORT_TESTING_SendClosure sc = {
88 .num_messages = 1 88 .num_messages = 1
@@ -101,22 +101,22 @@ test (char *argv[],
101 ccc = &my_ccc; 101 ccc = &my_ccc;
102 sc.ccc = ccc; 102 sc.ccc = ccc;
103 if (GNUNET_OK != 103 if (GNUNET_OK !=
104 GNUNET_TRANSPORT_TESTING_main (2, 104 GNUNET_TRANSPORT_TESTING_main(2,
105 &GNUNET_TRANSPORT_TESTING_connect_check, 105 &GNUNET_TRANSPORT_TESTING_connect_check,
106 ccc)) 106 ccc))
107 return 1; 107 return 1;
108 return 0; 108 return 0;
109} 109}
110 110
111 111
112int 112int
113main (int argc, 113main(int argc,
114 char *argv[]) 114 char *argv[])
115{ 115{
116 if ( (0 != test (argv, 116 if ((0 != test(argv,
117 GNUNET_NO)) || 117 GNUNET_NO)) ||
118 (0 != test (argv, 118 (0 != test(argv,
119 GNUNET_YES) ) ) 119 GNUNET_YES)))
120 return 1; 120 return 1;
121 return 0; 121 return 0;
122} 122}