diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:46:35 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:46:35 +0000 |
commit | 502af2167f7c218366666ca4944bd7cc54b5b19a (patch) | |
tree | a91fec5cc9769d260640bd91c6633cb9cf395524 /src/topology/test_gnunet_daemon_topology.c | |
parent | 03af5a603b7cc53432249d5854cd412aa90dde0d (diff) | |
download | gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.tar.gz gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.zip |
indentation
Diffstat (limited to 'src/topology/test_gnunet_daemon_topology.c')
-rw-r--r-- | src/topology/test_gnunet_daemon_topology.c | 134 |
1 files changed, 60 insertions, 74 deletions
diff --git a/src/topology/test_gnunet_daemon_topology.c b/src/topology/test_gnunet_daemon_topology.c index 85f328fe5..9d0c055cb 100644 --- a/src/topology/test_gnunet_daemon_topology.c +++ b/src/topology/test_gnunet_daemon_topology.c | |||
@@ -51,119 +51,105 @@ static struct GNUNET_TESTING_Daemon *last; | |||
51 | /** | 51 | /** |
52 | * Check whether peers successfully shut down. | 52 | * Check whether peers successfully shut down. |
53 | */ | 53 | */ |
54 | static void | 54 | static void |
55 | shutdown_callback (void *cls, | 55 | shutdown_callback (void *cls, const char *emsg) |
56 | const char *emsg) | ||
57 | { | 56 | { |
58 | if (emsg != NULL) | 57 | if (emsg != NULL) |
59 | { | 58 | { |
60 | #if VERBOSE | 59 | #if VERBOSE |
61 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 60 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); |
62 | "Shutdown of peers failed!\n"); | ||
63 | #endif | 61 | #endif |
64 | if (ok == 0) | 62 | if (ok == 0) |
65 | ok = 666; | 63 | ok = 666; |
66 | } | 64 | } |
67 | else | 65 | else |
68 | { | 66 | { |
69 | #if VERBOSE | 67 | #if VERBOSE |
70 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 68 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers successfully shut down!\n"); |
71 | "All peers successfully shut down!\n"); | ||
72 | #endif | 69 | #endif |
73 | } | 70 | } |
74 | } | 71 | } |
75 | 72 | ||
76 | 73 | ||
77 | static void | 74 | static void |
78 | clean_up_task (void *cls, | 75 | clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
79 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
80 | { | 76 | { |
81 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 77 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
82 | ok = 0; | 78 | ok = 0; |
83 | } | 79 | } |
84 | 80 | ||
85 | 81 | ||
86 | static void | 82 | static void |
87 | notify_connect_complete(void *cls, | 83 | notify_connect_complete (void *cls, |
88 | const struct GNUNET_PeerIdentity *first, | 84 | const struct GNUNET_PeerIdentity *first, |
89 | const struct GNUNET_PeerIdentity *second, | 85 | const struct GNUNET_PeerIdentity *second, |
90 | unsigned int distance, | 86 | unsigned int distance, |
91 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 87 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
92 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 88 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
93 | struct GNUNET_TESTING_Daemon *first_daemon, | 89 | struct GNUNET_TESTING_Daemon *first_daemon, |
94 | struct GNUNET_TESTING_Daemon *second_daemon, | 90 | struct GNUNET_TESTING_Daemon *second_daemon, |
95 | const char *emsg) | 91 | const char *emsg) |
96 | { | 92 | { |
97 | if (NULL != emsg) | 93 | if (NULL != emsg) |
98 | { | 94 | { |
99 | fprintf (stderr, | 95 | fprintf (stderr, "Failed to connect two peers: %s\n", emsg); |
100 | "Failed to connect two peers: %s\n", | 96 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
101 | emsg); | 97 | GNUNET_assert (0); |
102 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 98 | return; |
103 | GNUNET_assert (0); | 99 | } |
104 | return; | ||
105 | } | ||
106 | connect_left--; | 100 | connect_left--; |
107 | if (connect_left == 0) | 101 | if (connect_left == 0) |
108 | { | 102 | { |
109 | /* FIXME: check that topology adds a few more links | 103 | /* FIXME: check that topology adds a few more links |
110 | in addition to those that were seeded */ | 104 | * in addition to those that were seeded */ |
111 | GNUNET_SCHEDULER_add_now (&clean_up_task, | 105 | GNUNET_SCHEDULER_add_now (&clean_up_task, NULL); |
112 | NULL); | 106 | } |
113 | } | ||
114 | } | 107 | } |
115 | 108 | ||
116 | 109 | ||
117 | static | 110 | static void |
118 | void my_cb(void *cls, | 111 | my_cb (void *cls, |
119 | const struct GNUNET_PeerIdentity *id, | 112 | const struct GNUNET_PeerIdentity *id, |
120 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 113 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
121 | struct GNUNET_TESTING_Daemon *d, | 114 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
122 | const char *emsg) | ||
123 | { | 115 | { |
124 | GNUNET_assert (id != NULL); | 116 | GNUNET_assert (id != NULL); |
125 | peers_left--; | 117 | peers_left--; |
126 | if (first == NULL) | 118 | if (first == NULL) |
127 | { | 119 | { |
128 | connect_left = NUM_PEERS; | 120 | connect_left = NUM_PEERS; |
129 | first = d; | 121 | first = d; |
130 | last = d; | 122 | last = d; |
131 | return; | 123 | return; |
132 | } | 124 | } |
133 | GNUNET_TESTING_daemons_connect (last, d, TIMEOUT, CONNECT_ATTEMPTS, | 125 | GNUNET_TESTING_daemons_connect (last, d, TIMEOUT, CONNECT_ATTEMPTS, |
134 | GNUNET_YES, | 126 | GNUNET_YES, ¬ify_connect_complete, NULL); |
135 | ¬ify_connect_complete, | ||
136 | NULL); | ||
137 | if (peers_left == 0) | 127 | if (peers_left == 0) |
138 | { | 128 | { |
139 | /* close circle */ | 129 | /* close circle */ |
140 | GNUNET_TESTING_daemons_connect (d, first, TIMEOUT, CONNECT_ATTEMPTS, | 130 | GNUNET_TESTING_daemons_connect (d, first, TIMEOUT, CONNECT_ATTEMPTS, |
141 | GNUNET_YES, | 131 | GNUNET_YES, ¬ify_connect_complete, NULL); |
142 | ¬ify_connect_complete, | 132 | } |
143 | NULL); | ||
144 | } | ||
145 | } | 133 | } |
146 | 134 | ||
147 | 135 | ||
148 | static void | 136 | static void |
149 | run (void *cls, | 137 | run (void *cls, |
150 | char *const *args, | 138 | char *const *args, |
151 | const char *cfgfile, | 139 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
152 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
153 | { | 140 | { |
154 | ok = 1; | 141 | ok = 1; |
155 | #if VERBOSE | 142 | #if VERBOSE |
156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 143 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); |
157 | "Starting daemons.\n"); | ||
158 | #endif | 144 | #endif |
159 | peers_left = NUM_PEERS; | 145 | peers_left = NUM_PEERS; |
160 | pg = GNUNET_TESTING_daemons_start (cfg, | 146 | pg = GNUNET_TESTING_daemons_start (cfg, |
161 | peers_left, | 147 | peers_left, |
162 | peers_left, | 148 | peers_left, |
163 | peers_left, | 149 | peers_left, |
164 | TIMEOUT, | 150 | TIMEOUT, |
165 | NULL, NULL, | 151 | NULL, NULL, |
166 | &my_cb, NULL, NULL, NULL, NULL); | 152 | &my_cb, NULL, NULL, NULL, NULL); |
167 | GNUNET_assert (pg != NULL); | 153 | GNUNET_assert (pg != NULL); |
168 | } | 154 | } |
169 | 155 | ||
@@ -171,7 +157,7 @@ run (void *cls, | |||
171 | static int | 157 | static int |
172 | check () | 158 | check () |
173 | { | 159 | { |
174 | char *const argv[] = { | 160 | char *const argv[] = { |
175 | "test-gnunet-daemon-topology", | 161 | "test-gnunet-daemon-topology", |
176 | "-c", | 162 | "-c", |
177 | "test_gnunet_daemon_topology_data.conf", | 163 | "test_gnunet_daemon_topology_data.conf", |