Skip to content

net/http: port clientserver_test.go from TestTransportDiscardsUnneededConns - #723

Merged
tamnd merged 1 commit into
mainfrom
clientserver2
Oct 27, 2026
Merged

tamnd merged 1 commit into
mainfrom
clientserver2

Conversation

@tamnd

@tamnd tamnd commented Oct 27, 2026

Copy link
Copy Markdown
Owner

What this is

This ports the next nine tests of Go 1.27's net/http/clientserver_test.go, from TestTransportDiscardsUnneededConns down to TestBadResponseAfterReadingBody. They go in tests/http_clientserver_test.c and use the harness from #722. This is part of #6.

Go test Modes
TestTransportDiscardsUnneededConns h2
TestTransportGCRequest h1, h2, each with Body and NoBody
TestTransportRejectsInvalidHeaders h1, h2
TestInterruptWithPanic h1, h2, each with boom and ErrAbortHandler
TestH12_AutoGzipWithDumpResponse h1 against h2
TestCloseIdleConnections h1, h2
TestNoSniffExpectRequestBody h1, h2
TestServerUndeclaredTrailers h1, h2
TestBadResponseAfterReadingBody h1

Not in Go

Where the code departs from Go's, it has a "Not in Go" comment. The main ones:

  • TestTransportGCRequest. There's no garbage collector to watch the request go away. Instead the request is freed as soon as its response is, so a transport that kept a pointer to it would touch freed memory, and ASan would catch that.
  • TestInterruptWithPanic. The nil subtest is left out. It sets GODEBUG=panicnil=1, and burrow has no such setting, so panic(nil) always carries a value, which is what Go does without it.
  • TestTransportDiscardsUnneededConns. The test's TLS config gets "h2" in next_protos up front. Go's transport adds it to the shared config itself, but burrow's only puts it in the clone each of its own connections gets. The wrapper conn also keeps the pieces the transport's free_conn hook needs to free them.
  • TestBadResponseAfterReadingBody. Post takes an IoReader, which can't say it is also a closer, so the test builds the request Post would make and sets the counting closer as its body by hand.
  • TestTransportRejectsInvalidHeaders. The failure message prints the response's status where Go prints the whole response.

Tests

I ran these on server3 (Linux, clang) at 44f77eb. The job runs the static checks, then builds http_clientserver_test and httptest_test three times: plain, with ASan+UBSan, and with TSan. The log, verbatim:

44f77eb net/http: port clientserver_test.go from TestTransportDiscardsUnneededConns
ok tools/check-banned.sh
ok tools/check-headers.sh
ok tools/check-annotations.sh
ok tools/check-alloc.sh
ok tools/check-globals.sh
ok tools/check-statics.sh
ok tools/check-fips-module.sh
== build-cs7 make exit 0
http_clientserver_test exit 0: PASS
httptest_test exit 0: PASS
verbose exit 0: 100 PASS, 0 SKIP, 0 FAIL
== build-cs7a make exit 0
http_clientserver_test exit 0: PASS
httptest_test exit 0: PASS
== build-cs7t make exit 0
http_clientserver_test exit 0: PASS
httptest_test exit 0: PASS
count=5 http_clientserver_test exit 0: PASS
count=5 httptest_test exit 0: PASS
tsan count=5 #1 exit 0: PASS
tsan count=5 #2 exit 0: PASS
tsan count=5 #3 exit 0: PASS
all done

The "verbose" line counts the --- PASS, --- SKIP and --- FAIL lines from a -test.v -test.short run, subtests included. It was 69 before this change, and the new tests add 31. The two count=5 lines run the plain build with -test.short -test.count=5. The three tsan lines run the TSan build of http_clientserver_test with -test.count=5 and without -test.short.

What's next

The rest of clientserver_test.go, from TestWriteHeader0. TestClientServerTLSConnWrapper needs the server and transport to take the TLS state from a conn that isn't a TlsConn, so that will come with its own library change.

…dConns

Port the next nine tests of clientserver_test.go, down to
TestBadResponseAfterReadingBody. The nil subtest of
TestInterruptWithPanic is left out, since burrow has no panicnil
setting.
@tamnd tamnd added the port Porting a standard library package, or part of one label Oct 27, 2026
@tamnd
tamnd merged commit 40c9a08 into main Oct 27, 2026
0 of 44 checks passed
@tamnd
tamnd deleted the clientserver2 branch October 27, 2026 18:01
@tamnd tamnd mentioned this pull request Oct 27, 2026
23 of 27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

port Porting a standard library package, or part of one

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant