diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-03-19 10:05:42 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-03-19 10:05:42 +0000 |
commit | 66c49d17094d8a6c80fe1880a8339f10493f23ee (patch) | |
tree | e26e76aeb223444e233e88564bb4c003a493e7d0 /src/ats | |
parent | 5e53368a783e8dbf20a3f505a27f2e5549b7cf34 (diff) | |
download | gnunet-66c49d17094d8a6c80fe1880a8339f10493f23ee.tar.gz gnunet-66c49d17094d8a6c80fe1880a8339f10493f23ee.zip |
test
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/Makefile.am | 10 | ||||
-rw-r--r-- | src/ats/test_ats_api_performance_monitor.c | 114 |
2 files changed, 124 insertions, 0 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am index 6aca15483..b94d88694 100644 --- a/src/ats/Makefile.am +++ b/src/ats/Makefile.am | |||
@@ -75,6 +75,7 @@ check_PROGRAMS = \ | |||
75 | test_ats_simplistic_change_preference \ | 75 | test_ats_simplistic_change_preference \ |
76 | test_ats_simplistic_pref_aging \ | 76 | test_ats_simplistic_pref_aging \ |
77 | test_ats_api_performance \ | 77 | test_ats_api_performance \ |
78 | test_ats_api_performance_monitor \ | ||
78 | $(GN_MLP_TEST) $(GN_MLP_PERF) $(GN_MLP_TEST_UPDATE) | 79 | $(GN_MLP_TEST) $(GN_MLP_PERF) $(GN_MLP_TEST_UPDATE) |
79 | # $(GN_MLP_TEST_AVG) | 80 | # $(GN_MLP_TEST_AVG) |
80 | # test_ats_api_scheduling_get_type | 81 | # test_ats_api_scheduling_get_type |
@@ -164,6 +165,15 @@ test_ats_api_performance_LDADD = \ | |||
164 | $(top_builddir)/src/testing/libgnunettesting.la \ | 165 | $(top_builddir)/src/testing/libgnunettesting.la \ |
165 | $(top_builddir)/src/hello/libgnunethello.la \ | 166 | $(top_builddir)/src/hello/libgnunethello.la \ |
166 | $(top_builddir)/src/ats/libgnunetats.la | 167 | $(top_builddir)/src/ats/libgnunetats.la |
168 | |||
169 | test_ats_api_performance_monitor_SOURCES = \ | ||
170 | test_ats_api_performance_monitor.c | ||
171 | test_ats_api_performance_monitor_LDADD = \ | ||
172 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
173 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
174 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
175 | $(top_builddir)/src/ats/libgnunetats.la | ||
176 | |||
167 | 177 | ||
168 | test_ats_simplistic_SOURCES = \ | 178 | test_ats_simplistic_SOURCES = \ |
169 | test_ats_simplistic.c test_ats_api_common.c | 179 | test_ats_simplistic.c test_ats_api_common.c |
diff --git a/src/ats/test_ats_api_performance_monitor.c b/src/ats/test_ats_api_performance_monitor.c new file mode 100644 index 000000000..3d1ab79b2 --- /dev/null +++ b/src/ats/test_ats_api_performance_monitor.c | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010,2011 Christian Grothoff (and other contributing authors) | ||
4 | |||
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 | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats/test_ats_api_performance_monitor.c | ||
22 | * @brief test performance monitoring | ||
23 | * @author Christian Grothoff | ||
24 | * @author Matthias Wachs | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_ats_service.h" | ||
28 | #include "gnunet_testing_lib.h" | ||
29 | #include "ats.h" | ||
30 | |||
31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | ||
32 | |||
33 | |||
34 | static GNUNET_SCHEDULER_TaskIdentifier die_task; | ||
35 | |||
36 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
37 | |||
38 | static struct GNUNET_ATS_PerformanceHandle *ph; | ||
39 | |||
40 | static struct GNUNET_ATS_PerformanceMonitorHandle *phm; | ||
41 | |||
42 | static int ret; | ||
43 | |||
44 | |||
45 | static void | ||
46 | end_now (int res) | ||
47 | { | ||
48 | if (GNUNET_SCHEDULER_NO_TASK != die_task) | ||
49 | { | ||
50 | GNUNET_SCHEDULER_cancel (die_task); | ||
51 | die_task = GNUNET_SCHEDULER_NO_TASK; | ||
52 | } | ||
53 | |||
54 | if (NULL != ph) | ||
55 | { | ||
56 | GNUNET_ATS_performance_done (ph); | ||
57 | ph = NULL; | ||
58 | } | ||
59 | ret = res; | ||
60 | } | ||
61 | |||
62 | static void | ||
63 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
64 | { | ||
65 | die_task = GNUNET_SCHEDULER_NO_TASK; | ||
66 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout\n"); | ||
67 | end_now (1); | ||
68 | } | ||
69 | |||
70 | |||
71 | static void | ||
72 | perf_mon_cb (void *cls, | ||
73 | struct GNUNET_PeerIdentity *peer, | ||
74 | struct GNUNET_ATS_Information *ats, | ||
75 | uint32_t ats_count) | ||
76 | { | ||
77 | |||
78 | } | ||
79 | |||
80 | |||
81 | static void | ||
82 | run (void *cls, | ||
83 | const struct GNUNET_CONFIGURATION_Handle *mycfg, | ||
84 | struct GNUNET_TESTING_Peer *peer) | ||
85 | { | ||
86 | ret = 1; | ||
87 | cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg; | ||
88 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | ||
89 | |||
90 | ph = GNUNET_ATS_performance_init (cfg, NULL, NULL); | ||
91 | GNUNET_assert (NULL != ph); | ||
92 | |||
93 | phm = GNUNET_ATS_performance_monitor_start (ph, &perf_mon_cb, &ret); | ||
94 | GNUNET_assert (NULL != phm); | ||
95 | |||
96 | GNUNET_ATS_performance_monitor_stop (phm); | ||
97 | |||
98 | GNUNET_ATS_performance_done (ph); | ||
99 | ph = NULL; | ||
100 | end_now (0); | ||
101 | } | ||
102 | |||
103 | |||
104 | int | ||
105 | main (int argc, char *argv[]) | ||
106 | { | ||
107 | if (0 != GNUNET_TESTING_peer_run ("test_ats_api_performance_monitor", | ||
108 | "test_ats_api.conf", | ||
109 | &run, NULL)) | ||
110 | return 1; | ||
111 | return ret; | ||
112 | } | ||
113 | |||
114 | /* end of file test_ats_api_performance_monitor.c */ | ||