aboutsummaryrefslogtreecommitdiff
path: root/src/nse
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-15 11:21:36 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-15 11:21:36 +0000
commit1dfa405cdd6ad888dff6386d4abecf44ef3828ab (patch)
treef4eb5e59749e336ea76166caf13eb549f6589430 /src/nse
parent43591012109e35be84cc4dad5fb91d08b50fc853 (diff)
downloadgnunet-1dfa405cdd6ad888dff6386d4abecf44ef3828ab.tar.gz
gnunet-1dfa405cdd6ad888dff6386d4abecf44ef3828ab.zip
-use port numbers that are less likely to conflict with source ports
Diffstat (limited to 'src/nse')
-rw-r--r--src/nse/Makefile.am1
-rw-r--r--src/nse/test_nse_api.c89
2 files changed, 10 insertions, 80 deletions
diff --git a/src/nse/Makefile.am b/src/nse/Makefile.am
index 2011661cf..8dcb56fbd 100644
--- a/src/nse/Makefile.am
+++ b/src/nse/Makefile.am
@@ -73,6 +73,7 @@ test_nse_api_SOURCES = \
73 test_nse_api.c 73 test_nse_api.c
74test_nse_api_LDADD = \ 74test_nse_api_LDADD = \
75 $(top_builddir)/src/nse/libgnunetnse.la \ 75 $(top_builddir)/src/nse/libgnunetnse.la \
76 $(top_builddir)/src/testing/libgnunettesting.la \
76 $(top_builddir)/src/util/libgnunetutil.la 77 $(top_builddir)/src/util/libgnunetutil.la
77 78
78test_nse_multipeer_SOURCES = \ 79test_nse_multipeer_SOURCES = \
diff --git a/src/nse/test_nse_api.c b/src/nse/test_nse_api.c
index f99cb3b03..c71d9161c 100644
--- a/src/nse/test_nse_api.c
+++ b/src/nse/test_nse_api.c
@@ -22,42 +22,15 @@
22 * @brief testcase for nse_api.c 22 * @brief testcase for nse_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_nse_service.h" 26#include "gnunet_nse_service.h"
27#include "gnunet_testing_lib-new.h"
31 28
32#define START_ARM GNUNET_YES
33 29
34static struct GNUNET_NSE_Handle *h; 30static struct GNUNET_NSE_Handle *h;
35 31
36static GNUNET_SCHEDULER_TaskIdentifier die_task; 32static GNUNET_SCHEDULER_TaskIdentifier die_task;
37 33
38struct PeerContext
39{
40 struct GNUNET_CONFIGURATION_Handle *cfg;
41#if START_ARM
42 struct GNUNET_OS_Process *arm_proc;
43#endif
44};
45
46static struct PeerContext p1;
47
48
49static void
50stop_arm (struct PeerContext *p)
51{
52#if START_ARM
53 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
54 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
55 GNUNET_OS_process_wait (p->arm_proc);
56 GNUNET_OS_process_destroy (p->arm_proc);
57 p->arm_proc = NULL;
58#endif
59 GNUNET_CONFIGURATION_destroy (p->cfg);
60}
61 34
62/** 35/**
63 * Signature of the main function of a task. 36 * Signature of the main function of a task.
@@ -103,26 +76,7 @@ check_nse_message (void *cls, struct GNUNET_TIME_Absolute timestamp,
103 76
104 77
105static void 78static void
106setup_peer (struct PeerContext *p, const char *cfgname) 79run (void *cls,
107{
108 p->cfg = GNUNET_CONFIGURATION_create ();
109#if START_ARM
110 p->arm_proc =
111 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
112 "gnunet-service-arm",
113#if VERBOSE_ARM
114 "-L", "DEBUG",
115#endif
116 "-c", cfgname, NULL);
117#endif
118 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
119
120}
121
122
123
124static void
125run (void *cls, char *const *args, const char *cfgfile,
126 const struct GNUNET_CONFIGURATION_Handle *cfg) 80 const struct GNUNET_CONFIGURATION_Handle *cfg)
127{ 81{
128 die_task = 82 die_task =
@@ -130,47 +84,22 @@ run (void *cls, char *const *args, const char *cfgfile,
130 (GNUNET_TIME_UNIT_MINUTES, 1), &end_test, 84 (GNUNET_TIME_UNIT_MINUTES, 1), &end_test,
131 NULL); 85 NULL);
132 86
133 setup_peer (&p1, cfgfile);
134 h = GNUNET_NSE_connect (cfg, &check_nse_message, cls); 87 h = GNUNET_NSE_connect (cfg, &check_nse_message, cls);
135 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to NSE service.\n"); 88 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to NSE service.\n");
136 GNUNET_assert (h != NULL); 89 GNUNET_assert (h != NULL);
137} 90}
138 91
139 92
140static int
141check ()
142{
143 int ok = 1;
144
145 char *const argv[] = { "test-nse-api",
146 "-c",
147 "test_nse.conf",
148 "-L", "WARNING",
149 NULL
150 };
151 struct GNUNET_GETOPT_CommandLineOption options[] = {
152 GNUNET_GETOPT_OPTION_END
153 };
154
155 GNUNET_PROGRAM_run (5, argv, "test-nse-api", "nohelp", options, &run, &ok);
156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping arm.\n");
157 stop_arm (&p1);
158 if (0 != ok)
159 FPRINTF (stderr, "%s", "No information received from NSE service!\n");
160 return ok;
161}
162
163
164int 93int
165main (int argc, char *argv[]) 94main (int argc, char *argv[])
166{ 95{
167 int ret; 96 int ok = 1;
168 97
169 GNUNET_log_setup ("test_nse_api", 98 if (0 != GNUNET_TESTING_peer_run ("test_nse_api",
170 "WARNING", 99 "test_nse.conf",
171 NULL); 100 &run, &ok))
172 ret = check (); 101 return 1;
173 return ret; 102 return ok;
174} 103}
175 104
176/* end of test_nse_api.c */ 105/* end of test_nse_api.c */