diff options
Diffstat (limited to 'src/fs/test_fs_collection.c')
-rw-r--r-- | src/fs/test_fs_collection.c | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/src/fs/test_fs_collection.c b/src/fs/test_fs_collection.c deleted file mode 100644 index 3ff8c3ab9..000000000 --- a/src/fs/test_fs_collection.c +++ /dev/null | |||
@@ -1,120 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2006, 2009 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 3, 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_collection.c | ||
23 | * @brief testcase for fs_collection.c | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | |||
27 | #include "platform.h" | ||
28 | #include "gnunet_util_lib.h" | ||
29 | #include "gnunet_fs_service.h" | ||
30 | |||
31 | static struct GNUNET_CONFIGURATION_Handle *cfg; | ||
32 | |||
33 | static void* progress_cb (void *cls, | ||
34 | const struct GNUNET_FS_ProgressInfo *info) | ||
35 | { | ||
36 | GNUNET_break (0); | ||
37 | return NULL; | ||
38 | } | ||
39 | |||
40 | |||
41 | static void | ||
42 | task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
43 | { | ||
44 | struct GNUNET_FS_Namespace *have; | ||
45 | struct GNUNET_FS_Namespace *ns; | ||
46 | char *emsg; | ||
47 | struct GNUNET_FS_Uri *uri; | ||
48 | struct GNUNET_FS_Handle *fsh; | ||
49 | struct GNUNET_CONTAINER_MetaData *md; | ||
50 | |||
51 | fsh = GNUNET_FS_start (tc->sched, | ||
52 | cfg, | ||
53 | "test-fs-collection", | ||
54 | &progress_cb, | ||
55 | NULL, | ||
56 | GNUNET_FS_FLAGS_NONE, | ||
57 | GNUNET_FS_OPTIONS_END); | ||
58 | GNUNET_assert (NULL != fsh); | ||
59 | GNUNET_FS_collection_stop (fsh); | ||
60 | GNUNET_assert (NULL == GNUNET_FS_collection_get (fsh)); | ||
61 | ns = GNUNET_FS_namespace_create (fsh, "test-namespace"); | ||
62 | GNUNET_assert (NULL != ns); | ||
63 | GNUNET_assert (GNUNET_OK == GNUNET_FS_collection_start (fsh, | ||
64 | ns)); | ||
65 | GNUNET_FS_namespace_delete (ns, GNUNET_NO); | ||
66 | have = GNUNET_FS_collection_get (fsh); | ||
67 | GNUNET_assert (NULL != have); | ||
68 | GNUNET_FS_namespace_delete (have, GNUNET_NO); | ||
69 | uri = | ||
70 | GNUNET_FS_uri_parse ("gnunet://fs/chk/0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0", &emsg); | ||
71 | GNUNET_assert (NULL != uri); | ||
72 | md = GNUNET_CONTAINER_meta_data_create (); | ||
73 | GNUNET_FS_collection_add (fsh, uri, md); | ||
74 | GNUNET_CONTAINER_meta_data_destroy (md); | ||
75 | GNUNET_FS_uri_destroy (uri); | ||
76 | GNUNET_FS_stop (fsh); | ||
77 | fsh = GNUNET_FS_start (tc->sched, | ||
78 | cfg, | ||
79 | "test-fs-collection", | ||
80 | &progress_cb, | ||
81 | NULL, | ||
82 | GNUNET_FS_FLAGS_NONE, | ||
83 | GNUNET_FS_OPTIONS_END); | ||
84 | have = GNUNET_FS_collection_get (fsh); | ||
85 | GNUNET_assert (NULL != have); | ||
86 | GNUNET_FS_namespace_delete (have, GNUNET_NO); | ||
87 | GNUNET_FS_collection_publish (fsh); | ||
88 | GNUNET_FS_collection_stop (fsh); | ||
89 | GNUNET_assert (NULL == GNUNET_FS_collection_get (fsh)); | ||
90 | GNUNET_FS_stop (fsh); | ||
91 | } | ||
92 | |||
93 | |||
94 | int | ||
95 | main (int argc, char *argv[]) | ||
96 | { | ||
97 | int ok; | ||
98 | |||
99 | GNUNET_log_setup ("test_fs_collection", | ||
100 | #if VERBOSE | ||
101 | "DEBUG", | ||
102 | #else | ||
103 | "WARNING", | ||
104 | #endif | ||
105 | NULL); | ||
106 | GNUNET_CRYPTO_random_disable_entropy_gathering (); | ||
107 | cfg = GNUNET_CONFIGURATION_create (); | ||
108 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_parse (cfg, | ||
109 | "test_fs_collection_data.conf")) | ||
110 | { | ||
111 | GNUNET_CONFIGURATION_destroy (cfg); | ||
112 | return -1; | ||
113 | } | ||
114 | ok = GNUNET_YES; | ||
115 | GNUNET_SCHEDULER_run (&task, &ok); | ||
116 | GNUNET_CONFIGURATION_destroy (cfg); | ||
117 | return (ok == GNUNET_YES) ? 0 : 1; | ||
118 | } | ||
119 | |||
120 | /* end of test_fs_collection.c */ | ||