diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-09-13 03:18:26 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-09-13 03:18:26 +0000 |
commit | 2e9791b5b713120238ea95113537fa55ff49b95d (patch) | |
tree | 98c0c6e0171109e7e4403fc50b6cae03a5c26c15 /src/block/test_block.c | |
parent | a42b4e0ed22b65631caea4bb456f3d8fc21f11b1 (diff) | |
download | gnunet-2e9791b5b713120238ea95113537fa55ff49b95d.tar.gz gnunet-2e9791b5b713120238ea95113537fa55ff49b95d.zip |
new block lib
Diffstat (limited to 'src/block/test_block.c')
-rw-r--r-- | src/block/test_block.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/src/block/test_block.c b/src/block/test_block.c index bdb806e5b..02719e5aa 100644 --- a/src/block/test_block.c +++ b/src/block/test_block.c | |||
@@ -29,8 +29,67 @@ | |||
29 | 29 | ||
30 | #define VERBOSE GNUNET_NO | 30 | #define VERBOSE GNUNET_NO |
31 | 31 | ||
32 | static int | ||
33 | test_fs (struct GNUNET_BLOCK_Context *ctx) | ||
34 | { | ||
35 | GNUNET_HashCode key; | ||
36 | char block[4]; | ||
37 | |||
38 | memset (block, 1, sizeof (block)); | ||
39 | if (GNUNET_OK != | ||
40 | GNUNET_BLOCK_get_key (ctx, | ||
41 | GNUNET_BLOCK_TYPE_DBLOCK, | ||
42 | block, | ||
43 | sizeof (block), | ||
44 | &key)) | ||
45 | return 1; | ||
46 | if (GNUNET_BLOCK_EVALUATION_OK_LAST != | ||
47 | GNUNET_BLOCK_evaluate (ctx, | ||
48 | GNUNET_BLOCK_TYPE_DBLOCK, | ||
49 | &key, | ||
50 | NULL, 0, | ||
51 | NULL, 0, | ||
52 | block, sizeof (block))) | ||
53 | return 2; | ||
54 | if (GNUNET_BLOCK_EVALUATION_REQUEST_VALID != | ||
55 | GNUNET_BLOCK_evaluate (ctx, | ||
56 | GNUNET_BLOCK_TYPE_DBLOCK, | ||
57 | &key, | ||
58 | NULL, 0, | ||
59 | NULL, 0, | ||
60 | NULL, 0)) | ||
61 | return 4; | ||
62 | GNUNET_log_skip (1, GNUNET_NO); | ||
63 | if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID != | ||
64 | GNUNET_BLOCK_evaluate (ctx, | ||
65 | GNUNET_BLOCK_TYPE_DBLOCK, | ||
66 | &key, | ||
67 | NULL, 0, | ||
68 | "bogus", 5, | ||
69 | NULL, 0)) | ||
70 | return 8; | ||
71 | GNUNET_log_skip (0, GNUNET_YES); | ||
72 | return 0; | ||
73 | } | ||
74 | |||
32 | int | 75 | int |
33 | main (int argc, char *argv[]) | 76 | main (int argc, char *argv[]) |
34 | { | 77 | { |
35 | return 0; /* testcase passed */ | 78 | int ret; |
79 | struct GNUNET_BLOCK_Context *ctx; | ||
80 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
81 | |||
82 | GNUNET_log_setup ("test-block", "WARNING", NULL); | ||
83 | cfg = GNUNET_CONFIGURATION_create (); | ||
84 | GNUNET_CONFIGURATION_set_value_string (cfg, | ||
85 | "block", | ||
86 | "PLUGINS", | ||
87 | "fs"); | ||
88 | ctx = GNUNET_BLOCK_context_create (cfg); | ||
89 | ret = test_fs (ctx); | ||
90 | GNUNET_BLOCK_context_destroy (ctx); | ||
91 | GNUNET_CONFIGURATION_destroy (cfg); | ||
92 | if (ret != 0) | ||
93 | fprintf (stderr, "Tests failed: %d\n", ret); | ||
94 | return ret; | ||
36 | } | 95 | } |