2 This file is part of GNUnet
3 (C) 2008, 2009, 2012 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 testing/test_testing_new_servicestartup.c
23 * @brief test case for testing service startup using new testing API
24 * @author Sree Harsha Totakura
28 #include "gnunet_testing_lib-new.h"
31 #define LOG(kind,...) \
32 GNUNET_log (kind, __VA_ARGS__)
34 #define TIME_REL_SEC(sec) \
35 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec)
40 static int test_success;
43 * The shutdown task. Used to signal that testing is done and service has to be
49 shutdown_task(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
51 test_success = GNUNET_YES;
52 GNUNET_SCHEDULER_shutdown ();
57 * The testing callback function
60 * @param cfg the configuration with which the current testing service is run
63 test_run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
65 GNUNET_assert (NULL == cls);
66 GNUNET_assert (NULL != cfg);
67 LOG (GNUNET_ERROR_TYPE_DEBUG, "Service arm started successfully\n");
68 GNUNET_SCHEDULER_add_delayed (TIME_REL_SEC (3), &shutdown_task, NULL);
73 * The main point of execution
75 int main (int argc, char *argv[])
83 GNUNET_log_setup ("test_testing_new_servicestartup", "DEBUG", NULL);
84 _tmpdir = getenv ("TMP");
86 _tmpdir = getenv ("TEMP");
88 _tmpdir = getenv ("TMPDIR");
91 GNUNET_asprintf (&tmpdir, "%s/%s", _tmpdir, "test-gnunet-testing_new-XXXXXX");
93 tmpdir_w = GNUNET_malloc (MAX_PATH + 1);
94 GNUNET_assert (ERROR_SUCCESS == plibc_conv_to_win_path (tmpdir, tmpdir_w));
97 //GNUNET_assert (0 == _mktemp_s (tmpdir, strlen (tmpdir) + 1));
99 GNUNET_assert (mkdtemp (tmpdir) == tmpdir);
102 test_success = GNUNET_NO;
103 GNUNET_assert (0 == GNUNET_TESTING_service_run (tmpdir,
105 "test_testing_defaults.conf",
108 GNUNET_free (tmpdir);
109 return (GNUNET_YES == test_success) ? 0 : 1;