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.c
23 * @brief Test for fs_namespace.c
24 * @author Christian Grothoff
30 #include "gnunet_util_lib.h"
31 #include "gnunet_arm_service.h"
32 #include "gnunet_fs_service.h"
34 #define VERBOSE GNUNET_NO
36 #define START_ARM GNUNET_YES
38 static struct GNUNET_SCHEDULER_Handle *sched;
40 static struct PeerContext p1;
42 static struct GNUNET_FS_Handle *fs;
46 static struct GNUNET_FS_Namespace *ns;
48 static struct GNUNET_TIME_Absolute expiration;
50 static struct GNUNET_CONTAINER_MetaData *meta;
52 static struct GNUNET_FS_Uri *uri_this;
54 static struct GNUNET_FS_Uri *uri_next;
59 struct GNUNET_CONFIGURATION_Handle *cfg;
67 progress_cb (void *cls,
68 const struct GNUNET_FS_ProgressInfo *event)
75 setup_peer (struct PeerContext *p, const char *cfgname)
77 p->cfg = GNUNET_CONFIGURATION_create ();
79 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
86 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
91 stop_arm (struct PeerContext *p)
94 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
95 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
96 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
97 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
98 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
99 "ARM process %u stopped\n", p->arm_pid);
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 sks_cont_next (void *cls,
116 const struct GNUNET_FS_Uri *uri,
119 GNUNET_assert (NULL == emsg);
124 sks_cont_this (void *cls,
125 const struct GNUNET_FS_Uri *uri,
128 GNUNET_assert (NULL == emsg);
130 GNUNET_FS_publish_sks (fs,
138 GNUNET_FS_PUBLISH_OPTION_NONE,
150 ns = GNUNET_FS_namespace_create (fs,
152 GNUNET_assert (NULL != ns);
153 expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
154 meta = GNUNET_CONTAINER_meta_data_create ();
157 GNUNET_FS_uri_parse ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42", NULL);
159 GNUNET_FS_uri_parse ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.43", NULL);
160 GNUNET_FS_publish_sks (fs,
168 GNUNET_FS_PUBLISH_OPTION_NONE,
176 struct GNUNET_SCHEDULER_Handle *s,
179 const struct GNUNET_CONFIGURATION_Handle *cfg)
182 setup_peer (&p1, "test_fs_namespace_data.conf");
183 fs = GNUNET_FS_start (sched,
188 GNUNET_FS_FLAGS_NONE,
189 GNUNET_FS_OPTIONS_END);
195 main (int argc, char *argv[])
197 char *const argvx[] = {
200 "test_fs_namespace_data.conf",
206 struct GNUNET_GETOPT_CommandLineOption options[] = {
207 GNUNET_GETOPT_OPTION_END
210 GNUNET_log_setup ("test_fs_namespace_list_updateable",
217 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1,
218 argvx, "test-fs-namespace",
219 "nohelp", options, &run, NULL);
221 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-namespace/");
226 /* end of test_fs_namespace_list_updateable.c */