aboutsummaryrefslogtreecommitdiff
path: root/src/arm/test_gnunet_service_manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arm/test_gnunet_service_manager.c')
-rw-r--r--src/arm/test_gnunet_service_manager.c103
1 files changed, 53 insertions, 50 deletions
diff --git a/src/arm/test_gnunet_service_manager.c b/src/arm/test_gnunet_service_manager.c
index 100e1569c..2be86e79f 100644
--- a/src/arm/test_gnunet_service_manager.c
+++ b/src/arm/test_gnunet_service_manager.c
@@ -51,17 +51,17 @@ static struct GNUNET_ARM_Handle *arm;
51#endif 51#endif
52 52
53static void 53static void
54arm_stopped (void *cls, int success) 54arm_stopped (void *cls, enum GNUNET_ARM_ProcessStatus success)
55{ 55{
56 if (success != GNUNET_NO) 56 if (success != GNUNET_ARM_PROCESS_DOWN)
57 { 57 {
58 GNUNET_break (0); 58 GNUNET_break (0);
59 ret = 4; 59 ret = 4;
60 } 60 }
61 else 61 else
62 { 62 {
63 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM stopped\n"); 63 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM stopped\n");
64 } 64 }
65#if START_ARM 65#if START_ARM
66 GNUNET_ARM_disconnect (arm); 66 GNUNET_ARM_disconnect (arm);
67 arm = NULL; 67 arm = NULL;
@@ -74,15 +74,16 @@ hostNameResolveCB (void *cls, const struct sockaddr *addr, socklen_t addrlen)
74 if ((ret == 0) || (ret == 4)) 74 if ((ret == 0) || (ret == 4))
75 return; 75 return;
76 if (NULL == addr) 76 if (NULL == addr)
77 { 77 {
78 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Name not resolved!\n"); 78 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Name not resolved!\n");
79#if START_ARM 79#if START_ARM
80 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); 80 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL);
81#endif 81#endif
82 ret = 3; 82 ret = 3;
83 return; 83 return;
84 } 84 }
85 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Resolved hostname, now stopping ARM\n"); 85 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
86 "Resolved hostname, now stopping ARM\n");
86 ret = 0; 87 ret = 0;
87#if START_ARM 88#if START_ARM
88 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); 89 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL);
@@ -91,27 +92,28 @@ hostNameResolveCB (void *cls, const struct sockaddr *addr, socklen_t addrlen)
91 92
92 93
93static void 94static void
94arm_notify (void *cls, int success) 95arm_notify (void *cls, enum GNUNET_ARM_ProcessStatus success)
95{ 96{
96 if (success != GNUNET_YES) 97 if (success != GNUNET_ARM_PROCESS_STARTING)
97 { 98 {
98 GNUNET_break (0); 99 GNUNET_break (0);
99 ret = 1; 100 ret = 1;
100 return; 101 return;
101 } 102 }
102 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to resolve our own hostname!\n"); 103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
104 "Trying to resolve our own hostname!\n");
103 /* connect to the resolver service */ 105 /* connect to the resolver service */
104 if (NULL == 106 if (NULL ==
105 GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, TIMEOUT, &hostNameResolveCB, 107 GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, TIMEOUT,
106 NULL)) 108 &hostNameResolveCB, NULL))
107 { 109 {
108 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 110 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
109 "Unable initiate connection to resolver service\n"); 111 "Unable initiate connection to resolver service\n");
110 ret = 2; 112 ret = 2;
111#if START_ARM 113#if START_ARM
112 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); 114 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL);
113#endif 115#endif
114 } 116 }
115} 117}
116 118
117 119
@@ -144,9 +146,9 @@ check ()
144 GNUNET_GETOPT_OPTION_END 146 GNUNET_GETOPT_OPTION_END
145 }; 147 };
146 GNUNET_assert (GNUNET_OK == 148 GNUNET_assert (GNUNET_OK ==
147 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 149 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
148 argv, "test-gnunet-service-manager", 150 argv, "test-gnunet-service-manager",
149 "nohelp", options, &run, NULL)); 151 "nohelp", options, &run, NULL));
150} 152}
151 153
152 154
@@ -156,27 +158,28 @@ main (int argc, char *argv[])
156 char hostname[GNUNET_OS_get_hostname_max_length () + 1]; 158 char hostname[GNUNET_OS_get_hostname_max_length () + 1];
157 159
158 if (0 != gethostname (hostname, sizeof (hostname) - 1)) 160 if (0 != gethostname (hostname, sizeof (hostname) - 1))
159 { 161 {
160 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 162 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
161 "gethostname"); 163 "gethostname");
162 fprintf (stderr, 164 fprintf (stderr,
163 "Failed to determine my own hostname, testcase not run.\n"); 165 "Failed to determine my own hostname, testcase not run.\n");
164 return 0; 166 return 0;
165 } 167 }
166 if (NULL == gethostbyname (hostname)) 168 if (NULL == gethostbyname (hostname))
167 { 169 {
168 fprintf (stderr, "Failed to resolve my hostname `%s', testcase not run.\n", 170 fprintf (stderr,
169 hostname); 171 "Failed to resolve my hostname `%s', testcase not run.\n",
170 return 0; 172 hostname);
171 } 173 return 0;
174 }
172 175
173 GNUNET_log_setup ("test-gnunet-service-manager", 176 GNUNET_log_setup ("test-gnunet-service-manager",
174#if VERBOSE 177#if VERBOSE
175 "DEBUG", 178 "DEBUG",
176#else 179#else
177 "WARNING", 180 "WARNING",
178#endif 181#endif
179 NULL); 182 NULL);
180 check (); 183 check ();
181 return ret; 184 return ret;
182} 185}