diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/fs/test_fs_test_lib.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/fs/test_fs_test_lib.c')
-rw-r--r-- | src/fs/test_fs_test_lib.c | 143 |
1 files changed, 72 insertions, 71 deletions
diff --git a/src/fs/test_fs_test_lib.c b/src/fs/test_fs_test_lib.c index 7e27469cc..25b843e85 100644 --- a/src/fs/test_fs_test_lib.c +++ b/src/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,74 +50,75 @@ 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)). |
60 | { | 60 | rel_value_us) |
61 | GNUNET_break(0); | 61 | { |
62 | ret = 1; | 62 | GNUNET_break (0); |
63 | } | 63 | ret = 1; |
64 | } | ||
64 | else | 65 | else |
65 | { | 66 | { |
66 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 67 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
67 | "Finished download, shutting down\n"); | 68 | "Finished download, shutting down\n"); |
68 | } | 69 | } |
69 | if (NULL != fn) | 70 | if (NULL != fn) |
70 | { | 71 | { |
71 | GNUNET_DISK_directory_remove(fn); | 72 | GNUNET_DISK_directory_remove (fn); |
72 | GNUNET_free(fn); | 73 | GNUNET_free (fn); |
73 | } | 74 | } |
74 | GNUNET_SCHEDULER_shutdown(); | 75 | GNUNET_SCHEDULER_shutdown (); |
75 | } | 76 | } |
76 | 77 | ||
77 | 78 | ||
78 | static void | 79 | static void |
79 | do_download(void *cls, | 80 | do_download (void *cls, |
80 | const struct GNUNET_FS_Uri *uri, | 81 | const struct GNUNET_FS_Uri *uri, |
81 | const char *fn) | 82 | const char *fn) |
82 | { | 83 | { |
83 | if (NULL == uri) | 84 | if (NULL == uri) |
84 | { | 85 | { |
85 | GNUNET_break(0); | 86 | GNUNET_break (0); |
86 | GNUNET_SCHEDULER_shutdown(); | 87 | GNUNET_SCHEDULER_shutdown (); |
87 | ret = 1; | 88 | ret = 1; |
88 | return; | 89 | return; |
89 | } | 90 | } |
90 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 91 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
91 | "Downloading %llu bytes\n", | 92 | "Downloading %llu bytes\n", |
92 | (unsigned long long)FILESIZE); | 93 | (unsigned long long) FILESIZE); |
93 | start_time = GNUNET_TIME_absolute_get(); | 94 | start_time = GNUNET_TIME_absolute_get (); |
94 | GNUNET_FS_TEST_download(the_peers[0], | 95 | GNUNET_FS_TEST_download (the_peers[0], |
95 | TIMEOUT, 1, SEED, | 96 | TIMEOUT, 1, SEED, |
96 | uri, | 97 | uri, |
97 | VERBOSE, | 98 | VERBOSE, |
98 | &do_stop, | 99 | &do_stop, |
99 | (NULL == fn) ? NULL : GNUNET_strdup(fn)); | 100 | (NULL == fn) ? NULL : GNUNET_strdup (fn)); |
100 | } | 101 | } |
101 | 102 | ||
102 | 103 | ||
103 | static void | 104 | static void |
104 | do_publish(void *cls, | 105 | do_publish (void *cls, |
105 | struct GNUNET_TESTBED_Operation *op, | 106 | struct GNUNET_TESTBED_Operation *op, |
106 | const char *emsg) | 107 | const char *emsg) |
107 | { | 108 | { |
108 | GNUNET_TESTBED_operation_done(op); | 109 | GNUNET_TESTBED_operation_done (op); |
109 | if (NULL != emsg) | 110 | if (NULL != emsg) |
110 | { | 111 | { |
111 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect peers: %s\n", emsg); | 112 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to connect peers: %s\n", emsg); |
112 | GNUNET_break(0); | 113 | GNUNET_break (0); |
113 | ret = 1; | 114 | ret = 1; |
114 | GNUNET_SCHEDULER_shutdown(); | 115 | GNUNET_SCHEDULER_shutdown (); |
115 | return; | 116 | return; |
116 | } | 117 | } |
117 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", | 118 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", |
118 | (unsigned long long)FILESIZE); | 119 | (unsigned long long) FILESIZE); |
119 | GNUNET_FS_TEST_publish(the_peers[0], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, | 120 | GNUNET_FS_TEST_publish (the_peers[0], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, |
120 | VERBOSE, &do_download, NULL); | 121 | VERBOSE, &do_download, NULL); |
121 | } | 122 | } |
122 | 123 | ||
123 | 124 | ||
@@ -134,23 +135,23 @@ do_publish(void *cls, | |||
134 | * failed | 135 | * failed |
135 | */ | 136 | */ |
136 | static void | 137 | static void |
137 | run(void *cls, | 138 | run (void *cls, |
138 | struct GNUNET_TESTBED_RunHandle *h, | 139 | struct GNUNET_TESTBED_RunHandle *h, |
139 | unsigned int num_peers, | 140 | unsigned int num_peers, |
140 | struct GNUNET_TESTBED_Peer **peers, | 141 | struct GNUNET_TESTBED_Peer **peers, |
141 | unsigned int links_succeeded, | 142 | unsigned int links_succeeded, |
142 | unsigned int links_failed) | 143 | unsigned int links_failed) |
143 | { | 144 | { |
144 | unsigned int i; | 145 | unsigned int i; |
145 | 146 | ||
146 | GNUNET_assert(NUM_DAEMONS == num_peers); | 147 | GNUNET_assert (NUM_DAEMONS == num_peers); |
147 | for (i = 0; i < num_peers; i++) | 148 | for (i = 0; i < num_peers; i++) |
148 | the_peers[i] = peers[i]; | 149 | the_peers[i] = peers[i]; |
149 | GNUNET_TESTBED_overlay_connect(NULL, | 150 | GNUNET_TESTBED_overlay_connect (NULL, |
150 | &do_publish, | 151 | &do_publish, |
151 | NULL, | 152 | NULL, |
152 | peers[0], | 153 | peers[0], |
153 | peers[1]); | 154 | peers[1]); |
154 | } | 155 | } |
155 | 156 | ||
156 | 157 | ||
@@ -162,15 +163,15 @@ run(void *cls, | |||
162 | * @return 0 on success | 163 | * @return 0 on success |
163 | */ | 164 | */ |
164 | int | 165 | int |
165 | main(int argc, char *argv[]) | 166 | main (int argc, char *argv[]) |
166 | { | 167 | { |
167 | GNUNET_DISK_directory_remove("/tmp/gnunet-test-fs-lib/"); | 168 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); |
168 | (void)GNUNET_TESTBED_test_run("test_fs_test_lib", | 169 | (void) GNUNET_TESTBED_test_run ("test_fs_test_lib", |
169 | "fs_test_lib_data.conf", | 170 | "fs_test_lib_data.conf", |
170 | NUM_DAEMONS, | 171 | NUM_DAEMONS, |
171 | 0, NULL, NULL, | 172 | 0, NULL, NULL, |
172 | &run, NULL); | 173 | &run, NULL); |
173 | GNUNET_DISK_directory_remove("/tmp/gnunet-test-fs-lib/"); | 174 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); |
174 | return ret; | 175 | return ret; |
175 | } | 176 | } |
176 | 177 | ||