2 This file is part of GNUnet.
3 (C) 2010 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 2, 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, 60)
45 static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS];
47 static struct GNUNET_SCHEDULER_Handle *sched;
53 const struct GNUNET_SCHEDULER_TaskContext *tc)
55 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
62 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
63 "Finished download, shutting down\n",
64 (unsigned long long) FILESIZE);
66 GNUNET_FS_TEST_daemons_stop (sched,
73 do_download (void *cls,
74 const struct GNUNET_FS_Uri *uri)
79 GNUNET_SCHEDULER_add_now (sched,
85 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
86 "Downloading %llu bytes\n",
87 (unsigned long long) FILESIZE);
88 GNUNET_FS_TEST_download (sched,
98 do_publish (void *cls,
99 const struct GNUNET_SCHEDULER_TaskContext *tc)
101 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
105 GNUNET_SCHEDULER_add_now (sched,
110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
111 "Publishing %llu bytes\n",
112 (unsigned long long) FILESIZE);
113 GNUNET_FS_TEST_publish (sched,
116 1, GNUNET_NO, FILESIZE, SEED,
123 do_connect (void *cls,
124 const struct GNUNET_SCHEDULER_TaskContext *tc)
126 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
130 GNUNET_SCHEDULER_add_now (sched,
135 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
136 "Daemons started, will now try to connect them\n");
137 GNUNET_FS_TEST_daemons_connect (sched,
148 struct GNUNET_SCHEDULER_Handle *s,
151 const struct GNUNET_CONFIGURATION_Handle *cfg)
154 GNUNET_FS_TEST_daemons_start (sched,
164 main (int argc, char *argv[])
166 char *const argvx[] = {
169 "fs_test_lib_data.conf",
175 struct GNUNET_GETOPT_CommandLineOption options[] = {
176 GNUNET_GETOPT_OPTION_END
179 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
180 GNUNET_log_setup ("test_fs_test_lib",
187 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1,
188 argvx, "test-fs-test-lib",
189 "nohelp", options, &run, NULL);
190 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
194 /* end of test_fs_test_lib.c */