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 (
64 &communicator_available,
73 char *opt_cfg_filename;
77 struct GNUNET_CONFIGURATION_Handle *cfg;
79 struct GNUNET_GETOPT_CommandLineOption service_options[] = {
80 GNUNET_GETOPT_option_cfgfile (&opt_cfg_filename),
81 GNUNET_GETOPT_option_help (NULL),
82 GNUNET_GETOPT_option_loglevel (&loglev),
83 GNUNET_GETOPT_option_logfile (&logfile),
84 GNUNET_GETOPT_OPTION_END
87 if (GNUNET_OK != GNUNET_log_setup ("test_communicator_unix",
95 xdg = getenv ("XDG_CONFIG_HOME");
97 GNUNET_asprintf (&cfg_filename,
101 GNUNET_OS_project_data_get ()->config_file);
103 cfg_filename = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file);
104 cfg = GNUNET_CONFIGURATION_create ();
105 if (NULL != opt_cfg_filename)
108 GNUNET_DISK_file_test (opt_cfg_filename)) ||
110 GNUNET_CONFIGURATION_load (cfg,
113 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
114 _("Malformed configuration file `%s', exit ...\n"),
116 return GNUNET_SYSERR;
122 GNUNET_DISK_file_test (cfg_filename))
125 GNUNET_CONFIGURATION_load (cfg,
128 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
129 _("Malformed configuration file `%s', exit ...\n"),
131 return GNUNET_SYSERR;
137 GNUNET_CONFIGURATION_load (cfg,
140 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
141 _("Malformed configuration, exit ...\n"));
142 return GNUNET_SYSERR;
146 GNUNET_SCHEDULER_run (&run,