diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-11-24 23:09:36 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-11-24 23:09:36 +0000 |
commit | ffbcecfb3a225e8f592780c4a6eba56e6ae8a8f3 (patch) | |
tree | 1a5f0bf706cd5b4b39346853b19b1a89c86f28a5 /src/fs/test_gnunet_service_fs_p2p.c | |
parent | eb402314191286004d4b5450508080b3ef7b4e5b (diff) | |
download | gnunet-ffbcecfb3a225e8f592780c4a6eba56e6ae8a8f3.tar.gz gnunet-ffbcecfb3a225e8f592780c4a6eba56e6ae8a8f3.zip |
-add multi-peer testcase for stream-based transfers (expected to fail right now), and option to disable anonymous transfers --- to force stream-based transfers
Diffstat (limited to 'src/fs/test_gnunet_service_fs_p2p.c')
-rw-r--r-- | src/fs/test_gnunet_service_fs_p2p.c | 61 |
1 files changed, 26 insertions, 35 deletions
diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c index 218f16b01..34326fa70 100644 --- a/src/fs/test_gnunet_service_fs_p2p.c +++ b/src/fs/test_gnunet_service_fs_p2p.c | |||
@@ -42,14 +42,16 @@ | |||
42 | 42 | ||
43 | #define SEED 42 | 43 | #define SEED 42 |
44 | 44 | ||
45 | static const char *progname; | ||
46 | |||
47 | static unsigned int anonymity_level; | ||
48 | |||
45 | static struct GNUNET_TESTBED_Peer *daemons[NUM_DAEMONS]; | 49 | static struct GNUNET_TESTBED_Peer *daemons[NUM_DAEMONS]; |
46 | 50 | ||
47 | static int ok; | 51 | static int ok; |
48 | 52 | ||
49 | static struct GNUNET_TIME_Absolute start_time; | 53 | static struct GNUNET_TIME_Absolute start_time; |
50 | 54 | ||
51 | static struct GNUNET_TESTBED_Operation *op; | ||
52 | |||
53 | 55 | ||
54 | static void | 56 | static void |
55 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 57 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -94,62 +96,51 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri) | |||
94 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", | 96 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", |
95 | (unsigned long long) FILESIZE); | 97 | (unsigned long long) FILESIZE); |
96 | start_time = GNUNET_TIME_absolute_get (); | 98 | start_time = GNUNET_TIME_absolute_get (); |
97 | GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, | 99 | GNUNET_FS_TEST_download (daemons[0], TIMEOUT, |
100 | anonymity_level, SEED, uri, | ||
101 | VERBOSE, &do_stop, | ||
98 | NULL); | 102 | NULL); |
99 | } | 103 | } |
100 | 104 | ||
101 | 105 | ||
102 | static void | 106 | static void |
103 | do_publish (void *cls, | 107 | do_publish (void *cls, |
104 | struct GNUNET_TESTBED_Operation *opret, | ||
105 | const char *emsg) | ||
106 | { | ||
107 | GNUNET_assert (op == opret); | ||
108 | GNUNET_TESTBED_operation_done (op); | ||
109 | op = NULL; | ||
110 | |||
111 | if (NULL != emsg) | ||
112 | { | ||
113 | GNUNET_SCHEDULER_shutdown (); | ||
114 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
115 | "Timeout during connect attempt, shutting down with error: %s\n", | ||
116 | emsg); | ||
117 | ok = 1; | ||
118 | return; | ||
119 | } | ||
120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", | ||
121 | (unsigned long long) FILESIZE); | ||
122 | GNUNET_FS_TEST_publish (daemons[1], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, | ||
123 | VERBOSE, &do_download, NULL); | ||
124 | } | ||
125 | |||
126 | |||
127 | static void | ||
128 | do_connect (void *cls, | ||
129 | unsigned int num_peers, | 108 | unsigned int num_peers, |
130 | struct GNUNET_TESTBED_Peer **peers) | 109 | struct GNUNET_TESTBED_Peer **peers) |
131 | { | 110 | { |
132 | unsigned int i; | 111 | unsigned int i; |
133 | 112 | ||
113 | if (NULL != strstr (progname, "stream")) | ||
114 | anonymity_level = 0; | ||
115 | else | ||
116 | anonymity_level = 1; | ||
134 | GNUNET_assert (NUM_DAEMONS == num_peers); | 117 | GNUNET_assert (NUM_DAEMONS == num_peers); |
135 | for (i=0;i<num_peers;i++) | 118 | for (i=0;i<num_peers;i++) |
136 | daemons[i] = peers[i]; | 119 | daemons[i] = peers[i]; |
137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", |
138 | "Daemons started, will now try to connect them\n"); | 121 | (unsigned long long) FILESIZE); |
139 | op = GNUNET_TESTBED_overlay_connect (NULL, | 122 | GNUNET_FS_TEST_publish (daemons[1], TIMEOUT, |
140 | &do_publish, NULL, | 123 | anonymity_level, GNUNET_NO, |
141 | daemons[0], daemons[1]); | 124 | FILESIZE, SEED, |
125 | VERBOSE, &do_download, NULL); | ||
142 | } | 126 | } |
143 | 127 | ||
144 | 128 | ||
145 | int | 129 | int |
146 | main (int argc, char *argv[]) | 130 | main (int argc, char *argv[]) |
147 | { | 131 | { |
132 | const char *config; | ||
133 | |||
134 | progname = argv[0]; | ||
135 | if (NULL != strstr (progname, "stream")) | ||
136 | config = "test_gnunet_service_fs_p2p_stream.conf"; | ||
137 | else | ||
138 | config = "fs_test_lib_data.conf"; | ||
148 | GNUNET_TESTBED_test_run ("test-gnunet-service-fs-p2p", | 139 | GNUNET_TESTBED_test_run ("test-gnunet-service-fs-p2p", |
149 | "fs_test_lib_data.conf", | 140 | config, |
150 | NUM_DAEMONS, | 141 | NUM_DAEMONS, |
151 | 0, NULL, NULL, | 142 | 0, NULL, NULL, |
152 | &do_connect, NULL); | 143 | &do_publish, NULL); |
153 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); | 144 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); |
154 | return ok; | 145 | return ok; |
155 | } | 146 | } |