glitch in the license text detected by hyazinthe, thank you!
[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 /**
16  * @file fs/test_plugin_block_fs.c
17  * @brief test for plugin_block_fs.c
18  * @author Christian Grothoff
19  */
20 #include "platform.h"
21 #include "gnunet_block_lib.h"
22
23
24 static int
25 test_fs (struct GNUNET_BLOCK_Context *ctx)
26 {
27   struct GNUNET_HashCode key;
28   char block[4];
29
30   memset (block, 1, sizeof (block));
31   if (GNUNET_OK !=
32       GNUNET_BLOCK_get_key (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, block,
33                             sizeof (block), &key))
34     return 1;
35   if (GNUNET_BLOCK_EVALUATION_OK_LAST !=
36       GNUNET_BLOCK_evaluate (ctx,
37                              GNUNET_BLOCK_TYPE_FS_DBLOCK,
38                              NULL,
39                              GNUNET_BLOCK_EO_NONE,
40                              &key,
41                              NULL, 0,
42                              block, sizeof (block)))
43     return 2;
44   if (GNUNET_BLOCK_EVALUATION_REQUEST_VALID !=
45       GNUNET_BLOCK_evaluate (ctx,
46                              GNUNET_BLOCK_TYPE_FS_DBLOCK,
47                              NULL,
48                              GNUNET_BLOCK_EO_NONE,
49                              &key,
50                              NULL, 0,
51                              NULL, 0))
52     return 4;
53   GNUNET_log_skip (1, GNUNET_NO);
54   if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID !=
55       GNUNET_BLOCK_evaluate (ctx,
56                              GNUNET_BLOCK_TYPE_FS_DBLOCK,
57                              NULL,
58                              GNUNET_BLOCK_EO_NONE,
59                              &key,
60                              "bogus", 5,
61                              NULL, 0))
62     return 8;
63   GNUNET_log_skip (0, GNUNET_YES);
64   return 0;
65 }
66
67
68 int
69 main (int argc, char *argv[])
70 {
71   int ret;
72   struct GNUNET_BLOCK_Context *ctx;
73   struct GNUNET_CONFIGURATION_Handle *cfg;
74
75   GNUNET_log_setup ("test-block", "WARNING", NULL);
76   cfg = GNUNET_CONFIGURATION_create ();
77   ctx = GNUNET_BLOCK_context_create (cfg);
78   ret = test_fs (ctx);
79   GNUNET_BLOCK_context_destroy (ctx);
80   GNUNET_CONFIGURATION_destroy (cfg);
81   if (ret != 0)
82     FPRINTF (stderr, "Tests failed: %d\n", ret);
83   return ret;
84 }
85
86 /* end of test_plugin_block_fs.c */