2 This file is part of GNUnet.
3 (C) 2013 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 psycstore/test_psycstore.c
23 * @brief Testcase for the PSYCstore service
24 * @author Gabor X Toth
25 * @author Christian Grothoff
29 #include "gnunet_common.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_psycstore_service.h"
32 #include "gnunet_testing_lib.h"
35 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
39 * Return value from 'main'.
44 * Handle to PSYCstore service.
46 static struct GNUNET_PSYCSTORE_Handle *h;
49 * Handle to PSYCstore operation.
51 static struct GNUNET_PSYCSTORE_Operation *op;
54 * Handle for task for timeout termination.
56 static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
60 * Clean up all resources used.
67 GNUNET_PSYCSTORE_operation_cancel (op);
72 GNUNET_PSYCSTORE_disconnect (h);
75 GNUNET_SCHEDULER_shutdown ();
80 * Termiante the testcase (failure).
83 * @param tc scheduler context
86 endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
94 * Termiante the testcase (success).
97 * @param tc scheduler context
100 end_normally (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
108 * Finish the testcase (successfully).
113 if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
115 GNUNET_SCHEDULER_cancel (endbadly_task);
116 endbadly_task = GNUNET_SCHEDULER_NO_TASK;
118 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
119 &end_normally, NULL);
124 * Main function of the test, run from scheduler.
127 * @param cfg configuration we use (also to connect to PSYCstore service)
128 * @param peer handle to access more of the peer (not used)
132 const struct GNUNET_CONFIGURATION_Handle *cfg,
133 struct GNUNET_TESTING_Peer *peer)
135 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
137 h = GNUNET_PSYCSTORE_connect (cfg);
138 GNUNET_assert (NULL != h);
144 main (int argc, char *argv[])
148 GNUNET_TESTING_service_run ("test-psycstore",
150 "test_psycstore.conf",
158 /* end of test_psycstore.c */