library routines for testing FS publishing and downloading; this code is limited to flat files and no keywords (those functions can be tested with single-peer setups; this is for testing routing). More...
Go to the source code of this file.
Data Structures | |
struct | TestPublishOperation |
Handle for a publishing operation started for testing FS. More... | |
struct | TestDownloadOperation |
Handle for a download operation started for testing FS. More... | |
Macros | |
#define | CONTENT_LIFETIME GNUNET_TIME_UNIT_HOURS |
Functions | |
static void | report_uri (void *cls) |
Task scheduled to report on the completion of our publish operation. More... | |
static void | publish_timeout (void *cls) |
Task scheduled to run when publish operation times out. More... | |
static void * | publish_progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) |
Progress callback for file-sharing events while publishing. More... | |
static size_t | file_generator (void *cls, uint64_t offset, size_t max, void *buf, char **emsg) |
Generate test data for publishing test. More... | |
static void * | publish_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) |
Connect adapter for publishing operation. More... | |
static void | fs_disconnect_adapter (void *cls, void *op_result) |
Adapter function called to destroy connection to file-sharing service. More... | |
static void | publish_fs_connect_complete_cb (void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg) |
Callback to be called when testbed has connected to the fs service. More... | |
void | GNUNET_FS_TEST_publish (struct GNUNET_TESTBED_Peer *peer, 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) |
Publish a file at the given daemon. More... | |
static void | download_timeout (void *cls) |
Task scheduled to run when download operation times out. More... | |
static void | report_success (void *cls) |
Task scheduled to report on the completion of our download operation. More... | |
static void * | download_progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) |
Progress callback for file-sharing events while downloading. More... | |
static void * | download_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) |
Connect adapter for download operation. More... | |
static void | download_fs_connect_complete_cb (void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg) |
Callback to be called when testbed has connected to the fs service. More... | |
void | GNUNET_FS_TEST_download (struct GNUNET_TESTBED_Peer *peer, struct GNUNET_TIME_Relative timeout, uint32_t anonymity, uint32_t seed, const struct GNUNET_FS_Uri *uri, unsigned int verbose, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls) |
Perform test download. More... | |
library routines for testing FS publishing and downloading; this code is limited to flat files and no keywords (those functions can be tested with single-peer setups; this is for testing routing).
Definition in file fs_test_lib.c.
#define CONTENT_LIFETIME GNUNET_TIME_UNIT_HOURS |
Definition at line 34 of file fs_test_lib.c.
|
static |
Task scheduled to report on the completion of our publish operation.
cls | the publish operation context |
Definition at line 182 of file fs_test_lib.c.
References TestPublishOperation::do_index, TestPublishOperation::fs_op, GNUNET_DISK_directory_remove(), GNUNET_free, GNUNET_FS_publish_stop(), GNUNET_FS_uri_destroy(), GNUNET_TESTBED_operation_done(), GNUNET_YES, TestPublishOperation::publish_cont, TestPublishOperation::publish_cont_cls, TestPublishOperation::publish_context, TestPublishOperation::publish_tmp_file, and TestPublishOperation::publish_uri.
Referenced by publish_progress_cb().
|
static |
Task scheduled to run when publish operation times out.
cls | the publish operation context |
Definition at line 208 of file fs_test_lib.c.
References TestPublishOperation::fs_op, GNUNET_DISK_directory_remove(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_FS_publish_stop(), GNUNET_log, GNUNET_TESTBED_operation_done(), TestPublishOperation::publish_cont, TestPublishOperation::publish_cont_cls, TestPublishOperation::publish_context, TestPublishOperation::publish_timeout_task, and TestPublishOperation::publish_tmp_file.
Referenced by GNUNET_FS_TEST_publish().
|
static |
Progress callback for file-sharing events while publishing.
cls | the publish operation context |
info | information about the event |
Definition at line 231 of file fs_test_lib.c.
References GNUNET_ERROR_TYPE_INFO, GNUNET_FS_STATUS_DOWNLOAD_PROGRESS, GNUNET_FS_STATUS_PUBLISH_COMPLETED, GNUNET_FS_STATUS_PUBLISH_PROGRESS, GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY, GNUNET_FS_uri_dup(), GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), info, TestPublishOperation::publish_timeout_task, TestPublishOperation::publish_uri, report_uri(), and TestPublishOperation::verbose.
Referenced by publish_connect_adapter().
|
static |
Generate test data for publishing test.
cls | pointer to uint32_t with publishing seed |
offset | offset to generate data for |
max | maximum number of bytes to generate |
buf | where to write generated data |
emsg | where to store error message (unused) |
Definition at line 281 of file fs_test_lib.c.
References buf, max, and TestPublishOperation::publish_seed.
Referenced by publish_fs_connect_complete_cb().
|
static |
Connect adapter for publishing operation.
cls | the 'struct TestPublishOperation' |
cfg | configuration of the peer to connect to; will be available until GNUNET_TESTBED_operation_done() is called on the operation returned from GNUNET_TESTBED_service_connect() |
Definition at line 319 of file fs_test_lib.c.
References cfg, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END, GNUNET_FS_start(), and publish_progress_cb().
Referenced by GNUNET_FS_TEST_publish().
|
static |
Adapter function called to destroy connection to file-sharing service.
cls | the 'struct GNUNET_FS_Handle' |
op_result | unused (different for publish/download!) |
Definition at line 339 of file fs_test_lib.c.
References fs, GNUNET_FS_stop(), and op_result().
Referenced by GNUNET_FS_TEST_download(), and GNUNET_FS_TEST_publish().
|
static |
Callback to be called when testbed has connected to the fs service.
cls | the 'struct TestPublishOperation' |
op | the operation that has been finished |
ca_result | the 'struct GNUNET_FS_Handle ' (NULL on error) |
emsg | error message in case the operation has failed; will be NULL if operation has executed successfully. |
Definition at line 358 of file fs_test_lib.c.
References TestPublishOperation::anonymity, GNUNET_FS_BlockOptions::anonymity_level, bo, bsize, buf, CONTENT_LIFETIME, GNUNET_FS_BlockOptions::content_priority, DBLOCK_SIZE, TestPublishOperation::do_index, GNUNET_FS_BlockOptions::expiration_time, fh, file_generator(), TestPublishOperation::fs, TestPublishOperation::fs_op, GNUNET_assert, GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_write(), GNUNET_DISK_mktemp(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_WRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_FS_file_information_create_from_file(), GNUNET_FS_file_information_create_from_reader(), GNUNET_FS_PUBLISH_OPTION_NONE, GNUNET_FS_publish_start(), GNUNET_log, GNUNET_MIN, GNUNET_OK, GNUNET_TESTBED_operation_done(), GNUNET_TIME_relative_to_absolute(), GNUNET_YES, TestPublishOperation::publish_cont, TestPublishOperation::publish_cont_cls, TestPublishOperation::publish_context, TestPublishOperation::publish_seed, TestPublishOperation::publish_tmp_file, GNUNET_FS_BlockOptions::replication_level, TestPublishOperation::size, and size.
Referenced by GNUNET_FS_TEST_publish().
void GNUNET_FS_TEST_publish | ( | struct GNUNET_TESTBED_Peer * | peer, |
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 | ||
) |
Publish a file at the given daemon.
peer | where to publish |
timeout | if this operation cannot be completed within the given period, call the continuation with an error code |
anonymity | option for publication |
do_index | GNUNET_YES for index, GNUNET_NO for insertion, GNUNET_SYSERR for simulation |
size | size of the file to publish |
seed | seed to use for file generation |
verbose | how verbose to be in reporting |
cont | function to call when done |
cont_cls | closure for cont |
Definition at line 433 of file fs_test_lib.c.
References TestPublishOperation::anonymity, anonymity, TestPublishOperation::do_index, fs_disconnect_adapter(), TestPublishOperation::fs_op, GNUNET_new, GNUNET_SCHEDULER_add_delayed(), GNUNET_TESTBED_service_connect(), peer, publish_connect_adapter(), TestPublishOperation::publish_cont, TestPublishOperation::publish_cont_cls, publish_fs_connect_complete_cb(), TestPublishOperation::publish_seed, publish_timeout(), TestPublishOperation::publish_timeout_task, TestPublishOperation::size, size, timeout, verbose, and TestPublishOperation::verbose.
|
static |
Task scheduled to run when download operation times out.
cls | the download operation context |
Definition at line 471 of file fs_test_lib.c.
References TestDownloadOperation::download_cont, TestDownloadOperation::download_cont_cls, TestDownloadOperation::download_context, TestDownloadOperation::download_timeout_task, TestDownloadOperation::fs_op, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_FS_download_stop(), GNUNET_FS_uri_destroy(), GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_TESTBED_operation_done(), GNUNET_YES, and TestDownloadOperation::uri.
Referenced by GNUNET_FS_TEST_download().
|
static |
Task scheduled to report on the completion of our download operation.
cls | the download operation context |
Definition at line 494 of file fs_test_lib.c.
References TestDownloadOperation::download_cont, TestDownloadOperation::download_cont_cls, TestDownloadOperation::download_context, TestDownloadOperation::fs_op, GNUNET_free, GNUNET_FS_download_stop(), GNUNET_FS_uri_destroy(), GNUNET_SCHEDULER_add_now(), GNUNET_TESTBED_operation_done(), GNUNET_YES, and TestDownloadOperation::uri.
Referenced by download_progress_cb().
|
static |
Progress callback for file-sharing events while downloading.
cls | the download operation context |
info | information about the event |
Definition at line 515 of file fs_test_lib.c.
References TestDownloadOperation::download_timeout_task, GNUNET_ERROR_TYPE_INFO, GNUNET_FS_STATUS_DOWNLOAD_ACTIVE, GNUNET_FS_STATUS_DOWNLOAD_COMPLETED, GNUNET_FS_STATUS_DOWNLOAD_INACTIVE, GNUNET_FS_STATUS_DOWNLOAD_PROGRESS, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), info, report_success(), and TestDownloadOperation::verbose.
Referenced by download_connect_adapter().
|
static |
Connect adapter for download operation.
cls | the 'struct TestDownloadOperation' |
cfg | configuration of the peer to connect to; will be available until GNUNET_TESTBED_operation_done() is called on the operation returned from GNUNET_TESTBED_service_connect() |
Definition at line 560 of file fs_test_lib.c.
References cfg, download_progress_cb(), GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END, and GNUNET_FS_start().
Referenced by GNUNET_FS_TEST_download().
|
static |
Callback to be called when testbed has connected to the fs service.
cls | the 'struct TestPublishOperation' |
op | the operation that has been finished |
ca_result | the 'struct GNUNET_FS_Handle ' (NULL on error) |
emsg | error message in case the operation has failed; will be NULL if operation has executed successfully. |
Definition at line 583 of file fs_test_lib.c.
References TestDownloadOperation::anonymity, TestDownloadOperation::download_context, TestDownloadOperation::fs, GNUNET_assert, GNUNET_FS_DOWNLOAD_OPTION_NONE, GNUNET_FS_download_start(), TestDownloadOperation::size, and TestDownloadOperation::uri.
Referenced by GNUNET_FS_TEST_download().
void GNUNET_FS_TEST_download | ( | struct GNUNET_TESTBED_Peer * | peer, |
struct GNUNET_TIME_Relative | timeout, | ||
uint32_t | anonymity, | ||
uint32_t | seed, | ||
const struct GNUNET_FS_Uri * | uri, | ||
unsigned int | verbose, | ||
GNUNET_SCHEDULER_TaskCallback | cont, | ||
void * | cont_cls | ||
) |
Perform test download.
peer | which peer to download from |
timeout | if this operation cannot be completed within the given period, call the continuation with an error code |
anonymity | option for download |
seed | used for file validation |
uri | URI of file to download (CHK/LOC only) |
verbose | how verbose to be in reporting |
cont | function to call when done |
cont_cls | closure for cont |
Definition at line 600 of file fs_test_lib.c.
References TestDownloadOperation::anonymity, anonymity, download_connect_adapter(), TestDownloadOperation::download_cont, TestDownloadOperation::download_cont_cls, download_fs_connect_complete_cb(), TestDownloadOperation::download_seed, download_timeout(), TestDownloadOperation::download_timeout_task, fs_disconnect_adapter(), TestDownloadOperation::fs_op, GNUNET_FS_uri_chk_get_file_size(), GNUNET_FS_uri_dup(), GNUNET_new, GNUNET_SCHEDULER_add_delayed(), GNUNET_TESTBED_service_connect(), peer, TestDownloadOperation::size, timeout, TestDownloadOperation::uri, uri, verbose, and TestDownloadOperation::verbose.