2 This file is part of GNUnet.
3 Copyright (C) 2019 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
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 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @file transport/test_communicator_unix.c
23 * @brief test the unix communicator
24 * @author Julius Bünger
27 #include "gnunet_util_lib.h"
28 #include "transport-testing2.h"
29 #include "gnunet_ats_transport_service.h"
30 #include "gnunet_signatures.h"
31 #include "transport.h"
35 * - start two communicators
36 * - act like transport services
37 * - get_server_addresses (service.c)
38 * - open_listen_socket (service.c)
39 * - GNUNET_MQ_queue_for_callbacks (service.c)
40 * - let them communicate
46 #define LOG(kind,...) GNUNET_log_from (kind, "test_transport_communicator_unix", __VA_ARGS__)
49 communicator_available (void *cls,
50 const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
52 LOG (GNUNET_ERROR_TYPE_DEBUG,
53 "communicator_available()\n");
59 struct GNUNET_CONFIGURATION_Handle *cfg = cls;
61 GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
63 "test_communicator_1.conf",
64 &communicator_available,
66 GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
68 "test_communicator_2.conf",
69 &communicator_available,
78 char *opt_cfg_filename;
82 struct GNUNET_CONFIGURATION_Handle *cfg;
84 struct GNUNET_GETOPT_CommandLineOption service_options[] = {
85 GNUNET_GETOPT_option_cfgfile (&opt_cfg_filename),
86 GNUNET_GETOPT_option_help (NULL),
87 GNUNET_GETOPT_option_loglevel (&loglev),
88 GNUNET_GETOPT_option_logfile (&logfile),
89 GNUNET_GETOPT_OPTION_END
92 if (GNUNET_OK != GNUNET_log_setup ("test_communicator_unix",
100 xdg = getenv ("XDG_CONFIG_HOME");
102 GNUNET_asprintf (&cfg_filename,
106 GNUNET_OS_project_data_get ()->config_file);
108 cfg_filename = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file);
109 cfg = GNUNET_CONFIGURATION_create ();
110 if (NULL != opt_cfg_filename)
113 GNUNET_DISK_file_test (opt_cfg_filename)) ||
115 GNUNET_CONFIGURATION_load (cfg,
118 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
119 _("Malformed configuration file `%s', exit ...\n"),
121 return GNUNET_SYSERR;
127 GNUNET_DISK_file_test (cfg_filename))
130 GNUNET_CONFIGURATION_load (cfg,
133 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
134 _("Malformed configuration file `%s', exit ...\n"),
136 return GNUNET_SYSERR;
142 GNUNET_CONFIGURATION_load (cfg,
145 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
146 _("Malformed configuration, exit ...\n"));
147 return GNUNET_SYSERR;
151 GNUNET_SCHEDULER_run (&run,