2 This file is part of GNUnet.
3 (C) 2004, 2005, 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 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_start_stop.c
23 * @brief testcase for fs.c (start-stop only)
24 * @author Christian Grothoff
28 #include "gnunet_util_lib.h"
29 #include "gnunet_arm_service.h"
30 #include "gnunet_fs_service.h"
32 #define VERBOSE GNUNET_NO
34 #define START_ARM GNUNET_YES
36 static struct PeerContext p1;
40 struct GNUNET_CONFIGURATION_Handle *cfg;
42 struct GNUNET_OS_Process *arm_proc;
48 progress_cb (void *cls,
49 const struct GNUNET_FS_ProgressInfo *event)
56 setup_peer (struct PeerContext *p, const char *cfgname)
58 p->cfg = GNUNET_CONFIGURATION_create ();
60 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
67 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
72 stop_arm (struct PeerContext *p)
75 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
76 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
77 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
78 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
79 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
80 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
81 GNUNET_OS_process_close (p->arm_proc);
84 GNUNET_CONFIGURATION_destroy (p->cfg);
92 const struct GNUNET_CONFIGURATION_Handle *cfg)
94 struct GNUNET_FS_Handle *fs;
96 setup_peer (&p1, "test_fs_data.conf");
97 fs = GNUNET_FS_start (cfg,
101 GNUNET_FS_FLAGS_NONE,
102 GNUNET_FS_OPTIONS_END);
103 GNUNET_assert (NULL != fs);
104 sleep (1); /* FIXME */
110 main (int argc, char *argv[])
112 char *const argvx[] = {
113 "test-fs-start-stop",
121 struct GNUNET_GETOPT_CommandLineOption options[] = {
122 GNUNET_GETOPT_OPTION_END
125 GNUNET_log_setup ("test_fs_start_stop",
132 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1,
133 argvx, "test-fs-start-stop",
134 "nohelp", options, &run, NULL);
136 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs/");
140 /* end of test_fs_start_stop.c */