diff --git a/tests/basics/buildfile b/tests/basics/buildfile index 45a1ca0..57c22ed 100644 --- a/tests/basics/buildfile +++ b/tests/basics/buildfile @@ -1,3 +1,9 @@ -import libs = libasio%lib{asio} +import! [metadata, rule_hint=cxx.link] asio = libasio%lib{asio} -exe{driver}: cxx{driver} $libs +exe{driver}: cxx{driver} $asio + +if ($cxx.target.class == 'windows') + cxx.poptions += -D_WIN32_WINNT=0x0601 + +if $($asio: libasio.ssl) + cxx.poptions += "-DLIBASIO_TESTS_SSL_ENABLED" diff --git a/tests/basics/driver.cpp b/tests/basics/driver.cpp index 61b03c6..6b47a7a 100644 --- a/tests/basics/driver.cpp +++ b/tests/basics/driver.cpp @@ -1,7 +1,58 @@ -#include +// The following source code was taken mostly verbatim from +// upstream/asio/src/tests/unit/local/connect_pair.cpp. +// +// Because a large proportion of Asio's code is located in header files it's +// not always easy to tell but stepping through this program with a debugger +// confirms that multiple .ipp files are visited which means this program does +// execute code compiled into the library. +// + +#include + +#include +#include +#include + +#ifdef LIBASIO_TESTS_SSL_ENABLED +#include +#endif int main () { + using namespace asio; + namespace local = asio::local; + typedef local::datagram_protocol dp; + typedef local::stream_protocol sp; + + try + { + asio::io_context io_context; + asio::error_code ec1; + + dp::socket s1 (io_context); + dp::socket s2 (io_context); + local::connect_pair (s1, s2); + + dp::socket s3 (io_context); + dp::socket s4 (io_context); + local::connect_pair (s3, s4, ec1); + + sp::socket s5 (io_context); + sp::socket s6 (io_context); + local::connect_pair (s5, s6); + + sp::socket s7 (io_context); + sp::socket s8 (io_context); + local::connect_pair (s7, s8, ec1); + +#ifdef LIBASIO_TESTS_SSL_ENABLED + asio::ssl::context ssl_ctx (asio::ssl::context::sslv23); +#endif + } + catch (std::exception&) + { + } + return 0; } diff --git a/tests/build/root.build b/tests/build/root.build index 706e686..dc3c9bb 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -4,7 +4,6 @@ using cxx hxx{*}: extension = hpp ixx{*}: extension = ipp -txx{*}: extension = tpp cxx{*}: extension = cpp # Assume headers are importable unless stated otherwise.