2 #include "gnunet_util_lib.h"
3 #include "gnunet_dht_service.h"
4 #include "gnunet_mesh_service_new.h"
6 static struct GNUNET_MESH_MessageHandler handlers[] = {
10 static struct GNUNET_OS_Process *arm_pid;
12 static struct GNUNET_MESH_Handle *mesh;
14 static struct GNUNET_DHT_Handle *dht;
17 do_shutdown (void *cls,
18 const struct GNUNET_SCHEDULER_TaskContext *tc)
21 GNUNET_MESH_disconnect (mesh);
22 if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM))
23 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
24 GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid));
25 GNUNET_OS_process_close (arm_pid);
32 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) {
33 GNUNET_MESH_ApplicationType app;
37 arm_pid = GNUNET_OS_start_process (NULL, NULL,
41 "-c", "test_mesh.conf",
43 dht = GNUNET_DHT_connect(cfg, 100);
45 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Couldn't connect to dht :(\n");
47 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "YAY! CONNECTED TO DHT :D\n");
51 mesh = GNUNET_MESH_connect(cfg, NULL, NULL, handlers, &app);
53 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Couldn't connect to mesh :(\n");
55 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "YAY! CONNECTED TO MESH :D\n");
58 /* do real test work here */
59 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
68 int main (int argc, char *argv[]) {
70 char *const argv2[] = {"test-mesh-api",
71 "-c", "test_mesh.conf",
75 struct GNUNET_GETOPT_CommandLineOption options[] = {
76 GNUNET_GETOPT_OPTION_END
78 GNUNET_log_setup ("test-dht-api","DEBUG", NULL);
79 ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1,
80 argv2, "test-mesh-api", "nohelp",
82 if (ret != GNUNET_OK) {
83 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "test-mesh-api': Failed with error code %d\n", ret);