paragraph for gnunet devs that don't know how to use the web
[oweals/gnunet.git] / src / fs / test_plugin_block_fs.c
1 /*
2      This file is part of GNUnet
3      Copyright (C) 2010, 2012 GNUnet e.V.
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your 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      Affero General Public License for more details.
14     
15      You should have received a copy of the GNU Affero General Public License
16      along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18 /**
19  * @file fs/test_plugin_block_fs.c
20  * @brief test for plugin_block_fs.c
21  * @author Christian Grothoff
22  */
23 #include "platform.h"
24 #include "gnunet_block_lib.h"
25
26
27 static int
28 test_fs (struct GNUNET_BLOCK_Context *ctx)
29 {
30   struct GNUNET_HashCode key;
31   char block[4];
32
33   memset (block, 1, sizeof (block));
34   if (GNUNET_OK !=
35       GNUNET_BLOCK_get_key (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, block,
36                             sizeof (block), &key))
37     return 1;
38   if (GNUNET_BLOCK_EVALUATION_OK_LAST !=
39       GNUNET_BLOCK_evaluate (ctx,
40                              GNUNET_BLOCK_TYPE_FS_DBLOCK,
41                              NULL,
42                              GNUNET_BLOCK_EO_NONE,
43                              &key,
44                              NULL, 0,
45                              block, sizeof (block)))
46     return 2;
47   if (GNUNET_BLOCK_EVALUATION_REQUEST_VALID !=
48       GNUNET_BLOCK_evaluate (ctx,
49                              GNUNET_BLOCK_TYPE_FS_DBLOCK,
50                              NULL,
51                              GNUNET_BLOCK_EO_NONE,
52                              &key,
53                              NULL, 0,
54                              NULL, 0))
55     return 4;
56   GNUNET_log_skip (1, GNUNET_NO);
57   if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID !=
58       GNUNET_BLOCK_evaluate (ctx,
59                              GNUNET_BLOCK_TYPE_FS_DBLOCK,
60                              NULL,
61                              GNUNET_BLOCK_EO_NONE,
62                              &key,
63                              "bogus", 5,
64                              NULL, 0))
65     return 8;
66   GNUNET_log_skip (0, GNUNET_YES);
67   return 0;
68 }
69
70
71 int
72 main (int argc, char *argv[])
73 {
74   int ret;
75   struct GNUNET_BLOCK_Context *ctx;
76   struct GNUNET_CONFIGURATION_Handle *cfg;
77
78   GNUNET_log_setup ("test-block", "WARNING", NULL);
79   cfg = GNUNET_CONFIGURATION_create ();
80   ctx = GNUNET_BLOCK_context_create (cfg);
81   ret = test_fs (ctx);
82   GNUNET_BLOCK_context_destroy (ctx);
83   GNUNET_CONFIGURATION_destroy (cfg);
84   if (ret != 0)
85     FPRINTF (stderr, "Tests failed: %d\n", ret);
86   return ret;
87 }
88
89 /* end of test_plugin_block_fs.c */