2 This file is part of GNUnet.
3 (C) 2010, 2012 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 fs/test_fs_test_lib.c
23 * @brief test fs test library
24 * @author Christian Grothoff
27 #include "fs_test_lib.h"
29 #define VERBOSE GNUNET_NO
32 * File-size we use for testing.
34 #define FILESIZE (1024 * 1024 * 2)
37 * How long until we give up on transmitting the message?
39 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
45 static struct GNUNET_TESTBED_Peer *the_peers[NUM_DAEMONS];
51 do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
53 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
60 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n",
61 (unsigned long long) FILESIZE);
63 GNUNET_SCHEDULER_shutdown ();
68 do_download (void *cls, const struct GNUNET_FS_Uri *uri)
73 GNUNET_SCHEDULER_shutdown ();
77 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n",
78 (unsigned long long) FILESIZE);
79 GNUNET_FS_TEST_download (the_peers[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop,
85 do_publish (void *cls,
86 struct GNUNET_TESTBED_Operation *op,
89 GNUNET_TESTBED_operation_done (op);
92 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to connect peers: %s\n", emsg);
95 GNUNET_SCHEDULER_shutdown ();
98 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n",
99 (unsigned long long) FILESIZE);
100 GNUNET_FS_TEST_publish (the_peers[0], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED,
101 VERBOSE, &do_download, NULL);
107 * Actual main function for the test.
110 * @param num_peers number of peers in 'peers'
111 * @param peers handle to peers run in the testbed
115 unsigned int num_peers,
116 struct GNUNET_TESTBED_Peer **peers)
120 GNUNET_assert (NUM_DAEMONS == num_peers);
121 for (i=0;i<num_peers;i++)
122 the_peers[i] = peers[i];
123 GNUNET_TESTBED_overlay_connect (NULL,
132 * Main function that initializes the testbed.
134 * @param argc ignored
135 * @param argv ignored
136 * @return 0 on success
139 main (int argc, char *argv[])
141 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
142 (void) GNUNET_TESTBED_test_run ("test_fs_test_lib",
143 "fs_test_lib_data.conf",
147 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
151 /* end of test_fs_test_lib.c */