dht_test_lib.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. This file is part of GNUnet.
  3. (C) 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 dht/dht_test_lib.h
  19. * @author Christian Grothoff
  20. * @brief library for writing DHT tests
  21. */
  22. #ifndef DHT_TEST_LIB_H
  23. #define DHT_TEST_LIB_H
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #if 0 /* keep Emacsens' auto-indent happy */
  28. }
  29. #endif
  30. #endif
  31. #include "gnunet_testbed_service.h"
  32. #include "gnunet_dht_service.h"
  33. /**
  34. * Test context for a DHT Test.
  35. */
  36. struct GNUNET_DHT_TEST_Context;
  37. /**
  38. * Main function of a DHT test.
  39. *
  40. * @param cls closure
  41. * @param ctx argument to give to GNUNET_DHT_TEST_cleanup on test end
  42. * @param num_peers number of peers that are running
  43. * @param peers array of peers
  44. * @param dhts handle to each of the DHTs of the peers
  45. */
  46. typedef void (*GNUNET_DHT_TEST_AppMain) (void *cls,
  47. struct GNUNET_DHT_TEST_Context *ctx,
  48. unsigned int num_peers,
  49. struct GNUNET_TESTBED_Peer **peers,
  50. struct GNUNET_DHT_Handle **dhts);
  51. /**
  52. * Run a test using the given name, configuration file and number of
  53. * peers.
  54. *
  55. * @param testname name of the test (for logging)
  56. * @param cfgname name of the configuration file
  57. * @param num_peers number of peers to start
  58. * @param tmain main function to run once the testbed is ready
  59. * @param tmain_cls closure for 'tmain'
  60. */
  61. void
  62. GNUNET_DHT_TEST_run (const char *testname,
  63. const char *cfgname,
  64. unsigned int num_peers,
  65. GNUNET_DHT_TEST_AppMain tmain,
  66. void *tmain_cls);
  67. /**
  68. * Clean up the testbed.
  69. *
  70. * @param ctx handle for the testbed
  71. */
  72. void
  73. GNUNET_DHT_TEST_cleanup (struct GNUNET_DHT_TEST_Context *ctx);
  74. #if 0 /* keep Emacsens' auto-indent happy */
  75. {
  76. #endif
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. /* ifndef DHT_TEST_LIB_H */
  81. #endif