Skip to content

Coverage/Fixes#257

Merged
sgerbino merged 5 commits into
cppalliance:developfrom
sgerbino:pr/coverage
May 29, 2026
Merged

Coverage/Fixes#257
sgerbino merged 5 commits into
cppalliance:developfrom
sgerbino:pr/coverage

Conversation

@sgerbino

@sgerbino sgerbino commented May 29, 2026

Copy link
Copy Markdown
Collaborator

Includes #252.

mvandeberg and others added 2 commits May 29, 2026 15:43
- Add Windows make_local_stream_pair() via temp-listener emulation of
  socketpair(), enabling socket-pair tests on IOCP
- Implement assign_socket() in win_local_stream_service so raw SOCKET
  handles can be registered with the IOCP port
- Replace ConnectEx/AcceptEx with blocking connect()/accept() on
  worker threads for AF_UNIX — the IOCP extension functions are not
  reliable for AF_UNIX on all Windows versions
- Add portable temp_socket_dir helper using std::filesystem for
  temp paths across platforms
- Guard local datagram code (SOCK_DGRAM) as POSIX-only at compile time
  — Windows does not support AF_UNIX SOCK_DGRAM
- Remove dead IOCP datagram implementation files
  (win_local_dgram_service.hpp, win_local_dgram_socket.hpp)
- Document Windows limitation on local_datagram_socket and
  local_datagram headers
- socket_option: IP_MULTICAST_LOOP and IP_MULTICAST_TTL are u_char options
  on BSD-derived kernels; the previous int storage caused setsockopt to
  return EINVAL on macOS. Add byte_boolean_option / byte_integer_option
  (public ABI) and byte_boolean<> / byte_integer<> (native templates)
  with single-byte storage; rebase multicast_loop_v4 and multicast_hops_v4
  onto them. IPv6 variants are unaffected.

- native_local_datagram_socket: include of the deleted IOCP datagram
  service was reachable in any IOCP build. Wrap the whole header in
  BOOST_COROSIO_POSIX to mirror local_datagram_socket.hpp.

- posix_resolver_service and win_resolver_service: replace
  make_service<thread_pool>() with use_service<thread_pool>(). The
  original call threw 'invalid argument' whenever
  io_context_options.thread_pool_size != 1 because pre_create_services
  had already constructed the pool with non-default args.

- iocp wait_reactor and tcp_acceptor_service: resolve a pre-cancelled
  stop_token race in wait() and accept() paths that caused tests to
  hang on Windows IOCP under specific completion orderings.
@cppalliance-bot

cppalliance-bot commented May 29, 2026

Copy link
Copy Markdown

An automated preview of the documentation is available at https://257.corosio.prtest3.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-05-29 17:53:39 UTC

@cppalliance-bot

cppalliance-bot commented May 29, 2026

Copy link
Copy Markdown

GCOVR code coverage report https://257.corosio.prtest3.cppalliance.org/gcovr/index.html
LCOV code coverage report https://257.corosio.prtest3.cppalliance.org/genhtml/index.html
Coverage Diff Report https://257.corosio.prtest3.cppalliance.org/diff-report/index.html

Build time: 2026-05-29 18:04:30 UTC

@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.77%. Comparing base (1c5b7d7) to head (0929b09).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #257   +/-   ##
========================================
  Coverage    77.76%   77.77%           
========================================
  Files           96       96           
  Lines         7264     7262    -2     
  Branches      1775     1773    -2     
========================================
- Hits          5649     5648    -1     
  Misses        1104     1104           
+ Partials       511      510    -1     
Files with missing lines Coverage Δ
...orosio/native/detail/iocp/win_resolver_service.hpp 69.26% <ø> (+0.29%) ⬆️
...sio/native/detail/posix/posix_resolver_service.hpp 81.46% <ø> (-0.07%) ⬇️
...lude/boost/corosio/native/native_socket_option.hpp 100.00% <ø> (ø)
include/boost/corosio/socket_option.hpp 93.22% <ø> (ø)
src/corosio/src/io_context.cpp 95.83% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c5b7d7...0929b09. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sgerbino sgerbino force-pushed the pr/coverage branch 3 times, most recently from d5264ab to 3aae8f7 Compare May 29, 2026 15:25
sgerbino added 2 commits May 29, 2026 17:45
Adds targeted unit tests across the public API and native shadow layers
to close the largest line-coverage gaps in the develop baseline.

Major areas:

- tls_context: cover malformed PEM, mismatched cert/key, cipher list,
  protocol version round-trip, verify mode/depth, hostname, SNI/ALPN,
  CRL, OCSP staple, password callback (24% to 100%).
- io_context and scheduler detail: backend tag construction, run_for,
  run_until, restart, post-throws, deterministic multithreaded
  notify_one + wait_for coverage.
- socket_option: set/get round-trip for every public option plus the
  native templated variants; wrong-protocol error paths.
- local sockets: connect/accept error paths, abstract namespace,
  path-length boundary, mid-flight cancel, datagram send/recv. Adopt
  the temp_socket_dir helper introduced upstream.
- reactor internals: concurrent read/write on same descriptor,
  mid-flight cancel, close-during-op, wait_type::error paths, stop-token
  cancellation. Add reactor_paths.cpp aggregating these scenarios.
- tcp_server, posix_resolver_service, host_name, file services:
  lifecycle, accept loop, flag variants, error mapping.
- Add testConstructionWithThreadPoolSize regression for the resolver
  use_service fix.

Cross-platform reconciliation observed in CI:
- BSD-family kernels reject multicast set_option values (zero buffer
  sizes, leave-without-route, IPV6 ifindex 0) that Linux accepts;
  wrap in try/catch with documented platform variation.
- macOS returns EMSGSIZE for zero-length UDP datagrams; broaden the
  expectation to any error so MinGW and others pass too.
- Windows IOCP: gate testIoContextOptionsMaxEventsZero/BudgetInitClamp
  and the single-threaded resolver tests as POSIX-only; relax buffer
  size assertions to permit Windows's accept-zero-as-zero contract.
- POSIX-guard local socket tests that exercise abstract namespace and
  related Linux-only behavior.
- testMultithreadedNotifyAndWaitFor restructured to depend only on a
  work guard and counter drain, not on wall-clock timing, so it
  remains deterministic under thread-sanitizer.
- Signal-set shutdown test switched from POSIX-only SIGUSR1/2 to the
  portable SIGINT/SIGTERM pair.
The public make_local_stream_pair / make_local_datagram_pair were
primarily used to construct test fixtures; production callers exist
in theory but are vanishingly rare compared to test and benchmark
usage. PR cppalliance#252's Windows implementation was specifically motivated
by tests on IOCP.

Move both helpers into include/boost/corosio/test/local_socket_pair.hpp
under boost::corosio::test, alongside the existing templated stream
variant that the perf benchmarks already use. The test/ helper drives
bind+accept+connect via the public acceptor API, which works on every
backend after PR cppalliance#252 enabled AF_UNIX SOCK_STREAM on Windows IOCP --
so the bespoke socketpair-emulation Windows code in
src/corosio/src/local_socket_pair.cpp is no longer needed.

- Delete include/boost/corosio/local_socket_pair.hpp
- Delete src/corosio/src/local_socket_pair.cpp
- Remove the umbrella include in boost/corosio.hpp
- Add make_local_datagram_pair to test/local_socket_pair.hpp (POSIX-only)
- Migrate the three test files that called the public helpers
  (local_stream_socket.cpp, local_datagram_socket.cpp, reactor_paths.cpp)
  via using-declarations so call sites stay identical
Mirror asio::local::connect_pair as a free function in
boost::corosio. POSIX uses socketpair(); Windows performs a
private bind/listen/accept on the caller thread paired with a
connect on a short-lived worker thread, so the caller's
io_context is never driven.

Returns std::error_code (noexcept). Stream and POSIX-only
datagram overloads. native_local_stream_socket<Backend> slices
to the base parameter; assign() routes through the backend
service.

Replaces the test-only make_local_*_pair helpers from 4b952ec;
tests, benchmarks, and the user guide are migrated.
@sgerbino sgerbino merged commit 2046d55 into cppalliance:develop May 29, 2026
42 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Beast2 May 29, 2026
@sgerbino sgerbino deleted the pr/coverage branch May 29, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants