aboutsummaryrefslogtreecommitdiff
path: root/src/arm/test_arm_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arm/test_arm_api.c')
-rw-r--r--src/arm/test_arm_api.c73
1 files changed, 38 insertions, 35 deletions
diff --git a/src/arm/test_arm_api.c b/src/arm/test_arm_api.c
index 5fbbaa6b1..74e225809 100644
--- a/src/arm/test_arm_api.c
+++ b/src/arm/test_arm_api.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors) 3 (C) 2009, 2011 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -45,18 +45,20 @@ static struct GNUNET_ARM_Handle *arm;
45static int ok = 1; 45static int ok = 1;
46 46
47static void 47static void
48arm_stopped (void *cls, int success) 48arm_stopped (void *cls, enum GNUNET_ARM_ProcessStatus success)
49{ 49{
50 if (success != GNUNET_NO) 50 GNUNET_break (success == GNUNET_ARM_PROCESS_DOWN);
51 if (success != GNUNET_ARM_PROCESS_DOWN)
51 ok = 3; 52 ok = 3;
52 else if (ok == 1) 53 else if (ok == 1)
53 ok = 0; 54 ok = 0;
54} 55}
55 56
57
56static void 58static void
57arm_notify_stop (void *cls, int success) 59arm_notify_stop (void *cls, enum GNUNET_ARM_ProcessStatus success)
58{ 60{
59 GNUNET_assert (success == GNUNET_NO); 61 GNUNET_break (success == GNUNET_ARM_PROCESS_DOWN);
60#if START_ARM 62#if START_ARM
61 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); 63 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL);
62#endif 64#endif
@@ -67,49 +69,50 @@ static void
67dns_notify (void *cls, const struct sockaddr *addr, socklen_t addrlen) 69dns_notify (void *cls, const struct sockaddr *addr, socklen_t addrlen)
68{ 70{
69 if (addr == NULL) 71 if (addr == NULL)
70 {
71 if (ok != 0)
72 { 72 {
73 GNUNET_break (0); 73 if (ok != 0)
74 ok = 2; 74 {
75 GNUNET_break (0);
76 ok = 2;
77 }
78 GNUNET_ARM_stop_service (arm, "resolver", TIMEOUT, &arm_notify_stop,
79 NULL);
80 return;
75 } 81 }
76 GNUNET_ARM_stop_service (arm, "resolver", TIMEOUT, &arm_notify_stop, NULL); 82 GNUNET_break (addr != NULL);
77 return;
78 }
79 GNUNET_assert (addr != NULL);
80 ok = 0; 83 ok = 0;
81} 84}
82 85
83 86
84static void 87static void
85resolver_notify (void *cls, int success) 88resolver_notify (void *cls, enum GNUNET_ARM_ProcessStatus success)
86{ 89{
87 if (success != GNUNET_YES) 90 if (success != GNUNET_ARM_PROCESS_STARTING)
88 { 91 {
89 GNUNET_break (0); 92 GNUNET_break (0);
90 ok = 2; 93 ok = 2;
91#if START_ARM 94#if START_ARM
92 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); 95 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL);
93#endif 96#endif
94 return; 97 return;
95 } 98 }
96 GNUNET_RESOLVER_ip_get ("localhost", AF_INET, TIMEOUT, &dns_notify, NULL); 99 GNUNET_RESOLVER_ip_get ("localhost", AF_INET, TIMEOUT, &dns_notify, NULL);
97} 100}
98 101
99 102
100static void 103static void
101arm_notify (void *cls, int success) 104arm_notify (void *cls, enum GNUNET_ARM_ProcessStatus success)
102{ 105{
103 if (success != GNUNET_YES) 106 if (success != GNUNET_ARM_PROCESS_STARTING)
104 { 107 {
105 GNUNET_break (0); 108 GNUNET_break (0);
106 ok = 2; 109 ok = 2;
107#if START_ARM 110#if START_ARM
108 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); 111 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL);
109#endif 112#endif
110 } 113 }
111 GNUNET_ARM_start_service (arm, "resolver", START_TIMEOUT, &resolver_notify, 114 GNUNET_ARM_start_service (arm, "resolver", START_TIMEOUT, &resolver_notify,
112 NULL); 115 NULL);
113} 116}
114 117
115 118
@@ -143,9 +146,9 @@ check ()
143 GNUNET_GETOPT_OPTION_END 146 GNUNET_GETOPT_OPTION_END
144 }; 147 };
145 GNUNET_assert (GNUNET_OK == 148 GNUNET_assert (GNUNET_OK ==
146 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 149 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
147 argv, "test-arm-api", "nohelp", options, 150 argv, "test-arm-api", "nohelp", options,
148 &task, NULL)); 151 &task, NULL));
149 return ok; 152 return ok;
150} 153}
151 154
@@ -157,11 +160,11 @@ main (int argc, char *argv[])
157 160
158 GNUNET_log_setup ("test-arm-api", 161 GNUNET_log_setup ("test-arm-api",
159#if VERBOSE 162#if VERBOSE
160 "DEBUG", 163 "DEBUG",
161#else 164#else
162 "WARNING", 165 "WARNING",
163#endif 166#endif
164 NULL); 167 NULL);
165 ret = check (); 168 ret = check ();
166 169
167 return ret; 170 return ret;