test_testbed_api_test_timeout.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. This file is part of GNUnet
  3. Copyright (C) 2008--2013 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 src/testbed/test_testbed_api_test.c
  18. * @brief testing cases for testing notications via test master callback upon
  19. * timeout while setting up testbed using functions
  20. * GNUNET_TESTBED_test_run()
  21. * @author Sree Harsha Totakura <sreeharsha@totakura.in>
  22. */
  23. #include "platform.h"
  24. #include "gnunet_util_lib.h"
  25. #include "gnunet_testbed_service.h"
  26. /**
  27. * Generic logging shortcut
  28. */
  29. #define LOG(kind,...) \
  30. GNUNET_log (kind, __VA_ARGS__)
  31. /**
  32. * Number of peers we want to start
  33. */
  34. #define NUM_PEERS 25
  35. /**
  36. * Testing result
  37. */
  38. static int result;
  39. /**
  40. * shortcut to exit during failure
  41. */
  42. #define FAIL_TEST(cond) do { \
  43. if (!(cond)) { \
  44. GNUNET_break(0); \
  45. GNUNET_SCHEDULER_shutdown (); \
  46. return; \
  47. } \
  48. } while (0)
  49. /**
  50. * Controller event callback
  51. *
  52. * @param cls NULL
  53. * @param event the controller event
  54. */
  55. static void
  56. controller_event_cb (void *cls,
  57. const struct GNUNET_TESTBED_EventInformation *event)
  58. {
  59. FAIL_TEST (0);
  60. }
  61. /**
  62. * Signature of a main function for a testcase.
  63. *
  64. * @param cls closure
  65. * @param h the run handle
  66. * @param num_peers number of peers in 'peers'
  67. * @param peers- handle to peers run in the testbed
  68. * @param links_succeeded the number of overlay link connection attempts that
  69. * succeeded
  70. * @param links_failed the number of overlay link connection attempts that
  71. * failed
  72. */
  73. static void
  74. test_master (void *cls,
  75. struct GNUNET_TESTBED_RunHandle *h,
  76. unsigned int num_peers,
  77. struct GNUNET_TESTBED_Peer **peers_,
  78. unsigned int links_succeeded,
  79. unsigned int links_failed)
  80. {
  81. FAIL_TEST (NULL == cls);
  82. FAIL_TEST (0 == num_peers);
  83. FAIL_TEST (NULL == peers_);
  84. result = GNUNET_OK;
  85. GNUNET_SCHEDULER_shutdown ();
  86. }
  87. /**
  88. * Main function
  89. */
  90. int
  91. main (int argc, char **argv)
  92. {
  93. uint64_t event_mask;
  94. result = GNUNET_SYSERR;
  95. event_mask = 0;
  96. (void) GNUNET_TESTBED_test_run ("test_testbed_api_test",
  97. "test_testbed_api_test_timeout.conf", NUM_PEERS,
  98. event_mask, &controller_event_cb, NULL,
  99. &test_master, NULL);
  100. if (GNUNET_OK != result)
  101. return 1;
  102. return 0;
  103. }
  104. /* end of test_testbed_api_test.c */