cadet_test_lib.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2012,2017 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your 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. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file cadet/cadet_test_lib.h
  18. * @author Bartlomiej Polot
  19. * @brief library for writing CADET tests
  20. */
  21. #ifndef CADET_TEST_LIB_H
  22. #define CADET_TEST_LIB_H
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #if 0 /* keep Emacsens' auto-indent happy */
  27. }
  28. #endif
  29. #endif
  30. #include "gnunet_testbed_service.h"
  31. #include "gnunet_cadet_service.h"
  32. /**
  33. * Test context for a CADET Test.
  34. */
  35. struct GNUNET_CADET_TEST_Context;
  36. /**
  37. * Main function of a CADET test.
  38. *
  39. * @param cls Closure.
  40. * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
  41. * @param num_peers Number of peers that are running.
  42. * @param peers Array of peers.
  43. * @param cadets Handle to each of the CADETs of the peers.
  44. */
  45. typedef void (*GNUNET_CADET_TEST_AppMain) (void *cls,
  46. struct GNUNET_CADET_TEST_Context *ctx,
  47. unsigned int num_peers,
  48. struct GNUNET_TESTBED_Peer **peers,
  49. struct GNUNET_CADET_Handle **cadets);
  50. /**
  51. * Run a test using the given name, configuration file and number of peers.
  52. * All cadet callbacks will receive the peer number (long) as the closure.
  53. *
  54. * @param testname Name of the test (for logging).
  55. * @param cfgfile Name of the configuration file.
  56. * @param num_peers Number of peers to start.
  57. * @param tmain Main function to run once the testbed is ready.
  58. * @param tmain_cls Closure for @a tmain.
  59. * @param connects Handler for incoming channels.
  60. * @param window_changes Handler for the window size change notification.
  61. * @param disconnects Cleaner for destroyed incoming channels.
  62. * @param handlers Message handlers.
  63. * @param ports Ports the peers offer, NULL-terminated.
  64. */
  65. void
  66. GNUNET_CADET_TEST_ruN(const char *testname,
  67. const char *cfgfile,
  68. unsigned int num_peers,
  69. GNUNET_CADET_TEST_AppMain tmain,
  70. void *tmain_cls,
  71. GNUNET_CADET_ConnectEventHandler connects,
  72. GNUNET_CADET_WindowSizeEventHandler window_changes,
  73. GNUNET_CADET_DisconnectEventHandler disconnects,
  74. struct GNUNET_MQ_MessageHandler *handlers,
  75. const struct GNUNET_HashCode **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