2 This file is part of GNUnet.
3 (C) 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.
21 * @file namestore/test_namestore_api.c
22 * @brief testcase for namestore_api.c
25 #include "gnunet_common.h"
26 #include "gnunet_namestore_service.h"
28 #define VERBOSE GNUNET_EXTRA_LOGGING
30 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
32 static struct GNUNET_NAMESTORE_Handle * nsh;
34 static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
35 static struct GNUNET_OS_Process *arm;
41 start_arm (const char *cfgname)
43 arm = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
44 "gnunet-service-arm", "-c", cfgname,
58 if (0 != GNUNET_OS_process_kill (arm, SIGTERM))
59 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
60 GNUNET_OS_process_wait (arm);
61 GNUNET_OS_process_close (arm);
67 * Re-establish the connection to the service.
69 * @param cls handle to use to re-connect.
70 * @param tc scheduler context
73 endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
84 if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
86 GNUNET_SCHEDULER_cancel (endbadly_task);
87 endbadly_task = GNUNET_SCHEDULER_NO_TASK;
98 run (void *cls, char *const *args, const char *cfgfile,
99 const struct GNUNET_CONFIGURATION_Handle *cfg)
101 endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL);
104 GNUNET_assert (arm != NULL);
106 nsh = GNUNET_NAMESTORE_connect (cfg);
107 GNUNET_break (NULL != nsh);
108 GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
118 static char *const argv[] = { "test-namestore-api",
120 "test_namestore_api.conf",
126 static struct GNUNET_GETOPT_CommandLineOption options[] = {
127 GNUNET_GETOPT_OPTION_END
131 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test-namestore-api",
132 "nohelp", options, &run, &res);
137 main (int argc, char *argv[])
146 /* end of test_namestore_api.c */