Skip to content

Commit 1e9dd98

Browse files
committed
Update socket_base test to tolerate when SO_DONTROUTE is unsupported.
1 parent 57a9e31 commit 1e9dd98

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

src/tests/unit/socket_base.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,11 @@ void test()
335335
ASIO_CHECK_MESSAGE(ec == asio::error::no_protocol_option,
336336
ec.value() << ", " << ec.message());
337337
#else // defined(ASIO_WINDOWS) && defined(UNDER_CE)
338-
ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
338+
// Some platforms (e.g. OpenBSD) do not support the SO_DONTROUTE option.
339+
bool do_not_route_unsupported =
340+
(ec == asio::error::operation_not_supported);
341+
ASIO_CHECK_MESSAGE(!ec || do_not_route_unsupported,
342+
ec.value() << ", " << ec.message());
339343
#endif // defined(ASIO_WINDOWS) && defined(UNDER_CE)
340344

341345
socket_base::do_not_route do_not_route2;
@@ -345,10 +349,11 @@ void test()
345349
ASIO_CHECK_MESSAGE(ec == asio::error::no_protocol_option,
346350
ec.value() << ", " << ec.message());
347351
#else // defined(ASIO_WINDOWS) && defined(UNDER_CE)
348-
ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
349-
ASIO_CHECK(do_not_route2.value());
350-
ASIO_CHECK(static_cast<bool>(do_not_route2));
351-
ASIO_CHECK(!!do_not_route2);
352+
ASIO_CHECK_MESSAGE(!ec || do_not_route_unsupported,
353+
ec.value() << ", " << ec.message());
354+
ASIO_CHECK(do_not_route2.value() || do_not_route_unsupported);
355+
ASIO_CHECK(static_cast<bool>(do_not_route2) || do_not_route_unsupported);
356+
ASIO_CHECK(!!do_not_route2 || do_not_route_unsupported);
352357
#endif // defined(ASIO_WINDOWS) && defined(UNDER_CE)
353358

354359
socket_base::do_not_route do_not_route3(false);
@@ -361,7 +366,8 @@ void test()
361366
ASIO_CHECK_MESSAGE(ec == asio::error::no_protocol_option,
362367
ec.value() << ", " << ec.message());
363368
#else // defined(ASIO_WINDOWS) && defined(UNDER_CE)
364-
ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
369+
ASIO_CHECK_MESSAGE(!ec || do_not_route_unsupported,
370+
ec.value() << ", " << ec.message());
365371
#endif // defined(ASIO_WINDOWS) && defined(UNDER_CE)
366372

367373
socket_base::do_not_route do_not_route4;
@@ -371,10 +377,11 @@ void test()
371377
ASIO_CHECK_MESSAGE(ec == asio::error::no_protocol_option,
372378
ec.value() << ", " << ec.message());
373379
#else // defined(ASIO_WINDOWS) && defined(UNDER_CE)
374-
ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
375-
ASIO_CHECK(!do_not_route4.value());
376-
ASIO_CHECK(!static_cast<bool>(do_not_route4));
377-
ASIO_CHECK(!do_not_route4);
380+
ASIO_CHECK_MESSAGE(!ec || do_not_route_unsupported,
381+
ec.value() << ", " << ec.message());
382+
ASIO_CHECK(!do_not_route4.value() || do_not_route_unsupported);
383+
ASIO_CHECK(!static_cast<bool>(do_not_route4) || do_not_route_unsupported);
384+
ASIO_CHECK(!do_not_route4 || do_not_route_unsupported);
378385
#endif // defined(ASIO_WINDOWS) && defined(UNDER_CE)
379386

380387
// keep_alive class.

0 commit comments

Comments
 (0)