diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-03-07 20:18:54 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-03-07 20:18:54 +0000 |
commit | 9ee55ce36b1b2da9d3d2bb82bea555294b35637d (patch) | |
tree | 364d62108ee370571998afff9b36e007a535c765 /src/arm/test_gnunet_service_arm.c | |
parent | 99bc2dfc35d208d676d7726a66eb01b7ad1604c9 (diff) | |
download | gnunet-9ee55ce36b1b2da9d3d2bb82bea555294b35637d.tar.gz gnunet-9ee55ce36b1b2da9d3d2bb82bea555294b35637d.zip |
simplify test, log failure cause
Diffstat (limited to 'src/arm/test_gnunet_service_arm.c')
-rw-r--r-- | src/arm/test_gnunet_service_arm.c | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/src/arm/test_gnunet_service_arm.c b/src/arm/test_gnunet_service_arm.c index 7f5256a93..f95031ff7 100644 --- a/src/arm/test_gnunet_service_arm.c +++ b/src/arm/test_gnunet_service_arm.c | |||
@@ -38,6 +38,7 @@ | |||
38 | 38 | ||
39 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 39 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
40 | 40 | ||
41 | |||
41 | static int ret = 1; | 42 | static int ret = 1; |
42 | 43 | ||
43 | static int resolved_ok; | 44 | static int resolved_ok; |
@@ -65,8 +66,11 @@ arm_stop_cb (void *cls, | |||
65 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); | 66 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); |
66 | GNUNET_break (result == GNUNET_ARM_RESULT_STOPPED); | 67 | GNUNET_break (result == GNUNET_ARM_RESULT_STOPPED); |
67 | if (result != GNUNET_ARM_RESULT_STOPPED) | 68 | if (result != GNUNET_ARM_RESULT_STOPPED) |
69 | { | ||
70 | GNUNET_break (0); | ||
68 | ret = 4; | 71 | ret = 4; |
69 | GNUNET_SCHEDULER_add_now (trigger_disconnect, NULL); | 72 | } |
73 | GNUNET_SCHEDULER_add_now (&trigger_disconnect, NULL); | ||
70 | } | 74 | } |
71 | 75 | ||
72 | 76 | ||
@@ -95,31 +99,40 @@ service_list (void *cls, | |||
95 | } | 99 | } |
96 | 100 | ||
97 | stop_arm: | 101 | stop_arm: |
98 | GNUNET_ARM_request_service_stop (arm, "arm", TIMEOUT, | 102 | GNUNET_ARM_request_service_stop (arm, |
103 | "arm", | ||
104 | TIMEOUT, | ||
99 | &arm_stop_cb, NULL); | 105 | &arm_stop_cb, NULL); |
100 | } | 106 | } |
101 | 107 | ||
102 | 108 | ||
103 | static void | 109 | static void |
104 | hostNameResolveCB (void *cls, | 110 | hostname_resolve_cb (void *cls, |
105 | const struct sockaddr *addr, | 111 | const struct sockaddr *addr, |
106 | socklen_t addrlen) | 112 | socklen_t addrlen) |
107 | { | 113 | { |
108 | if ((ret == 0) || (ret == 4) || (resolved_ok == 1)) | 114 | if ((0 == ret) || (4 == ret) || (1 == resolved_ok)) |
109 | return; | 115 | return; |
110 | if (NULL == addr) | 116 | if (NULL == addr) |
111 | { | 117 | { |
112 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 118 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
113 | "Name not resolved!\n"); | 119 | "Name not resolved!\n"); |
120 | GNUNET_break (0); | ||
114 | ret = 3; | 121 | ret = 3; |
115 | GNUNET_ARM_request_service_stop (arm, "arm", TIMEOUT, | 122 | GNUNET_ARM_request_service_stop (arm, |
123 | "arm", | ||
124 | TIMEOUT, | ||
116 | &arm_stop_cb, NULL); | 125 | &arm_stop_cb, NULL); |
126 | return; | ||
117 | } | 127 | } |
118 | else if (asked_for_a_list == 0) | 128 | if (0 == asked_for_a_list) |
119 | { | 129 | { |
120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
121 | "Resolved hostname, now checking the service list\n"); | 131 | "Resolved hostname, now checking the service list\n"); |
122 | GNUNET_ARM_request_service_list (arm, TIMEOUT, service_list, NULL); | 132 | GNUNET_ARM_request_service_list (arm, |
133 | TIMEOUT, | ||
134 | &service_list, | ||
135 | NULL); | ||
123 | asked_for_a_list = 1; | 136 | asked_for_a_list = 1; |
124 | resolved_ok = 1; | 137 | resolved_ok = 1; |
125 | } | 138 | } |
@@ -139,10 +152,12 @@ arm_start_cb (void *cls, | |||
139 | /* connect to the resolver service */ | 152 | /* connect to the resolver service */ |
140 | if (NULL == | 153 | if (NULL == |
141 | GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, TIMEOUT, | 154 | GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, TIMEOUT, |
142 | &hostNameResolveCB, NULL)) | 155 | &hostname_resolve_cb, |
156 | NULL)) | ||
143 | { | 157 | { |
144 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 158 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
145 | "Unable initiate connection to resolver service\n"); | 159 | "Unable initiate connection to resolver service\n"); |
160 | GNUNET_break (0); | ||
146 | ret = 2; | 161 | ret = 2; |
147 | GNUNET_ARM_request_service_stop (arm, | 162 | GNUNET_ARM_request_service_stop (arm, |
148 | "arm", TIMEOUT, | 163 | "arm", TIMEOUT, |
@@ -157,21 +172,6 @@ run (void *cls, | |||
157 | const char *cfgfile, | 172 | const char *cfgfile, |
158 | const struct GNUNET_CONFIGURATION_Handle *c) | 173 | const struct GNUNET_CONFIGURATION_Handle *c) |
159 | { | 174 | { |
160 | char *armconfig; | ||
161 | |||
162 | if (NULL != cfgfile) | ||
163 | { | ||
164 | if (GNUNET_OK != | ||
165 | GNUNET_CONFIGURATION_get_value_filename (c, "arm", "CONFIG", | ||
166 | &armconfig)) | ||
167 | { | ||
168 | GNUNET_CONFIGURATION_set_value_string ((struct GNUNET_CONFIGURATION_Handle *) c, | ||
169 | "arm", "CONFIG", | ||
170 | cfgfile); | ||
171 | } | ||
172 | else | ||
173 | GNUNET_free (armconfig); | ||
174 | } | ||
175 | arm = GNUNET_ARM_connect (c, NULL, NULL); | 175 | arm = GNUNET_ARM_connect (c, NULL, NULL); |
176 | GNUNET_ARM_request_service_start (arm, "arm", | 176 | GNUNET_ARM_request_service_start (arm, "arm", |
177 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | 177 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, |
@@ -185,7 +185,8 @@ main (int argc, char *av[]) | |||
185 | { | 185 | { |
186 | static char *const argv[] = { | 186 | static char *const argv[] = { |
187 | "test-gnunet-service-arm", | 187 | "test-gnunet-service-arm", |
188 | "-c", "test_arm_api_data.conf", | 188 | "-c", |
189 | "test_arm_api_data.conf", | ||
189 | NULL | 190 | NULL |
190 | }; | 191 | }; |
191 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 192 | static struct GNUNET_GETOPT_CommandLineOption options[] = { |
@@ -217,6 +218,12 @@ main (int argc, char *av[]) | |||
217 | argv, "test-gnunet-service-arm", | 218 | argv, "test-gnunet-service-arm", |
218 | "nohelp", options, | 219 | "nohelp", options, |
219 | &run, NULL)); | 220 | &run, NULL)); |
221 | if (0 != ret) | ||
222 | { | ||
223 | fprintf (stderr, | ||
224 | "Test failed with error code %d\n", | ||
225 | ret); | ||
226 | } | ||
220 | return ret; | 227 | return ret; |
221 | } | 228 | } |
222 | 229 | ||