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;
15 do_shutdown (void *cls,
16 const struct GNUNET_SCHEDULER_TaskContext *tc)
19 GNUNET_MESH_disconnect (mesh);
21 if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM)) {
22 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);
30 error_shutdown (void *cls,
31 const struct GNUNET_SCHEDULER_TaskContext *tc)
34 GNUNET_MESH_disconnect (mesh);
36 if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM)) {
37 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
39 GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid));
40 GNUNET_OS_process_close (arm_pid);
46 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) {
47 GNUNET_MESH_ApplicationType app;
49 arm_pid = GNUNET_OS_start_process (NULL, NULL,
53 "-c", "test_mesh.conf",
56 mesh = GNUNET_MESH_connect(cfg, NULL, NULL, handlers, &app);
58 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Couldn't connect to mesh :(\n");
60 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "YAY! CONNECTED TO MESH :D\n");
63 /* do real test work here */
64 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(
65 GNUNET_TIME_UNIT_SECONDS, 5),
71 int main (int argc, char *argv[]) {
73 char *const argv2[] = {"test-mesh-api",
74 "-c", "test_mesh.conf",
78 struct GNUNET_GETOPT_CommandLineOption options[] = {
79 GNUNET_GETOPT_OPTION_END
81 GNUNET_log_setup ("test-dht-api","DEBUG", NULL);
82 ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1,
83 argv2, "test-mesh-api", "nohelp",
85 if (ret != GNUNET_OK) {
86 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
87 "test-mesh-api': Failed with error code %d\n", ret);