diff options
Diffstat (limited to 'src/nse/test_nse_api.c')
-rw-r--r-- | src/nse/test_nse_api.c | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/src/nse/test_nse_api.c b/src/nse/test_nse_api.c index aaaad1fc6..c06b2be8b 100644 --- a/src/nse/test_nse_api.c +++ b/src/nse/test_nse_api.c | |||
@@ -68,15 +68,13 @@ stop_arm (struct PeerContext *p) | |||
68 | * @param tc context information (why was this task triggered now) | 68 | * @param tc context information (why was this task triggered now) |
69 | */ | 69 | */ |
70 | static void | 70 | static void |
71 | end_test (void *cls, | 71 | end_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
72 | const struct GNUNET_SCHEDULER_TaskContext * tc) | ||
73 | { | 72 | { |
74 | if (h != NULL) | 73 | if (h != NULL) |
75 | { | 74 | { |
76 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 75 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from NSE service.\n"); |
77 | "Disconnecting from NSE service.\n"); | 76 | GNUNET_NSE_disconnect (h); |
78 | GNUNET_NSE_disconnect (h); | 77 | } |
79 | } | ||
80 | } | 78 | } |
81 | 79 | ||
82 | /** | 80 | /** |
@@ -90,20 +88,20 @@ end_test (void *cls, | |||
90 | * | 88 | * |
91 | */ | 89 | */ |
92 | static void | 90 | static void |
93 | check_nse_message (void *cls, | 91 | check_nse_message (void *cls, |
94 | struct GNUNET_TIME_Absolute timestamp, | 92 | struct GNUNET_TIME_Absolute timestamp, |
95 | double estimate, double std_dev) | 93 | double estimate, double std_dev) |
96 | { | 94 | { |
97 | int *ok = cls; | 95 | int *ok = cls; |
98 | 96 | ||
99 | fprintf (stderr, | 97 | fprintf (stderr, |
100 | "Received NSE message, estimate %f, standard deviation %f.\n", | 98 | "Received NSE message, estimate %f, standard deviation %f.\n", |
101 | estimate, std_dev); | 99 | estimate, std_dev); |
102 | /* Fantastic check below. Expect NaN, the only thing not equal to itself. */ | 100 | /* Fantastic check below. Expect NaN, the only thing not equal to itself. */ |
103 | (*ok) = 0; | 101 | (*ok) = 0; |
104 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | 102 | if (die_task != GNUNET_SCHEDULER_NO_TASK) |
105 | GNUNET_SCHEDULER_cancel(die_task); | 103 | GNUNET_SCHEDULER_cancel (die_task); |
106 | die_task = GNUNET_SCHEDULER_add_now(&end_test, NULL); | 104 | die_task = GNUNET_SCHEDULER_add_now (&end_test, NULL); |
107 | } | 105 | } |
108 | 106 | ||
109 | 107 | ||
@@ -113,12 +111,12 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
113 | p->cfg = GNUNET_CONFIGURATION_create (); | 111 | p->cfg = GNUNET_CONFIGURATION_create (); |
114 | #if START_ARM | 112 | #if START_ARM |
115 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, | 113 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, |
116 | "gnunet-service-arm", | 114 | "gnunet-service-arm", |
117 | "gnunet-service-arm", | 115 | "gnunet-service-arm", |
118 | #if VERBOSE_ARM | 116 | #if VERBOSE_ARM |
119 | "-L", "DEBUG", | 117 | "-L", "DEBUG", |
120 | #endif | 118 | #endif |
121 | "-c", cfgname, NULL); | 119 | "-c", cfgname, NULL); |
122 | #endif | 120 | #endif |
123 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 121 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
124 | 122 | ||
@@ -129,8 +127,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
129 | static void | 127 | static void |
130 | run (void *cls, | 128 | run (void *cls, |
131 | char *const *args, | 129 | char *const *args, |
132 | const char *cfgfile, | 130 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
133 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
134 | { | 131 | { |
135 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 132 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
136 | (GNUNET_TIME_UNIT_MINUTES, 1), | 133 | (GNUNET_TIME_UNIT_MINUTES, 1), |
@@ -138,8 +135,7 @@ run (void *cls, | |||
138 | 135 | ||
139 | setup_peer (&p1, cfgfile); | 136 | setup_peer (&p1, cfgfile); |
140 | h = GNUNET_NSE_connect (cfg, &check_nse_message, cls); | 137 | h = GNUNET_NSE_connect (cfg, &check_nse_message, cls); |
141 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 138 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to NSE service.\n"); |
142 | "Connecting to NSE service.\n"); | ||
143 | GNUNET_assert (h != NULL); | 139 | GNUNET_assert (h != NULL); |
144 | } | 140 | } |
145 | 141 | ||
@@ -148,13 +144,14 @@ static int | |||
148 | check () | 144 | check () |
149 | { | 145 | { |
150 | int ok = 1; | 146 | int ok = 1; |
147 | |||
151 | char *const argv[] = { "test-nse-api", | 148 | char *const argv[] = { "test-nse-api", |
152 | "-c", | 149 | "-c", |
153 | "test_nse.conf", | 150 | "test_nse.conf", |
154 | #if DEBUG_NSE | 151 | #if DEBUG_NSE |
155 | "-L", "DEBUG", | 152 | "-L", "DEBUG", |
156 | #else | 153 | #else |
157 | "-L", "WARNING", | 154 | "-L", "WARNING", |
158 | #endif | 155 | #endif |
159 | NULL | 156 | NULL |
160 | }; | 157 | }; |
@@ -162,10 +159,8 @@ check () | |||
162 | GNUNET_GETOPT_OPTION_END | 159 | GNUNET_GETOPT_OPTION_END |
163 | }; | 160 | }; |
164 | 161 | ||
165 | GNUNET_PROGRAM_run (5, argv, "test-nse-api", "nohelp", | 162 | GNUNET_PROGRAM_run (5, argv, "test-nse-api", "nohelp", options, &run, &ok); |
166 | options, &run, &ok); | 163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping arm.\n"); |
167 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
168 | "Stopping arm.\n"); | ||
169 | stop_arm (&p1); | 164 | stop_arm (&p1); |
170 | return ok; | 165 | return ok; |
171 | } | 166 | } |