1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
/*
This file is part of GNUnet.
(C) 2010 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/**
* @file fs/fs_test_lib.h
* @brief library routines for testing FS publishing and downloading
* with multiple peers; this code is limited to flat files
* and no keywords (those functions can be tested with
* single-peer setups; this is for testing routing).
* @author Christian Grothoff
*/
#ifndef FS_TEST_LIB_H
#define FS_TEST_LIB_H
#include "gnunet_util_lib.h"
#include "gnunet_fs_service.h"
/**
* Handle for a daemon started for testing FS.
*/
struct GNUNET_FS_TestDaemon;
/**
* Start daemons for testing.
*
* @param template_cfg_file configuration template to use
* @param timeout if this operation cannot be completed within the
* given period, call the continuation with an error code
* @param total number of daemons to start
* @param daemons array of 'total' entries to be initialized
* (array must already be allocated, will be filled)
* @param cont function to call when done; note that if 'cont'
* is called with reason "TIMEOUT", then starting the
* daemons has failed and the client MUST NOT call
* 'GNUNET_FS_TEST_daemons_stop'!
* @param cont_cls closure for cont
*/
void
GNUNET_FS_TEST_daemons_start (const char *template_cfg_file,
struct GNUNET_TIME_Relative timeout,
unsigned int total,
struct GNUNET_FS_TestDaemon **daemons,
GNUNET_SCHEDULER_Task cont, void *cont_cls);
struct GNUNET_FS_TEST_ConnectContext;
/**
* Connect two daemons for testing.
*
* @param daemon1 first daemon to connect
* @param daemon2 second first daemon to connect
* @param timeout if this operation cannot be completed within the
* given period, call the continuation with an error code
* @param cont function to call when done
* @param cont_cls closure for cont
*/
struct GNUNET_FS_TEST_ConnectContext *
GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1,
struct GNUNET_FS_TestDaemon *daemon2,
struct GNUNET_TIME_Relative timeout,
GNUNET_SCHEDULER_Task cont, void *cont_cls);
/**
* Cancel connect operation.
*
* @param cc operation to cancel
*/
void
GNUNET_FS_TEST_daemons_connect_cancel (struct GNUNET_FS_TEST_ConnectContext
*cc);
/**
* Obtain peer group used for testing.
*
* @param daemons array with the daemons (must contain at least one)
* @return peer group
*/
struct GNUNET_TESTING_PeerGroup *
GNUNET_FS_TEST_get_group (struct GNUNET_FS_TestDaemon **daemons);
/**
* Obtain peer configuration used for testing.
*
* @param daemons array with the daemons
* @param off which configuration to get
* @return peer configuration
*/
const struct GNUNET_CONFIGURATION_Handle *
GNUNET_FS_TEST_get_configuration (struct GNUNET_FS_TestDaemon **daemons,
unsigned int off);
/**
* Stop daemons used for testing.
*
* @param total number of daemons to stop
* @param daemons array with the daemons (values will be clobbered)
*/
void
GNUNET_FS_TEST_daemons_stop (unsigned int total,
struct GNUNET_FS_TestDaemon **daemons);
/**
* Function signature.
*
* @param cls closure (user defined)
* @param uri a URI, NULL for errors
*/
typedef void (*GNUNET_FS_TEST_UriContinuation) (void *cls,
const struct GNUNET_FS_Uri *
uri);
/**
* Publish a file at the given daemon.
*
* @param daemon where to publish
* @param timeout if this operation cannot be completed within the
* given period, call the continuation with an error code
* @param anonymity option for publication
* @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
* GNUNET_SYSERR for simulation
* @param size size of the file to publish
* @param seed seed to use for file generation
* @param verbose how verbose to be in reporting
* @param cont function to call when done
* @param cont_cls closure for cont
*/
void
GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon,
struct GNUNET_TIME_Relative timeout, uint32_t anonymity,
int do_index, uint64_t size, uint32_t seed,
unsigned int verbose,
GNUNET_FS_TEST_UriContinuation cont, void *cont_cls);
/**
* Perform test download.
*
* @param daemon which peer to download from
* @param timeout if this operation cannot be completed within the
* given period, call the continuation with an error code
* @param anonymity option for download
* @param seed used for file validation
* @param uri URI of file to download (CHK/LOC only)
* @param verbose how verbose to be in reporting
* @param cont function to call when done
* @param cont_cls closure for cont
*/
void
GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon,
struct GNUNET_TIME_Relative timeout,
uint32_t anonymity, uint32_t seed,
const struct GNUNET_FS_Uri *uri, unsigned int verbose,
GNUNET_SCHEDULER_Task cont, void *cont_cls);
#endif
|