aboutsummaryrefslogtreecommitdiff
path: root/src/fs/test_gnunet_service_fs_migration.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-09-09 13:28:48 +0000
committerChristian Grothoff <christian@grothoff.org>2012-09-09 13:28:48 +0000
commit9d732bb204de9177aad6ae70c910cbf2615d81a3 (patch)
tree44ddd6e9e1dad749db51003acfa46d7835593dc6 /src/fs/test_gnunet_service_fs_migration.c
parenta1d7926951beb7466a1462e43b9933530e5825f7 (diff)
downloadgnunet-9d732bb204de9177aad6ae70c910cbf2615d81a3.tar.gz
gnunet-9d732bb204de9177aad6ae70c910cbf2615d81a3.zip
make fs tests build against new testbed library -- they do not pass yet
Diffstat (limited to 'src/fs/test_gnunet_service_fs_migration.c')
-rw-r--r--src/fs/test_gnunet_service_fs_migration.c101
1 files changed, 35 insertions, 66 deletions
diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c
index 00aab4f42..f1f2084f9 100644
--- a/src/fs/test_gnunet_service_fs_migration.c
+++ b/src/fs/test_gnunet_service_fs_migration.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors) 3 (C) 2010, 2012 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
@@ -25,7 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "fs_test_lib.h" 27#include "fs_test_lib.h"
28#include "gnunet_testing_lib.h" 28#include "gnunet_testbed_service.h"
29 29
30#define VERBOSE GNUNET_NO 30#define VERBOSE GNUNET_NO
31 31
@@ -46,13 +46,12 @@
46 46
47#define SEED 42 47#define SEED 42
48 48
49static struct GNUNET_FS_TestDaemon *daemons[2]; 49static struct GNUNET_TESTBED_Peer *daemons[2];
50 50
51static int ok; 51static int ok;
52 52
53static struct GNUNET_TIME_Absolute start_time; 53static struct GNUNET_TIME_Absolute start_time;
54 54
55static struct GNUNET_FS_TEST_ConnectContext *cc;
56 55
57static void 56static void
58do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 57do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -60,12 +59,7 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
60 struct GNUNET_TIME_Relative del; 59 struct GNUNET_TIME_Relative del;
61 char *fancy; 60 char *fancy;
62 61
63 if (NULL != cc) 62 GNUNET_SCHEDULER_shutdown ();
64 {
65 GNUNET_FS_TEST_daemons_connect_cancel (cc);
66 cc = NULL;
67 }
68 GNUNET_FS_TEST_daemons_stop (2, daemons);
69 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) 63 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
70 { 64 {
71 del = GNUNET_TIME_absolute_get_duration (start_time); 65 del = GNUNET_TIME_absolute_get_duration (start_time);
@@ -89,13 +83,14 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
89 83
90 84
91static void 85static void
92do_download (void *cls, const char *emsg) 86do_download (void *cls,
87 const char *emsg)
93{ 88{
94 struct GNUNET_FS_Uri *uri = cls; 89 struct GNUNET_FS_Uri *uri = cls;
95 90
96 if (emsg != NULL) 91 if (NULL != emsg)
97 { 92 {
98 GNUNET_FS_TEST_daemons_stop (2, daemons); 93 GNUNET_SCHEDULER_shutdown ();
99 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to stop source daemon: %s\n", 94 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to stop source daemon: %s\n",
100 emsg); 95 emsg);
101 GNUNET_FS_uri_destroy (uri); 96 GNUNET_FS_uri_destroy (uri);
@@ -115,11 +110,9 @@ static void
115stop_source_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 110stop_source_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
116{ 111{
117 struct GNUNET_FS_Uri *uri = cls; 112 struct GNUNET_FS_Uri *uri = cls;
118 struct GNUNET_TESTING_PeerGroup *pg;
119 113
120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping source peer\n"); 114 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping source peer\n");
121 pg = GNUNET_FS_TEST_get_group (daemons); 115 GNUNET_TESTBED_peer_stop (daemons[1], &do_download, uri);
122 GNUNET_TESTING_daemons_vary (pg, 1, GNUNET_NO, TIMEOUT, &do_download, uri);
123} 116}
124 117
125 118
@@ -130,7 +123,7 @@ do_wait (void *cls, const struct GNUNET_FS_Uri *uri)
130 123
131 if (NULL == uri) 124 if (NULL == uri)
132 { 125 {
133 GNUNET_FS_TEST_daemons_stop (2, daemons); 126 GNUNET_SCHEDULER_shutdown ();
134 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 127 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
135 "Timeout during upload attempt, shutting down with error\n"); 128 "Timeout during upload attempt, shutting down with error\n");
136 ok = 1; 129 ok = 1;
@@ -143,14 +136,16 @@ do_wait (void *cls, const struct GNUNET_FS_Uri *uri)
143 136
144 137
145static void 138static void
146do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 139do_publish (void *cls,
140 struct GNUNET_TESTBED_Operation *op,
141 const char *emsg)
147{ 142{
148 cc = NULL; 143 if (NULL != emsg)
149 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
150 { 144 {
151 GNUNET_FS_TEST_daemons_stop (2, daemons); 145 GNUNET_SCHEDULER_shutdown ();
152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 146 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
153 "Timeout during connect attempt, shutting down with error\n"); 147 "Error connecting peers: %s\n",
148 emsg);
154 ok = 1; 149 ok = 1;
155 return; 150 return;
156 } 151 }
@@ -162,58 +157,32 @@ do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
162 157
163 158
164static void 159static void
165do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 160do_connect (void *cls,
161 unsigned int num_peers,
162 struct GNUNET_TESTBED_Peer **peers)
166{ 163{
167 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) 164 unsigned int i;
168 { 165
169 FPRINTF (stderr, "%s", "Daemons failed to start!\n"); 166 GNUNET_assert (2 == num_peers);
170 GNUNET_break (0); 167 for (i=0;i<num_peers;i++)
171 ok = 1; 168 daemons[i] = peers[i];
172 return;
173 }
174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 169 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
175 "Daemons started, will now try to connect them\n"); 170 "Daemons started, will now try to connect them\n");
176 cc = GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, 171 GNUNET_TESTBED_overlay_connect (NULL,
177 &do_publish, NULL); 172 &do_publish, NULL,
178} 173 daemons[0], daemons[1]);
179
180
181static void
182run (void *cls, char *const *args, const char *cfgfile,
183 const struct GNUNET_CONFIGURATION_Handle *cfg)
184{
185 GNUNET_FS_TEST_daemons_start ("test_gnunet_service_fs_migration_data.conf",
186 TIMEOUT, 2, daemons, &do_connect, NULL);
187} 174}
188 175
189 176
190int 177int
191main (int argc, char *argv[]) 178main (int argc, char *argv[])
192{ 179{
193 char *const argvx[] = { 180 GNUNET_TESTBED_test_run ("test-gnunet-service-fs-migration",
194 "test-gnunet-service-fs-migration", 181 "fs_test_lib_data.conf",
195 "-c", 182 2,
196 "fs_test_lib_data.conf", 183 0, NULL, NULL,
197#if VERBOSE 184 &do_connect,
198 "-L", "DEBUG", 185 NULL);
199#endif
200 NULL
201 };
202 struct GNUNET_GETOPT_CommandLineOption options[] = {
203 GNUNET_GETOPT_OPTION_END
204 };
205
206 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-service-fs-migration/");
207 GNUNET_log_setup ("test_gnunet_service_fs_migration",
208#if VERBOSE
209 "DEBUG",
210#else
211 "WARNING",
212#endif
213 NULL);
214 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
215 "test-gnunet-service-fs-migration", "nohelp", options,
216 &run, NULL);
217 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-service-fs-migration/"); 186 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-service-fs-migration/");
218 return ok; 187 return ok;
219} 188}