2 * This file is part of GNUnet
3 * (C) 2013 Christian Grothoff (and other contributing authors)
5 * GNUnet is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 3, or (at your
8 * 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 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNUnet; see the file COPYING. If not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * @file multicast/test_multicast.c
23 * @brief Tests for the Multicast API.
24 * @author Gabor X Toth
30 #include "gnunet_crypto_lib.h"
31 #include "gnunet_common.h"
32 #include "gnunet_util_lib.h"
33 #include "gnunet_testing_lib.h"
34 #include "gnunet_multicast_service.h"
36 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
38 #define DEBUG_SERVICE 0
41 * Return value from 'main'.
45 static const struct GNUNET_CONFIGURATION_Handle *cfg;
48 * Handle for task for timeout termination.
50 static GNUNET_SCHEDULER_TaskIdentifier end_badly_task;
54 * Clean up all resources used.
64 * Terminate the test case (failure).
67 * @param tc scheduler context
70 end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
74 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test FAILED.\n");
79 * Terminate the test case (success).
82 * @param tc scheduler context
85 end_normally (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
89 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test PASSED.\n");
94 * Finish the test case (successfully).
99 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending tests.\n");
101 if (end_badly_task != GNUNET_SCHEDULER_NO_TASK)
103 GNUNET_SCHEDULER_cancel (end_badly_task);
104 end_badly_task = GNUNET_SCHEDULER_NO_TASK;
106 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
107 &end_normally, NULL);
112 * Main function of the test, run from scheduler.
115 * @param cfg configuration we use (also to connect to Multicast service)
116 * @param peer handle to access more of the peer (not used)
120 run (void *cls, char *const *args, const char *cfgfile,
121 const struct GNUNET_CONFIGURATION_Handle *c)
124 const struct GNUNET_CONFIGURATION_Handle *c,
125 struct GNUNET_TESTING_Peer *peer)
129 end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
131 /* FIXME: add tests */
138 main (int argc, char *argv[])
142 const struct GNUNET_GETOPT_CommandLineOption opts[] = {
143 GNUNET_GETOPT_OPTION_END
145 if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "test-multicast",
146 "test-multicast [options]",
150 if (0 != GNUNET_TESTING_peer_run ("test-multicast", "test_multicast.conf", &run, NULL))
156 /* end of test_multicast.c */