diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-02-22 10:09:38 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-02-22 10:09:38 +0000 |
commit | 94706428e8d7067cac7dec5d04ccc1cf99a56af5 (patch) | |
tree | 3da776fd1ff6e24b8353278ae510b4c6acf919f5 | |
parent | 6e62186491decd07bcf6f083c2404712cb572787 (diff) | |
download | gnunet-94706428e8d7067cac7dec5d04ccc1cf99a56af5.tar.gz gnunet-94706428e8d7067cac7dec5d04ccc1cf99a56af5.zip |
fix leak, rename
-rw-r--r-- | src/fs/Makefile.am | 11 | ||||
-rw-r--r-- | src/fs/fs_test_lib.c (renamed from src/fs/test_fs_lib.c) | 3 | ||||
-rw-r--r-- | src/fs/fs_test_lib.h (renamed from src/fs/test_fs_lib.h) | 0 | ||||
-rw-r--r-- | src/fs/test_fs_test_lib.c | 162 | ||||
-rw-r--r-- | src/fs/test_gnunet_service_fs_p2p.c | 2 |
5 files changed, 175 insertions, 3 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am index 743d93e14..6ac789c38 100644 --- a/src/fs/Makefile.am +++ b/src/fs/Makefile.am | |||
@@ -42,7 +42,7 @@ libgnunetfs_la_LDFLAGS = \ | |||
42 | 42 | ||
43 | 43 | ||
44 | libgnunetfstest_a_SOURCES = \ | 44 | libgnunetfstest_a_SOURCES = \ |
45 | test_fs_lib.c test_fs_lib.h | 45 | fs_test_lib.c fs_test_lib.h |
46 | 46 | ||
47 | libgnunetfstest_a_LIBADD = \ | 47 | libgnunetfstest_a_LIBADD = \ |
48 | $(top_builddir)/src/fs/libgnunetfs.la \ | 48 | $(top_builddir)/src/fs/libgnunetfs.la \ |
@@ -138,6 +138,7 @@ TESTS = \ | |||
138 | test_fs_start_stop \ | 138 | test_fs_start_stop \ |
139 | test_fs_unindex \ | 139 | test_fs_unindex \ |
140 | test_fs_uri \ | 140 | test_fs_uri \ |
141 | test_fs_test_lib \ | ||
141 | test_gnunet_service_fs_p2p | 142 | test_gnunet_service_fs_p2p |
142 | # $(check_PROGRAMS) | 143 | # $(check_PROGRAMS) |
143 | 144 | ||
@@ -220,6 +221,14 @@ test_fs_uri_LDADD = \ | |||
220 | $(top_builddir)/src/fs/libgnunetfs.la \ | 221 | $(top_builddir)/src/fs/libgnunetfs.la \ |
221 | $(top_builddir)/src/util/libgnunetutil.la | 222 | $(top_builddir)/src/util/libgnunetutil.la |
222 | 223 | ||
224 | test_fs_test_lib_SOURCES = \ | ||
225 | test_fs_test_lib.c | ||
226 | test_fs_test_lib_LDADD = \ | ||
227 | $(top_builddir)/src/fs/libgnunetfstest.a \ | ||
228 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
229 | $(top_builddir)/src/fs/libgnunetfs.la \ | ||
230 | $(top_builddir)/src/util/libgnunetutil.la | ||
231 | |||
223 | test_gnunet_service_fs_p2p_SOURCES = \ | 232 | test_gnunet_service_fs_p2p_SOURCES = \ |
224 | test_gnunet_service_fs_p2p.c | 233 | test_gnunet_service_fs_p2p.c |
225 | test_gnunet_service_fs_p2p_LDADD = \ | 234 | test_gnunet_service_fs_p2p_LDADD = \ |
diff --git a/src/fs/test_fs_lib.c b/src/fs/fs_test_lib.c index 8b8f3db06..1687aa7e9 100644 --- a/src/fs/test_fs_lib.c +++ b/src/fs/fs_test_lib.c | |||
@@ -27,7 +27,7 @@ | |||
27 | * @author Christian Grothoff | 27 | * @author Christian Grothoff |
28 | */ | 28 | */ |
29 | #include "platform.h" | 29 | #include "platform.h" |
30 | #include "test_fs_lib.h" | 30 | #include "fs_test_lib.h" |
31 | #include "gnunet_testing_lib.h" | 31 | #include "gnunet_testing_lib.h" |
32 | 32 | ||
33 | 33 | ||
@@ -443,6 +443,7 @@ GNUNET_FS_TEST_daemons_stop (struct GNUNET_SCHEDULER_Handle *sched, | |||
443 | GNUNET_TESTING_daemons_stop (daemons[0]->group); | 443 | GNUNET_TESTING_daemons_stop (daemons[0]->group); |
444 | for (i=0;i<total;i++) | 444 | for (i=0;i<total;i++) |
445 | { | 445 | { |
446 | GNUNET_FS_stop (daemons[i]->fs); | ||
446 | GNUNET_CONFIGURATION_destroy (daemons[i]->cfg); | 447 | GNUNET_CONFIGURATION_destroy (daemons[i]->cfg); |
447 | GNUNET_free (daemons[i]); | 448 | GNUNET_free (daemons[i]); |
448 | daemons[i] = NULL; | 449 | daemons[i] = NULL; |
diff --git a/src/fs/test_fs_lib.h b/src/fs/fs_test_lib.h index b9bbf7480..b9bbf7480 100644 --- a/src/fs/test_fs_lib.h +++ b/src/fs/fs_test_lib.h | |||
diff --git a/src/fs/test_fs_test_lib.c b/src/fs/test_fs_test_lib.c new file mode 100644 index 000000000..3118d685d --- /dev/null +++ b/src/fs/test_fs_test_lib.c | |||
@@ -0,0 +1,162 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010 Christian Grothoff (and other contributing authors) | ||
4 | |||
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 | ||
7 | by the Free Software Foundation; either version 2, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file fs/test_fs_test_lib.c | ||
23 | * @brief test fs test library | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "test_fs_lib.h" | ||
28 | |||
29 | #define VERBOSE GNUNET_YES | ||
30 | |||
31 | /** | ||
32 | * File-size we use for testing. | ||
33 | */ | ||
34 | #define FILESIZE (1024 * 1024 * 2) | ||
35 | |||
36 | /** | ||
37 | * How long until we give up on transmitting the message? | ||
38 | */ | ||
39 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) | ||
40 | |||
41 | #define NUM_DAEMONS 2 | ||
42 | |||
43 | #define SEED 42 | ||
44 | |||
45 | static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS]; | ||
46 | |||
47 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
48 | |||
49 | |||
50 | static void | ||
51 | do_stop (void *cls, | ||
52 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
53 | { | ||
54 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); | ||
55 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
56 | "Finished download, shutting down\n", | ||
57 | (unsigned long long) FILESIZE); | ||
58 | GNUNET_FS_TEST_daemons_stop (sched, | ||
59 | NUM_DAEMONS, | ||
60 | daemons); | ||
61 | } | ||
62 | |||
63 | |||
64 | static void | ||
65 | do_download (void *cls, | ||
66 | const struct GNUNET_FS_Uri *uri) | ||
67 | { | ||
68 | GNUNET_assert (NULL != uri); | ||
69 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
70 | "Downloading %llu bytes\n", | ||
71 | (unsigned long long) FILESIZE); | ||
72 | GNUNET_FS_TEST_download (sched, | ||
73 | daemons[0], | ||
74 | TIMEOUT, | ||
75 | 1, SEED, uri, | ||
76 | VERBOSE, | ||
77 | &do_stop, NULL); | ||
78 | } | ||
79 | |||
80 | |||
81 | static void | ||
82 | do_publish (void *cls, | ||
83 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
84 | { | ||
85 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); | ||
86 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
87 | "Publishing %llu bytes\n", | ||
88 | (unsigned long long) FILESIZE); | ||
89 | GNUNET_FS_TEST_publish (sched, | ||
90 | daemons[0], | ||
91 | TIMEOUT, | ||
92 | 1, GNUNET_NO, FILESIZE, SEED, | ||
93 | VERBOSE, | ||
94 | &do_download, NULL); | ||
95 | } | ||
96 | |||
97 | |||
98 | static void | ||
99 | do_connect (void *cls, | ||
100 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
101 | { | ||
102 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); | ||
103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
104 | "Daemons started, will now try to connect them\n"); | ||
105 | GNUNET_FS_TEST_daemons_connect (sched, | ||
106 | daemons[0], | ||
107 | daemons[1], | ||
108 | TIMEOUT, | ||
109 | &do_publish, | ||
110 | NULL); | ||
111 | } | ||
112 | |||
113 | |||
114 | static void | ||
115 | run (void *cls, | ||
116 | struct GNUNET_SCHEDULER_Handle *s, | ||
117 | char *const *args, | ||
118 | const char *cfgfile, | ||
119 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
120 | { | ||
121 | sched = s; | ||
122 | GNUNET_FS_TEST_daemons_start (sched, | ||
123 | TIMEOUT, | ||
124 | NUM_DAEMONS, | ||
125 | daemons, | ||
126 | &do_connect, | ||
127 | NULL); | ||
128 | } | ||
129 | |||
130 | |||
131 | int | ||
132 | main (int argc, char *argv[]) | ||
133 | { | ||
134 | char *const argvx[] = { | ||
135 | "test-gnunet-service-fs-p2p", | ||
136 | "-c", | ||
137 | "test_fs_lib_data.conf", | ||
138 | #if VERBOSE | ||
139 | "-L", "DEBUG", | ||
140 | #endif | ||
141 | NULL | ||
142 | }; | ||
143 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
144 | GNUNET_GETOPT_OPTION_END | ||
145 | }; | ||
146 | |||
147 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); | ||
148 | GNUNET_log_setup ("test_gnunet_service_fs_p2p", | ||
149 | #if VERBOSE | ||
150 | "DEBUG", | ||
151 | #else | ||
152 | "WARNING", | ||
153 | #endif | ||
154 | NULL); | ||
155 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, | ||
156 | argvx, "test-gnunet-service-fs-p2p", | ||
157 | "nohelp", options, &run, NULL); | ||
158 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); | ||
159 | return 0; | ||
160 | } | ||
161 | |||
162 | /* end of test_gnunet_service_fs_p2p.c */ | ||
diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c index 6b95221d1..aff5d7b9a 100644 --- a/src/fs/test_gnunet_service_fs_p2p.c +++ b/src/fs/test_gnunet_service_fs_p2p.c | |||
@@ -87,7 +87,7 @@ do_publish (void *cls, | |||
87 | "Publishing %llu bytes\n", | 87 | "Publishing %llu bytes\n", |
88 | (unsigned long long) FILESIZE); | 88 | (unsigned long long) FILESIZE); |
89 | GNUNET_FS_TEST_publish (sched, | 89 | GNUNET_FS_TEST_publish (sched, |
90 | daemons[0], | 90 | daemons[1], |
91 | TIMEOUT, | 91 | TIMEOUT, |
92 | 1, GNUNET_NO, FILESIZE, SEED, | 92 | 1, GNUNET_NO, FILESIZE, SEED, |
93 | VERBOSE, | 93 | VERBOSE, |