diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/fs/test_fs_test_lib.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/fs/test_fs_test_lib.c')
-rw-r--r-- | src/fs/test_fs_test_lib.c | 149 |
1 files changed, 74 insertions, 75 deletions
diff --git a/src/fs/test_fs_test_lib.c b/src/fs/test_fs_test_lib.c index 52b0bf2c0..7e27469cc 100644 --- a/src/fs/test_fs_test_lib.c +++ b/src/fs/test_fs_test_lib.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 | /** | 21 | /** |
22 | * @file fs/test_fs_test_lib.c | 22 | * @file fs/test_fs_test_lib.c |
@@ -36,7 +36,7 @@ | |||
36 | /** | 36 | /** |
37 | * How long until we give up on transmitting the message? | 37 | * How long until we give up on transmitting the message? |
38 | */ | 38 | */ |
39 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) | 39 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 300) |
40 | 40 | ||
41 | #define NUM_DAEMONS 2 | 41 | #define NUM_DAEMONS 2 |
42 | 42 | ||
@@ -50,75 +50,74 @@ static int ret; | |||
50 | 50 | ||
51 | 51 | ||
52 | static void | 52 | static void |
53 | do_stop (void *cls) | 53 | do_stop(void *cls) |
54 | { | 54 | { |
55 | char *fn = cls; | 55 | char *fn = cls; |
56 | 56 | ||
57 | if (0 == | 57 | if (0 == |
58 | GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (start_time, | 58 | GNUNET_TIME_absolute_get_remaining(GNUNET_TIME_absolute_add(start_time, |
59 | TIMEOUT)).rel_value_us) | 59 | TIMEOUT)).rel_value_us) |
60 | { | 60 | { |
61 | GNUNET_break (0); | 61 | GNUNET_break(0); |
62 | ret = 1; | 62 | ret = 1; |
63 | } | 63 | } |
64 | else | 64 | else |
65 | { | 65 | { |
66 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 66 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
67 | "Finished download, shutting down\n"); | 67 | "Finished download, shutting down\n"); |
68 | } | 68 | } |
69 | if (NULL != fn) | 69 | if (NULL != fn) |
70 | { | 70 | { |
71 | GNUNET_DISK_directory_remove (fn); | 71 | GNUNET_DISK_directory_remove(fn); |
72 | GNUNET_free (fn); | 72 | GNUNET_free(fn); |
73 | } | 73 | } |
74 | GNUNET_SCHEDULER_shutdown (); | 74 | GNUNET_SCHEDULER_shutdown(); |
75 | } | 75 | } |
76 | 76 | ||
77 | 77 | ||
78 | static void | 78 | static void |
79 | do_download (void *cls, | 79 | do_download(void *cls, |
80 | const struct GNUNET_FS_Uri *uri, | 80 | const struct GNUNET_FS_Uri *uri, |
81 | const char *fn) | 81 | const char *fn) |
82 | { | 82 | { |
83 | if (NULL == uri) | 83 | if (NULL == uri) |
84 | { | 84 | { |
85 | GNUNET_break (0); | 85 | GNUNET_break(0); |
86 | GNUNET_SCHEDULER_shutdown (); | 86 | GNUNET_SCHEDULER_shutdown(); |
87 | ret = 1; | 87 | ret = 1; |
88 | return; | 88 | return; |
89 | } | 89 | } |
90 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 90 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
91 | "Downloading %llu bytes\n", | 91 | "Downloading %llu bytes\n", |
92 | (unsigned long long) FILESIZE); | 92 | (unsigned long long)FILESIZE); |
93 | start_time = GNUNET_TIME_absolute_get (); | 93 | start_time = GNUNET_TIME_absolute_get(); |
94 | GNUNET_FS_TEST_download (the_peers[0], | 94 | GNUNET_FS_TEST_download(the_peers[0], |
95 | TIMEOUT, 1, SEED, | 95 | TIMEOUT, 1, SEED, |
96 | uri, | 96 | uri, |
97 | VERBOSE, | 97 | VERBOSE, |
98 | &do_stop, | 98 | &do_stop, |
99 | (NULL == fn) ? NULL : GNUNET_strdup (fn)); | 99 | (NULL == fn) ? NULL : GNUNET_strdup(fn)); |
100 | } | 100 | } |
101 | 101 | ||
102 | 102 | ||
103 | static void | 103 | static void |
104 | do_publish (void *cls, | 104 | do_publish(void *cls, |
105 | struct GNUNET_TESTBED_Operation *op, | 105 | struct GNUNET_TESTBED_Operation *op, |
106 | const char *emsg) | 106 | const char *emsg) |
107 | { | 107 | { |
108 | GNUNET_TESTBED_operation_done (op); | 108 | GNUNET_TESTBED_operation_done(op); |
109 | if (NULL != emsg) | 109 | if (NULL != emsg) |
110 | { | 110 | { |
111 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to connect peers: %s\n", emsg); | 111 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect peers: %s\n", emsg); |
112 | GNUNET_break (0); | 112 | GNUNET_break(0); |
113 | ret = 1; | 113 | ret = 1; |
114 | GNUNET_SCHEDULER_shutdown (); | 114 | GNUNET_SCHEDULER_shutdown(); |
115 | return; | 115 | return; |
116 | } | 116 | } |
117 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", | 117 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", |
118 | (unsigned long long) FILESIZE); | 118 | (unsigned long long)FILESIZE); |
119 | GNUNET_FS_TEST_publish (the_peers[0], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, | 119 | GNUNET_FS_TEST_publish(the_peers[0], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, |
120 | VERBOSE, &do_download, NULL); | 120 | VERBOSE, &do_download, NULL); |
121 | |||
122 | } | 121 | } |
123 | 122 | ||
124 | 123 | ||
@@ -135,23 +134,23 @@ do_publish (void *cls, | |||
135 | * failed | 134 | * failed |
136 | */ | 135 | */ |
137 | static void | 136 | static void |
138 | run (void *cls, | 137 | run(void *cls, |
139 | struct GNUNET_TESTBED_RunHandle *h, | 138 | struct GNUNET_TESTBED_RunHandle *h, |
140 | unsigned int num_peers, | 139 | unsigned int num_peers, |
141 | struct GNUNET_TESTBED_Peer **peers, | 140 | struct GNUNET_TESTBED_Peer **peers, |
142 | unsigned int links_succeeded, | 141 | unsigned int links_succeeded, |
143 | unsigned int links_failed) | 142 | unsigned int links_failed) |
144 | { | 143 | { |
145 | unsigned int i; | 144 | unsigned int i; |
146 | 145 | ||
147 | GNUNET_assert (NUM_DAEMONS == num_peers); | 146 | GNUNET_assert(NUM_DAEMONS == num_peers); |
148 | for (i=0;i<num_peers;i++) | 147 | for (i = 0; i < num_peers; i++) |
149 | the_peers[i] = peers[i]; | 148 | the_peers[i] = peers[i]; |
150 | GNUNET_TESTBED_overlay_connect (NULL, | 149 | GNUNET_TESTBED_overlay_connect(NULL, |
151 | &do_publish, | 150 | &do_publish, |
152 | NULL, | 151 | NULL, |
153 | peers[0], | 152 | peers[0], |
154 | peers[1]); | 153 | peers[1]); |
155 | } | 154 | } |
156 | 155 | ||
157 | 156 | ||
@@ -163,15 +162,15 @@ run (void *cls, | |||
163 | * @return 0 on success | 162 | * @return 0 on success |
164 | */ | 163 | */ |
165 | int | 164 | int |
166 | main (int argc, char *argv[]) | 165 | main(int argc, char *argv[]) |
167 | { | 166 | { |
168 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); | 167 | GNUNET_DISK_directory_remove("/tmp/gnunet-test-fs-lib/"); |
169 | (void) GNUNET_TESTBED_test_run ("test_fs_test_lib", | 168 | (void)GNUNET_TESTBED_test_run("test_fs_test_lib", |
170 | "fs_test_lib_data.conf", | 169 | "fs_test_lib_data.conf", |
171 | NUM_DAEMONS, | 170 | NUM_DAEMONS, |
172 | 0, NULL, NULL, | 171 | 0, NULL, NULL, |
173 | &run, NULL); | 172 | &run, NULL); |
174 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); | 173 | GNUNET_DISK_directory_remove("/tmp/gnunet-test-fs-lib/"); |
175 | return ret; | 174 | return ret; |
176 | } | 175 | } |
177 | 176 | ||