diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-10 01:20:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-10 01:20:55 +0000 |
commit | c25db0cd4a0c561323b47cdd880866eab473ed49 (patch) | |
tree | 7d6ca5eb8cea6dc1503a1f21f718f2e207e27ff6 /src/peerinfo/perf_peerinfo_api.c | |
parent | 5ab33d2f38aa43fd772e33e70fb709e6c91b1d8a (diff) | |
download | gnunet-c25db0cd4a0c561323b47cdd880866eab473ed49.tar.gz gnunet-c25db0cd4a0c561323b47cdd880866eab473ed49.zip |
-using new testing library for peerinfo test
Diffstat (limited to 'src/peerinfo/perf_peerinfo_api.c')
-rwxr-xr-x | src/peerinfo/perf_peerinfo_api.c | 75 |
1 files changed, 14 insertions, 61 deletions
diff --git a/src/peerinfo/perf_peerinfo_api.c b/src/peerinfo/perf_peerinfo_api.c index 34888fada..a1e309d64 100755 --- a/src/peerinfo/perf_peerinfo_api.c +++ b/src/peerinfo/perf_peerinfo_api.c | |||
@@ -19,18 +19,16 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file peerinfo/test_peerinfo_hammer.c | 22 | * @file peerinfo/perf_peerinfo_api.c |
23 | * @brief testcase for peerinfo_api.c, hopefully hammer the peerinfo service | 23 | * @brief testcase for peerinfo_api.c, hopefully hammer the peerinfo service |
24 | * @author Nathan Evans | 24 | * @author Nathan Evans |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_hello_lib.h" | 28 | #include "gnunet_hello_lib.h" |
29 | #include "gnunet_getopt_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_os_lib.h" | 30 | #include "gnunet_testing_lib-new.h" |
31 | #include "gnunet_peerinfo_service.h" | 31 | #include "gnunet_peerinfo_service.h" |
32 | #include "gnunet_program_lib.h" | ||
33 | #include "gnunet_time_lib.h" | ||
34 | #include "peerinfo.h" | 32 | #include "peerinfo.h" |
35 | #include <gauger.h> | 33 | #include <gauger.h> |
36 | 34 | ||
@@ -38,8 +36,6 @@ | |||
38 | 36 | ||
39 | #define NUM_REQUESTS 5000 | 37 | #define NUM_REQUESTS 5000 |
40 | 38 | ||
41 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
42 | |||
43 | static struct GNUNET_PEERINFO_IteratorContext *ic[NUM_REQUESTS]; | 39 | static struct GNUNET_PEERINFO_IteratorContext *ic[NUM_REQUESTS]; |
44 | 40 | ||
45 | static struct GNUNET_PEERINFO_Handle *h; | 41 | static struct GNUNET_PEERINFO_Handle *h; |
@@ -112,12 +108,11 @@ process (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
112 | 108 | ||
113 | 109 | ||
114 | static void | 110 | static void |
115 | run (void *cls, char *const *args, const char *cfgfile, | 111 | run (void *cls, |
116 | const struct GNUNET_CONFIGURATION_Handle *c) | 112 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
117 | { | 113 | { |
118 | size_t i; | 114 | size_t i; |
119 | 115 | ||
120 | cfg = c; | ||
121 | h = GNUNET_PEERINFO_connect (cfg); | 116 | h = GNUNET_PEERINFO_connect (cfg); |
122 | GNUNET_assert (h != NULL); | 117 | GNUNET_assert (h != NULL); |
123 | for (i = 0; i < NUM_REQUESTS; i++) | 118 | for (i = 0; i < NUM_REQUESTS; i++) |
@@ -130,61 +125,19 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
130 | } | 125 | } |
131 | } | 126 | } |
132 | 127 | ||
133 | static int | ||
134 | check () | ||
135 | { | ||
136 | int ok = 0; | ||
137 | |||
138 | char *const argv[] = { "perf-peerinfo-api", | ||
139 | "-c", | ||
140 | "test_peerinfo_api_data.conf", | ||
141 | "-L", "ERROR", | ||
142 | NULL | ||
143 | }; | ||
144 | #if START_SERVICE | ||
145 | struct GNUNET_OS_Process *proc; | ||
146 | |||
147 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
148 | GNUNET_GETOPT_OPTION_END | ||
149 | }; | ||
150 | proc = | ||
151 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-peerinfo", | ||
152 | "gnunet-service-peerinfo", | ||
153 | "-L", "ERROR", | ||
154 | "-c", "test_peerinfo_api_data.conf", NULL); | ||
155 | #endif | ||
156 | GNUNET_assert (NULL != proc); | ||
157 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | ||
158 | "perf-peerinfo-api", "nohelp", options, &run, &ok); | ||
159 | FPRINTF (stderr, "Received %u/%u calls before timeout\n", numpeers, | ||
160 | NUM_REQUESTS * NUM_REQUESTS / 2); | ||
161 | GAUGER ("PEERINFO", "Peerinfo lookups", numpeers / 30, "peers/s"); | ||
162 | #if START_SERVICE | ||
163 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | ||
164 | { | ||
165 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
166 | ok = 1; | ||
167 | } | ||
168 | GNUNET_OS_process_wait (proc); | ||
169 | GNUNET_OS_process_destroy (proc); | ||
170 | proc = NULL; | ||
171 | #endif | ||
172 | return ok; | ||
173 | } | ||
174 | |||
175 | 128 | ||
176 | int | 129 | int |
177 | main (int argc, char *argv[]) | 130 | main (int argc, char *argv[]) |
178 | { | 131 | { |
179 | int ret = 0; | 132 | if (0 != GNUNET_TESTING_service_run ("perf-gnunet-peerinfo", |
180 | 133 | "peerinfo", | |
181 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-peerinfo"); | 134 | "test_peerinfo_api_data.conf", |
182 | GNUNET_log_setup ("perf_peerinfo_api", | 135 | &run, NULL)) |
183 | "ERROR", | 136 | return 1; |
184 | NULL); | 137 | FPRINTF (stderr, "Received %u/%u calls before timeout\n", numpeers, |
185 | ret = check (); | 138 | NUM_REQUESTS * NUM_REQUESTS / 2); |
186 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-peerinfo"); | 139 | GAUGER ("PEERINFO", "Peerinfo lookups", numpeers / 30, "peers/s"); |
187 | return ret; | 140 | return 0; |
188 | } | 141 | } |
189 | 142 | ||
190 | /* end of perf_peerinfo_api.c */ | 143 | /* end of perf_peerinfo_api.c */ |