aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/test_mesh_api.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-08-30 09:10:02 +0000
committerBart Polot <bart@net.in.tum.de>2011-08-30 09:10:02 +0000
commitd89572e31baedfab391428de67a376abc14ff849 (patch)
tree52c41e70cea4ef022967313081c4e941023b06ad /src/mesh/test_mesh_api.c
parent3c9b3f415156a699558e7494862c4bbbe22c31f0 (diff)
downloadgnunet-d89572e31baedfab391428de67a376abc14ff849.tar.gz
gnunet-d89572e31baedfab391428de67a376abc14ff849.zip
Fix tests, peer commands api <-> service
Diffstat (limited to 'src/mesh/test_mesh_api.c')
-rw-r--r--src/mesh/test_mesh_api.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/src/mesh/test_mesh_api.c b/src/mesh/test_mesh_api.c
index fbef7ee19..8e7bca807 100644
--- a/src/mesh/test_mesh_api.c
+++ b/src/mesh/test_mesh_api.c
@@ -67,33 +67,25 @@ static struct GNUNET_MESH_MessageHandler handlers[] = { {&callback, 1, 0},
67static void 67static void
68do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 68do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
69{ 69{
70 fprintf (stderr, "++++++++ STARTING SHUTDOWN\n");
71 fprintf (stderr, "+++++++++ ABORT TASK\n");
72 if (0 != abort_task) 70 if (0 != abort_task)
73 { 71 {
74 GNUNET_SCHEDULER_cancel (abort_task); 72 GNUNET_SCHEDULER_cancel (abort_task);
75 } 73 }
76 fprintf (stderr, "+++++++++ DISCONNECT MESH\n");
77 if (NULL != mesh) 74 if (NULL != mesh)
78 { 75 {
79 GNUNET_MESH_disconnect (mesh); 76 GNUNET_MESH_disconnect (mesh);
80 } 77 }
81 fprintf (stderr, "+++++++++ KILL PROCESS\n");
82 if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM)) 78 if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM))
83 { 79 {
84 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 80 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
85 } 81 }
86 fprintf (stderr, "+++++++++ WAIT\n");
87 GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid)); 82 GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid));
88 fprintf (stderr, "+++++++++ PROCESS CLOSE\n");
89 GNUNET_OS_process_close (arm_pid); 83 GNUNET_OS_process_close (arm_pid);
90 fprintf (stderr, "++++++++ END SHUTDOWN\n");
91} 84}
92 85
93static void 86static void
94do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 87do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
95{ 88{
96 fprintf (stderr, "++++++++ STARTING ABORT\n");
97 if (0 != test_task) 89 if (0 != test_task)
98 { 90 {
99 GNUNET_SCHEDULER_cancel (test_task); 91 GNUNET_SCHEDULER_cancel (test_task);
@@ -101,16 +93,15 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
101 result = GNUNET_SYSERR; 93 result = GNUNET_SYSERR;
102 abort_task = 0; 94 abort_task = 0;
103 do_shutdown (cls, tc); 95 do_shutdown (cls, tc);
104 fprintf (stderr, "++++++++ END ABORT\n");
105} 96}
106 97
107static void 98static void
108test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 99test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
109{ 100{
110 struct GNUNET_CONFIGURATION_Handle *cfg = cls; 101 struct GNUNET_CONFIGURATION_Handle *cfg = cls;
111 static const GNUNET_MESH_ApplicationType app[] = { 1, 2, 3, 0 }; 102 static const GNUNET_MESH_ApplicationType app[] = { 1, 2, 3, 4, 5, 6, 7, 8, 0};
103 struct GNUNET_MESH_Tunnel *t;
112 104
113 fprintf (stderr, "++++++++ STARTING TEST\n");
114 test_task = (GNUNET_SCHEDULER_TaskIdentifier) 0; 105 test_task = (GNUNET_SCHEDULER_TaskIdentifier) 0;
115 mesh = GNUNET_MESH_connect (cfg, NULL, NULL, handlers, app); 106 mesh = GNUNET_MESH_connect (cfg, NULL, NULL, handlers, app);
116 if (NULL == mesh) 107 if (NULL == mesh)
@@ -123,10 +114,16 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
123 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "YAY! CONNECTED TO MESH :D\n"); 114 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "YAY! CONNECTED TO MESH :D\n");
124 } 115 }
125 116
117 t = GNUNET_MESH_tunnel_create(mesh,
118 NULL,
119 NULL,
120 NULL);
121
122 GNUNET_MESH_tunnel_destroy(t);
123
126 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 124 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
127 (GNUNET_TIME_UNIT_SECONDS, 3), &do_shutdown, 125 (GNUNET_TIME_UNIT_SECONDS, 5), &do_shutdown,
128 NULL); 126 NULL);
129 fprintf (stderr, "++++++++ END TEST\n");
130} 127}
131 128
132 129
@@ -134,8 +131,7 @@ static void
134run (void *cls, char *const *args, const char *cfgfile, 131run (void *cls, char *const *args, const char *cfgfile,
135 const struct GNUNET_CONFIGURATION_Handle *cfg) 132 const struct GNUNET_CONFIGURATION_Handle *cfg)
136{ 133{
137 fprintf (stderr, "++++++++ STARTING RUN\n"); 134 GNUNET_log_setup ("test_mesh_api",
138 GNUNET_log_setup ("test_mesh_small",
139#if VERBOSE 135#if VERBOSE
140 "DEBUG", 136 "DEBUG",
141#else 137#else
@@ -154,12 +150,9 @@ run (void *cls, char *const *args, const char *cfgfile,
154 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 150 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
155 (GNUNET_TIME_UNIT_SECONDS, 20), &do_abort, 151 (GNUNET_TIME_UNIT_SECONDS, 20), &do_abort,
156 NULL); 152 NULL);
157 test_task =
158 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &test,
159 (void *) cfg);
160// GNUNET_SCHEDULER_add_now (&test, (void *)cfg);
161 153
162 fprintf (stderr, "++++++++ END RUN\n"); 154 test_task = GNUNET_SCHEDULER_add_now (&test, (void *)cfg);
155
163} 156}
164 157
165 158
@@ -179,7 +172,6 @@ main (int argc, char *argv[])
179 GNUNET_GETOPT_OPTION_END 172 GNUNET_GETOPT_OPTION_END
180 }; 173 };
181 174
182 fprintf (stderr, "++++++++ STARTING TEST_API\n");
183 ret = 175 ret =
184 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, 176 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
185 "test-mesh-api", "nohelp", options, &run, NULL); 177 "test-mesh-api", "nohelp", options, &run, NULL);
@@ -196,6 +188,5 @@ main (int argc, char *argv[])
196 return 1; 188 return 1;
197 } 189 }
198 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test ok\n"); 190 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test ok\n");
199 fprintf (stderr, "++++++++ END TEST_API\n");
200 return 0; 191 return 0;
201} 192}