test_plugin_block_fs.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. This file is part of GNUnet
  3. (C) 2010, 2012 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16. */
  17. /**
  18. * @file fs/test_plugin_block_fs.c
  19. * @brief test for plugin_block_fs.c
  20. * @author Christian Grothoff
  21. */
  22. #include "platform.h"
  23. #include "gnunet_block_lib.h"
  24. static int
  25. test_fs (struct GNUNET_BLOCK_Context *ctx)
  26. {
  27. struct GNUNET_HashCode key;
  28. char block[4];
  29. memset (block, 1, sizeof (block));
  30. if (GNUNET_OK !=
  31. GNUNET_BLOCK_get_key (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, block,
  32. sizeof (block), &key))
  33. return 1;
  34. if (GNUNET_BLOCK_EVALUATION_OK_LAST !=
  35. GNUNET_BLOCK_evaluate (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, &key, NULL, 0,
  36. NULL, 0, block, sizeof (block)))
  37. return 2;
  38. if (GNUNET_BLOCK_EVALUATION_REQUEST_VALID !=
  39. GNUNET_BLOCK_evaluate (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, &key, NULL, 0,
  40. NULL, 0, NULL, 0))
  41. return 4;
  42. GNUNET_log_skip (1, GNUNET_NO);
  43. if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID !=
  44. GNUNET_BLOCK_evaluate (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, &key, NULL, 0,
  45. "bogus", 5, NULL, 0))
  46. return 8;
  47. GNUNET_log_skip (0, GNUNET_YES);
  48. return 0;
  49. }
  50. int
  51. main (int argc, char *argv[])
  52. {
  53. int ret;
  54. struct GNUNET_BLOCK_Context *ctx;
  55. struct GNUNET_CONFIGURATION_Handle *cfg;
  56. GNUNET_log_setup ("test-block", "WARNING", NULL);
  57. cfg = GNUNET_CONFIGURATION_create ();
  58. ctx = GNUNET_BLOCK_context_create (cfg);
  59. ret = test_fs (ctx);
  60. GNUNET_BLOCK_context_destroy (ctx);
  61. GNUNET_CONFIGURATION_destroy (cfg);
  62. if (ret != 0)
  63. FPRINTF (stderr, "Tests failed: %d\n", ret);
  64. return ret;
  65. }
  66. /* end of test_plugin_block_fs.c */