diff options
Diffstat (limited to 'src/transport/test_transport_api_timeout.c')
-rw-r--r-- | src/transport/test_transport_api_timeout.c | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/src/transport/test_transport_api_timeout.c b/src/transport/test_transport_api_timeout.c index f562dd196..dd2639136 100644 --- a/src/transport/test_transport_api_timeout.c +++ b/src/transport/test_transport_api_timeout.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_timeout.c | 21 | * @file transport/test_transport_api_timeout.c |
22 | * @brief test case for transport plugin implementations complying timeout | 22 | * @brief test case for transport plugin implementations complying timeout |
@@ -34,9 +34,9 @@ | |||
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 WAIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 37 | #define WAIT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30) |
38 | 38 | ||
39 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90) | 39 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 90) |
40 | 40 | ||
41 | #define MTYPE 12345 | 41 | #define MTYPE 12345 |
42 | 42 | ||
@@ -52,94 +52,94 @@ static unsigned int disconnects; | |||
52 | 52 | ||
53 | 53 | ||
54 | static void | 54 | static void |
55 | custom_shutdown (void *cls) | 55 | custom_shutdown(void *cls) |
56 | { | 56 | { |
57 | if (NULL != timer_task) | 57 | if (NULL != timer_task) |
58 | { | 58 | { |
59 | GNUNET_SCHEDULER_cancel (timer_task); | 59 | GNUNET_SCHEDULER_cancel(timer_task); |
60 | timer_task = NULL; | 60 | timer_task = NULL; |
61 | } | 61 | } |
62 | if (0 == disconnects) | 62 | if (0 == disconnects) |
63 | { | 63 | { |
64 | ccc->global_ret = GNUNET_OK; | 64 | ccc->global_ret = GNUNET_OK; |
65 | } | 65 | } |
66 | else | 66 | else |
67 | { | 67 | { |
68 | ccc->global_ret =- GNUNET_SYSERR; | 68 | ccc->global_ret = -GNUNET_SYSERR; |
69 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 69 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
70 | "Fail! Had %u disconnects while waiting %s\n", | 70 | "Fail! Had %u disconnects while waiting %s\n", |
71 | disconnects, | 71 | disconnects, |
72 | GNUNET_STRINGS_relative_time_to_string (WAIT, | 72 | GNUNET_STRINGS_relative_time_to_string(WAIT, |
73 | GNUNET_YES)); | 73 | GNUNET_YES)); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | 77 | ||
78 | static void | 78 | static void |
79 | notify_receive (void *cls, | 79 | notify_receive(void *cls, |
80 | struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, | 80 | struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, |
81 | const struct GNUNET_PeerIdentity *sender, | 81 | const struct GNUNET_PeerIdentity *sender, |
82 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | 82 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) |
83 | { | 83 | { |
84 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 84 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
85 | "Received message of type %d from peer %s!\n", | 85 | "Received message of type %d from peer %s!\n", |
86 | ntohs (message->header.type), | 86 | ntohs(message->header.type), |
87 | GNUNET_i2s (sender)); | 87 | GNUNET_i2s(sender)); |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | static void | 91 | static void |
92 | notify_disconnect (void *cls, | 92 | notify_disconnect(void *cls, |
93 | struct GNUNET_TRANSPORT_TESTING_PeerContext *me, | 93 | struct GNUNET_TRANSPORT_TESTING_PeerContext *me, |
94 | const struct GNUNET_PeerIdentity *other) | 94 | const struct GNUNET_PeerIdentity *other) |
95 | { | 95 | { |
96 | GNUNET_TRANSPORT_TESTING_log_disconnect (cls, | 96 | GNUNET_TRANSPORT_TESTING_log_disconnect(cls, |
97 | me, | 97 | me, |
98 | other); | 98 | other); |
99 | if (shutdown_flag != GNUNET_YES) | 99 | if (shutdown_flag != GNUNET_YES) |
100 | { | 100 | { |
101 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 101 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
102 | "FAIL! Peer `%s' disconnected during waiting period!\n", | 102 | "FAIL! Peer `%s' disconnected during waiting period!\n", |
103 | GNUNET_i2s (other)); | 103 | GNUNET_i2s(other)); |
104 | disconnects++; | 104 | disconnects++; |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | static void | 109 | static void |
110 | timer (void *cls) | 110 | timer(void *cls) |
111 | { | 111 | { |
112 | static unsigned int percentage; | 112 | static unsigned int percentage; |
113 | 113 | ||
114 | timer_task = NULL; | 114 | timer_task = NULL; |
115 | percentage += 10; | 115 | percentage += 10; |
116 | time_running = GNUNET_TIME_relative_add (time_running, | 116 | time_running = GNUNET_TIME_relative_add(time_running, |
117 | GNUNET_TIME_relative_divide (WAIT, | 117 | GNUNET_TIME_relative_divide(WAIT, |
118 | 10)); | 118 | 10)); |
119 | 119 | ||
120 | if (time_running.rel_value_us == | 120 | if (time_running.rel_value_us == |
121 | GNUNET_TIME_relative_max (time_running, WAIT).rel_value_us) | 121 | GNUNET_TIME_relative_max(time_running, WAIT).rel_value_us) |
122 | { | 122 | { |
123 | fprintf (stderr, "%s", "100%%\n"); | 123 | fprintf(stderr, "%s", "100%%\n"); |
124 | shutdown_flag = GNUNET_YES; | 124 | shutdown_flag = GNUNET_YES; |
125 | GNUNET_SCHEDULER_shutdown (); | 125 | GNUNET_SCHEDULER_shutdown(); |
126 | } | 126 | } |
127 | else | 127 | else |
128 | { | 128 | { |
129 | fprintf (stderr, | 129 | fprintf(stderr, |
130 | "%u%%..", | 130 | "%u%%..", |
131 | percentage); | 131 | percentage); |
132 | timer_task = | 132 | timer_task = |
133 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (WAIT, 10), | 133 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_divide(WAIT, 10), |
134 | &timer, | 134 | &timer, |
135 | NULL); | 135 | NULL); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | 139 | ||
140 | int | 140 | int |
141 | main (int argc, | 141 | main(int argc, |
142 | char *argv[]) | 142 | char *argv[]) |
143 | { | 143 | { |
144 | struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = { | 144 | struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = { |
145 | .connect_continuation = &timer, | 145 | .connect_continuation = &timer, |
@@ -153,9 +153,9 @@ main (int argc, | |||
153 | 153 | ||
154 | ccc = &my_ccc; | 154 | ccc = &my_ccc; |
155 | if (GNUNET_OK != | 155 | if (GNUNET_OK != |
156 | GNUNET_TRANSPORT_TESTING_main (2, | 156 | GNUNET_TRANSPORT_TESTING_main(2, |
157 | &GNUNET_TRANSPORT_TESTING_connect_check, | 157 | &GNUNET_TRANSPORT_TESTING_connect_check, |
158 | ccc)) | 158 | ccc)) |
159 | return 1; | 159 | return 1; |
160 | return 0; | 160 | return 0; |
161 | } | 161 | } |