]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/asio/test/generic/seq_packet_protocol.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / asio / test / generic / seq_packet_protocol.cpp
CommitLineData
7c673cae
FG
1//
2// generic/seq_packet_protocol.cpp
3// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4//
b32b8144 5// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7c673cae
FG
6//
7// Distributed under the Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9//
10
11// Disable autolinking for unit tests.
12#if !defined(BOOST_ALL_NO_LIB)
13#define BOOST_ALL_NO_LIB 1
14#endif // !defined(BOOST_ALL_NO_LIB)
15
16// Test that header file is self-contained.
17#include <boost/asio/generic/seq_packet_protocol.hpp>
18
19#include <cstring>
b32b8144 20#include <boost/asio/io_context.hpp>
7c673cae
FG
21#include "../unit_test.hpp"
22
23#if defined(__cplusplus_cli) || defined(__cplusplus_winrt)
24# define generic cpp_generic
25#endif
26
27//------------------------------------------------------------------------------
28
29// generic_seq_packet_protocol_socket_compile test
30// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31// The following test checks that all public member functions on the class
32// generic::seq_packet_socket::socket compile and link correctly. Runtime
33// failures are ignored.
34
35namespace generic_seq_packet_protocol_socket_compile {
36
37void connect_handler(const boost::system::error_code&)
38{
39}
40
41void send_handler(const boost::system::error_code&, std::size_t)
42{
43}
44
45void receive_handler(const boost::system::error_code&, std::size_t)
46{
47}
48
49void test()
50{
51 using namespace boost::asio;
52 namespace generic = boost::asio::generic;
53 typedef generic::seq_packet_protocol spp;
54
55 const int af_inet = BOOST_ASIO_OS_DEF(AF_INET);
56 const int sock_seqpacket = BOOST_ASIO_OS_DEF(SOCK_SEQPACKET);
57
58 try
59 {
b32b8144 60 io_context ioc;
7c673cae
FG
61 char mutable_char_buffer[128] = "";
62 const char const_char_buffer[128] = "";
63 const socket_base::message_flags in_flags = 0;
64 socket_base::message_flags out_flags = 0;
65 socket_base::send_buffer_size socket_option;
66 socket_base::bytes_readable io_control_command;
67 boost::system::error_code ec;
68
69 // basic_seq_packet_socket constructors.
70
b32b8144
FG
71 spp::socket socket1(ioc);
72 spp::socket socket2(ioc, spp(af_inet, 0));
73 spp::socket socket3(ioc, spp::endpoint());
7c673cae
FG
74#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
75 spp::socket::native_handle_type native_socket1
76 = ::socket(af_inet, sock_seqpacket, 0);
b32b8144 77 spp::socket socket4(ioc, spp(af_inet, 0), native_socket1);
7c673cae
FG
78#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
79
80#if defined(BOOST_ASIO_HAS_MOVE)
81 spp::socket socket5(std::move(socket4));
82#endif // defined(BOOST_ASIO_HAS_MOVE)
83
84 // basic_seq_packet_socket operators.
85
86#if defined(BOOST_ASIO_HAS_MOVE)
b32b8144 87 socket1 = spp::socket(ioc);
7c673cae
FG
88 socket1 = std::move(socket2);
89#endif // defined(BOOST_ASIO_HAS_MOVE)
90
91 // basic_io_object functions.
92
b32b8144
FG
93 spp::socket::executor_type ex = socket1.get_executor();
94 (void)ex;
95
96#if !defined(BOOST_ASIO_NO_DEPRECATED)
97 io_context& ioc_ref = socket1.get_io_context();
98 (void)ioc_ref;
99
100 io_context& ioc_ref2 = socket1.get_io_service();
101 (void)ioc_ref2;
102#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
7c673cae
FG
103
104 // basic_socket functions.
105
106 spp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
107 (void)lowest_layer;
108
109 socket1.open(spp(af_inet, 0));
110 socket1.open(spp(af_inet, 0), ec);
111
112#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
113 spp::socket::native_handle_type native_socket2
114 = ::socket(af_inet, sock_seqpacket, 0);
115 socket1.assign(spp(af_inet, 0), native_socket2);
116 spp::socket::native_handle_type native_socket3
117 = ::socket(af_inet, sock_seqpacket, 0);
118 socket1.assign(spp(af_inet, 0), native_socket3, ec);
119#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
120
121 bool is_open = socket1.is_open();
122 (void)is_open;
123
124 socket1.close();
125 socket1.close(ec);
126
b32b8144 127 spp::socket::native_handle_type native_socket4 = socket1.native_handle();
7c673cae
FG
128 (void)native_socket4;
129
130 socket1.cancel();
131 socket1.cancel(ec);
132
133 bool at_mark1 = socket1.at_mark();
134 (void)at_mark1;
135 bool at_mark2 = socket1.at_mark(ec);
136 (void)at_mark2;
137
138 std::size_t available1 = socket1.available();
139 (void)available1;
140 std::size_t available2 = socket1.available(ec);
141 (void)available2;
142
143 socket1.bind(spp::endpoint());
144 socket1.bind(spp::endpoint(), ec);
145
146 socket1.connect(spp::endpoint());
147 socket1.connect(spp::endpoint(), ec);
148
149 socket1.async_connect(spp::endpoint(), connect_handler);
150
151 socket1.set_option(socket_option);
152 socket1.set_option(socket_option, ec);
153
154 socket1.get_option(socket_option);
155 socket1.get_option(socket_option, ec);
156
157 socket1.io_control(io_control_command);
158 socket1.io_control(io_control_command, ec);
159
160 spp::endpoint endpoint1 = socket1.local_endpoint();
161 spp::endpoint endpoint2 = socket1.local_endpoint(ec);
162
163 spp::endpoint endpoint3 = socket1.remote_endpoint();
164 spp::endpoint endpoint4 = socket1.remote_endpoint(ec);
165
166 socket1.shutdown(socket_base::shutdown_both);
167 socket1.shutdown(socket_base::shutdown_both, ec);
168
169 // basic_seq_packet_socket functions.
170
171 socket1.send(buffer(mutable_char_buffer), in_flags);
172 socket1.send(buffer(const_char_buffer), in_flags);
173 socket1.send(null_buffers(), in_flags);
174 socket1.send(buffer(mutable_char_buffer), in_flags, ec);
175 socket1.send(buffer(const_char_buffer), in_flags, ec);
176 socket1.send(null_buffers(), in_flags, ec);
177
178 socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler);
179 socket1.async_send(buffer(const_char_buffer), in_flags, send_handler);
180 socket1.async_send(null_buffers(), in_flags, send_handler);
181
182 socket1.receive(buffer(mutable_char_buffer), out_flags);
183 socket1.receive(null_buffers(), out_flags);
184 socket1.receive(buffer(mutable_char_buffer), in_flags, out_flags);
185 socket1.receive(null_buffers(), in_flags, out_flags);
186 socket1.receive(buffer(mutable_char_buffer), in_flags, out_flags, ec);
187 socket1.receive(null_buffers(), in_flags, out_flags, ec);
188
189 socket1.async_receive(buffer(mutable_char_buffer), out_flags,
190 receive_handler);
191 socket1.async_receive(null_buffers(), out_flags, receive_handler);
192 socket1.async_receive(buffer(mutable_char_buffer), in_flags,
193 out_flags, receive_handler);
194 socket1.async_receive(null_buffers(), in_flags, out_flags, receive_handler);
195 }
196 catch (std::exception&)
197 {
198 }
199}
200
201} // namespace generic_seq_packet_protocol_socket_compile
202
203//------------------------------------------------------------------------------
204
205BOOST_ASIO_TEST_SUITE
206(
207 "generic/seq_packet_protocol",
208 BOOST_ASIO_TEST_CASE(generic_seq_packet_protocol_socket_compile::test)
209)