2 This file is part of GNUnet.
3 (C) 2006, 2009 Christian Grothoff (and other contributing authors)
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.
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.
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.
22 * @file fs/test_fs_collection.c
23 * @brief testcase for fs_collection.c
24 * @author Christian Grothoff
28 #include "gnunet_util_lib.h"
29 #include "gnunet_fs_service.h"
31 static struct GNUNET_CONFIGURATION_Handle *cfg;
33 static void* progress_cb (void *cls,
34 const struct GNUNET_FS_ProgressInfo *info)
42 task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
44 struct GNUNET_FS_Namespace *have;
45 struct GNUNET_FS_Namespace *ns;
47 struct GNUNET_FS_Uri *uri;
48 struct GNUNET_FS_Handle *fsh;
49 struct GNUNET_CONTAINER_MetaData *md;
51 fsh = GNUNET_FS_start (tc->sched,
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,
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);
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);
77 fsh = GNUNET_FS_start (tc->sched,
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));
95 main (int argc, char *argv[])
99 GNUNET_log_setup ("test_fs_collection",
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"))
111 GNUNET_CONFIGURATION_destroy (cfg);
115 GNUNET_SCHEDULER_run (&task, &ok);
116 GNUNET_CONFIGURATION_destroy (cfg);
117 return (ok == GNUNET_YES) ? 0 : 1;
120 /* end of test_fs_collection.c */