diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-22 21:35:51 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-22 21:35:51 +0000 |
commit | 8d0883a3f695261cfd8651ed53734f2f4fb30417 (patch) | |
tree | 389c86b7c6ec9777498ae54e4650c9dbc69b94fc /src/transport/test_transport_api_manipulation_send_tcp.c | |
parent | b77b2502d587f576baff39120e6f37235c5b5b90 (diff) | |
download | gnunet-8d0883a3f695261cfd8651ed53734f2f4fb30417.tar.gz gnunet-8d0883a3f695261cfd8651ed53734f2f4fb30417.zip |
migrate more tests to new transmission API
Diffstat (limited to 'src/transport/test_transport_api_manipulation_send_tcp.c')
-rw-r--r-- | src/transport/test_transport_api_manipulation_send_tcp.c | 81 |
1 files changed, 36 insertions, 45 deletions
diff --git a/src/transport/test_transport_api_manipulation_send_tcp.c b/src/transport/test_transport_api_manipulation_send_tcp.c index 7e73f0b9c..95a6b5140 100644 --- a/src/transport/test_transport_api_manipulation_send_tcp.c +++ b/src/transport/test_transport_api_manipulation_send_tcp.c | |||
@@ -36,9 +36,6 @@ | |||
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 | ||
39 | #define TEST_MESSAGE_SIZE 2600 | ||
40 | |||
41 | |||
42 | static struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc; | 39 | static struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc; |
43 | 40 | ||
44 | static int messages_recv; | 41 | static int messages_recv; |
@@ -52,24 +49,27 @@ static struct GNUNET_TIME_Absolute start_delayed; | |||
52 | static struct GNUNET_TIME_Relative dur_delayed; | 49 | static struct GNUNET_TIME_Relative dur_delayed; |
53 | 50 | ||
54 | 51 | ||
55 | static size_t | 52 | static void |
56 | get_size (unsigned int cnt_down) | 53 | do_free (void *cls) |
57 | { | 54 | { |
58 | return TEST_MESSAGE_SIZE; | 55 | struct GNUNET_TRANSPORT_TESTING_SendClosure *sc = cls; |
56 | |||
57 | GNUNET_free (sc); | ||
59 | } | 58 | } |
60 | 59 | ||
61 | 60 | ||
62 | static void | 61 | static void |
63 | sendtask (void *cls) | 62 | sendtask (void *cls) |
64 | { | 63 | { |
64 | struct GNUNET_TRANSPORT_TESTING_SendClosure *sc; | ||
65 | struct GNUNET_TIME_Relative delay; | 65 | struct GNUNET_TIME_Relative delay; |
66 | struct GNUNET_ATS_Properties prop; | 66 | struct GNUNET_ATS_Properties prop; |
67 | struct GNUNET_TRANSPORT_TESTING_SendClosure sc = { | ||
68 | .num_messages = 1, | ||
69 | .get_size_cb = &get_size, | ||
70 | .ccc = ccc | ||
71 | }; | ||
72 | 67 | ||
68 | sc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_SendClosure); | ||
69 | sc->num_messages = 1; | ||
70 | sc->ccc = ccc; | ||
71 | sc->cont = &do_free; | ||
72 | sc->cont_cls = sc; | ||
73 | if (0 == messages_recv) | 73 | if (0 == messages_recv) |
74 | { | 74 | { |
75 | start_normal = GNUNET_TIME_absolute_get (); | 75 | start_normal = GNUNET_TIME_absolute_get (); |
@@ -78,20 +78,14 @@ sendtask (void *cls) | |||
78 | { | 78 | { |
79 | memset (&prop, 0, sizeof (prop)); | 79 | memset (&prop, 0, sizeof (prop)); |
80 | delay = GNUNET_TIME_UNIT_SECONDS; | 80 | delay = GNUNET_TIME_UNIT_SECONDS; |
81 | GNUNET_TRANSPORT_set_traffic_metric (ccc->p[1]->th, | ||
82 | &ccc->p[0]->id, | ||
83 | &prop, | ||
84 | GNUNET_TIME_UNIT_ZERO, | ||
85 | delay); | ||
86 | prop.distance = 10; | ||
87 | GNUNET_TRANSPORT_set_traffic_metric (ccc->p[0]->th, | 81 | GNUNET_TRANSPORT_set_traffic_metric (ccc->p[0]->th, |
88 | &ccc->p[1]->id, | 82 | &ccc->p[1]->id, |
89 | &prop, | 83 | &prop, |
90 | delay, | 84 | GNUNET_TIME_UNIT_ZERO, |
91 | delay); | 85 | delay); |
92 | start_delayed = GNUNET_TIME_absolute_get(); | 86 | start_delayed = GNUNET_TIME_absolute_get(); |
93 | } | 87 | } |
94 | GNUNET_TRANSPORT_TESTING_simple_send (&sc); | 88 | GNUNET_TRANSPORT_TESTING_large_send (sc); |
95 | } | 89 | } |
96 | 90 | ||
97 | 91 | ||
@@ -114,13 +108,8 @@ notify_receive (void *cls, | |||
114 | GNUNET_free (ps); | 108 | GNUNET_free (ps); |
115 | } | 109 | } |
116 | 110 | ||
117 | if ( (GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE == ntohs (message->type)) && | 111 | if ( (GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE != ntohs (message->type)) || |
118 | (TEST_MESSAGE_SIZE == ntohs (message->size)) ) | 112 | (GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE != ntohs (message->size)) ) |
119 | { | ||
120 | if (GNUNET_NO == ccc->global_ret) | ||
121 | ccc->global_ret = GNUNET_OK; | ||
122 | } | ||
123 | else | ||
124 | { | 113 | { |
125 | GNUNET_break (0); | 114 | GNUNET_break (0); |
126 | ccc->global_ret = GNUNET_SYSERR; | 115 | ccc->global_ret = GNUNET_SYSERR; |
@@ -139,28 +128,30 @@ notify_receive (void *cls, | |||
139 | GNUNET_YES)); | 128 | GNUNET_YES)); |
140 | GNUNET_SCHEDULER_add_now (&sendtask, | 129 | GNUNET_SCHEDULER_add_now (&sendtask, |
141 | NULL); | 130 | NULL); |
131 | messages_recv++; | ||
132 | return; | ||
142 | } | 133 | } |
143 | if (1 == messages_recv) | 134 | /* Received manipulated message */ |
135 | dur_delayed = GNUNET_TIME_absolute_get_duration(start_delayed); | ||
136 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
137 | "Received delayed message %u after %s\n", | ||
138 | messages_recv, | ||
139 | GNUNET_STRINGS_relative_time_to_string (dur_delayed, | ||
140 | GNUNET_YES)); | ||
141 | if (dur_delayed.rel_value_us < GNUNET_TIME_UNIT_SECONDS.rel_value_us) | ||
144 | { | 142 | { |
145 | /* Received manipulated message */ | 143 | GNUNET_break (0); |
146 | dur_delayed = GNUNET_TIME_absolute_get_duration(start_delayed); | 144 | ccc->global_ret = GNUNET_SYSERR; |
147 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 145 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
148 | "Received delayed message %u after %s\n", | 146 | "Delayed message was not delayed correctly: took only %s\n", |
149 | messages_recv, | 147 | GNUNET_STRINGS_relative_time_to_string (dur_delayed, |
150 | GNUNET_STRINGS_relative_time_to_string (dur_delayed, | 148 | GNUNET_YES)); |
151 | GNUNET_YES)); | 149 | } |
152 | if (dur_delayed.rel_value_us < GNUNET_TIME_UNIT_SECONDS.rel_value_us) | 150 | else |
153 | { | 151 | { |
154 | GNUNET_break (0); | 152 | ccc->global_ret = GNUNET_OK; |
155 | ccc->global_ret = GNUNET_SYSERR; | ||
156 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
157 | "Delayed message was not delayed correctly: took only %s\n", | ||
158 | GNUNET_STRINGS_relative_time_to_string (dur_delayed, | ||
159 | GNUNET_YES)); | ||
160 | } | ||
161 | GNUNET_SCHEDULER_shutdown (); | ||
162 | } | 153 | } |
163 | messages_recv++; | 154 | GNUNET_SCHEDULER_shutdown (); |
164 | } | 155 | } |
165 | 156 | ||
166 | 157 | ||