Skip to content

CI: add mingw-w64 job + headless stdin-binary regression test#101

Merged
josephnef merged 1 commit into
masterfrom
ci-mingw-stdin-selftest
Jun 24, 2026
Merged

CI: add mingw-w64 job + headless stdin-binary regression test#101
josephnef merged 1 commit into
masterfrom
ci-mingw-stdin-selftest

Conversation

@josephnef

Copy link
Copy Markdown
Collaborator

Problem

CI builds the Windows target with MSVC + vcpkg only — mingw-w64 (GCC on Windows) is never exercised. That's the toolchain the recent stream-demo binary-stdin fix (#100) targets: mingw defines _WIN32 but not _MSC_VER, and gets libusb from pkg-config rather than vcpkg. Two gaps follow:

  • Nothing catches a mingw build/link break (e.g. the CMake VCPKG_ROOT guard, or a missing include branch).
  • Worse, the actual runtime bug class is invisible to a build-only check: reverting the _setmode gate from _WIN32 back to _MSC_VER compiles clean on mingw and only truncates the first PSDU at runtime.

Change

1. build-mingw CI job — MSYS2 / MINGW64, libusb via pkgconf, VCPKG_ROOT unset (so CMake takes the pkg-config path). Builds all targets and runs ctest.

2. Headless stdin-binary regression test

  • txdemo/stream_stdin.h — single source of truth for the _WIN32-gated set_stdin_binary() plus a tri-state read_exact(). Both stream demos now use it (removes two duplicate read_exact copies; behavior preserved — StreamTxDemo aborts on a truncated record, StreamDuplexDemo stops its TX thread and keeps RX running).
  • StreamStdinSelftest + tests/stream_stdin_test.cmake — pipes a canonical <u32_le len><PSDU> stream containing 0x1A/CRLF through the same gate the demos use and asserts the round-trip. No libusb, no radio. Registered as the stream_stdin_binary ctest.

Because the demos and the self-test share the gate, a regression fails ctest on the Windows/mingw jobs instead of only surfacing on hardware. ctest now runs in every job, so a total gate removal is also caught on the MSVC cell.

Verification

Local (macOS): all targets build, ctest passes (records=5 bytes=20 OK), and a truncated-at-0x1A stream correctly fails the test. The mingw job and Windows text-mode behavior validate in CI.

Notes

  • build-mingw is intentionally not a required status check yet — suggest landing it non-required and promoting once it's proven stable.
  • The now-redundant io.h/fcntl.h in the demos' _MSC_VER/__MINGW32__ include branches were left in place to keep this diff off the just-merged StreamTxDemo: fix mingw/Windows-GCC build and binary stdin #100 include structure; trivial follow-up to tidy.

🤖 Generated with Claude Code

The stream-link TX demos read a binary <u32_le len><PSDU> stream from stdin,
which only works on Windows if stdin is in binary mode. That gate has to be
_WIN32 (not _MSC_VER) so it also fires under mingw/GCC — a distinction CI never
exercised, because the Windows matrix cell is MSVC + vcpkg only. A build-only
mingw job would still miss it: reverting the gate to _MSC_VER compiles clean on
mingw and only truncates bytes at runtime.

So this does two things:

1. build-mingw job (MSYS2 / MINGW64, libusb via pkg-config, VCPKG_ROOT unset) —
   builds the library, the two stream demos and the self-test, then runs ctest.
   Exercises the CMake pkg-config path the MSVC+vcpkg cell never hits. The other
   demos (WiFiDriverDemo / WiFiDriverTxDemo / PrecoderDemo) use POSIX-only APIs
   such as fork() and are intentionally not built here — they were never mingw
   targets.

2. A headless self-test that catches the runtime regression. Extract the
   binary-stdin gate + length-prefixed reader into txdemo/stream_stdin.h (single
   source of truth, used by both stream demos), add StreamStdinSelftest which
   round-trips a canonical stream containing 0x1A/CRLF with no libusb, and
   register it as the stream_stdin_binary ctest (tests/stream_stdin_test.cmake
   pipes --gen into the reader). Because the demos and the self-test share the
   same gate, reverting it fails ctest on the Windows/mingw jobs.

ctest now runs in every CI job (the existing matrix cells too, so a total gate
removal is caught on MSVC as well). Verified locally on macOS: all targets
build, the test passes, and a truncated-at-0x1A stream fails it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@josephnef josephnef force-pushed the ci-mingw-stdin-selftest branch from 024054f to 6dc0d13 Compare June 24, 2026 08:47
@josephnef josephnef merged commit 6657a3c into master Jun 24, 2026
6 checks passed
@josephnef josephnef deleted the ci-mingw-stdin-selftest branch June 24, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant