diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-09-09 13:28:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-09-09 13:28:48 +0000 |
commit | 9d732bb204de9177aad6ae70c910cbf2615d81a3 (patch) | |
tree | 44ddd6e9e1dad749db51003acfa46d7835593dc6 /src/fs/test_gnunet_service_fs_p2p.c | |
parent | a1d7926951beb7466a1462e43b9933530e5825f7 (diff) | |
download | gnunet-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_p2p.c')
-rw-r--r-- | src/fs/test_gnunet_service_fs_p2p.c | 81 |
1 files changed, 28 insertions, 53 deletions
diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c index 7ca786ed2..df7b9604b 100644 --- a/src/fs/test_gnunet_service_fs_p2p.c +++ b/src/fs/test_gnunet_service_fs_p2p.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 |
@@ -42,13 +42,12 @@ | |||
42 | 42 | ||
43 | #define SEED 42 | 43 | #define SEED 42 |
44 | 44 | ||
45 | static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS]; | 45 | static struct GNUNET_TESTBED_Peer *daemons[NUM_DAEMONS]; |
46 | 46 | ||
47 | static int ok; | 47 | static int ok; |
48 | 48 | ||
49 | static struct GNUNET_TIME_Absolute start_time; | 49 | static struct GNUNET_TIME_Absolute start_time; |
50 | 50 | ||
51 | static struct GNUNET_FS_TEST_ConnectContext *cc; | ||
52 | 51 | ||
53 | static void | 52 | static void |
54 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 53 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -56,12 +55,7 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
56 | struct GNUNET_TIME_Relative del; | 55 | struct GNUNET_TIME_Relative del; |
57 | char *fancy; | 56 | char *fancy; |
58 | 57 | ||
59 | if (NULL != cc) | 58 | GNUNET_SCHEDULER_shutdown (); |
60 | { | ||
61 | GNUNET_FS_TEST_daemons_connect_cancel (cc); | ||
62 | cc = NULL; | ||
63 | } | ||
64 | GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); | ||
65 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) | 59 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) |
66 | { | 60 | { |
67 | del = GNUNET_TIME_absolute_get_duration (start_time); | 61 | del = GNUNET_TIME_absolute_get_duration (start_time); |
@@ -89,7 +83,7 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri) | |||
89 | { | 83 | { |
90 | if (NULL == uri) | 84 | if (NULL == uri) |
91 | { | 85 | { |
92 | GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); | 86 | GNUNET_SCHEDULER_shutdown (); |
93 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 87 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
94 | "Timeout during upload attempt, shutting down with error\n"); | 88 | "Timeout during upload attempt, shutting down with error\n"); |
95 | ok = 1; | 89 | ok = 1; |
@@ -104,14 +98,16 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri) | |||
104 | 98 | ||
105 | 99 | ||
106 | static void | 100 | static void |
107 | do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 101 | do_publish (void *cls, |
102 | struct GNUNET_TESTBED_Operation *op, | ||
103 | const char *emsg) | ||
108 | { | 104 | { |
109 | cc = NULL; | 105 | if (NULL != emsg) |
110 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | ||
111 | { | 106 | { |
112 | GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); | 107 | GNUNET_SCHEDULER_shutdown (); |
113 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 108 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
114 | "Timeout during connect attempt, shutting down with error\n"); | 109 | "Timeout during connect attempt, shutting down with error: %s\n", |
110 | emsg); | ||
115 | ok = 1; | 111 | ok = 1; |
116 | return; | 112 | return; |
117 | } | 113 | } |
@@ -123,52 +119,31 @@ do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
123 | 119 | ||
124 | 120 | ||
125 | static void | 121 | static void |
126 | do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 122 | do_connect (void *cls, |
123 | unsigned int num_peers, | ||
124 | struct GNUNET_TESTBED_Peer **peers) | ||
127 | { | 125 | { |
128 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); | 126 | unsigned int i; |
127 | |||
128 | GNUNET_assert (NUM_DAEMONS == num_peers); | ||
129 | for (i=0;i<num_peers;i++) | ||
130 | daemons[i] = peers[i]; | ||
129 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 131 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
130 | "Daemons started, will now try to connect them\n"); | 132 | "Daemons started, will now try to connect them\n"); |
131 | cc = GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, | 133 | GNUNET_TESTBED_overlay_connect (NULL, |
132 | &do_publish, NULL); | 134 | &do_publish, NULL, |
133 | } | 135 | daemons[0], daemons[1]); |
134 | |||
135 | |||
136 | static void | ||
137 | run (void *cls, char *const *args, const char *cfgfile, | ||
138 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
139 | { | ||
140 | GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS, | ||
141 | daemons, &do_connect, NULL); | ||
142 | } | 136 | } |
143 | 137 | ||
144 | 138 | ||
145 | int | 139 | int |
146 | main (int argc, char *argv[]) | 140 | main (int argc, char *argv[]) |
147 | { | 141 | { |
148 | char *const argvx[] = { | 142 | GNUNET_TESTBED_test_run ("test-gnunet-service-fs-p2p", |
149 | "test-gnunet-service-fs-p2p", | 143 | "fs_test_lib_data.conf", |
150 | "-c", | 144 | NUM_DAEMONS, |
151 | "fs_test_lib_data.conf", | 145 | 0, NULL, NULL, |
152 | #if VERBOSE | 146 | &do_connect, NULL); |
153 | "-L", "DEBUG", | ||
154 | #endif | ||
155 | NULL | ||
156 | }; | ||
157 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
158 | GNUNET_GETOPT_OPTION_END | ||
159 | }; | ||
160 | |||
161 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); | ||
162 | GNUNET_log_setup ("test_gnunet_service_fs_p2p", | ||
163 | #if VERBOSE | ||
164 | "DEBUG", | ||
165 | #else | ||
166 | "WARNING", | ||
167 | #endif | ||
168 | NULL); | ||
169 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, | ||
170 | "test-gnunet-service-fs-p2p", "nohelp", options, &run, | ||
171 | NULL); | ||
172 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); | 147 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); |
173 | return ok; | 148 | return ok; |
174 | } | 149 | } |