2 This file is part of GNUnet.
3 (C) 2005, 2006, 2008, 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 3, 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_namespace_list_updateable.c
23 * @brief Test for fs_namespace_list_updateable.c
24 * @author Christian Grothoff
27 #include "gnunet_util_lib.h"
28 #include "gnunet_arm_service.h"
29 #include "gnunet_fs_service.h"
31 #define VERBOSE GNUNET_NO
33 #define START_ARM GNUNET_YES
35 static struct PeerContext p1;
37 static struct GNUNET_FS_Handle *fs;
41 static struct GNUNET_FS_Namespace *ns;
43 static struct GNUNET_CONTAINER_MetaData *meta;
45 static struct GNUNET_FS_Uri *uri_this;
47 static struct GNUNET_FS_Uri *uri_next;
49 static struct GNUNET_FS_BlockOptions bo;
54 struct GNUNET_CONFIGURATION_Handle *cfg;
56 struct GNUNET_OS_Process *arm_proc;
62 progress_cb (void *cls,
63 const struct GNUNET_FS_ProgressInfo *event)
70 setup_peer (struct PeerContext *p, const char *cfgname)
72 p->cfg = GNUNET_CONFIGURATION_create ();
74 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
81 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
86 stop_arm (struct PeerContext *p)
89 if (NULL != p->arm_proc)
91 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
92 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
93 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
94 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
95 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
96 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
97 GNUNET_OS_process_close (p->arm_proc);
101 if (uri_this != NULL)
102 GNUNET_FS_uri_destroy (uri_this);
103 if (uri_next != NULL)
104 GNUNET_FS_uri_destroy (uri_next);
106 GNUNET_FS_namespace_delete (ns, GNUNET_NO);
108 GNUNET_CONTAINER_meta_data_destroy (meta);
109 GNUNET_CONFIGURATION_destroy (p->cfg);
115 check_next (void *cls,
117 const struct GNUNET_FS_Uri *last_uri,
118 const struct GNUNET_CONTAINER_MetaData *last_meta,
121 GNUNET_break (0 == strcmp (last_id, "next"));
122 GNUNET_break (0 == strcmp (next_id, "future"));
128 check_this_next (void *cls,
130 const struct GNUNET_FS_Uri *last_uri,
131 const struct GNUNET_CONTAINER_MetaData *last_meta,
134 GNUNET_break (0 == strcmp (last_id, "this"));
135 GNUNET_break (0 == strcmp (next_id, "next"));
138 GNUNET_FS_namespace_list_updateable (ns,
146 sks_cont_next (void *cls,
147 const struct GNUNET_FS_Uri *uri,
150 GNUNET_assert (NULL == emsg);
152 GNUNET_FS_namespace_list_updateable (ns,
161 check_this (void *cls,
163 const struct GNUNET_FS_Uri *last_uri,
164 const struct GNUNET_CONTAINER_MetaData *last_meta,
167 GNUNET_break (0 == strcmp (last_id, "this"));
168 GNUNET_break (0 == strcmp (next_id, "next"));
174 sks_cont_this (void *cls,
175 const struct GNUNET_FS_Uri *uri,
179 GNUNET_assert (NULL == emsg);
181 GNUNET_FS_namespace_list_updateable (ns,
185 GNUNET_FS_publish_sks (fs,
192 GNUNET_FS_PUBLISH_OPTION_NONE,
204 ns = GNUNET_FS_namespace_create (fs,
206 GNUNET_assert (NULL != ns);
207 bo.content_priority = 1;
208 bo.anonymity_level = 1;
209 bo.replication_level = 0;
210 bo.expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
211 meta = GNUNET_CONTAINER_meta_data_create ();
214 GNUNET_FS_uri_parse ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42", NULL);
216 GNUNET_FS_uri_parse ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.43", NULL);
217 GNUNET_FS_publish_sks (fs,
224 GNUNET_FS_PUBLISH_OPTION_NONE,
234 const struct GNUNET_CONFIGURATION_Handle *cfg)
236 setup_peer (&p1, "test_fs_namespace_data.conf");
237 fs = GNUNET_FS_start (cfg,
241 GNUNET_FS_FLAGS_NONE,
242 GNUNET_FS_OPTIONS_END);
248 main (int argc, char *argv[])
250 char *const argvx[] = {
253 "test_fs_namespace_data.conf",
259 struct GNUNET_GETOPT_CommandLineOption options[] = {
260 GNUNET_GETOPT_OPTION_END
263 GNUNET_log_setup ("test_fs_namespace_list_updateable",
270 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1,
271 argvx, "test-fs-namespace",
272 "nohelp", options, &run, NULL);
274 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-namespace/");
279 /* end of test_fs_namespace_list_updateable.c */