aboutsummaryrefslogtreecommitdiff
path: root/src/fs/test_fs_start_stop.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-08-22 17:57:31 +0000
committerChristian Grothoff <christian@grothoff.org>2009-08-22 17:57:31 +0000
commit2ae973618f3b51fa9bbf5532eaa1352cafc24ecc (patch)
treeea8bb13a4c7d390f88318b61bc6caf50ea6cf400 /src/fs/test_fs_start_stop.c
parent9a10e9c06a3b08c8ab73edb7d2093a6d452ecc05 (diff)
downloadgnunet-2ae973618f3b51fa9bbf5532eaa1352cafc24ecc.tar.gz
gnunet-2ae973618f3b51fa9bbf5532eaa1352cafc24ecc.zip
stuff
Diffstat (limited to 'src/fs/test_fs_start_stop.c')
-rw-r--r--src/fs/test_fs_start_stop.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/fs/test_fs_start_stop.c b/src/fs/test_fs_start_stop.c
new file mode 100644
index 000000000..1ec1176a6
--- /dev/null
+++ b/src/fs/test_fs_start_stop.c
@@ -0,0 +1,89 @@
1/*
2 This file is part of GNUnet.
3 (C) 2004, 2005, 2006 Christian Grothoff (and other contributing authors)
4
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 2, or (at your
8 option) any later version.
9
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.
14
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.
19*/
20
21/**
22 * @file applications/fs/fsui/fsui_start_stop_test.c
23 * @brief testcase for fsui (start-stop only)
24 * @author Christian Grothoff
25 */
26
27#include "platform.h"
28#include "gnunet_util.h"
29#include "gnunet_fsui_lib.h"
30
31#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GNUNET_GE_BREAK(NULL, 0); goto FAILURE; }
32
33
34static struct GNUNET_FSUI_Context *ctx;
35
36static void *
37eventCallback (void *cls, const GNUNET_FSUI_Event * event)
38{
39 return NULL;
40}
41
42#define START_DAEMON 1
43
44int
45main (int argc, char *argv[])
46{
47#if START_DAEMON
48 pid_t daemon;
49#endif
50 int ok;
51 struct GNUNET_GC_Configuration *cfg;
52
53 cfg = GNUNET_GC_create ();
54 if (-1 == GNUNET_GC_parse_configuration (cfg, "check.conf"))
55 {
56 GNUNET_GC_free (cfg);
57 return -1;
58 }
59#if START_DAEMON
60 daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
61 GNUNET_GE_ASSERT (NULL, daemon > 0);
62 CHECK (GNUNET_OK ==
63 GNUNET_wait_for_daemon_running (NULL, cfg,
64 60 * GNUNET_CRON_SECONDS));
65#endif
66 ok = GNUNET_YES;
67 GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS); /* give apps time to start */
68
69 /* ACTUAL TEST CODE */
70 ctx = GNUNET_FSUI_start (NULL, cfg, "fsui_start_stop_test", 32, GNUNET_YES, /* do resume! */
71 &eventCallback, NULL);
72 CHECK (ctx != NULL);
73 GNUNET_FSUI_stop (ctx);
74 ctx =
75 GNUNET_FSUI_start (NULL, cfg, "fsui_start_stop_test", 32, GNUNET_YES,
76 &eventCallback, NULL);
77 CHECK (ctx != NULL);
78FAILURE:
79 if (ctx != NULL)
80 GNUNET_FSUI_stop (ctx);
81#if START_DAEMON
82 GNUNET_GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
83#endif
84 GNUNET_GC_free (cfg);
85
86 return (ok == GNUNET_YES) ? 0 : 1;
87}
88
89/* end of fsui_start_stop_test.c */