Skip to content

Test how a report reaches curl and how curl's end is told - #27

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/test-curl-transport-promises
Nov 6, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/test-curl-transport-promises

Conversation

@dmccoystephenson

@dmccoystephenson dmccoystephenson commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Stage B test expansion for the README's "How a report is sent" section and the wire-format 201 rule. Most of these promises were previously asserted only as text in curlConfigFixesEveryOptionAndQuotesEveryValue, or not at all. Only test/test_trace_client.cpp is changed; these are characterization tests and production code is untouched.

No tracking issue — gap found during triage.

On every transport:

  • onlyA201IsSuccess: 200, 202, 204, 400 and 500 each reach the Logger; a 201 does not.
  • aRedirectIsAnAnswerAndIsNotFollowed: a 302 is logged and its target receives nothing. StubServer gained redirectTo for this; location is guarded by the server's mutex so that TSan sees an ordering with the worker threads.
  • aBaseUrlOfAnotherProtocolIsNeverTried: a file: base URL is refused by protocol, which is distinguished from the failure that a tried, missing file would give.

On the POSIX default transport, a shell script placed first on PATH stands in for curl (FakeCurl):

  • theCommandLineIsFixedAndTheRequestGoesOnStandardInput: the arguments are exactly -q --silent --config -, and the URL, key and body arrive on standard input.
  • theLoggerHearsHowCurlEnded: each exit path yields its message, including exit 127, 000 with exit 7, unparseable output, and a status that is believed whatever the exit code.
  • aCurlThatDiesEarlyIsAnErrorNotASignal: a request far larger than a pipe is written to a curl that has already gone, and no SIGPIPE reaches the test program.
  • curlStartsWithSigpipeUnblockedAndAtItsDefault: with SIGPIPE blocked on the sending thread and ignored by the host, the script's own SIGPIPE still ends it (curl did not finish).
  • closeKillsTheCurlItGaveUpOn: the process of an abandoned request is gone after close() gives up, rather than left running.

The five FakeCurl tests are registered only under TRACE_CLIENT_POSIX, so the printed test count differs by platform: 73 on the POSIX default transport, 68 on libcurl and on Windows. They are left out there rather than printed as ok without running. Automated coverage gap: the Windows send() paths and findCurl remain without equivalent tests.

Deferred issues

Test plan

  • make clean && make test (g++, C++11): 73 tests, 0 failed checks, up from 65
  • make clean && make test STD=c++2a (g++): 73 tests, 0 failed checks
  • make test-libcurl: 68 tests, 0 failed checks
  • Header mutated, then restored; each new test was shown to fail:
    • proto line replaced by location = true: aBaseUrlOfAnotherProtocolIsNeverTried and aRedirectIsAnAnswerAndIsNotFollowed failed
    • success widened to any 2xx: onlyA201IsSuccess failed
    • -q argument changed: theCommandLineIsFixedAndTheRequestGoesOnStandardInput failed
    • exit 127 branch changed: theLoggerHearsHowCurlEnded failed
    • SIGKILL changed to signal 0: closeKillsTheCurlItGaveUpOn failed
    • POSIX_SPAWN_SETSIGMASK removed, and separately POSIX_SPAWN_SETSIGDEF removed: curlStartsWithSigpipeUnblockedAndAtItsDefault failed each time
    • SIGPIPE left unblocked on the sending thread: the test binary was killed (make: *** [Makefile:19: test] Broken pipe), which is the failure aCurlThatDiesEarlyIsAnErrorNotASignal guards. The run's per-test lines were not kept, so the test it died in was not observed directly
  • CI Build green on head a3be266, including both linux-sanitizers legs, macos and windows: the nine POSIX default-transport jobs printed 73 tests, 0 failed checks, linux-libcurl and windows printed 68 tests, 0 failed checks, and no sanitizer report appears in the logs

clang++ is not installed locally and the TSan runtime was not run locally; both were covered by CI.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

The README's "How a report is sent" promises were mostly checked only
as config text. These tests run them: a stand-in curl on PATH shows the
fixed command line, the request on standard input, how each exit reaches
the Logger, an early death with no SIGPIPE, a clean signal state in curl
and the kill when close() gives up. StubServer learns to redirect, for
the redirect that is not followed; other 2xx answers and a file: base
URL are covered on every transport.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (performed inline in a headless dispatch; not an independent review):

  • Scope: PASS — one file, test/test_trace_client.cpp, all of it the new tests plus the StubServer redirect they need. The one deleted line is the response string split to carry the optional header.
  • Tests-new: PASS — no production method was added. Each new test was shown to fail by a header mutation listed in the PR description.
  • Tests-fix: PASS (n/a) — no bug fix; characterization only, and trace_client.hpp is unchanged (git status showed only the test file after the mutations were restored).
  • Sibling structure / renames: PASS (n/a) — no new files, no renamed identifiers.
  • Docs: PASS — no behavior changed, so no README row moves.
  • Issue resolution: PASS (n/a) — no Closes; no tracking issue, and the PR description says so.
  • CI: PASS — all 11 Build jobs succeeded on head a3be266. Nine printed 73 tests, 0 failed checks, linux-libcurl and windows printed 68 tests, 0 failed checks, and the logs contain no sanitizer report.
  • Registered: PASS — each of the 8 new names occurs on exactly 2 lines (16 matching lines). The local count rose from 65 to 73.
  • C++11: PASS — make test (g++, -std=c++11 -Werror) built clean, and both CI c++11 legs are green.
  • No new dependency: PASS — the header is untouched; the Makefile and CMakeLists.txt are untouched. FakeCurl uses /bin/sh in the tests only, under TRACE_CLIENT_POSIX.
  • Never throws / Curl argv fixed / Version triple: PASS (n/a) — none is touched, and the argv is now asserted by a test.
  • Sanitizers: PASS — both linux-sanitizers legs are green with the new tests running. location is read under the server's mutex rather than relying on the socket ordering, which TSan cannot see.

Findings:

  • test/test_trace_client.cpp:1643 — aBaseUrlOfAnotherProtocolIsNeverTried depends on curl's exit code 1 (unsupported protocol). It passed on the Linux, macOS and Windows runners, but a future curl that reported this differently would fail this test without the client having changed.
  • test/test_trace_client.cpp:1750 — closeKillsTheCurlItGaveUpOn proves the process is gone, not that it was killed rather than having exited. The script sleeps for 30 s, and the mutated run failed after its 10 s bound, so an early exit cannot pass by accident.
  • The SIGPIPE mutation killed the test binary, and the per-test output of that run was not kept, so the test it died in was inferred, not observed. aCurlThatDiesEarlyIsAnErrorNotASignal is the only new test that writes more than a pipe holds to a curl that does not read.
  • Not addressed: the POSIX-only tests have no Windows equivalent, so findCurl and the Windows send() paths still have no direct coverage of their exit handling. A Windows version would need a batch-file stand-in, which is a larger change.
  • Not addressed: the README's "Building" section describes the tests as running against a loopback HTTP server. That stays true of most tests, but the five FakeCurl tests reach no server. The statement that no real trace server is reached still holds, so this was left alone.

Do-not-auto-merge paths: none touched (no workflow, Makefile, CMakeLists, curl argv, quoting, spawn code, proto line, version or wire-format change). The header mutations were test probes only and were restored before the commit.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 498a216 into main Nov 6, 2026
11 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/test-curl-transport-promises branch November 6, 2026 06:14
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