aboutsummaryrefslogtreecommitdiff
path: root/src/statistics/test_statistics_api_loop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/statistics/test_statistics_api_loop.c')
-rw-r--r--src/statistics/test_statistics_api_loop.c47
1 files changed, 15 insertions, 32 deletions
diff --git a/src/statistics/test_statistics_api_loop.c b/src/statistics/test_statistics_api_loop.c
index ae798b830..f9a3a3ba6 100644
--- a/src/statistics/test_statistics_api_loop.c
+++ b/src/statistics/test_statistics_api_loop.c
@@ -22,18 +22,13 @@
22 * @brief testcase for statistics_api.c 22 * @brief testcase for statistics_api.c
23 */ 23 */
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_common.h" 25#include "gnunet_util_lib.h"
26#include "gnunet_getopt_lib.h"
27#include "gnunet_os_lib.h"
28#include "gnunet_program_lib.h"
29#include "gnunet_scheduler_lib.h"
30#include "gnunet_statistics_service.h" 26#include "gnunet_statistics_service.h"
31 27
32#define VERBOSE GNUNET_NO 28#define ROUNDS (1024 * 1024)
33 29
34#define START_SERVICE GNUNET_YES 30static struct GNUNET_STATISTICS_Handle *h;
35 31
36#define ROUNDS (1024 * 1024)
37 32
38static int 33static int
39check_1 (void *cls, const char *subsystem, const char *name, uint64_t value, 34check_1 (void *cls, const char *subsystem, const char *name, uint64_t value,
@@ -45,7 +40,6 @@ check_1 (void *cls, const char *subsystem, const char *name, uint64_t value,
45 return GNUNET_OK; 40 return GNUNET_OK;
46} 41}
47 42
48static struct GNUNET_STATISTICS_Handle *h;
49 43
50static void 44static void
51next (void *cls, int success) 45next (void *cls, int success)
@@ -57,11 +51,12 @@ next (void *cls, int success)
57 *ok = 0; 51 *ok = 0;
58} 52}
59 53
54
60static void 55static void
61run (void *cls, char *const *args, const char *cfgfile, 56run (void *cls, char *const *args, const char *cfgfile,
62 const struct GNUNET_CONFIGURATION_Handle *cfg) 57 const struct GNUNET_CONFIGURATION_Handle *cfg)
63{ 58{
64 int i; 59 unsigned int i;
65 char name[128]; 60 char name[128];
66 61
67 h = GNUNET_STATISTICS_create ("test-statistics-api-loop", cfg); 62 h = GNUNET_STATISTICS_create ("test-statistics-api-loop", cfg);
@@ -80,8 +75,8 @@ run (void *cls, char *const *args, const char *cfgfile,
80} 75}
81 76
82 77
83static int 78int
84check () 79main (int argc, char *argv_ign[])
85{ 80{
86 int ok = 1; 81 int ok = 1;
87 82
@@ -93,21 +88,19 @@ check ()
93 struct GNUNET_GETOPT_CommandLineOption options[] = { 88 struct GNUNET_GETOPT_CommandLineOption options[] = {
94 GNUNET_GETOPT_OPTION_END 89 GNUNET_GETOPT_OPTION_END
95 }; 90 };
96#if START_SERVICE
97 struct GNUNET_OS_Process *proc; 91 struct GNUNET_OS_Process *proc;
92 char *binary;
98 93
94 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-statistics");
99 proc = 95 proc =
100 GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-statistics", 96 GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
101 "gnunet-service-statistics", 97 NULL, NULL,
102#if DEBUG_STATISTICS 98 binary,
103 "-L", "DEBUG", 99 "gnunet-service-statistics",
104#endif 100 "-c", "test_statistics_api_data.conf", NULL);
105 "-c", "test_statistics_api_data.conf", NULL);
106#endif
107 GNUNET_assert (NULL != proc); 101 GNUNET_assert (NULL != proc);
108 GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run, 102 GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run,
109 &ok); 103 &ok);
110#if START_SERVICE
111 if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) 104 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
112 { 105 {
113 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 106 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
@@ -116,18 +109,8 @@ check ()
116 GNUNET_OS_process_wait (proc); 109 GNUNET_OS_process_wait (proc);
117 GNUNET_OS_process_destroy (proc); 110 GNUNET_OS_process_destroy (proc);
118 proc = NULL; 111 proc = NULL;
119#endif 112 GNUNET_free (binary);
120 return ok; 113 return ok;
121} 114}
122 115
123int
124main (int argc, char *argv[])
125{
126 int ret;
127
128 ret = check ();
129
130 return ret;
131}
132
133/* end of test_statistics_api_loop.c */ 116/* end of test_statistics_api_loop.c */