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 #define CHECK(a) if (!(a)) { ok = GNUNET_NO; GNUNET_break(0); goto FAILURE; }
34 main (int argc, char *argv[])
36 struct GNUNET_CONFIGURATION_Handle *cfg;
38 struct GNUNET_ClientServerConnection *sock;
39 struct GNUNET_CONTAINER_MetaData *meta;
40 struct GNUNET_CONTAINER_MetaData *have;
42 struct GNUNET_FS_Uri *uri;
43 struct GNUNET_CONTAINER_MetaData *md;
44 struct GNUNET_FS_Handle *fsh;
46 GNUNET_CRYPTO_random_disable_entropy_gathering ();
47 cfg = GNUNET_CONFIGURATION_create ();
48 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_parse (cfg, "check.conf"))
50 GNUNET_CONFIGURATION_destroy (cfg);
56 meta = GNUNET_CONTAINER_meta_data_create ();
57 GNUNET_CONTAINER_meta_data_insert (meta, EXTRACTOR_MIMETYPE, "test/foo");
60 fsh = GNUNET_FS_start (sched,
66 /* ACTUAL TEST CODE */
67 GNUNET_FS_collection_stop (fsh);
68 CHECK (NULL == GNUNET_FS_collection_get (fsh));
69 CHECK (GNUNET_OK == GNUNET_FS_collection_start (fsh,
71 have = GNUNET_FS_collection_get (fsh);
73 CHECK (GNUNET_CONTAINER_meta_data_test_equal (have, meta));
74 GNUNET_CONTAINER_meta_data_destroy (have);
77 GNUNET_FS_uri_parse ("gnunet://ecrs/chk/0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0", &emsg);
78 GNUNET_FS_collection_add (fsh, uri, md);
79 GNUNET_FS_uri_destroy (uri);
81 fsh = GNUNET_FS_start (sched, cfg,
85 have = GNUNET_FS_collection_get (fsh);
87 CHECK (GNUNET_CONTAINER_meta_data_test_equal (have, meta));
88 GNUNET_CONTAINER_meta_data_destroy (have);
89 GNUNET_FS_collection_publish (fsh);
90 GNUNET_FS_collection_stop (fsh);
91 CHECK (NULL == GNUNET_FS_collection_get (fsh));
94 /* END OF TEST CODE */
97 GNUNET_CONTAINER_meta_data_destroy (meta);
98 GNUNET_CONFIGURATION_destroy (cfg);
100 return (ok == GNUNET_YES) ? 0 : 1;
103 /* end of test_fs_collection.c */