aboutsummaryrefslogtreecommitdiff
path: root/src/statistics/test_statistics_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/statistics/test_statistics_api.c')
-rw-r--r--src/statistics/test_statistics_api.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/statistics/test_statistics_api.c b/src/statistics/test_statistics_api.c
index 378e17d0c..5c55a11a6 100644
--- a/src/statistics/test_statistics_api.c
+++ b/src/statistics/test_statistics_api.c
@@ -29,7 +29,7 @@
29#include "gnunet_scheduler_lib.h" 29#include "gnunet_scheduler_lib.h"
30#include "gnunet_statistics_service.h" 30#include "gnunet_statistics_service.h"
31 31
32#define VERBOSE GNUNET_NO 32#define DEBUG_STATISTICS GNUNET_NO
33 33
34#define START_SERVICE GNUNET_YES 34#define START_SERVICE GNUNET_YES
35 35
@@ -38,6 +38,11 @@ check_1 (void *cls,
38 const char *subsystem, 38 const char *subsystem,
39 const char *name, uint64_t value, int is_persistent) 39 const char *name, uint64_t value, int is_persistent)
40{ 40{
41 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
42 "Received value %llu for `%s:%s\n",
43 (unsigned long long) value,
44 subsystem,
45 name);
41 GNUNET_assert (0 == strcmp (name, "test-1")); 46 GNUNET_assert (0 == strcmp (name, "test-1"));
42 GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api")); 47 GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api"));
43 GNUNET_assert (value == 1); 48 GNUNET_assert (value == 1);
@@ -50,6 +55,11 @@ check_2 (void *cls,
50 const char *subsystem, 55 const char *subsystem,
51 const char *name, uint64_t value, int is_persistent) 56 const char *name, uint64_t value, int is_persistent)
52{ 57{
58 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
59 "Received value %llu for `%s:%s\n",
60 (unsigned long long) value,
61 subsystem,
62 name);
53 GNUNET_assert (0 == strcmp (name, "test-2")); 63 GNUNET_assert (0 == strcmp (name, "test-2"));
54 GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api")); 64 GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api"));
55 GNUNET_assert (value == 2); 65 GNUNET_assert (value == 2);
@@ -62,6 +72,11 @@ check_3 (void *cls,
62 const char *subsystem, 72 const char *subsystem,
63 const char *name, uint64_t value, int is_persistent) 73 const char *name, uint64_t value, int is_persistent)
64{ 74{
75 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
76 "Received value %llu for `%s:%s\n",
77 (unsigned long long) value,
78 subsystem,
79 name);
65 GNUNET_assert (0 == strcmp (name, "test-3")); 80 GNUNET_assert (0 == strcmp (name, "test-3"));
66 GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api")); 81 GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api"));
67 GNUNET_assert (value == 3); 82 GNUNET_assert (value == 3);
@@ -85,6 +100,8 @@ static void
85next (void *cls, int success) 100next (void *cls, int success)
86{ 101{
87 GNUNET_assert (success == GNUNET_OK); 102 GNUNET_assert (success == GNUNET_OK);
103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
104 "Issuing GET request\n");
88 GNUNET_break (NULL != 105 GNUNET_break (NULL !=
89 GNUNET_STATISTICS_get (h, NULL, "test-2", 106 GNUNET_STATISTICS_get (h, NULL, "test-2",
90 GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, cls)); 107 GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, cls));
@@ -102,6 +119,8 @@ run (void *cls,
102 GNUNET_STATISTICS_set (h, "test-2", 2, GNUNET_NO); 119 GNUNET_STATISTICS_set (h, "test-2", 2, GNUNET_NO);
103 GNUNET_STATISTICS_set (h, "test-3", 2, GNUNET_NO); 120 GNUNET_STATISTICS_set (h, "test-3", 2, GNUNET_NO);
104 GNUNET_STATISTICS_update (h, "test-3", 1, GNUNET_YES); 121 GNUNET_STATISTICS_update (h, "test-3", 1, GNUNET_YES);
122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
123 "Issuing GET request\n");
105 GNUNET_break (NULL != 124 GNUNET_break (NULL !=
106 GNUNET_STATISTICS_get (h, NULL, "test-1", 125 GNUNET_STATISTICS_get (h, NULL, "test-1",
107 GNUNET_TIME_UNIT_SECONDS, &next, &check_1, cls)); 126 GNUNET_TIME_UNIT_SECONDS, &next, &check_1, cls));
@@ -127,6 +146,11 @@ check ()
127 char *const argv[] = { "test-statistics-api", 146 char *const argv[] = { "test-statistics-api",
128 "-c", 147 "-c",
129 "test_statistics_api_data.conf", 148 "test_statistics_api_data.conf",
149#if DEBUG_STATISTICS
150 "-L", "DEBUG",
151#else
152 "-L", "WARNING",
153#endif
130 NULL 154 NULL
131 }; 155 };
132 struct GNUNET_GETOPT_CommandLineOption options[] = { 156 struct GNUNET_GETOPT_CommandLineOption options[] = {
@@ -141,7 +165,7 @@ check ()
141#endif 165#endif
142 "-c", "test_statistics_api_data.conf", NULL); 166 "-c", "test_statistics_api_data.conf", NULL);
143#endif 167#endif
144 GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", 168 GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp",
145 options, &run, &ok); 169 options, &run, &ok);
146#if START_SERVICE 170#if START_SERVICE
147 if (0 != PLIBC_KILL (pid, SIGTERM)) 171 if (0 != PLIBC_KILL (pid, SIGTERM))
@@ -163,7 +187,7 @@ check ()
163#endif 187#endif
164 "-c", "test_statistics_api_data.conf", NULL); 188 "-c", "test_statistics_api_data.conf", NULL);
165#endif 189#endif
166 GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", 190 GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp",
167 options, &run_more, &ok); 191 options, &run_more, &ok);
168#if START_SERVICE 192#if START_SERVICE
169 if (0 != PLIBC_KILL (pid, SIGTERM)) 193 if (0 != PLIBC_KILL (pid, SIGTERM))
@@ -181,6 +205,13 @@ main (int argc, char *argv[])
181{ 205{
182 int ret; 206 int ret;
183 207
208 GNUNET_log_setup ("test_statistics_api",
209#if DEBUG_STATISTICS
210 "DEBUG",
211#else
212 "WARNING",
213#endif
214 NULL);
184 ret = check (); 215 ret = check ();
185 216
186 return ret; 217 return ret;