aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-07-15 15:04:45 +0000
committerChristian Grothoff <christian@grothoff.org>2012-07-15 15:04:45 +0000
commit428fb513ef4353f382a5e1b35e838af1fed59058 (patch)
tree8b96409d27bfe90d724b85facd8e15fc7a80074b /src/fs
parentf50072ff43b084ae76ae17fed0610f315db81255 (diff)
downloadgnunet-428fb513ef4353f382a5e1b35e838af1fed59058.tar.gz
gnunet-428fb513ef4353f382a5e1b35e838af1fed59058.zip
-moving block test to resolve cyclic dependency
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/Makefile.am6
-rw-r--r--src/fs/test_plugin_block_fs.c77
2 files changed, 83 insertions, 0 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index 9615b67cd..43d60d6f2 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -205,6 +205,7 @@ if HAVE_BENCHMARKS
205endif 205endif
206 206
207check_PROGRAMS = \ 207check_PROGRAMS = \
208 test_plugin_block_fs \
208 test_fs_directory \ 209 test_fs_directory \
209 test_fs_download \ 210 test_fs_download \
210 test_fs_download_indexed \ 211 test_fs_download_indexed \
@@ -228,6 +229,11 @@ check_PROGRAMS = \
228 test_gnunet_service_fs_p2p \ 229 test_gnunet_service_fs_p2p \
229 $(FS_BENCHMARKS) 230 $(FS_BENCHMARKS)
230 231
232test_plugin_block_fs_SOURCES = \
233 test_plugin_block_fs.c
234test_plugin_block_fs_LDADD = \
235 $(top_builddir)/src/block/libgnunetblock.la \
236 $(top_builddir)/src/util/libgnunetutil.la
231 237
232if HAVE_PYTHON 238if HAVE_PYTHON
233check_SCRIPTS = \ 239check_SCRIPTS = \
diff --git a/src/fs/test_plugin_block_fs.c b/src/fs/test_plugin_block_fs.c
new file mode 100644
index 000000000..a9f5ce3f0
--- /dev/null
+++ b/src/fs/test_plugin_block_fs.c
@@ -0,0 +1,77 @@
1/*
2 This file is part of GNUnet
3 (C) 2010, 2012 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 3, 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 * @file fs/test_plugin_block_fs.c
22 * @brief test for plugin_block_fs.c
23 * @author Christian Grothoff
24 */
25#include "platform.h"
26#include "gnunet_block_lib.h"
27
28
29static int
30test_fs (struct GNUNET_BLOCK_Context *ctx)
31{
32 struct GNUNET_HashCode key;
33 char block[4];
34
35 memset (block, 1, sizeof (block));
36 if (GNUNET_OK !=
37 GNUNET_BLOCK_get_key (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, block,
38 sizeof (block), &key))
39 return 1;
40 if (GNUNET_BLOCK_EVALUATION_OK_LAST !=
41 GNUNET_BLOCK_evaluate (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, &key, NULL, 0,
42 NULL, 0, block, sizeof (block)))
43 return 2;
44 if (GNUNET_BLOCK_EVALUATION_REQUEST_VALID !=
45 GNUNET_BLOCK_evaluate (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, &key, NULL, 0,
46 NULL, 0, NULL, 0))
47 return 4;
48 GNUNET_log_skip (1, GNUNET_NO);
49 if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID !=
50 GNUNET_BLOCK_evaluate (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, &key, NULL, 0,
51 "bogus", 5, NULL, 0))
52 return 8;
53 GNUNET_log_skip (0, GNUNET_YES);
54 return 0;
55}
56
57
58int
59main (int argc, char *argv[])
60{
61 int ret;
62 struct GNUNET_BLOCK_Context *ctx;
63 struct GNUNET_CONFIGURATION_Handle *cfg;
64
65 GNUNET_log_setup ("test-block", "WARNING", NULL);
66 cfg = GNUNET_CONFIGURATION_create ();
67 GNUNET_CONFIGURATION_set_value_string (cfg, "block", "PLUGINS", "fs");
68 ctx = GNUNET_BLOCK_context_create (cfg);
69 ret = test_fs (ctx);
70 GNUNET_BLOCK_context_destroy (ctx);
71 GNUNET_CONFIGURATION_destroy (cfg);
72 if (ret != 0)
73 FPRINTF (stderr, "Tests failed: %d\n", ret);
74 return ret;
75}
76
77/* end of test_plugin_block_fs.c */