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_scheduler_lib.h"
29 #include "gnunet_testing_lib-new.h"
32 #define LOG(kind,...) \
33 GNUNET_log (kind, __VA_ARGS__)
35 #define TIME_REL_SEC(sec) \
36 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec)
41 static int test_success;
44 * The shutdown task. Used to signal that testing is done and service has to be
50 shutdown_task(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
52 test_success = GNUNET_YES;
53 GNUNET_SCHEDULER_shutdown ();
58 * The testing callback function
61 * @param cfg the configuration with which the current testing service is run
64 test_run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
66 GNUNET_assert (NULL == cls);
67 GNUNET_assert (NULL != cfg);
68 LOG (GNUNET_ERROR_TYPE_DEBUG, "Service arm started successfully\n");
69 GNUNET_SCHEDULER_add_delayed (TIME_REL_SEC (3), &shutdown_task, NULL);
74 * The main point of execution
76 int main (int argc, char *argv[])
84 GNUNET_log_setup ("test_testing_new_servicestartup", "DEBUG", NULL);
85 _tmpdir = getenv ("TMP");
87 _tmpdir = getenv ("TEMP");
89 _tmpdir = getenv ("TMPDIR");
92 GNUNET_asprintf (&tmpdir, "%s/%s", _tmpdir, "test-gnunet-testing_new-XXXXXX");
94 tmpdir_w = GNUNET_malloc (MAX_PATH + 1);
95 GNUNET_assert (ERROR_SUCCESS == plibc_conv_to_win_path (tmpdir, tmpdir_w));
98 //GNUNET_assert (0 == _mktemp_s (tmpdir, strlen (tmpdir) + 1));
100 GNUNET_assert (mkdtemp (tmpdir) == tmpdir);
103 test_success = GNUNET_NO;
104 GNUNET_assert (0 == GNUNET_TESTING_service_run (tmpdir,
106 "test_testing_defaults.conf",
109 GNUNET_free (tmpdir);
110 return (GNUNET_YES == test_success) ? 0 : 1;