Repository navigation
net/http: port clientserver_test.go up to TestStarRequestMethod - #722
Merged
Merged
Conversation
Add tests/http_clientserver.h, the run, runSynctest and newClientServerTest helpers from clientserver_test.go, and port the tests from TestNewClientServerTest through the TestH12_RequestContentLength tests.
…TestStarRequestMethod Keep each mode's run state in test memory, since a subtest that pauses in t.Parallel goes on after testing_t_run returns.
Without it BURROW_NETPOLL_READINESS is never defined there, and every test that needs TCP skipped.
Pass a real Error to every write, since the server's writer stores through it, and give the h12Compare request function the test's env in place of globals that the parallel tests overwrote.
r->a is the allocator that made the request, which on the server is the heap, so what the handlers made there leaked.
This was referenced Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
This ports the first part of Go 1.27's
net/http/clientserver_test.go: the shared harness plus every test from the top of the file down toTestStarRequestMethod. That's 33 tests, each running in h1 and h2 mode like Go's do. This is part of #6.The harness is in
tests/http_clientserver.hso that the serve, transport and client test ports can use it later. The tests are intests/http_clientserver_test.c.run,runSynctestrun,run_synctest, with aRunOptsnewClientServerTestnew_client_server_test,new_client_server_test_funcoptFakeNet,optQuietLog,optWithServerLogand the server/transport funcsCSTOptstestModeand itsSchemeTestMode,test_mode_string,test_mode_schemeh12Compare,normalizeRes,mostlyCopyH12Compare,h12_normalize_res,mostly_equalNot in Go
C has no closures and no garbage collector, so a few things work differently. Where the code departs from Go's, it has a "Not in Go" comment.
test_allocandtest_arenahand out memory that lasts until the test's cleanups run. That covers state that Go's closures would keep alive.t.Parallelreally pauses a subtest, and it carries on aftertesting_t_runhas returned. So each mode's run state is allocated withtest_alloc, not on the caller's stack.t.Parallelrun at the same time, so per-test state goes through an env pointer. For example,ReqFunctakes the test's env.r->a, which is the heap.cst_need_tcp. burrow only has TCP with the readiness poll FD, so the harness includesburrow/netpoll.h. Without it nearly every test skipped, which I caught on an early run.Tests
I ran these on server3 (Linux, clang) at 6a75265. The job builds
http_clientserver_testandhttptest_testthree times: plain, with ASan+UBSan, and with TSan. It also runs the static checks first. The log, verbatim:The "verbose" line counts the
--- PASS,--- SKIPand--- FAILlines from a-test.v -test.shortrun, so it includes the subtests. The two count=5 lines run the plain build with-test.short -test.count=5. The three tsan lines run the TSan build ofhttp_clientserver_testwith-test.count=5and without-test.short.What's next
The rest of
clientserver_test.go, starting withTestTransportDiscardsUnneededConns.