testutil_monitoring.hpp 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. Copyright (c) 2007-2017 Contributors as noted in the AUTHORS file
  3. This file is part of libzmq, the ZeroMQ core engine in C++.
  4. libzmq is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU Lesser General Public License (LGPL) as published
  6. by the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. As a special exception, the Contributors give you permission to link
  9. this library with independent modules to produce an executable,
  10. regardless of the license terms of these independent modules, and to
  11. copy and distribute the resulting executable under terms of your choice,
  12. provided that you also meet, for each linked independent module, the
  13. terms and conditions of the license of that module. An independent
  14. module is a module which is not derived from or based on this library.
  15. If you modify this library, you must extend this exception to your
  16. version of the library.
  17. libzmq is distributed in the hope that it will be useful, but WITHOUT
  18. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  19. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  20. License for more details.
  21. You should have received a copy of the GNU Lesser General Public License
  22. along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. */
  24. #ifndef __TESTUTIL_MONITORING_HPP_INCLUDED__
  25. #define __TESTUTIL_MONITORING_HPP_INCLUDED__
  26. #include "../include/zmq.h"
  27. #include "../src/stdint.hpp"
  28. #include <stddef.h>
  29. // General, i.e. non-security specific, monitor utilities
  30. int get_monitor_event_with_timeout (void *monitor_,
  31. int *value_,
  32. char **address_,
  33. int timeout_);
  34. // Read one event off the monitor socket; return value and address
  35. // by reference, if not null, and event number by value. Returns -1
  36. // in case of error.
  37. int get_monitor_event (void *monitor_, int *value_, char **address_);
  38. void expect_monitor_event (void *monitor_, int expected_event_);
  39. void print_unexpected_event_stderr (int event_,
  40. int err_,
  41. int expected_event_,
  42. int expected_err_);
  43. // expects that one or more occurrences of the expected event are received
  44. // via the specified socket monitor
  45. // returns the number of occurrences of the expected event
  46. // interrupts, if a ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL with EPIPE, ECONNRESET
  47. // or ECONNABORTED occurs; in this case, 0 is returned
  48. // this should be investigated further, see
  49. // https://github.com/zeromq/libzmq/issues/2644
  50. int expect_monitor_event_multiple (void *server_mon_,
  51. int expected_event_,
  52. int expected_err_ = -1,
  53. bool optional_ = false);
  54. int64_t get_monitor_event_v2 (void *monitor_,
  55. uint64_t *value_,
  56. char **local_address_,
  57. char **remote_address_);
  58. void expect_monitor_event_v2 (void *monitor_,
  59. int64_t expected_event_,
  60. const char *expected_local_address_ = NULL,
  61. const char *expected_remote_address_ = NULL);
  62. const char *get_zmqEventName (uint64_t event);
  63. void print_events (void *socket, int timeout, int limit);
  64. #endif