cadet_test_lib.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (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 cadet/cadet_test_lib.h
  19. * @author Bartlomiej Polot
  20. * @brief library for writing CADET tests
  21. */
  22. #ifndef CADET_TEST_LIB_H
  23. #define CADET_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_cadet_service.h"
  33. /**
  34. * Test context for a CADET Test.
  35. */
  36. struct GNUNET_CADET_TEST_Context;
  37. /**
  38. * Main function of a CADET test.
  39. *
  40. * @param cls Closure.
  41. * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
  42. * @param num_peers Number of peers that are running.
  43. * @param peers Array of peers.
  44. * @param cadetes Handle to each of the CADETs of the peers.
  45. */
  46. typedef void (*GNUNET_CADET_TEST_AppMain) (void *cls,
  47. struct GNUNET_CADET_TEST_Context *ctx,
  48. unsigned int num_peers,
  49. struct GNUNET_TESTBED_Peer **peers,
  50. struct GNUNET_CADET_Handle **cadetes);
  51. /**
  52. * Run a test using the given name, configuration file and number of
  53. * peers.
  54. * All cadet callbacks will receive the peer number as the closure.
  55. *
  56. * @param testname Name of the test (for logging).
  57. * @param cfgname Name of the configuration file.
  58. * @param num_peers Number of peers to start.
  59. * @param tmain Main function to run once the testbed is ready.
  60. * @param tmain_cls Closure for 'tmain'.
  61. * @param new_channel Handler for incoming tunnels.
  62. * @param cleaner Cleaner for destroyed incoming tunnels.
  63. * @param handlers Message handlers.
  64. * @param ports Ports the peers offer.
  65. */
  66. void
  67. GNUNET_CADET_TEST_run (const char *testname,
  68. const char *cfgname,
  69. unsigned int num_peers,
  70. GNUNET_CADET_TEST_AppMain tmain,
  71. void *tmain_cls,
  72. GNUNET_CADET_InboundChannelNotificationHandler new_channel,
  73. GNUNET_CADET_ChannelEndHandler cleaner,
  74. struct GNUNET_CADET_MessageHandler* handlers,
  75. const uint32_t* ports);
  76. /**
  77. * Clean up the testbed.
  78. *
  79. * @param ctx handle for the testbed
  80. */
  81. void
  82. GNUNET_CADET_TEST_cleanup (struct GNUNET_CADET_TEST_Context *ctx);
  83. #if 0 /* keep Emacsens' auto-indent happy */
  84. {
  85. #endif
  86. #ifdef __cplusplus
  87. }
  88. #endif
  89. /* ifndef CADET_TEST_LIB_H */
  90. #endif